diff --git a/src/oca/java/src/org/opennebula/client/PoolElement.java b/src/oca/java/src/org/opennebula/client/PoolElement.java index bf16ded3bc..e43d10d240 100644 --- a/src/oca/java/src/org/opennebula/client/PoolElement.java +++ b/src/oca/java/src/org/opennebula/client/PoolElement.java @@ -157,7 +157,7 @@ public abstract class PoolElement { } /** - * Changes the template permissions + * Changes the permissions * * @param client XML-RPC Client. * @param method XML-RPC method. diff --git a/src/oca/java/src/org/opennebula/client/image/Image.java b/src/oca/java/src/org/opennebula/client/image/Image.java index ef4d48f497..181970971a 100644 --- a/src/oca/java/src/org/opennebula/client/image/Image.java +++ b/src/oca/java/src/org/opennebula/client/image/Image.java @@ -192,6 +192,32 @@ public class Image extends PoolElement other_u, other_m, other_a); } + /** + * Changes the permissions + * + * @param client XML-RPC Client. + * @param id The id of the target object. + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse chmod(Client client, int id, String octet) + { + return chmod(client, CHMOD, id, octet); + } + + /** + * Changes the permissions + * + * @param client XML-RPC Client. + * @param id The id of the target object. + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse chmod(Client client, int id, int octet) + { + return chmod(client, CHMOD, id, octet); + } + /** * Changes the Image type * @@ -317,6 +343,28 @@ public class Image extends PoolElement return chown(client, id, uid, gid); } + /** + * Changes the owner + * + * @param uid The new owner user ID. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse chown(int uid) + { + return chown(uid, -1); + } + + /** + * Changes the group + * + * @param gid The new group ID. + * @return If an error occurs the error message contains the reason. + */ + public OneResponse chgrp(int gid) + { + return chown(-1, gid); + } + /** * Changes the Image permissions * @@ -342,25 +390,25 @@ public class Image extends PoolElement } /** - * Changes the owner - * - * @param uid The new owner user ID. + * Changes the permissions + * + * @param octet Permissions octed , e.g. 640 * @return If an error occurs the error message contains the reason. */ - public OneResponse chown(int uid) + public OneResponse chmod(String octet) { - return chown(uid, -1); + return chmod(client, id, octet); } /** - * Changes the group - * - * @param gid The new group ID. + * Changes the permissions + * + * @param octet Permissions octed , e.g. 640 * @return If an error occurs the error message contains the reason. */ - public OneResponse chgrp(int gid) + public OneResponse chmod(int octet) { - return chown(-1, gid); + return chmod(client, id, octet); } /** diff --git a/src/oca/java/src/org/opennebula/client/template/Template.java b/src/oca/java/src/org/opennebula/client/template/Template.java index 844ccbe424..3087174b2c 100644 --- a/src/oca/java/src/org/opennebula/client/template/Template.java +++ b/src/oca/java/src/org/opennebula/client/template/Template.java @@ -166,6 +166,32 @@ public class Template extends PoolElement other_u, other_m, other_a); } + /** + * Changes the permissions + * + * @param client XML-RPC Client. + * @param id The id of the target object. + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse chmod(Client client, int id, String octet) + { + return chmod(client, CHMOD, id, octet); + } + + /** + * Changes the permissions + * + * @param client XML-RPC Client. + * @param id The id of the target object. + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse chmod(Client client, int id, int octet) + { + return chmod(client, CHMOD, id, octet); + } + /** * Creates a VM instance from a Template * @@ -306,6 +332,28 @@ public class Template extends PoolElement other_u, other_m, other_a); } + /** + * Changes the permissions + * + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public OneResponse chmod(String octet) + { + return chmod(client, id, octet); + } + + /** + * Changes the permissions + * + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public OneResponse chmod(int octet) + { + return chmod(client, id, octet); + } + /** * Creates a VM instance from a Template * diff --git a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java index 4d5babff93..d16c4fb1e2 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java @@ -241,6 +241,32 @@ public class VirtualMachine extends PoolElement{ other_u, other_m, other_a); } + /** + * Changes the permissions + * + * @param client XML-RPC Client. + * @param id The id of the target object. + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse chmod(Client client, int id, String octet) + { + return chmod(client, CHMOD, id, octet); + } + + /** + * Changes the permissions + * + * @param client XML-RPC Client. + * @param id The id of the target object. + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse chmod(Client client, int id, int octet) + { + return chmod(client, CHMOD, id, octet); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -398,6 +424,28 @@ public class VirtualMachine extends PoolElement{ other_u, other_m, other_a); } + /** + * Changes the permissions + * + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public OneResponse chmod(String octet) + { + return chmod(client, id, octet); + } + + /** + * Changes the permissions + * + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public OneResponse chmod(int octet) + { + return chmod(client, id, octet); + } + // ================================= // 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 19f5a88f46..648e59a75c 100644 --- a/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java +++ b/src/oca/java/src/org/opennebula/client/vnet/VirtualNetwork.java @@ -210,6 +210,32 @@ public class VirtualNetwork extends PoolElement{ other_u, other_m, other_a); } + /** + * Changes the permissions + * + * @param client XML-RPC Client. + * @param id The id of the target object. + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse chmod(Client client, int id, String octet) + { + return chmod(client, CHMOD, id, octet); + } + + /** + * Changes the permissions + * + * @param client XML-RPC Client. + * @param id The id of the target object. + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public static OneResponse chmod(Client client, int id, int octet) + { + return chmod(client, CHMOD, id, octet); + } + /** * Replaces the VirtualNetwork template contents. * @@ -409,6 +435,28 @@ public class VirtualNetwork extends PoolElement{ other_u, other_m, other_a); } + /** + * Changes the permissions + * + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public OneResponse chmod(String octet) + { + return chmod(client, id, octet); + } + + /** + * Changes the permissions + * + * @param octet Permissions octed , e.g. 640 + * @return If an error occurs the error message contains the reason. + */ + public OneResponse chmod(int octet) + { + return chmod(client, id, octet); + } + /** * Replaces the VirtualNetwork template contents. * diff --git a/src/oca/java/test/TemplateTest.java b/src/oca/java/test/TemplateTest.java index 7b36b9cdd2..0953c1d3d0 100644 --- a/src/oca/java/test/TemplateTest.java +++ b/src/oca/java/test/TemplateTest.java @@ -187,6 +187,45 @@ public class TemplateTest assertTrue( template.xpath("PERMISSIONS/OTHER_M").equals("1") ); assertTrue( template.xpath("PERMISSIONS/OTHER_A").equals("0") ); } + + @Test + public void chmod_octet() + { + res = template.info(); + assertTrue( !res.isError() ); + + res = template.chmod(640); + assertTrue( !res.isError() ); + + res = template.info(); + assertTrue( !res.isError() ); + + assertTrue( template.xpath("PERMISSIONS/OWNER_U").equals("1") ); + assertTrue( template.xpath("PERMISSIONS/OWNER_M").equals("1") ); + assertTrue( template.xpath("PERMISSIONS/OWNER_A").equals("0") ); + assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("1") ); + assertTrue( template.xpath("PERMISSIONS/GROUP_M").equals("0") ); + assertTrue( template.xpath("PERMISSIONS/GROUP_A").equals("0") ); + assertTrue( template.xpath("PERMISSIONS/OTHER_U").equals("0") ); + assertTrue( template.xpath("PERMISSIONS/OTHER_M").equals("0") ); + assertTrue( template.xpath("PERMISSIONS/OTHER_A").equals("0") ); + + res = template.chmod("147"); + assertTrue( !res.isError() ); + + res = template.info(); + assertTrue( !res.isError() ); + + assertTrue( template.xpath("PERMISSIONS/OWNER_U").equals("0") ); + assertTrue( template.xpath("PERMISSIONS/OWNER_M").equals("0") ); + assertTrue( template.xpath("PERMISSIONS/OWNER_A").equals("1") ); + assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("1") ); + assertTrue( template.xpath("PERMISSIONS/GROUP_M").equals("0") ); + assertTrue( template.xpath("PERMISSIONS/GROUP_A").equals("0") ); + assertTrue( template.xpath("PERMISSIONS/OTHER_U").equals("1") ); + assertTrue( template.xpath("PERMISSIONS/OTHER_M").equals("1") ); + assertTrue( template.xpath("PERMISSIONS/OTHER_A").equals("1") ); + } @Test public void attributes() diff --git a/src/oca/java/test/test.sh b/src/oca/java/test/test.sh index 1a2c3ba4fc..7e0cb0cec2 100755 --- a/src/oca/java/test/test.sh +++ b/src/oca/java/test/test.sh @@ -41,7 +41,7 @@ PID=$$ oned -f & -sleep 4s; +sleep 10s; java -cp ../lib/*:../jar/*:$JUNIT_JAR:. org.junit.runner.JUnitCore $1