F #826 Fix some bugs (#2633)

This commit is contained in:
Christian González authored and Ruben S. Montero committed 2018-11-21 16:20:29 +01:00
1 parent d921610d15
commit f850d10bfe
4 files changed
+41 -31

No files matched your search

+8 -3
View File
@@ -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 \
@@ -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);
@@ -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, "");
}
/**
@@ -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<Template>
public class VirtualNetworkTemplatePool extends Pool implements Iterable<VirtualNetworkTemplate>
{
private static final String ELEMENT_NAME = "VNTEMPLATE";
private static final String INFO_METHOD = "vntemplatepool.info";