From f850d10bfe00d51d77dc3f5dc39474b99422cdf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez?= Date: Wed, 21 Nov 2018 16:20:29 +0100 Subject: [PATCH] F #826 Fix some bugs (#2633) --- install.sh | 11 +++- .../src/org/opennebula/client/acl/Acl.java | 2 + .../vntemplate/VirtualNetworkTemplate.java | 57 ++++++++++--------- .../VirtualNetworkTemplatePool.java | 2 +- 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/install.sh b/install.sh index aedc01108b..e82ef79ac2 100755 --- a/install.sh +++ b/install.sh @@ -610,6 +610,7 @@ BIN_FILES="src/nebula/oned \ src/cli/onemarket \ src/cli/onemarketapp \ src/cli/onevcenter \ + src/cli/onevntemplate \ src/onedb/onedb \ src/mad/utils/tty_expect \ share/scripts/one" @@ -1484,7 +1485,9 @@ RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/opennebula/acl_pool.rb \ src/oca/ruby/opennebula/marketplace.rb \ src/oca/ruby/opennebula/marketplaceapp_pool.rb \ src/oca/ruby/opennebula/marketplaceapp.rb \ - src/oca/ruby/opennebula/utils.rb" + src/oca/ruby/opennebula/utils.rb \ + src/oca/ruby/opennebula/vntemplate_pool.rb \ + src/oca/ruby/opennebula/vntemplate.rb" #------------------------------------------------------------------------------- # Common Cloud Files @@ -1627,7 +1630,8 @@ ONE_CLI_LIB_FILES="src/cli/one_helper/onegroup_helper.rb \ src/cli/one_helper/onevrouter_helper.rb \ src/cli/one_helper/onemarketapp_helper.rb \ src/cli/one_helper/onevcenter_helper.rb \ - src/cli/one_helper/onemarket_helper.rb" + src/cli/one_helper/onemarket_helper.rb \ + src/cli/one_helper/onevntemplate_helper.rb" CLI_BIN_FILES="src/cli/onevm \ src/cli/onehost \ @@ -1649,7 +1653,8 @@ CLI_BIN_FILES="src/cli/onevm \ src/cli/onevdc \ src/cli/onevrouter \ src/cli/onemarketapp \ - src/cli/onemarket" + src/cli/onemarket \ + src/cli/onevntemplate" CLI_CONF_FILES="src/cli/etc/onegroup.yaml \ src/cli/etc/onehost.yaml \ diff --git a/src/oca/java/src/org/opennebula/client/acl/Acl.java b/src/oca/java/src/org/opennebula/client/acl/Acl.java index 4661c04115..657ffd120b 100644 --- a/src/oca/java/src/org/opennebula/client/acl/Acl.java +++ b/src/oca/java/src/org/opennebula/client/acl/Acl.java @@ -74,6 +74,8 @@ public class Acl extends PoolElement{ tmpResources.put("VROUTER" , 0x0004000000000000L); tmpResources.put("MARKETPLACE", 0x0008000000000000L); tmpResources.put("MARKETPLACEAPP", 0x0010000000000000L); + tmpResources.put("VMGROUP", 0x0020000000000000L); + tmpResources.put("VNTEMPLATE", 0x0040000000000000L); RESOURCES = Collections.unmodifiableMap(tmpResources); diff --git a/src/oca/java/src/org/opennebula/client/vntemplate/VirtualNetworkTemplate.java b/src/oca/java/src/org/opennebula/client/vntemplate/VirtualNetworkTemplate.java index b470c9d8a4..b3bdd49708 100644 --- a/src/oca/java/src/org/opennebula/client/vntemplate/VirtualNetworkTemplate.java +++ b/src/oca/java/src/org/opennebula/client/vntemplate/VirtualNetworkTemplate.java @@ -76,19 +76,6 @@ public class VirtualNetworkTemplate extends PoolElement return client.call(ALLOCATE, description); } - /** - * Retrieves the information of the given VNTemplate. - * - * @param client XML-RPC Client. - * @param id The vntemplate id for the vntemplate to retrieve the information from - * @return If successful the message contains the string - * with the information returned by OpenNebula. - */ - public static OneResponse info(Client client, int id) - { - return info(client, id, false); - } - /** * Retrieves the information of the given VNTemplate. * @@ -182,21 +169,36 @@ public class VirtualNetworkTemplate extends PoolElement return client.call(CHMOD, id, owner_u, owner_m, owner_a, group_u, group_m, group_a, - other_u, other_m, other_a, - false); + 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 + * @param recursive chmods the template plus any image defined in DISK. + * * @return If an error occurs the error message contains the reason. */ public static OneResponse chmod(Client client, int id, String octet) { - return chmod(client, id, octet, false); + int owner_u = (Integer.parseInt(octet.substring(0, 1)) & 4) != 0 ? 1 : 0; + int owner_m = (Integer.parseInt(octet.substring(0, 1)) & 2) != 0 ? 1 : 0; + int owner_a = (Integer.parseInt(octet.substring(0, 1)) & 1) != 0 ? 1 : 0; + int group_u = (Integer.parseInt(octet.substring(1, 2)) & 4) != 0 ? 1 : 0; + int group_m = (Integer.parseInt(octet.substring(1, 2)) & 2) != 0 ? 1 : 0; + int group_a = (Integer.parseInt(octet.substring(1, 2)) & 1) != 0 ? 1 : 0; + int other_u = (Integer.parseInt(octet.substring(2, 3)) & 4) != 0 ? 1 : 0; + int other_m = (Integer.parseInt(octet.substring(2, 3)) & 2) != 0 ? 1 : 0; + int other_a = (Integer.parseInt(octet.substring(2, 3)) & 1) != 0 ? 1 : 0; + + return chmod(client, id, + owner_u, owner_m, owner_a, + group_u, group_m, group_a, + other_u, other_m, other_a); } /** @@ -205,11 +207,13 @@ public class VirtualNetworkTemplate extends PoolElement * @param client XML-RPC Client. * @param id The id of the target object. * @param octet Permissions octed , e.g. 640 + * @param recursive chmods the template plus any image defined in DISK. + * * @return If an error occurs the error message contains the reason. */ public static OneResponse chmod(Client client, int id, int octet) { - return chmod(client, id, octet, false); + return chmod(client, id, Integer.toString(octet)); } /** @@ -303,7 +307,7 @@ public class VirtualNetworkTemplate extends PoolElement */ public OneResponse info(boolean extended) { - OneResponse response = info(client, id, extended); + OneResponse response = info(client, id); super.processInfo(response); return response; } @@ -315,7 +319,7 @@ public class VirtualNetworkTemplate extends PoolElement */ public OneResponse delete() { - return delete(client, id, false); + return delete(client, id); } /** @@ -424,11 +428,10 @@ public class VirtualNetworkTemplate extends PoolElement int group_u, int group_m, int group_a, int other_u, int other_m, int other_a) { - return chmod(client, id, - owner_u, owner_m, owner_a, - group_u, group_m, group_a, - other_u, other_m, other_a, - false); + return client.call(CHMOD, id, + owner_u, owner_m, owner_a, + group_u, group_m, group_a, + other_u, other_m, other_a); } /** @@ -439,7 +442,7 @@ public class VirtualNetworkTemplate extends PoolElement */ public OneResponse chmod(String octet) { - return chmod(client, id, octet, false); + return chmod(client, id, octet); } /** @@ -450,7 +453,7 @@ public class VirtualNetworkTemplate extends PoolElement */ public OneResponse chmod(int octet) { - return chmod(client, id, octet, false); + return chmod(client, id, octet); } /** @@ -478,7 +481,7 @@ public class VirtualNetworkTemplate extends PoolElement */ public OneResponse instantiate(String name) { - return instantiate(client, id, name, "",); + return instantiate(client, id, name, ""); } /** diff --git a/src/oca/java/src/org/opennebula/client/vntemplate/VirtualNetworkTemplatePool.java b/src/oca/java/src/org/opennebula/client/vntemplate/VirtualNetworkTemplatePool.java index 84ef3107f3..363726b315 100644 --- a/src/oca/java/src/org/opennebula/client/vntemplate/VirtualNetworkTemplatePool.java +++ b/src/oca/java/src/org/opennebula/client/vntemplate/VirtualNetworkTemplatePool.java @@ -28,7 +28,7 @@ import org.w3c.dom.Node; * This class represents an OpenNebula Virtual Network Template pool. * It also offers static XML-RPC call wrappers. */ -public class VirtualNetworkTemplatePool extends Pool implements Iterable