mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-28 07:21:29 +03:00
Merge remote-tracking branch 'upstream/feature-1112' into feature-1112
This commit is contained in:
commit
c7e6724c96
@ -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();
|
||||
@ -195,6 +205,10 @@ public:
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att);
|
||||
|
||||
bool allocate_authorization(Template * obj_template,
|
||||
RequestAttributes& att,
|
||||
PoolObjectAuth * cluster_perms);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
@ -311,7 +311,7 @@ EOT
|
||||
|
||||
opts.on(*args) do |o|
|
||||
if e[:proc]
|
||||
e[:proc].call(o, @options)
|
||||
@options[e[:name].to_sym]=e[:proc].call(o, @options)
|
||||
elsif e[:name]=="help"
|
||||
help
|
||||
exit
|
||||
|
@ -8,7 +8,24 @@
|
||||
:size: 15
|
||||
:left: true
|
||||
|
||||
:HOSTS:
|
||||
:desc: Number of Hosts
|
||||
:size: 5
|
||||
:left: true
|
||||
|
||||
:NETS:
|
||||
:desc: Number of Networks
|
||||
:size: 5
|
||||
:left: true
|
||||
|
||||
:DATASTORES:
|
||||
:desc: Number of Datastores
|
||||
:size: 10
|
||||
:left: true
|
||||
|
||||
:default:
|
||||
- :ID
|
||||
- :NAME
|
||||
|
||||
- :HOSTS
|
||||
- :NETS
|
||||
- :DATASTORES
|
||||
|
@ -8,7 +8,31 @@
|
||||
:size: 15
|
||||
:left: true
|
||||
|
||||
:CLUSTER:
|
||||
:desc: Name of the Cluster
|
||||
:size: 8
|
||||
:left: true
|
||||
|
||||
:IMAGES:
|
||||
:desc: Number of Images
|
||||
:size: 6
|
||||
:left: true
|
||||
|
||||
:TYPE:
|
||||
:desc: Datastore driver
|
||||
:size: 6
|
||||
:left: true
|
||||
|
||||
:TM:
|
||||
:desc: Transfer driver
|
||||
:size: 6
|
||||
:left: true
|
||||
|
||||
:default:
|
||||
- :ID
|
||||
- :NAME
|
||||
- :CLUSTER
|
||||
- :IMAGES
|
||||
- :TYPE
|
||||
- :TM
|
||||
|
||||
|
@ -5,7 +5,12 @@
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Host
|
||||
:size: 15
|
||||
:size: 12
|
||||
:left: true
|
||||
|
||||
:CLUSTER:
|
||||
:desc: Name of the Cluster
|
||||
:size: 8
|
||||
:left: true
|
||||
|
||||
:RVM:
|
||||
@ -38,11 +43,12 @@
|
||||
|
||||
:STAT:
|
||||
:desc: Host status
|
||||
:size: 6
|
||||
:size: 4
|
||||
|
||||
:default:
|
||||
- :ID
|
||||
- :NAME
|
||||
- :CLUSTER
|
||||
- :RVM
|
||||
- :TCPU
|
||||
- :FCPU
|
||||
|
@ -3,11 +3,6 @@
|
||||
:desc: ONE identifier for the Image
|
||||
:size: 4
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Image
|
||||
:size: 12
|
||||
:left: true
|
||||
|
||||
:USER:
|
||||
:desc: Username of the Virtual Machine owner
|
||||
:size: 8
|
||||
@ -18,6 +13,16 @@
|
||||
:size: 8
|
||||
:left: true
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Image
|
||||
:size: 12
|
||||
:left: true
|
||||
|
||||
:DATASTORE:
|
||||
:desc: Name of the Datastore
|
||||
:size: 10
|
||||
:left: true
|
||||
|
||||
:SIZE:
|
||||
:desc: Size of the Image
|
||||
:size: 7
|
||||
@ -47,9 +52,9 @@
|
||||
- :USER
|
||||
- :GROUP
|
||||
- :NAME
|
||||
- :DATASTORE
|
||||
- :SIZE
|
||||
- :TYPE
|
||||
- :REGTIME
|
||||
- :PERSISTENT
|
||||
- :STAT
|
||||
- :RVMS
|
||||
|
@ -3,11 +3,6 @@
|
||||
:desc: ONE identifier for Virtual Network
|
||||
:size: 4
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Virtual Network
|
||||
:size: 15
|
||||
:left: true
|
||||
|
||||
:USER:
|
||||
:desc: Username of the Virtual Network owner
|
||||
:size: 8
|
||||
@ -18,6 +13,16 @@
|
||||
:size: 8
|
||||
:left: true
|
||||
|
||||
:NAME:
|
||||
:desc: Name of the Virtual Network
|
||||
:size: 15
|
||||
:left: true
|
||||
|
||||
:CLUSTER:
|
||||
:desc: Name of the Cluster
|
||||
:size: 8
|
||||
:left: true
|
||||
|
||||
:TYPE:
|
||||
:desc: Type of Virtual Network
|
||||
:size: 6
|
||||
@ -39,6 +44,7 @@
|
||||
- :USER
|
||||
- :GROUP
|
||||
- :NAME
|
||||
- :CLUSTER
|
||||
- :TYPE
|
||||
- :BRIDGE
|
||||
- :LEASES
|
||||
|
@ -17,6 +17,20 @@
|
||||
require 'one_helper'
|
||||
|
||||
class OneClusterHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
CLUSTER = {
|
||||
:name => "cluster",
|
||||
:short => "-c id|name",
|
||||
:large => "--cluster id|name" ,
|
||||
:description => "Selects the cluster",
|
||||
:format => String,
|
||||
:proc => lambda { |o, options|
|
||||
ch = OneClusterHelper.new
|
||||
rc, cid = ch.to_id(o)
|
||||
cid
|
||||
}
|
||||
}
|
||||
|
||||
def self.rname
|
||||
"CLUSTER"
|
||||
end
|
||||
@ -37,7 +51,19 @@ class OneClusterHelper < OpenNebulaHelper::OneHelper
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
default :ID, :NAME
|
||||
column :HOSTS, "Number of Hosts", :left, :size=>5 do |d|
|
||||
d["HOSTS"].size
|
||||
end
|
||||
|
||||
column :NETS, "Number of Networks", :left, :size=>5 do |d|
|
||||
d["HOSTS"].size
|
||||
end
|
||||
|
||||
column :DATASTORES, "Number of Datastores", :left, :size=>10 do |d|
|
||||
d["DATASTORES"].size
|
||||
end
|
||||
|
||||
default :ID, :NAME, :HOSTS, :NETS, :DATASTORES
|
||||
end
|
||||
|
||||
table
|
||||
@ -72,16 +98,16 @@ class OneClusterHelper < OpenNebulaHelper::OneHelper
|
||||
puts "%-15s" % [id]
|
||||
end
|
||||
|
||||
puts
|
||||
CLIHelper.print_header("%-15s" % ["DATASTORES"])
|
||||
cluster.datastore_ids.each do |id|
|
||||
puts "%-15s" % [id]
|
||||
end
|
||||
|
||||
puts
|
||||
CLIHelper.print_header("%-15s" % ["VNETS"])
|
||||
cluster.vnet_ids.each do |id|
|
||||
puts "%-15s" % [id]
|
||||
end
|
||||
|
||||
puts
|
||||
CLIHelper.print_header("%-15s" % ["DATASTORES"])
|
||||
cluster.datastore_ids.each do |id|
|
||||
puts "%-15s" % [id]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -17,6 +17,19 @@
|
||||
require 'one_helper'
|
||||
|
||||
class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
DATASTORE = {
|
||||
:name => "datastore",
|
||||
:short => "-d id|name",
|
||||
:large => "--datastore id|name" ,
|
||||
:description => "Selects the datastore",
|
||||
:format => String,
|
||||
:proc => lambda { |o, options|
|
||||
ch = OneDatastoreHelper.new
|
||||
rc, dsid = ch.to_id(o)
|
||||
dsid
|
||||
}
|
||||
}
|
||||
|
||||
def self.rname
|
||||
"DATASTORE"
|
||||
end
|
||||
@ -33,11 +46,35 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Datastore", :left, :size=>15 do |d|
|
||||
column :NAME, "Name of the Datastore", :left, :size=>12 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
default :ID, :NAME
|
||||
column :CLUSTER, "Name of the Cluster", :left, :size=>8 do |d|
|
||||
if d["CLUSTER"] == "none"
|
||||
"-"
|
||||
else
|
||||
d["CLUSTER"]
|
||||
end
|
||||
end
|
||||
|
||||
column :IMAGES, "Number of Images", :left, :size=>6 do |d|
|
||||
if d["IMAGES"]["ID"].nil?
|
||||
"0"
|
||||
else
|
||||
d["IMAGES"]["ID"].size
|
||||
end
|
||||
end
|
||||
|
||||
column :TYPE, "Datastore driver", :left, :size=>6 do |d|
|
||||
d["DS_MAD"]
|
||||
end
|
||||
|
||||
column :TM, "Transfer driver", :left, :size=>6 do |d|
|
||||
d["TM_MAD"]
|
||||
end
|
||||
|
||||
default :ID, :CLUSTER, :NAME, :IMAGES, :TYPE, :TM_MAD
|
||||
end
|
||||
|
||||
table
|
||||
@ -69,6 +106,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % ["USER", datastore['UNAME']]
|
||||
puts str % ["GROUP", datastore['GNAME']]
|
||||
puts str % ["CLUSTER", datastore['CLUSTER']]
|
||||
puts str % ["CLUSTER_ID", datastore['CLUSTER_ID']]
|
||||
|
||||
puts str % ["DS_MAD", datastore['DS_MAD']]
|
||||
puts str % ["TM_MAD", datastore['TM_MAD']]
|
||||
@ -87,14 +125,14 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
}
|
||||
puts
|
||||
|
||||
CLIHelper.print_header(str_h1 % "IMAGES", false)
|
||||
CLIHelper.print_header("%-15s" % ["ID"])
|
||||
CLIHelper.print_header(str_h1 % "DATASTORE TEMPLATE", false)
|
||||
puts datastore.template_str
|
||||
|
||||
puts
|
||||
|
||||
CLIHelper.print_header("%-15s" % "IMAGES")
|
||||
datastore.img_ids.each do |id|
|
||||
puts "%-15s" % [id]
|
||||
end
|
||||
|
||||
puts
|
||||
CLIHelper.print_header(str_h1 % "DATASTORE TEMPLATE",false)
|
||||
puts datastore.template_str
|
||||
end
|
||||
end
|
||||
|
@ -39,10 +39,18 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Host", :left, :size=>15 do |d|
|
||||
column :NAME, "Name of the Host", :left, :size=>12 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
column :CLUSTER, "Name of the Cluster", :left, :size=>8 do |d|
|
||||
if d["CLUSTER"] == "none"
|
||||
"-"
|
||||
else
|
||||
d["CLUSTER"]
|
||||
end
|
||||
end
|
||||
|
||||
column :RVM, "Number of Virtual Machines running", :size=>6 do |d|
|
||||
d["HOST_SHARE"]["RUNNING_VMS"]
|
||||
end
|
||||
@ -82,11 +90,11 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
||||
OpenNebulaHelper.unit_to_str(acpu,options)
|
||||
end
|
||||
|
||||
column :STAT, "Host status", :size=>6 do |d|
|
||||
column :STAT, "Host status", :size=>4 do |d|
|
||||
OneHostHelper.state_to_str(d["STATE"])
|
||||
end
|
||||
|
||||
default :ID, :NAME, :RVM, :TCPU, :FCPU, :ACPU, :TMEM, :FMEM,
|
||||
default :ID, :NAME, :CLUSTER, :RVM, :TCPU, :FCPU, :ACPU, :TMEM, :FMEM,
|
||||
:AMEM, :STAT
|
||||
end
|
||||
|
||||
|
@ -45,10 +45,6 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Image", :left, :size=>12 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
column :USER, "Username of the Virtual Machine owner", :left,
|
||||
:size=>8 do |d|
|
||||
helper.user_name(d, options)
|
||||
@ -59,13 +55,16 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
helper.group_name(d, options)
|
||||
end
|
||||
|
||||
column :TYPE, "Type of the Image", :size=>4 do |d,e|
|
||||
OneImageHelper.type_to_str(d["TYPE"])
|
||||
column :NAME, "Name of the Image", :left, :size=>12 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
column :REGTIME, "Registration time of the Image",
|
||||
:size=>20 do |d|
|
||||
OpenNebulaHelper.time_to_str(d["REGTIME"])
|
||||
column :DATASTORE, "Name of the Image", :left, :size=>10 do |d|
|
||||
d["DATASTORE"]
|
||||
end
|
||||
|
||||
column :TYPE, "Type of the Image", :size=>4 do |d,e|
|
||||
OneImageHelper.type_to_str(d["TYPE"])
|
||||
end
|
||||
|
||||
column :PERSISTENT, "Whether the Image is persistent or not",
|
||||
@ -87,7 +86,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
OpenNebulaHelper.unit_to_str(d['SIZE'].to_i,options,"M")
|
||||
end
|
||||
|
||||
default :ID, :USER, :GROUP, :NAME, :SIZE, :TYPE, :REGTIME,
|
||||
default :ID, :USER, :GROUP, :NAME, :DATASTORE, :SIZE, :TYPE,
|
||||
:PERSISTENT , :STAT, :RVMS
|
||||
end
|
||||
|
||||
|
@ -39,11 +39,6 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
d["ID"]
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Virtual Network", :left,
|
||||
:size=>15 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
column :USER, "Username of the Virtual Network owner", :left,
|
||||
:size=>8 do |d|
|
||||
helper.user_name(d, options)
|
||||
@ -54,11 +49,24 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
helper.group_name(d, options)
|
||||
end
|
||||
|
||||
column :NAME, "Name of the Virtual Network", :left,
|
||||
:size=>15 do |d|
|
||||
d["NAME"]
|
||||
end
|
||||
|
||||
column :CLUSTER, "Name of the Cluster", :left, :size=>8 do |d|
|
||||
if d["CLUSTER"] == "none"
|
||||
"-"
|
||||
else
|
||||
d["CLUSTER"]
|
||||
end
|
||||
end
|
||||
|
||||
column :TYPE, "Type of Virtual Network", :size=>6 do |d|
|
||||
OneVNetHelper.type_to_str(d["TYPE"])
|
||||
end
|
||||
|
||||
column :SIZE, "Size of the Virtual Network", :size=>6 do |d|
|
||||
column :SIZE, "Size of the Virtual Network", :size=>5 do |d|
|
||||
d["SIZE"]
|
||||
end
|
||||
|
||||
@ -68,7 +76,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
end
|
||||
|
||||
column :LEASES, "Number of this Virtual Network's given leases",
|
||||
:size=>7 do |d|
|
||||
:size=>6 do |d|
|
||||
d["TOTAL_LEASES"]
|
||||
end
|
||||
|
||||
|
@ -29,6 +29,7 @@ $: << RUBY_LIB_LOCATION+"/cli"
|
||||
|
||||
require 'command_parser'
|
||||
require 'one_helper/onedatastore_helper'
|
||||
require 'one_helper/onecluster_helper'
|
||||
|
||||
cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
usage "`onedatastore` <command> [<args>] [<options>]"
|
||||
@ -76,14 +77,17 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Creates a new Datastore from the given template file
|
||||
EOT
|
||||
|
||||
command :create, create_desc, :file, [:clusterid, nil] do
|
||||
helper.create_resource(options) do |datastore|
|
||||
template=File.read(args[0])
|
||||
command :create, create_desc, :file, :options=>[OneClusterHelper::CLUSTER] do
|
||||
|
||||
if args.size == 1
|
||||
datastore.allocate(template)
|
||||
else
|
||||
datastore.allocate(template, args[1].to_i)
|
||||
cid = options[:cluster] || ClusterPool::NONE_CLUSTER_ID
|
||||
|
||||
helper.create_resource(options) do |datastore|
|
||||
begin
|
||||
template=File.read(args[0])
|
||||
datastore.allocate(template, cid)
|
||||
rescue =>e
|
||||
STDERR.puts e.message
|
||||
exit -1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -29,6 +29,7 @@ $: << RUBY_LIB_LOCATION+"/cli"
|
||||
|
||||
require 'command_parser'
|
||||
require 'one_helper/onehost_helper'
|
||||
require 'one_helper/onecluster_helper'
|
||||
|
||||
cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
usage "`onehost` <command> [<args>] [<options>]"
|
||||
@ -41,9 +42,36 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
########################################################################
|
||||
set :option, CommandParser::OPTIONS
|
||||
|
||||
IM = {
|
||||
:name => "im",
|
||||
:short => "-i im_mad",
|
||||
:large => "--im im_mad" ,
|
||||
:description => "Set the information driver for the host",
|
||||
:format => String
|
||||
}
|
||||
|
||||
VMM = {
|
||||
:name => "vmm",
|
||||
:short => "-v vmm_mad",
|
||||
:large => "--vm vmm_mad" ,
|
||||
:description => "Set the virtualization driver for the host",
|
||||
:format => String
|
||||
}
|
||||
|
||||
VNET = {
|
||||
:name => "vnm",
|
||||
:short => "-n vnet_mad",
|
||||
:large => "--net vnet_mad" ,
|
||||
:description => "Set the network driver for the host",
|
||||
:format => String
|
||||
}
|
||||
|
||||
CREAT_OPTIONS = [ IM, VMM, VNET, OneClusterHelper::CLUSTER ]
|
||||
|
||||
########################################################################
|
||||
# Formatters for arguments
|
||||
########################################################################
|
||||
|
||||
set :format, :hostid, OneHostHelper.to_id_desc do |arg|
|
||||
helper.to_id(arg)
|
||||
end
|
||||
@ -60,14 +88,23 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Creates a new Host
|
||||
EOT
|
||||
|
||||
command :create, create_desc, :hostname, :im_mad, :vmm_mad,
|
||||
:vnm_mad, [:clusterid, nil] do
|
||||
command :create, create_desc, :hostname, :options=>CREAT_OPTIONS do
|
||||
if options[:im].nil? or options[:vmm].nil? or options[:vnm].nil?
|
||||
STDERR.puts "Drivers are mandatory to create a host:"
|
||||
STDERR.puts "\t -i information driver"
|
||||
STDERR.puts "\t -v hypervisor driver"
|
||||
STDERR.puts "\t -n network driver"
|
||||
exit -1
|
||||
end
|
||||
|
||||
cid = options[:cluster] || ClusterPool::NONE_CLUSTER_ID
|
||||
|
||||
helper.create_resource(options) do |host|
|
||||
if args.size == 4
|
||||
host.allocate(args[0], args[1], args[2], args[3])
|
||||
else
|
||||
host.allocate(args[0], args[1], args[2], args[3], args[4].to_i)
|
||||
end
|
||||
host.allocate(args[0],
|
||||
options[:im],
|
||||
options[:vmm],
|
||||
options[:vnm],
|
||||
cid)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,6 +29,7 @@ $: << RUBY_LIB_LOCATION+"/cli"
|
||||
|
||||
require 'command_parser'
|
||||
require 'one_helper/oneimage_helper'
|
||||
require 'one_helper/onedatastore_helper'
|
||||
|
||||
cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
usage "`oneimage` <command> [<args>] [<options>]"
|
||||
@ -45,6 +46,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
list_options << OpenNebulaHelper::XML
|
||||
list_options << OpenNebulaHelper::NUMERIC
|
||||
|
||||
CREATE_OPTIONS = [OneDatastoreHelper::DATASTORE]
|
||||
|
||||
########################################################################
|
||||
# Formatters for arguments
|
||||
########################################################################
|
||||
@ -56,10 +59,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
OpenNebulaHelper.rname_to_id(arg, "USER")
|
||||
end
|
||||
|
||||
set :format, :datastoreid, OpenNebulaHelper.rname_to_id_desc("DATASTORE") do |arg|
|
||||
OpenNebulaHelper.rname_to_id(arg, "DATASTORE")
|
||||
end
|
||||
|
||||
set :format, :imageid, OneImageHelper.to_id_desc do |arg|
|
||||
helper.to_id(arg)
|
||||
end
|
||||
@ -80,10 +79,20 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Creates a new Image from the given template file
|
||||
EOT
|
||||
|
||||
command :create, create_desc, :file, :datastoreid do
|
||||
command :create, create_desc, :file, :options=>CREATE_OPTIONS do
|
||||
if options[:datastore].nil?
|
||||
STDERR.puts "Datastore to save the image is mandatory: "
|
||||
STDERR.puts "\t -d datastore_id"
|
||||
exit -1
|
||||
end
|
||||
helper.create_resource(options) do |image|
|
||||
template=File.read(args[0])
|
||||
image.allocate(template, args[1])
|
||||
begin
|
||||
template=File.read(args[0])
|
||||
image.allocate(template, options[:datastore] )
|
||||
rescue => e
|
||||
STDERR.puts e.messsage
|
||||
exit -1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,6 +29,7 @@ $: << RUBY_LIB_LOCATION+"/cli"
|
||||
|
||||
require 'command_parser'
|
||||
require 'one_helper/onevnet_helper'
|
||||
require 'one_helper/onecluster_helper'
|
||||
|
||||
cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
usage "`onevnet` <command> [<args>] [<options>]"
|
||||
@ -41,6 +42,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
########################################################################
|
||||
set :option, CommandParser::OPTIONS
|
||||
|
||||
CREATE_OPTIONS = [OneClusterHelper::CLUSTER]
|
||||
|
||||
########################################################################
|
||||
# Formatters for arguments
|
||||
########################################################################
|
||||
@ -72,10 +75,17 @@ 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, options=>CREATE_OPTIONS do
|
||||
cid = options[:cluster] || ClusterPool::NONE_CLUSTER_ID
|
||||
|
||||
helper.create_resource(options) do |vn|
|
||||
template=File.read(args[0])
|
||||
vn.allocate(template)
|
||||
begin
|
||||
template=File.read(args[0])
|
||||
vn.allocate(template, cid)
|
||||
rescue => e
|
||||
STDERR.puts e.message
|
||||
exit -1
|
||||
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;
|
||||
|
@ -95,25 +95,10 @@ int Image::insert(SqlDB *db, string& error_str)
|
||||
string persistent_attr;
|
||||
string dev_prefix;
|
||||
string source_attr;
|
||||
string aname;
|
||||
string saved_id;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Check template for restricted attributes
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( uid != 0 && gid != GroupPool::ONEADMIN_ID )
|
||||
{
|
||||
ImageTemplate *img_template = static_cast<ImageTemplate *>(obj_template);
|
||||
|
||||
if (img_template->check(aname))
|
||||
{
|
||||
goto error_restricted;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Check default image attributes
|
||||
// ---------------------------------------------------------------------
|
||||
@ -242,11 +227,6 @@ error_path_and_source:
|
||||
error_str = "Template malformed, PATH and SOURCE are mutually exclusive.";
|
||||
goto error_common;
|
||||
|
||||
error_restricted:
|
||||
oss << "Template includes a restricted attribute " << aname << ".";
|
||||
error_str = oss.str();
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
NebulaLog::log("IMG", Log::ERROR, error_str);
|
||||
return -1;
|
||||
|
@ -27,6 +27,7 @@ ISCSIADM=iscsiadm
|
||||
LVCREATE=lvcreate
|
||||
LVREMOVE=lvremove
|
||||
LVS=lvs
|
||||
LN=ln
|
||||
MD5SUM=md5sum
|
||||
MKFS=mkfs
|
||||
MKISOFS=mkisofs
|
||||
@ -211,7 +212,7 @@ function mkfs_command {
|
||||
#This function executes $2 at $1 host and report error $3
|
||||
function ssh_exec_and_log
|
||||
{
|
||||
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
|
||||
SSH_EXEC_ERR=`$SSH $1 sh -s 2>&1 1>/dev/null <<EOF
|
||||
$2
|
||||
EOF`
|
||||
SSH_EXEC_RC=$?
|
||||
@ -232,7 +233,7 @@ EOF`
|
||||
#Creates path ($2) at $1
|
||||
function ssh_make_path
|
||||
{
|
||||
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
|
||||
SSH_EXEC_ERR=`$SSH $1 sh -s 2>&1 1>/dev/null <<EOF
|
||||
if [ ! -d $2 ]; then
|
||||
mkdir -p $2
|
||||
fi
|
||||
|
@ -82,7 +82,7 @@ module OpenNebula
|
||||
# @param im [String] Name of the im_driver (information/monitoring)
|
||||
# @param vmm [String] Name of the vmm_driver (hypervisor)
|
||||
# @param tm [String] Name of the vnm_driver (networking)
|
||||
# @param cluster_id [Integer] Id of the cluster
|
||||
# @param cluster_id [String] Id of the cluster
|
||||
#
|
||||
# @return [Integer, OpenNebula::Error] the new ID in case of
|
||||
# success, error otherwise
|
||||
|
@ -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>"
|
||||
|
||||
|
@ -107,43 +107,57 @@ class OneDB
|
||||
backup(ops[:backup], ops)
|
||||
end
|
||||
|
||||
result = nil
|
||||
i = 0
|
||||
begin
|
||||
result = nil
|
||||
i = 0
|
||||
|
||||
while ( matches.size > 0 )
|
||||
if ( matches.size > 1 )
|
||||
raise "There are more than one file that match \
|
||||
\"#{RUBY_LIB_LOCATION}/onedb/#{version}_to_*.rb\""
|
||||
while ( matches.size > 0 )
|
||||
if ( matches.size > 1 )
|
||||
raise "There are more than one file that match \
|
||||
\"#{RUBY_LIB_LOCATION}/onedb/#{version}_to_*.rb\""
|
||||
end
|
||||
|
||||
file = matches[0]
|
||||
|
||||
puts " > Running migrator #{file}" if ops[:verbose]
|
||||
|
||||
load(file)
|
||||
@backend.extend Migrator
|
||||
result = @backend.up
|
||||
|
||||
if !result
|
||||
raise "Error while upgrading from #{version} to " <<
|
||||
" #{@backend.db_version}"
|
||||
end
|
||||
|
||||
puts " > Done" if ops[:verbose]
|
||||
puts "" if ops[:verbose]
|
||||
|
||||
matches = Dir.glob(
|
||||
"#{RUBY_LIB_LOCATION}/onedb/#{@backend.db_version}_to_*.rb")
|
||||
end
|
||||
|
||||
file = matches[0]
|
||||
|
||||
puts " > Running migrator #{file}" if ops[:verbose]
|
||||
|
||||
load(file)
|
||||
@backend.extend Migrator
|
||||
result = @backend.up
|
||||
|
||||
if !result
|
||||
raise "Error while upgrading from #{version} to " <<
|
||||
" #{@backend.db_version}"
|
||||
# Modify db_versioning table
|
||||
if result != nil
|
||||
@backend.update_db_version(version)
|
||||
else
|
||||
puts "Database already uses version #{version}"
|
||||
end
|
||||
|
||||
puts " > Done" if ops[:verbose]
|
||||
puts "" if ops[:verbose]
|
||||
return 0
|
||||
|
||||
matches = Dir.glob(
|
||||
"#{RUBY_LIB_LOCATION}/onedb/#{@backend.db_version}_to_*.rb")
|
||||
rescue Exception => e
|
||||
puts e.message
|
||||
|
||||
puts
|
||||
puts "The database will be restored"
|
||||
|
||||
ops[:force] = true
|
||||
|
||||
restore(ops[:backup], ops)
|
||||
|
||||
return -1
|
||||
end
|
||||
|
||||
# Modify db_versioning table
|
||||
if result != nil
|
||||
@backend.update_db_version(version)
|
||||
else
|
||||
puts "Database already uses version #{version}"
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -76,9 +76,28 @@ bool VirtualMachineAllocate::allocate_authorization(
|
||||
|
||||
AuthRequest ar(att.uid, att.gid);
|
||||
string t64;
|
||||
string aname;
|
||||
|
||||
VirtualMachineTemplate * ttmpl = static_cast<VirtualMachineTemplate *>(tmpl);
|
||||
|
||||
// Check template for restricted attributes
|
||||
|
||||
if ( att.uid != 0 && att.gid != GroupPool::ONEADMIN_ID )
|
||||
{
|
||||
if (ttmpl->check(aname))
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "VM Template includes a restricted attribute " << aname;
|
||||
|
||||
failure_response(AUTHORIZATION,
|
||||
authorization_error(oss.str(), att),
|
||||
att);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ar.add_create_auth(auth_object, tmpl->to_xml(t64));
|
||||
|
||||
VirtualMachine::set_auth_request(att.uid, ar, ttmpl);
|
||||
@ -98,6 +117,39 @@ bool VirtualMachineAllocate::allocate_authorization(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
bool ImageAllocate::allocate_authorization(
|
||||
Template * tmpl,
|
||||
RequestAttributes& att,
|
||||
PoolObjectAuth * cluster_perms)
|
||||
{
|
||||
string aname;
|
||||
|
||||
ImageTemplate * itmpl = static_cast<ImageTemplate *>(tmpl);
|
||||
|
||||
// Check template for restricted attributes
|
||||
|
||||
if ( att.uid != 0 && att.gid != GroupPool::ONEADMIN_ID )
|
||||
{
|
||||
if (itmpl->check(aname))
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "Template includes a restricted attribute " << aname;
|
||||
|
||||
failure_response(AUTHORIZATION,
|
||||
authorization_error(oss.str(), att),
|
||||
att);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return RequestManagerAllocate::allocate_authorization(tmpl, att, cluster_perms);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
|
@ -39,6 +39,7 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
VMTemplate * rtmpl;
|
||||
|
||||
string error_str;
|
||||
string aname;
|
||||
|
||||
rtmpl = tpool->get(id,true);
|
||||
|
||||
@ -57,6 +58,26 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
|
||||
rtmpl->unlock();
|
||||
|
||||
// Check template for restricted attributes, but only if the Template owner
|
||||
// is not oneadmin
|
||||
|
||||
if ( perms.uid != 0 && perms.gid != GroupPool::ONEADMIN_ID )
|
||||
{
|
||||
if (tmpl->check(aname))
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "VM Template includes a restricted attribute " << aname;
|
||||
|
||||
failure_response(AUTHORIZATION,
|
||||
authorization_error(oss.str(), att),
|
||||
att);
|
||||
|
||||
delete tmpl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tmpl->erase("NAME");
|
||||
tmpl->set(new SingleAttribute("NAME",name));
|
||||
|
||||
|
@ -73,6 +73,9 @@ exec_and_log "$MKISOFS -o $ISO_FILE -J -R $ISO_DIR" "Error creating iso fs"
|
||||
|
||||
exec_and_log "$SCP $ISO_FILE $DST" "Error copying context ISO to $DST"
|
||||
|
||||
# Creates symbolic link to add a .iso suffix, needed for VMware CDROMs
|
||||
ssh_exec_and_log $DST_HOST "$LN -s $DST_PATH $DST_PATH.iso" "Error creating ISO symbolic link"
|
||||
|
||||
rm -rf $ISO_DIR > /dev/null 2>&1
|
||||
|
||||
exit 0
|
||||
|
@ -16,7 +16,7 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# ln fe:SOURCE host:remote_system_ds/disk.i size
|
||||
# ln fe:SOURCE host:remote_system_ds/disk.i
|
||||
# - fe is the front-end hostname
|
||||
# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
|
||||
# - host is the target host to deploy the VM
|
||||
@ -43,16 +43,41 @@ DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Link (ln) SRC into DST
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
log "Linking $SRC_PATH in $DST"
|
||||
# Is it a file or a folder (VMware)?
|
||||
if [ -d `arg_path $SRC` ]; then
|
||||
ssh_make_path $DST_HOST $DST_PATH
|
||||
|
||||
# It's a folder, make links for all elements
|
||||
SRC_FOLDER_NAME=`basename $SRC_PATH`
|
||||
SRC_WITH_NO_FOLDER=`dirname $SRC_PATH`
|
||||
SRC_DS_NAME=`basename $SRC_WITH_NO_FOLDER`
|
||||
REL_SRC_PATH="../../../$SRC_DS_NAME/$SRC_FOLDER_NAME"
|
||||
|
||||
log "Link all files in $SRC_PATH to $DST_PATH"
|
||||
|
||||
LINK_SCRIPT=$(cat <<EOF
|
||||
for file in \$(cd $DST_DIR ; find $SRC_PATH -type f); do
|
||||
FNAME=\$(basename \$file)
|
||||
(cd $DST_PATH ; ln -sf $REL_SRC_PATH/\$FNAME $DST_PATH/$FNAME)
|
||||
done
|
||||
EOF
|
||||
)
|
||||
ssh_exec_and_log $DST_HOST "$LINK_SCRIPT" "Could not link dir files from source DS to system DS"
|
||||
else
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
|
||||
# Just link a file
|
||||
log "Linking $SRC_PATH in $DST"
|
||||
|
||||
ssh_exec_and_log $DST_HOST \
|
||||
"cd $DST_DIR; ln -s $SRC_PATH $DST_PATH" \
|
||||
"Error linking $SRC to $DST"
|
||||
fi
|
||||
|
||||
ssh_exec_and_log $DST_HOST \
|
||||
"cd $DST_DIR; ln -s $SRC_PATH $DST_PATH" \
|
||||
"Error linking $SRC to $DST"
|
||||
|
||||
exit 0
|
||||
|
||||
|
@ -58,6 +58,6 @@ http://*)
|
||||
|
||||
*)
|
||||
log "Cloning $SRC in $DST_PATH"
|
||||
exec_and_log "$SCP $SRC $DST" "Error copying $SRC to $DST"
|
||||
exec_and_log "$SCP -r $SRC $DST" "Error copying $SRC to $DST"
|
||||
;;
|
||||
esac
|
||||
|
@ -49,6 +49,6 @@ SRC_HOST=`arg_host $SRC`
|
||||
# Move the image back to the datastore
|
||||
#-------------------------------------------------------------------------------
|
||||
log "Moving $SRC_PATH to datastore as $DST_PATH"
|
||||
exec_and_log "$SCP $SRC $DST" "Error copying $SRC to $DST"
|
||||
exec_and_log "$SCP -r $SRC $DST" "Error copying $SRC to $DST"
|
||||
|
||||
exit 0
|
||||
|
@ -70,3 +70,18 @@ function is_disk
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
#Makes path src ($1) relative to dst ($2)
|
||||
function make_relative {
|
||||
src=$1
|
||||
dst=$2
|
||||
|
||||
common=$dst
|
||||
|
||||
while [ -z "`echo $src | grep -E "^$common"`" ]; do
|
||||
common=`dirname $common`
|
||||
dots="../$dots"
|
||||
done
|
||||
|
||||
echo $dots${src#$common/}
|
||||
}
|
||||
|
@ -198,26 +198,9 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
|
||||
int rc;
|
||||
string name;
|
||||
|
||||
SingleAttribute * attr;
|
||||
string aname;
|
||||
string value;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Check template for restricted attributes
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( uid != 0 && gid != GroupPool::ONEADMIN_ID )
|
||||
{
|
||||
VirtualMachineTemplate *vt =
|
||||
static_cast<VirtualMachineTemplate *>(obj_template);
|
||||
|
||||
if (vt->check(aname))
|
||||
{
|
||||
goto error_restricted;
|
||||
}
|
||||
}
|
||||
SingleAttribute * attr;
|
||||
string value;
|
||||
ostringstream oss;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Set a name if the VM has not got one and VM_ID
|
||||
@ -327,11 +310,6 @@ error_leases_rollback:
|
||||
release_network_leases();
|
||||
goto error_common;
|
||||
|
||||
error_restricted:
|
||||
oss << "VM Template includes a restricted attribute " << aname << ".";
|
||||
error_str = oss.str();
|
||||
goto error_common;
|
||||
|
||||
error_name_length:
|
||||
oss << "NAME is too long; max length is 128 chars.";
|
||||
error_str = oss.str();
|
||||
|
@ -222,19 +222,19 @@ int LibVirtDriver::deployment_description_vmware(
|
||||
{
|
||||
file << "\t\t<disk type='block' device='disk'>" << endl;
|
||||
file << "\t\t\t<source file=[" << datastore << "] " << vm->get_oid()
|
||||
<< "/images/disk." << i << "'/>" << endl;
|
||||
<< "/disk." << i << "'/>" << endl;
|
||||
}
|
||||
else if ( type == "CDROM" )
|
||||
{
|
||||
file << "\t\t<disk type='file' device='cdrom'>" << endl;
|
||||
file << "\t\t\t<source file=[" << datastore << "] " << vm->get_oid()
|
||||
<< "/images/disk." << i << ".iso'/>" << endl;
|
||||
<< "/disk." << i << ".iso'/>" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
file << "\t\t<disk type='file' device='disk'>" << endl
|
||||
<< "\t\t\t<source file='[" << datastore <<"] " << vm->get_oid()
|
||||
<< "/images/disk." << i << "/disk.vmdk'/>" << endl;
|
||||
<< "/disk." << i << "/disk.vmdk'/>" << endl;
|
||||
}
|
||||
|
||||
file << "\t\t\t<target dev='" << target << "'";
|
||||
|
@ -28,8 +28,9 @@ MEMORY = 256
|
||||
OS = [ ARCH = i686 ]
|
||||
DISK = [ DRIVER = file ]
|
||||
|
||||
# Name of the datastore in the remote VMware hypervisors
|
||||
# mounting $ONE_LOCATION/var exported as a nfs share
|
||||
# by the OpenNebula front-end
|
||||
# Name of the system datastore in the remote VMware hypervisors
|
||||
# mounting DATASTORE_LOCATION/var/datastore/0 exported as a nfs share
|
||||
# by the OpenNebula front-end. This would need to be changed
|
||||
# *only* with custom TM drivers
|
||||
|
||||
DATASTORE = images
|
||||
DATASTORE = 0
|
||||
|
@ -165,7 +165,8 @@ class VMwareDriver
|
||||
def restore(checkpoint)
|
||||
begin
|
||||
# Define the VM
|
||||
dfile = File.dirname(File.dirname(checkpoint)) + "/deployment.0"
|
||||
dfile = VAR_LOCATION + "/" +
|
||||
File.basename(File.dirname(checkpoint)) + "/deployment.0"
|
||||
rescue => e
|
||||
OpenNebula.log_error("Cannot open checkpoint #{e.message}")
|
||||
exit -1
|
||||
|
Loading…
Reference in New Issue
Block a user