mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Merge branch 'feature-1112' of git.opennebula.org:one into feature-1112
This commit is contained in:
commit
58989e2e79
@ -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();
|
||||
|
@ -78,6 +78,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
|
||||
|
||||
|
@ -52,7 +52,7 @@ DatastorePool::DatastorePool(SqlDB * db):
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
oss << "NAME = " << SYSTEM_DS_NAME << endl
|
||||
<< "DS_MAD = fs" << endl
|
||||
<< "DS_MAD = -" << endl
|
||||
<< "TM_MAD = shared";
|
||||
|
||||
ds_tmpl = new DatastoreTemplate;
|
||||
|
@ -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
|
||||
|
@ -25,7 +25,38 @@ module Migrator
|
||||
"OpenNebula 3.3.80"
|
||||
end
|
||||
|
||||
SHORT_VM_STATES=%w{init pend hold actv stop susp done fail}
|
||||
|
||||
SHORT_LCM_STATES=%w{prol boot runn migr save save save migr prol,
|
||||
epil epil shut shut fail clea unkn}
|
||||
|
||||
def up
|
||||
|
||||
header_done = false
|
||||
|
||||
@db.fetch("SELECT oid,name,state,lcm_state FROM vm_pool WHERE ( state <> 1 AND state <> 6 )") do |row|
|
||||
if ( !header_done )
|
||||
puts "You can't have active VMs. Please shutdown or delete the following VMs:"
|
||||
puts
|
||||
puts " ID STAT NAME"
|
||||
|
||||
header_done = true
|
||||
end
|
||||
|
||||
if row[:state] != 3
|
||||
state_str = SHORT_VM_STATES[row[:state]]
|
||||
else
|
||||
state_str = SHORT_LCM_STATES[row[:lcm_state]]
|
||||
end
|
||||
|
||||
puts "#{'%6.6s' % row[:oid].to_s} #{state_str} #{row[:name]}"
|
||||
end
|
||||
|
||||
if ( header_done )
|
||||
puts
|
||||
return false
|
||||
end
|
||||
|
||||
one_location = ENV["ONE_LOCATION"]
|
||||
|
||||
if !one_location
|
||||
@ -91,14 +122,14 @@ module Migrator
|
||||
" <OTHER_M>0</OTHER_M>" <<
|
||||
" <OTHER_A>0</OTHER_A>" <<
|
||||
" </PERMISSIONS>" <<
|
||||
" <DS_MAD>fs</DS_MAD>" <<
|
||||
" <DS_MAD>-</DS_MAD>" <<
|
||||
" <TM_MAD>shared</TM_MAD>" <<
|
||||
" <BASE_PATH>#{var_location}/datastores/0</BASE_PATH>" <<
|
||||
" <CLUSTER_ID>-1</CLUSTER_ID>" <<
|
||||
" <CLUSTER>none</CLUSTER>" <<
|
||||
" <IMAGES/>" <<
|
||||
" <TEMPLATE>" <<
|
||||
" <DS_MAD><![CDATA[fs]]></DS_MAD>" <<
|
||||
" <DS_MAD><![CDATA[-]]></DS_MAD>" <<
|
||||
" <TM_MAD><![CDATA[shared]]></TM_MAD>" <<
|
||||
" </TEMPLATE>" <<
|
||||
"</DATASTORE>"
|
||||
@ -208,9 +239,7 @@ module Migrator
|
||||
if ( hash.length == 32 && hash =~ /^[0-9A-F]+$/i )
|
||||
e.text = "#{var_location}/datastores/1/#{hash}"
|
||||
|
||||
# TODO: create link, or mv image file?
|
||||
`ln -s #{previous_source} #{e.text}`
|
||||
# `mv #{e.text} #{previous_source}`
|
||||
end
|
||||
}
|
||||
|
||||
@ -250,15 +279,15 @@ module Migrator
|
||||
" <OTHER_M>0</OTHER_M>" <<
|
||||
" <OTHER_A>0</OTHER_A>" <<
|
||||
" </PERMISSIONS>" <<
|
||||
" <DS_MAD>fs</DS_MAD>" << # TODO
|
||||
" <TM_MAD>shared</TM_MAD>" << # TODO
|
||||
" <DS_MAD>fs</DS_MAD>" <<
|
||||
" <TM_MAD>shared</TM_MAD>" <<
|
||||
" <BASE_PATH>#{var_location}/datastores/1</BASE_PATH>" <<
|
||||
" <CLUSTER_ID>-1</CLUSTER_ID>" <<
|
||||
" <CLUSTER>none</CLUSTER>" <<
|
||||
images_element <<
|
||||
" <TEMPLATE>" <<
|
||||
" <DS_MAD><![CDATA[fs]]></DS_MAD>" << # TODO
|
||||
" <TM_MAD><![CDATA[shared]]></TM_MAD>" << # TODO
|
||||
" <DS_MAD><![CDATA[fs]]></DS_MAD>" <<
|
||||
" <TM_MAD><![CDATA[shared]]></TM_MAD>" <<
|
||||
" </TEMPLATE>" <<
|
||||
"</DATASTORE>"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user