diff --git a/include/RequestManagerAllocate.h b/include/RequestManagerAllocate.h index 9522314868..8b3497b418 100644 --- a/include/RequestManagerAllocate.h +++ b/include/RequestManagerAllocate.h @@ -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(); diff --git a/src/cli/onehost b/src/cli/onehost index a56a49792c..354c3c284e 100755 --- a/src/cli/onehost +++ b/src/cli/onehost @@ -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 ######################################################################## diff --git a/src/cli/onevnet b/src/cli/onevnet index 720673db27..6f8a7084ff 100755 --- a/src/cli/onevnet +++ b/src/cli/onevnet @@ -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 diff --git a/src/datastore/DatastorePool.cc b/src/datastore/DatastorePool.cc index 7dfd9fe096..1557659a39 100644 --- a/src/datastore/DatastorePool.cc +++ b/src/datastore/DatastorePool.cc @@ -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; diff --git a/src/oca/ruby/OpenNebula/VirtualNetwork.rb b/src/oca/ruby/OpenNebula/VirtualNetwork.rb index 1c24e0ad95..2b82cc1622 100644 --- a/src/oca/ruby/OpenNebula/VirtualNetwork.rb +++ b/src/oca/ruby/OpenNebula/VirtualNetwork.rb @@ -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 diff --git a/src/onedb/3.3.0_to_3.3.80.rb b/src/onedb/3.3.0_to_3.3.80.rb index 7194edc1e5..3dff69249c 100644 --- a/src/onedb/3.3.0_to_3.3.80.rb +++ b/src/onedb/3.3.0_to_3.3.80.rb @@ -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 " 0" << " 0" << " " << - " fs" << + " -" << " shared" << " #{var_location}/datastores/0" << " -1" << " none" << " " << " " << "" @@ -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 " 0" << " 0" << " " << - " fs" << # TODO - " shared" << # TODO + " fs" << + " shared" << " #{var_location}/datastores/1" << " -1" << " none" << images_element << " " << ""