opennebula-cli 5.6.2 → 5.7.80.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/oneacct +37 -35
- data/bin/oneacl +15 -15
- data/bin/onecluster +31 -31
- data/bin/onedatastore +35 -35
- data/bin/oneflow +274 -237
- data/bin/oneflow-template +161 -138
- data/bin/onegroup +32 -30
- data/bin/onehost +68 -63
- data/bin/oneimage +92 -81
- data/bin/onemarket +31 -29
- data/bin/onemarketapp +83 -75
- data/bin/onesecgroup +37 -33
- data/bin/oneshowback +40 -43
- data/bin/onetemplate +73 -70
- data/bin/oneuser +171 -158
- data/bin/onevcenter +70 -64
- data/bin/onevdc +61 -45
- data/bin/onevm +396 -260
- data/bin/onevmgroup +47 -47
- data/bin/onevnet +94 -158
- data/bin/onevntemplate +361 -0
- data/bin/onevrouter +76 -70
- data/bin/onezone +30 -31
- data/lib/one_helper.rb +106 -22
- data/lib/one_helper/oneacl_helper.rb +6 -4
- data/lib/one_helper/onevcenter_helper.rb +1 -1
- data/lib/one_helper/onevm_helper.rb +134 -91
- data/lib/one_helper/onevnet_helper.rb +20 -8
- data/lib/one_helper/onevntemplate_helper.rb +104 -0
- metadata +9 -6
data/bin/onezone
CHANGED
@@ -16,31 +16,32 @@
|
|
16
16
|
# limitations under the License. #
|
17
17
|
#--------------------------------------------------------------------------- #
|
18
18
|
|
19
|
-
ONE_LOCATION=ENV[
|
19
|
+
ONE_LOCATION = ENV['ONE_LOCATION']
|
20
20
|
|
21
21
|
if !ONE_LOCATION
|
22
|
-
RUBY_LIB_LOCATION=
|
22
|
+
RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
|
23
23
|
else
|
24
|
-
RUBY_LIB_LOCATION=ONE_LOCATION+
|
24
|
+
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
$LOAD_PATH << RUBY_LIB_LOCATION
|
28
|
+
$LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
|
29
29
|
|
30
30
|
require 'command_parser'
|
31
31
|
require 'one_helper/onezone_helper'
|
32
32
|
|
33
|
-
|
34
|
-
usage
|
33
|
+
CommandParser::CmdParser.new(ARGV) do
|
34
|
+
usage '`onezone` <command> [<args>] [<options>]'
|
35
35
|
version OpenNebulaHelper::ONE_VERSION
|
36
36
|
|
37
37
|
helper = OneZoneHelper.new
|
38
38
|
|
39
39
|
ENDPOINT = {
|
40
|
-
:name =>
|
41
|
-
:short
|
42
|
-
:large =>
|
43
|
-
:description => "Don't overwrite endpoint file located in home folder,
|
40
|
+
:name => 'keep',
|
41
|
+
:short => '-k',
|
42
|
+
:large => '--keep',
|
43
|
+
:description => "Don't overwrite endpoint file located in home folder,"\
|
44
|
+
' use it as a temporary zone.',
|
44
45
|
:format => String
|
45
46
|
}
|
46
47
|
|
@@ -51,7 +52,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
51
52
|
########################################################################
|
52
53
|
# Global Options
|
53
54
|
########################################################################
|
54
|
-
set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
|
55
|
+
set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
|
55
56
|
|
56
57
|
list_options = CLIHelper::OPTIONS
|
57
58
|
list_options << OpenNebulaHelper::XML
|
@@ -82,9 +83,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
82
83
|
begin
|
83
84
|
template = File.read(args[0])
|
84
85
|
zone.allocate(template)
|
85
|
-
rescue => e
|
86
|
+
rescue StandardError => e
|
86
87
|
STDERR.puts e.message
|
87
|
-
exit
|
88
|
+
exit(-1)
|
88
89
|
end
|
89
90
|
end
|
90
91
|
end
|
@@ -94,7 +95,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
94
95
|
EOT
|
95
96
|
|
96
97
|
command :rename, rename_desc, :zoneid, :name do
|
97
|
-
helper.perform_action(args[0],options,
|
98
|
+
helper.perform_action(args[0], options, 'renamed') do |o|
|
98
99
|
o.rename(args[1])
|
99
100
|
end
|
100
101
|
end
|
@@ -104,13 +105,13 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
104
105
|
EOT
|
105
106
|
|
106
107
|
command :"server-add", addserver_desc, :zoneid, :options =>
|
107
|
-
[
|
108
|
+
[OneZoneHelper::SERVER_NAME, OneZoneHelper::SERVER_ENDPOINT] do
|
108
109
|
|
109
110
|
if options[:server_name].nil? || options[:server_rpc].nil?
|
110
|
-
STDERR.puts
|
111
|
+
STDERR.puts 'To add a server set:'
|
111
112
|
STDERR.puts "\t-n <server name>"
|
112
113
|
STDERR.puts "\t-r <RPC endpoint>"
|
113
|
-
exit
|
114
|
+
exit(-1)
|
114
115
|
end
|
115
116
|
|
116
117
|
template = <<-EOT
|
@@ -120,10 +121,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
120
121
|
]
|
121
122
|
EOT
|
122
123
|
|
123
|
-
helper.perform_action(args[0], options,
|
124
|
+
helper.perform_action(args[0], options, 'server added') do |o|
|
124
125
|
o.add_servers(template)
|
125
126
|
end
|
126
|
-
|
127
127
|
end
|
128
128
|
|
129
129
|
delserver_desc = <<-EOT.unindent
|
@@ -131,10 +131,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
131
131
|
EOT
|
132
132
|
|
133
133
|
command :"server-del", delserver_desc, :zoneid, :serverid do
|
134
|
-
helper.perform_action(args[0], options,
|
134
|
+
helper.perform_action(args[0], options, 'server deleted') do |o|
|
135
135
|
o.delete_servers(args[1].to_i)
|
136
136
|
end
|
137
|
-
|
138
137
|
end
|
139
138
|
|
140
139
|
resetserver_desc = <<-EOT.unindent
|
@@ -143,7 +142,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
143
142
|
EOT
|
144
143
|
|
145
144
|
command :"server-reset", resetserver_desc, :zoneid, :serverid do
|
146
|
-
helper.perform_action(args[0], options,
|
145
|
+
helper.perform_action(args[0], options, 'server reset') do |o|
|
147
146
|
o.reset_server(args[1].to_i)
|
148
147
|
end
|
149
148
|
end
|
@@ -154,8 +153,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
154
153
|
EOT
|
155
154
|
|
156
155
|
command :update, update_desc, :zoneid, [:file, nil],
|
157
|
-
|
158
|
-
helper.perform_action(args[0],options,
|
156
|
+
:options => OpenNebulaHelper::APPEND do
|
157
|
+
helper.perform_action(args[0], options, 'modified') do |obj|
|
159
158
|
if options[:append]
|
160
159
|
str = OpenNebulaHelper.append_template(args[0], obj, args[1])
|
161
160
|
else
|
@@ -174,7 +173,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
174
173
|
EOT
|
175
174
|
|
176
175
|
command :delete, delete_desc, [:range, :zoneid_list] do
|
177
|
-
helper.perform_actions(args[0],options,
|
176
|
+
helper.perform_actions(args[0], options, 'deleted') do |obj|
|
178
177
|
obj.delete
|
179
178
|
end
|
180
179
|
end
|
@@ -183,7 +182,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
183
182
|
Lists Zones in the pool
|
184
183
|
EOT
|
185
184
|
|
186
|
-
command :list, list_desc, :options=>list_options do
|
185
|
+
command :list, list_desc, :options => list_options do
|
187
186
|
helper.list_pool(options)
|
188
187
|
end
|
189
188
|
|
@@ -191,16 +190,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
191
190
|
Shows information for the given Zone
|
192
191
|
EOT
|
193
192
|
|
194
|
-
command :show, show_desc
|
195
|
-
helper.show_resource(args[0],options)
|
193
|
+
command :show, show_desc, :zoneid, :options => OpenNebulaHelper::XML do
|
194
|
+
helper.show_resource(args[0], options)
|
196
195
|
end
|
197
196
|
|
198
197
|
set_desc = <<-EOT.unindent
|
199
198
|
Set shell session access point for the CLI to the given Zone
|
200
199
|
EOT
|
201
200
|
|
202
|
-
command :set, set_desc
|
203
|
-
if options.
|
201
|
+
command :set, set_desc, :zoneid, :options => ENDPOINT do
|
202
|
+
if options.key? :keep
|
204
203
|
helper.set_zone(args[0], true)
|
205
204
|
else
|
206
205
|
helper.set_zone(args[0], false)
|
data/lib/one_helper.rb
CHANGED
@@ -15,7 +15,6 @@
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
17
|
require 'cli_helper'
|
18
|
-
|
19
18
|
require 'open3'
|
20
19
|
require 'io/console'
|
21
20
|
|
@@ -179,6 +178,20 @@ EOT
|
|
179
178
|
}
|
180
179
|
]
|
181
180
|
|
181
|
+
AS_USER = {
|
182
|
+
:name => 'as_uid',
|
183
|
+
:large => '--as_uid uid',
|
184
|
+
:format => Integer,
|
185
|
+
:description => 'The User ID to instantiate the VM'
|
186
|
+
}
|
187
|
+
|
188
|
+
AS_GROUP = {
|
189
|
+
:name => 'as_gid',
|
190
|
+
:large => '--as_gid gid',
|
191
|
+
:format => Integer,
|
192
|
+
:description => 'The Group ID to instantiate the VM'
|
193
|
+
}
|
194
|
+
|
182
195
|
#NOTE: Other options defined using this array, add new options at the end
|
183
196
|
TEMPLATE_OPTIONS=[
|
184
197
|
{
|
@@ -246,7 +259,8 @@ EOT
|
|
246
259
|
:description => "Networks to attach. To use a network owned by"<<
|
247
260
|
" other user use user[network]. Additional"<<
|
248
261
|
" attributes are supported like with the --disk"<<
|
249
|
-
" option."
|
262
|
+
" option. Also you can use auto if you want that" <<
|
263
|
+
" OpenNebula select automatically the network",
|
250
264
|
:format => Array
|
251
265
|
},
|
252
266
|
{
|
@@ -367,18 +381,8 @@ EOT
|
|
367
381
|
:description => "In a vCenter environment sets the the VMs and Template folder where the VM will be placed in." \
|
368
382
|
" The path uses slashes to separate folders. For example: --vcenter_vm_folder \"/Management/VMs\""
|
369
383
|
},
|
370
|
-
|
371
|
-
|
372
|
-
:large => '--as_uid uid',
|
373
|
-
:format => Integer,
|
374
|
-
:description => 'The User ID to instantiate the VM'
|
375
|
-
},
|
376
|
-
{
|
377
|
-
:name => 'as_gid',
|
378
|
-
:large => '--as_gid gid',
|
379
|
-
:format => Integer,
|
380
|
-
:description => 'The Group ID to instantiate the VM'
|
381
|
-
}
|
384
|
+
AS_GROUP,
|
385
|
+
AS_USER
|
382
386
|
]
|
383
387
|
|
384
388
|
FORCE={
|
@@ -1241,15 +1245,19 @@ EOT
|
|
1241
1245
|
user, object=*res
|
1242
1246
|
|
1243
1247
|
template<<"#{section.upcase}=[\n"
|
1244
|
-
|
1245
|
-
|
1246
|
-
key, value = extra_attribute.split("=")
|
1247
|
-
template<<" #{key.upcase}=\"#{value}\",\n"
|
1248
|
-
end
|
1249
|
-
if object.match(/^\d+$/)
|
1250
|
-
template<<" #{name.upcase}_ID=#{object}\n"
|
1248
|
+
if object.downcase == "auto"
|
1249
|
+
template<<" NETWORK_MODE=\"#{object}\"\n"
|
1251
1250
|
else
|
1252
|
-
template<<" #{name.upcase}=\"#{
|
1251
|
+
template<<" #{name.upcase}_UNAME=\"#{user}\",\n" if user
|
1252
|
+
extra_attributes.each do |extra_attribute|
|
1253
|
+
key, value = extra_attribute.split("=")
|
1254
|
+
template<<" #{key.upcase}=\"#{value}\",\n"
|
1255
|
+
end
|
1256
|
+
if object.match(/^\d+$/)
|
1257
|
+
template<<" #{name.upcase}_ID=#{object}\n"
|
1258
|
+
else
|
1259
|
+
template<<" #{name.upcase}=\"#{object}\"\n"
|
1260
|
+
end
|
1253
1261
|
end
|
1254
1262
|
template<<"]\n"
|
1255
1263
|
end if objects
|
@@ -1404,6 +1412,82 @@ EOT
|
|
1404
1412
|
[0, template]
|
1405
1413
|
end
|
1406
1414
|
|
1415
|
+
def self.create_ar(options)
|
1416
|
+
ar = 'AR = [ '
|
1417
|
+
|
1418
|
+
if options[:ip]
|
1419
|
+
if options[:ip6_global] || options[:ip6_ula]
|
1420
|
+
ar << 'TYPE="IP4_6"'
|
1421
|
+
elsif options[:ip6]
|
1422
|
+
ar << 'TYPE="IP4_6_STATIC"'
|
1423
|
+
else
|
1424
|
+
ar << 'TYPE="IP4"'
|
1425
|
+
end
|
1426
|
+
elsif options[:ip6]
|
1427
|
+
ar << 'TYPE="IP6_STATIC"'
|
1428
|
+
elsif options[:ip6_global] || options[:ip6_ula]
|
1429
|
+
ar << 'TYPE="IP6"'
|
1430
|
+
else
|
1431
|
+
ar << 'TYPE="ETHER"'
|
1432
|
+
end
|
1433
|
+
|
1434
|
+
if options[:size]
|
1435
|
+
ar << ', SIZE = ' << options[:size]
|
1436
|
+
else
|
1437
|
+
STDERR.puts 'Address range needs to specify size (-s size)'
|
1438
|
+
exit(-1)
|
1439
|
+
end
|
1440
|
+
|
1441
|
+
if options[:ip6]
|
1442
|
+
m = %r{([\h:]*)\/(\d.*)$}.match(options[:ip6])
|
1443
|
+
|
1444
|
+
if m.nil? || m[1].nil?
|
1445
|
+
STDERR.puts 'Missing or wrong IP6'
|
1446
|
+
exit(-1)
|
1447
|
+
else
|
1448
|
+
begin
|
1449
|
+
require 'ipaddr'
|
1450
|
+
|
1451
|
+
ip = IPAddr.new(m[1])
|
1452
|
+
|
1453
|
+
if !ip.ipv6?
|
1454
|
+
STDERR.puts 'Wrong IP6 format address'
|
1455
|
+
exit(-1)
|
1456
|
+
end
|
1457
|
+
rescue StandardError
|
1458
|
+
STDERR.puts 'Wrong IP6 format address'
|
1459
|
+
exit(-1)
|
1460
|
+
end
|
1461
|
+
|
1462
|
+
end
|
1463
|
+
|
1464
|
+
if m[2].nil?
|
1465
|
+
STDERR.puts 'IP6 address need to set the prefix length'
|
1466
|
+
exit(-1)
|
1467
|
+
end
|
1468
|
+
|
1469
|
+
ar << ", PREFIX_LENGTH=\"#{m[2]}\""
|
1470
|
+
|
1471
|
+
options[:ip6] = m[1]
|
1472
|
+
end
|
1473
|
+
|
1474
|
+
ar << ', IP = ' << options[:ip] if options[:ip]
|
1475
|
+
ar << ', IP6 = ' << options[:ip6] if options[:ip6]
|
1476
|
+
ar << ', MAC = ' << options[:mac] if options[:mac]
|
1477
|
+
if options[:ip6_global]
|
1478
|
+
ar << ', GLOBAL_PREFIX = ' << options[:ip6_global]
|
1479
|
+
end
|
1480
|
+
if options[:ip6_ula]
|
1481
|
+
ar << ', ULA_PREFIX = ' << options[:ip6_ula]
|
1482
|
+
end
|
1483
|
+
ar << ', GATEWAY = ' << options[:gateway] if options[:gateway]
|
1484
|
+
ar << ', MASK = ' << options[:netmask] if options[:netmask]
|
1485
|
+
ar << ', VN_MAD = ' << options[:vn_mad] if options[:vn_mad]
|
1486
|
+
ar << ', VLAN_ID = ' << options[:vlanid] if options[:vlanid]
|
1487
|
+
|
1488
|
+
ar << ']'
|
1489
|
+
end
|
1490
|
+
|
1407
1491
|
def self.create_template_options_used?(options)
|
1408
1492
|
# Get the template options names as symbols. options hash
|
1409
1493
|
# uses symbols
|
@@ -44,7 +44,7 @@ private
|
|
44
44
|
def self.resource_mask(str)
|
45
45
|
resource_type=str.split("/")[0]
|
46
46
|
|
47
|
-
mask = "
|
47
|
+
mask = "------------------"
|
48
48
|
|
49
49
|
resource_type.split("+").each{|type|
|
50
50
|
case type
|
@@ -82,6 +82,8 @@ private
|
|
82
82
|
mask[15] = "A"
|
83
83
|
when "VMGROUP"
|
84
84
|
mask[16] = "P"
|
85
|
+
when "VNTEMPLATE"
|
86
|
+
mask[17] = "t"
|
85
87
|
end
|
86
88
|
}
|
87
89
|
mask
|
@@ -121,8 +123,8 @@ private
|
|
121
123
|
d['STRING'].split(" ")[0]
|
122
124
|
end
|
123
125
|
|
124
|
-
column :
|
125
|
-
:size =>
|
126
|
+
column :RES_VHNIUTGDCOZSvRMAPt, "Resource to which the rule applies",
|
127
|
+
:size => 22 do |d|
|
126
128
|
OneAclHelper::resource_mask d['STRING'].split(" ")[1]
|
127
129
|
end
|
128
130
|
|
@@ -139,7 +141,7 @@ private
|
|
139
141
|
OneAclHelper::right_mask d['STRING'].split(" ")[2]
|
140
142
|
end
|
141
143
|
|
142
|
-
default :ID, :USER, :
|
144
|
+
default :ID, :USER, :RES_VHNIUTGDCOZSvRMAPt, :RID, :OPE_UMAC, :ZONE
|
143
145
|
end
|
144
146
|
|
145
147
|
table
|
@@ -171,6 +171,33 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
171
171
|
:description=> "Does not communicate with the guest OS"
|
172
172
|
}
|
173
173
|
|
174
|
+
POFF = {
|
175
|
+
:name => "poweroff",
|
176
|
+
:large => "--poff",
|
177
|
+
:description => "Do the migrate by poweringoff the vm"
|
178
|
+
}
|
179
|
+
|
180
|
+
POFFHARD = {
|
181
|
+
:name => "poweroff_hard",
|
182
|
+
:large => "--poff-hard",
|
183
|
+
:description => "Do the migrate by poweringoff hard the vm"
|
184
|
+
}
|
185
|
+
|
186
|
+
ALIAS = {
|
187
|
+
:name => "alias",
|
188
|
+
:short => "-a alias",
|
189
|
+
:large => "--alias alias",
|
190
|
+
:description=> "Attach the NIC as an ALIAS",
|
191
|
+
:format => String
|
192
|
+
}
|
193
|
+
|
194
|
+
NIC_NAME = {
|
195
|
+
:name => "nic_name",
|
196
|
+
:large => "--nic_name name",
|
197
|
+
:description=> "Name of the NIC",
|
198
|
+
:format => String
|
199
|
+
}
|
200
|
+
|
174
201
|
def self.rname
|
175
202
|
"VM"
|
176
203
|
end
|
@@ -529,6 +556,16 @@ in the frontend machine.
|
|
529
556
|
puts
|
530
557
|
end
|
531
558
|
|
559
|
+
def get_migration_type(options)
|
560
|
+
if options[:poweroff]
|
561
|
+
return 1
|
562
|
+
elsif options[:poweroff_hard]
|
563
|
+
return 2
|
564
|
+
else
|
565
|
+
return 0
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
532
569
|
private
|
533
570
|
|
534
571
|
def factory(id=nil)
|
@@ -800,132 +837,138 @@ in the frontend machine.
|
|
800
837
|
|
801
838
|
extra_ips.uniq!
|
802
839
|
|
803
|
-
|
804
|
-
|
840
|
+
['NIC', 'NIC_ALIAS'].each do |type|
|
841
|
+
if vm.has_elements?("/VM/TEMPLATE/#{type}") ||
|
842
|
+
vm.has_elements?("/VM/TEMPLATE/PCI[NIC_ID>-1]") || !extra_ips.empty?
|
805
843
|
|
806
|
-
|
807
|
-
|
844
|
+
puts
|
845
|
+
CLIHelper.print_header(str_h1 % "VM #{type == 'NIC' ? 'NICS' : 'ALIAS'}",false)
|
808
846
|
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
847
|
+
nic_default = {"NETWORK" => "-",
|
848
|
+
"IP" => "-",
|
849
|
+
"MAC"=> "-",
|
850
|
+
"BRIDGE"=>"-"}
|
813
851
|
|
814
|
-
|
852
|
+
shown_ips = []
|
815
853
|
|
816
|
-
|
817
|
-
|
854
|
+
array_id = 0
|
855
|
+
vm_nics = [vm_hash['VM']['TEMPLATE'][type]]
|
818
856
|
|
819
|
-
|
857
|
+
if type == 'NIC'
|
858
|
+
vm_pcis = [vm_hash['VM']['TEMPLATE']['PCI']].flatten.compact
|
820
859
|
|
821
|
-
|
822
|
-
|
823
|
-
|
860
|
+
vm_pcis.each do |pci|
|
861
|
+
if !pci['NIC_ID'].nil?
|
862
|
+
vm_nics << pci
|
863
|
+
end
|
864
|
+
end
|
824
865
|
end
|
825
|
-
end
|
826
866
|
|
827
|
-
|
828
|
-
|
867
|
+
vm_nics.flatten!
|
868
|
+
vm_nics.compact!
|
829
869
|
|
830
|
-
|
870
|
+
vm_nics.each {|nic|
|
831
871
|
|
832
|
-
|
872
|
+
next if nic.has_key?("CLI_DONE")
|
833
873
|
|
834
|
-
|
835
|
-
|
836
|
-
|
874
|
+
["IP6_LINK", "IP6_ULA", "IP6_GLOBAL", "IP6"].each do |attr|
|
875
|
+
if nic.has_key?(attr)
|
876
|
+
shown_ips << nic[attr]
|
837
877
|
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
878
|
+
ipstr = {"IP" => nic.delete(attr),
|
879
|
+
"CLI_DONE" => true,
|
880
|
+
"DOUBLE_ENTRY" => true}
|
881
|
+
vm_nics.insert(array_id+1,ipstr)
|
842
882
|
|
843
|
-
|
883
|
+
array_id += 1
|
884
|
+
end
|
844
885
|
end
|
845
|
-
end
|
846
886
|
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
887
|
+
["VROUTER_IP", "VROUTER_IP6_LINK",
|
888
|
+
"VROUTER_IP6_ULA", "VROUTER_IP6_GLOBAL"].each do |attr|
|
889
|
+
if nic.has_key?(attr)
|
890
|
+
shown_ips << nic[attr]
|
851
891
|
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
892
|
+
ipstr = {"IP" => nic.delete(attr) + " (VRouter)",
|
893
|
+
"CLI_DONE" => true,
|
894
|
+
"DOUBLE_ENTRY" => true}
|
895
|
+
vm_nics.insert(array_id+1,ipstr)
|
856
896
|
|
857
|
-
|
897
|
+
array_id += 1
|
898
|
+
end
|
858
899
|
end
|
859
|
-
end
|
860
900
|
|
861
|
-
|
901
|
+
shown_ips << nic["IP"] if nic.has_key?("IP")
|
862
902
|
|
863
|
-
|
864
|
-
|
865
|
-
|
903
|
+
nic.merge!(nic_default) {|k,v1,v2| v1}
|
904
|
+
array_id += 1
|
905
|
+
}
|
866
906
|
|
867
|
-
|
907
|
+
extra_ips -= shown_ips
|
868
908
|
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
909
|
+
# Add extra IPs to the VM NICS table
|
910
|
+
extra_ips.each do |ip|
|
911
|
+
vm_nics << {
|
912
|
+
"NIC_ID" => "-",
|
913
|
+
"IP" => ip,
|
914
|
+
"NETWORK" => "Additional IP",
|
915
|
+
"BRIDGE" => "-"
|
916
|
+
}
|
917
|
+
end
|
878
918
|
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
919
|
+
CLIHelper::ShowTable.new(nil, self) do
|
920
|
+
column :ID, "", :size=>3 do |d|
|
921
|
+
if d["DOUBLE_ENTRY"]
|
922
|
+
""
|
923
|
+
else
|
924
|
+
d["NIC_ID"]
|
925
|
+
end
|
885
926
|
end
|
886
|
-
end
|
887
927
|
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
928
|
+
column :NETWORK, "", :left, :size=>20 do |d|
|
929
|
+
if d["DOUBLE_ENTRY"]
|
930
|
+
""
|
931
|
+
else
|
932
|
+
d["NETWORK"]
|
933
|
+
end
|
893
934
|
end
|
894
|
-
end
|
895
935
|
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
936
|
+
column :BRIDGE, "", :left, :size=>12 do |d|
|
937
|
+
if d["DOUBLE_ENTRY"]
|
938
|
+
""
|
939
|
+
else
|
940
|
+
d["BRIDGE"]
|
941
|
+
end
|
901
942
|
end
|
902
|
-
end
|
903
943
|
|
904
|
-
|
905
|
-
|
906
|
-
|
944
|
+
column :IP, "",:left, :donottruncate, :size=>15 do |d|
|
945
|
+
d["IP"]
|
946
|
+
end
|
907
947
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
948
|
+
column :MAC, "", :left, :size=>17 do |d|
|
949
|
+
if d["DOUBLE_ENTRY"]
|
950
|
+
""
|
951
|
+
else
|
952
|
+
d["MAC"]
|
953
|
+
end
|
913
954
|
end
|
914
|
-
end
|
915
955
|
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
956
|
+
if type == 'NIC'
|
957
|
+
column :PCI_ID, "", :left, :size=>8 do |d|
|
958
|
+
if d["DOUBLE_ENTRY"]
|
959
|
+
""
|
960
|
+
else
|
961
|
+
d["PCI_ID"]
|
962
|
+
end
|
963
|
+
end
|
921
964
|
end
|
922
|
-
end
|
923
965
|
|
924
|
-
|
966
|
+
end.show(vm_nics,{})
|
925
967
|
|
926
|
-
|
927
|
-
|
928
|
-
|
968
|
+
while vm.has_elements?("/VM/TEMPLATE/#{type}")
|
969
|
+
vm.delete_element("/VM/TEMPLATE/#{type}")
|
970
|
+
end if !options[:all]
|
971
|
+
end
|
929
972
|
end
|
930
973
|
|
931
974
|
while vm.has_elements?("/VM/TEMPLATE/NIC")
|