diff --git a/src/oca/java/src/org/opennebula/client/user/User.java b/src/oca/java/src/org/opennebula/client/user/User.java index f81da16fb1..16da68bd83 100644 --- a/src/oca/java/src/org/opennebula/client/user/User.java +++ b/src/oca/java/src/org/opennebula/client/user/User.java @@ -34,6 +34,7 @@ public class User extends PoolElement{ private static final String PASSWD = METHOD_PREFIX + "passwd"; private static final String CHGRP = METHOD_PREFIX + "chgrp"; private static final String CHAUTH = METHOD_PREFIX + "chauth"; + private static final String UPDATE = METHOD_PREFIX + "update"; /** * Creates a new User representation. @@ -157,6 +158,19 @@ public class User extends PoolElement{ return client.call(CHAUTH, id, auth); } + /** + * Replaces the user template contents. + * + * @param client XML-RPC Client. + * @param id The user id of the target user we want to modify. + * @param new_template New template contents. + * @return If successful the message contains the user id. + */ + public static OneResponse update(Client client, int id, String new_template) + { + return client.call(UPDATE, id, new_template); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -218,6 +232,17 @@ public class User extends PoolElement{ return chauth(client, id, auth); } + /** + * Replaces the user template contents. + * + * @param new_template New template contents. + * @return If successful the message contains the user id. + */ + public OneResponse update(String new_template) + { + return update(client, id, new_template); + } + // ================================= // Helpers // ================================= diff --git a/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java b/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java index 8a13cffdd2..ac58d7a316 100644 --- a/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java +++ b/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java @@ -35,6 +35,7 @@ public class VirtualNetwork extends PoolElement{ private static final String ADDLEASES = METHOD_PREFIX + "addleases"; private static final String RMLEASES = METHOD_PREFIX + "rmleases"; private static final String CHOWN = METHOD_PREFIX + "chown"; + private static final String UPDATE = METHOD_PREFIX + "update"; /** @@ -153,6 +154,19 @@ public class VirtualNetwork extends PoolElement{ return client.call(CHOWN, id, uid, gid); } + /** + * Replaces the VirtualNetwork template contents. + * + * @param client XML-RPC Client. + * @param id The user id of the target vnet we want to modify. + * @param new_template New template contents. + * @return If successful the message contains the vnet id. + */ + public static OneResponse update(Client client, int id, String new_template) + { + return client.call(UPDATE, id, new_template); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -291,6 +305,17 @@ public class VirtualNetwork extends PoolElement{ return chown(-1, gid); } + /** + * Replaces the VirtualNetwork template contents. + * + * @param new_template New template contents. + * @return If successful the message contains the vnet id. + */ + public OneResponse update(String new_template) + { + return update(client, id, new_template); + } + // ================================= // Helpers // ================================= diff --git a/src/oca/java/test/UserTest.java b/src/oca/java/test/UserTest.java index 079dd7c31e..d8e9a0f720 100644 --- a/src/oca/java/test/UserTest.java +++ b/src/oca/java/test/UserTest.java @@ -94,7 +94,7 @@ public class UserTest } @Test - public void update() + public void info() { res = user.info(); assertTrue( res.getErrorMessage(), !res.isError() ); @@ -129,6 +129,22 @@ public class UserTest assertTrue( user.xpath("AUTH_DRIVER").equals("new_driver") ); } + @Test + public void update() + { + String new_template = "ATT2 = NEW_VAL\n" + + "ATT3 = VAL3"; + + res = user.update(new_template); + assertTrue( !res.isError() ); + + res = user.info(); + assertTrue( !res.isError() ); + assertTrue( user.xpath("TEMPLATE/ATT1").equals( "" ) ); + assertTrue( user.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) ); + assertTrue( user.xpath("TEMPLATE/ATT3").equals( "VAL3" ) ); + } + @Test public void delete() { diff --git a/src/oca/java/test/VirtualNetworkTest.java b/src/oca/java/test/VirtualNetworkTest.java index 8d97ad1ead..dcea0775e6 100644 --- a/src/oca/java/test/VirtualNetworkTest.java +++ b/src/oca/java/test/VirtualNetworkTest.java @@ -117,7 +117,7 @@ public class VirtualNetworkTest } @Test - public void update() + public void info() { res = vnet.info(); assertTrue( !res.isError() ); @@ -208,4 +208,20 @@ public class VirtualNetworkTest fixed_vnet.delete(); } + + @Test + public void update() + { + String new_template = "ATT2 = NEW_VAL\n" + + "ATT3 = VAL3"; + + res = vnet.update(new_template); + assertTrue( !res.isError() ); + + res = vnet.info(); + assertTrue( !res.isError() ); + assertTrue( vnet.xpath("TEMPLATE/ATT1").equals( "" ) ); + assertTrue( vnet.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) ); + assertTrue( vnet.xpath("TEMPLATE/ATT3").equals( "VAL3" ) ); + } }