mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
========================================================= F #1884: it is possible to import objects with a single ID F #1884: its possible to add defaults file [vcenter Importer] F #1884: STDOUT changes around networks and template questions
This commit is contained in:
parent
192d535930
commit
a05322ff2f
@ -145,10 +145,21 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
||||
res[arg] = self.method(arg).call(opts[arg])
|
||||
end
|
||||
|
||||
res[:config] = parse_file(opts[:configuration]) if opts[:configuration]
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
def parse_file(path)
|
||||
begin
|
||||
config = YAML::load(File.read(path))
|
||||
rescue Exception => e
|
||||
str_error="Unable to read '#{path}'. Invalid YAML syntax:\n"
|
||||
|
||||
raise str_error
|
||||
end
|
||||
end
|
||||
|
||||
def format_list()
|
||||
config = TABLE[@vobject][:columns]
|
||||
table = CLIHelper::ShowTable.new() do
|
||||
@ -201,6 +212,8 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
||||
type: ''
|
||||
}
|
||||
|
||||
STDOUT.print "\n- Template: \e[92m#{t[:template_name]}\e[39m\n\n"\
|
||||
|
||||
# LINKED CLONE OPTION
|
||||
STDOUT.print "\n For faster deployment operations"\
|
||||
" and lower disk usage, OpenNebula"\
|
||||
@ -284,6 +297,8 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
||||
return answer
|
||||
}
|
||||
|
||||
STDOUT.print "\n- Network: \e[92m#{n[:name]}\e[39m\n\n"\
|
||||
|
||||
opts = { size: "255", type: "ether" }
|
||||
|
||||
question = " How many VMs are you planning"\
|
||||
@ -291,7 +306,7 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
|
||||
opts[:size] = ask.call(question, "255")
|
||||
|
||||
question = " What type of Virtual Network"\
|
||||
" do you want to create (IPv[4],IPv[6], [E]thernet)?"
|
||||
" do you want to create (IPv[4],IPv[6], [E]thernet)? "
|
||||
type_answer = ask.call(question, "ether")
|
||||
|
||||
supported_types = ["4","6","ether", "e", "ip4", "ip6" ]
|
||||
|
@ -70,6 +70,13 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
:description => "OpenNebula datastore used"
|
||||
}
|
||||
|
||||
CONFIG = {
|
||||
:name => "configuration",
|
||||
:large => "--config file",
|
||||
:format => String,
|
||||
:description => "Configuration file for custom options"
|
||||
}
|
||||
|
||||
VCENTER = {
|
||||
:name => "vcenter",
|
||||
:large => "--vcenter vCenter" ,
|
||||
@ -162,7 +169,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
exit 0
|
||||
end
|
||||
|
||||
command :import_defaults, import_desc, [:oid, nil] , :options=>[ OBJECT, HOST, DATASTORE ] do
|
||||
command :import_defaults, import_desc, [:oid, nil] , :options=>[ OBJECT, HOST, DATASTORE, CONFIG ] do
|
||||
|
||||
if options[:host] && options[:object]
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(options[:host])
|
||||
|
@ -289,6 +289,7 @@ class NetImporter < VCenterDriver::VcImporter
|
||||
def initialize(one_client, vi_client)
|
||||
super(one_client, vi_client)
|
||||
@one_class = OpenNebula::VirtualNetwork
|
||||
@defaults = { size: "255", type: "ether" }
|
||||
end
|
||||
|
||||
def get_list(args = {})
|
||||
@ -330,7 +331,8 @@ class NetImporter < VCenterDriver::VcImporter
|
||||
case type
|
||||
when "4", "ip4", "ip"
|
||||
str << "IP4\""
|
||||
str << ",IP=\"#{opts[:ip]}\"" if opts[:ip]
|
||||
opts[:ip] = "192.168.1.1" if opts[:ip].empty?
|
||||
str << ",IP=\"#{opts[:ip]}\""
|
||||
when 'ip6'
|
||||
str << "IP6\""
|
||||
str << ",GLOBAL_PREFIX=\"#{opts[:global_prefix]}\"" if opts[:global_prefix]
|
||||
@ -375,10 +377,6 @@ class NetImporter < VCenterDriver::VcImporter
|
||||
return res
|
||||
end
|
||||
|
||||
def defaults
|
||||
{ size: "255", type: "ether" }
|
||||
end
|
||||
|
||||
def attr
|
||||
"TEMPLATE/VCENTER_NET_REF"
|
||||
end
|
||||
|
@ -190,6 +190,12 @@ module VCenterDriver
|
||||
end
|
||||
end
|
||||
|
||||
if args !~ /\D/
|
||||
ind = args.to_i
|
||||
|
||||
return keys[ind]
|
||||
end
|
||||
|
||||
return args
|
||||
end
|
||||
|
||||
@ -204,8 +210,11 @@ module VCenterDriver
|
||||
#
|
||||
def retrieve_resources(opts = {})
|
||||
list = get_list(opts)
|
||||
|
||||
@defaults = opts[:config] if opts[:config]
|
||||
VCenterDriver::VIHelper.clean_ref_hash
|
||||
|
||||
|
||||
return list
|
||||
end
|
||||
|
||||
@ -342,6 +351,8 @@ module VCenterDriver
|
||||
# Default opts
|
||||
#
|
||||
def defaults
|
||||
return @defaults if @defaults
|
||||
|
||||
{}
|
||||
end
|
||||
|
||||
|
@ -3397,6 +3397,16 @@ class VmImporter < VCenterDriver::VcImporter
|
||||
def initialize(one_client, vi_client)
|
||||
super(one_client, vi_client)
|
||||
@one_class = OpenNebula::Template
|
||||
|
||||
@defaults = {
|
||||
linked_clone: '0',
|
||||
copy: '0',
|
||||
name: '',
|
||||
folder: '',
|
||||
resourcepool: [],
|
||||
type: ''
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
def get_list(args = {})
|
||||
@ -3535,17 +3545,6 @@ class VmImporter < VCenterDriver::VcImporter
|
||||
return res
|
||||
end
|
||||
|
||||
def defaults
|
||||
opts = {
|
||||
linked_clone: '0',
|
||||
copy: '0',
|
||||
name: '',
|
||||
folder: '',
|
||||
resourcepool: [],
|
||||
type: ''
|
||||
}
|
||||
end
|
||||
|
||||
def attr
|
||||
"TEMPLATE/VCENTER_TEMPLATE_REF"
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user