mirror of
https://github.com/OpenNebula/one.git
synced 2025-04-01 06:50:25 +03:00
Feature #1112: Add new cluster_id parameter to one.vn.allocate
This commit is contained in:
parent
3e9af3242c
commit
f2e6303c3e
@ -146,7 +146,7 @@ public:
|
||||
VirtualNetworkAllocate():
|
||||
RequestManagerAllocate("VirtualNetworkAllocate",
|
||||
"Allocates a new virtual network",
|
||||
"A:ss",
|
||||
"A:ssi",
|
||||
true)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -170,6 +170,16 @@ public:
|
||||
RequestAttributes& att,
|
||||
int cluster_id,
|
||||
const string& cluster_name);
|
||||
|
||||
int get_cluster_id(xmlrpc_c::paramList const& paramList)
|
||||
{
|
||||
return xmlrpc_c::value_int(paramList.getInt(2));
|
||||
};
|
||||
|
||||
int add_to_cluster(Cluster* cluster, int id, string& error_msg)
|
||||
{
|
||||
return cluster->add_datastore(id, error_msg);
|
||||
};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -181,7 +191,7 @@ public:
|
||||
ImageAllocate():
|
||||
RequestManagerAllocate("ImageAllocate",
|
||||
"Allocates a new image",
|
||||
"A:ss",
|
||||
"A:ssi",
|
||||
true)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -52,6 +52,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
helper.list_to_id(arg)
|
||||
end
|
||||
|
||||
set :format, :clusterid, OpenNebulaHelper.rname_to_id_desc("CLUSTER") do |arg|
|
||||
OpenNebulaHelper.rname_to_id(arg, "CLUSTER")
|
||||
end
|
||||
|
||||
########################################################################
|
||||
# Commands
|
||||
########################################################################
|
||||
|
@ -52,6 +52,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
OpenNebulaHelper.rname_to_id(arg, "USER")
|
||||
end
|
||||
|
||||
set :format, :clusterid, OpenNebulaHelper.rname_to_id_desc("CLUSTER") do |arg|
|
||||
OpenNebulaHelper.rname_to_id(arg, "CLUSTER")
|
||||
end
|
||||
|
||||
set :format, :vnetid, OneVNetHelper.to_id_desc do |arg|
|
||||
helper.to_id(arg)
|
||||
end
|
||||
@ -72,10 +76,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Creates a new Virtual Network from the given template file
|
||||
EOT
|
||||
|
||||
command :create, create_desc, :file do
|
||||
command :create, create_desc, :file, [:clusterid, nil] do
|
||||
helper.create_resource(options) do |vn|
|
||||
template=File.read(args[0])
|
||||
vn.allocate(template)
|
||||
|
||||
if args.size == 1
|
||||
vn.allocate(template)
|
||||
else
|
||||
vn.allocate(template, args[1].to_i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -78,9 +78,13 @@ module OpenNebula
|
||||
|
||||
# Allocates a new VirtualNetwork in OpenNebula
|
||||
#
|
||||
# +description+ A string containing the template of the VirtualNetwork.
|
||||
def allocate(description)
|
||||
super(VN_METHODS[:allocate],description)
|
||||
# @param description [String] The template of the VirtualNetwork.
|
||||
# @param cluster_id [Integer] Id of the cluster
|
||||
#
|
||||
# @return [Integer, OpenNebula::Error] the new ID in case of
|
||||
# success, error otherwise
|
||||
def allocate(description,cluster_id=ClusterPool::NONE_CLUSTER_ID)
|
||||
super(VN_METHODS[:allocate], description, cluster_id)
|
||||
end
|
||||
|
||||
# Replaces the template contents
|
||||
|
Loading…
x
Reference in New Issue
Block a user