opennebula-cli 6.0.0.2 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/oneacct +2 -13
- data/bin/oneacl +2 -13
- data/bin/onecluster +2 -13
- data/bin/onedatastore +2 -13
- data/bin/oneflow +2 -13
- data/bin/oneflow-template +2 -13
- data/bin/onegroup +2 -13
- data/bin/onehook +6 -17
- data/bin/onehost +2 -13
- data/bin/oneimage +6 -17
- data/bin/onemarket +2 -13
- data/bin/onemarketapp +10 -21
- data/bin/onesecgroup +2 -13
- data/bin/oneshowback +2 -13
- data/bin/onetemplate +8 -28
- data/bin/oneuser +2 -13
- data/bin/onevcenter +3 -14
- data/bin/onevdc +2 -13
- data/bin/onevm +18 -180
- data/bin/onevmgroup +6 -17
- data/bin/onevnet +6 -17
- data/bin/onevntemplate +6 -17
- data/bin/onevrouter +6 -17
- data/bin/onezone +3 -14
- data/lib/one_helper.rb +2 -2
- data/lib/one_helper/onecluster_helper.rb +42 -75
- data/lib/one_helper/onevm_helper.rb +0 -20
- data/lib/one_helper/onevnet_helper.rb +151 -173
- data/lib/one_helper/onezone_helper.rb +4 -12
- data/share/schemas/xsd/opennebula_configuration.xsd +0 -1
- data/share/schemas/xsd/vnet.xsd +0 -2
- metadata +6 -6
@@ -16,176 +16,174 @@
|
|
16
16
|
require 'one_helper'
|
17
17
|
require 'one_helper/onevm_helper'
|
18
18
|
|
19
|
-
# OneVnet Command Helper
|
20
19
|
class OneVNetHelper < OpenNebulaHelper::OneHelper
|
21
|
-
|
22
20
|
AR = {
|
23
|
-
:name =>
|
24
|
-
:short =>
|
25
|
-
:large =>
|
21
|
+
:name => "address_range",
|
22
|
+
:short => "-a ar_id",
|
23
|
+
:large => "--address_range ar_id",
|
26
24
|
:format => Integer,
|
27
|
-
:description =>
|
25
|
+
:description => "ID of the address range"
|
28
26
|
}
|
29
27
|
|
30
28
|
SHOW_AR = {
|
31
|
-
:name =>
|
32
|
-
:large =>
|
33
|
-
:description =>
|
29
|
+
:name => "show_ar",
|
30
|
+
:large => "--show-ar",
|
31
|
+
:description => "Show also AR templates"
|
34
32
|
}
|
35
33
|
|
36
34
|
MAC = {
|
37
|
-
:name =>
|
38
|
-
:short =>
|
39
|
-
:large =>
|
35
|
+
:name => "mac",
|
36
|
+
:short => "-m mac",
|
37
|
+
:large => "--mac mac",
|
40
38
|
:format => String,
|
41
|
-
:description =>
|
39
|
+
:description => "First MAC address in : notation"
|
42
40
|
}
|
43
41
|
|
44
42
|
IP = {
|
45
|
-
:name =>
|
46
|
-
:short =>
|
47
|
-
:large =>
|
43
|
+
:name => "ip",
|
44
|
+
:short => "-i ip",
|
45
|
+
:large => "--ip ip",
|
48
46
|
:format => String,
|
49
|
-
:description =>
|
47
|
+
:description => "First IP address in . notation"
|
50
48
|
}
|
51
49
|
|
52
50
|
IP6 = {
|
53
|
-
:name =>
|
54
|
-
:short =>
|
55
|
-
:large =>
|
51
|
+
:name => "ip6",
|
52
|
+
:short => "-6 ip6",
|
53
|
+
:large => "--ip6 ip6",
|
56
54
|
:format => String,
|
57
|
-
:description =>
|
55
|
+
:description => "First IPv6 address, in CIDR notation e.g. 2001::1/48"
|
58
56
|
}
|
59
57
|
|
60
58
|
SIZE = {
|
61
|
-
:name =>
|
62
|
-
:short =>
|
63
|
-
:large =>
|
59
|
+
:name => "size",
|
60
|
+
:short => "-s size",
|
61
|
+
:large => "--size size",
|
64
62
|
:format => String,
|
65
|
-
:description =>
|
63
|
+
:description => "Number of addresses"
|
66
64
|
}
|
67
65
|
|
68
66
|
IP6_GLOBAL = {
|
69
|
-
:name =>
|
70
|
-
:short =>
|
71
|
-
:large =>
|
67
|
+
:name => "ip6_global",
|
68
|
+
:short => "-g ip6_pref",
|
69
|
+
:large => "--ip6_global ip6_pref",
|
72
70
|
:format => String,
|
73
|
-
:description =>
|
71
|
+
:description => "IP6 global prefix"
|
74
72
|
}
|
75
73
|
|
76
74
|
IP6_ULA = {
|
77
|
-
:name =>
|
78
|
-
:short =>
|
79
|
-
:large =>
|
75
|
+
:name => "ip6_ula",
|
76
|
+
:short => "-u ip6_pref",
|
77
|
+
:large => "--ip6_ula ip6_pref",
|
80
78
|
:format => String,
|
81
|
-
:description =>
|
79
|
+
:description => "IP6 ula prefix"
|
82
80
|
}
|
83
81
|
|
84
82
|
NAME = {
|
85
|
-
:name =>
|
86
|
-
:short =>
|
87
|
-
:large =>
|
83
|
+
:name => "name",
|
84
|
+
:short => "-n reservation name",
|
85
|
+
:large => "--name reservation name",
|
88
86
|
:format => String,
|
89
|
-
:description =>
|
87
|
+
:description => "Name of the address reservation"
|
90
88
|
}
|
91
89
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
90
|
+
# R_SIZE = {
|
91
|
+
# :name => "rsize",
|
92
|
+
# :short => "-s reservation size",
|
93
|
+
# :large => "--size reservation size",
|
94
|
+
# :format => String,
|
95
|
+
# :description => "Number of addresses to reserve"
|
96
|
+
# }
|
99
97
|
|
100
98
|
GATEWAY = {
|
101
|
-
:name =>
|
102
|
-
:large =>
|
99
|
+
:name => "gateway",
|
100
|
+
:large => "--gateway ip",
|
103
101
|
:format => String,
|
104
|
-
:description=>
|
102
|
+
:description=> "IP of the gateway"
|
105
103
|
}
|
106
104
|
|
107
105
|
NETMASK = {
|
108
|
-
:name =>
|
109
|
-
:large =>
|
106
|
+
:name => "netmask",
|
107
|
+
:large => "--netmask mask",
|
110
108
|
:format => String,
|
111
|
-
:description=>
|
109
|
+
:description=> "Netmask in dot notation"
|
112
110
|
}
|
113
111
|
|
114
112
|
VN_MAD = {
|
115
|
-
:name =>
|
116
|
-
:large =>
|
113
|
+
:name => "vn_mad",
|
114
|
+
:large => "--vn_mad mad",
|
117
115
|
:format => String,
|
118
|
-
:description=>
|
116
|
+
:description=> "Use this driver for the network"
|
119
117
|
}
|
120
118
|
|
121
119
|
VLAN_ID = {
|
122
|
-
:name =>
|
123
|
-
:large =>
|
120
|
+
:name => "vlanid",
|
121
|
+
:large => "--vlanid id",
|
124
122
|
:format => String,
|
125
|
-
:description=>
|
123
|
+
:description=> "VLAN ID assigned"
|
126
124
|
}
|
127
125
|
|
128
126
|
ADDAR_OPTIONS = [
|
129
127
|
SIZE, MAC, IP, IP6, IP6_GLOBAL, IP6_ULA, GATEWAY, NETMASK, VN_MAD,
|
130
|
-
VLAN_ID
|
131
|
-
]
|
128
|
+
VLAN_ID ]
|
132
129
|
|
133
130
|
def self.rname
|
134
|
-
|
131
|
+
"VNET"
|
135
132
|
end
|
136
133
|
|
137
134
|
def self.conf_file
|
138
|
-
|
135
|
+
"onevnet.yaml"
|
139
136
|
end
|
140
137
|
|
141
138
|
def format_pool(options)
|
142
139
|
config_file = self.class.table_conf
|
143
140
|
|
144
|
-
CLIHelper::ShowTable.new(config_file, self) do
|
145
|
-
column :ID,
|
146
|
-
d[
|
141
|
+
table = CLIHelper::ShowTable.new(config_file, self) do
|
142
|
+
column :ID, "ONE identifier for Virtual Network", :size=>4 do |d|
|
143
|
+
d["ID"]
|
147
144
|
end
|
148
145
|
|
149
|
-
column :USER,
|
150
|
-
|
146
|
+
column :USER, "Username of the Virtual Network owner", :left,
|
147
|
+
:size=>15 do |d|
|
151
148
|
helper.user_name(d, options)
|
152
149
|
end
|
153
150
|
|
154
|
-
column :GROUP,
|
155
|
-
|
151
|
+
column :GROUP, "Group of the Virtual Network", :left,
|
152
|
+
:size=>12 do |d|
|
156
153
|
helper.group_name(d, options)
|
157
154
|
end
|
158
155
|
|
159
|
-
column :NAME,
|
160
|
-
|
161
|
-
d[
|
156
|
+
column :NAME, "Name of the Virtual Network", :left,
|
157
|
+
:size=>19 do |d|
|
158
|
+
d["NAME"]
|
162
159
|
end
|
163
160
|
|
164
|
-
column :CLUSTERS,
|
165
|
-
OpenNebulaHelper.clusters_str(d[
|
161
|
+
column :CLUSTERS, "Cluster IDs", :left, :size=>10 do |d|
|
162
|
+
OpenNebulaHelper.clusters_str(d["CLUSTERS"]["ID"]) rescue "-"
|
166
163
|
end
|
167
164
|
|
168
|
-
column :BRIDGE,
|
169
|
-
|
170
|
-
d[
|
165
|
+
column :BRIDGE, "Bridge associated to the Virtual Network", :left,
|
166
|
+
:size=>8 do |d|
|
167
|
+
d["BRIDGE"]
|
171
168
|
end
|
172
169
|
|
173
170
|
column :LEASES, "Number of this Virtual Network's given leases",
|
174
|
-
|
175
|
-
d[
|
171
|
+
:size=>6 do |d|
|
172
|
+
d["USED_LEASES"]
|
176
173
|
end
|
177
174
|
|
178
175
|
default :ID, :USER, :GROUP, :NAME, :CLUSTERS, :BRIDGE, :LEASES
|
179
176
|
end
|
177
|
+
|
178
|
+
table
|
180
179
|
end
|
181
180
|
|
182
181
|
def show_ar(vn, ar_id)
|
183
|
-
CLIHelper.print_header(
|
184
|
-
false)
|
182
|
+
CLIHelper.print_header("%-80s" % ["TEMPLATE FOR AR #{ar_id}"], false)
|
185
183
|
|
186
184
|
begin
|
187
185
|
template = vn.template_like_str("AR_POOL/AR[AR_ID=#{ar_id}]")
|
188
|
-
rescue
|
186
|
+
rescue
|
189
187
|
STDERR.puts "Can not get template for AR #{ar_id}"
|
190
188
|
return
|
191
189
|
end
|
@@ -283,7 +281,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
283
281
|
|
284
282
|
private
|
285
283
|
|
286
|
-
def factory(id
|
284
|
+
def factory(id=nil)
|
287
285
|
if id
|
288
286
|
OpenNebula::VirtualNetwork.new_with_id(id, @client)
|
289
287
|
else
|
@@ -292,63 +290,55 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
292
290
|
end
|
293
291
|
end
|
294
292
|
|
295
|
-
def factory_pool(user_flag
|
293
|
+
def factory_pool(user_flag=-2)
|
296
294
|
OpenNebula::VirtualNetworkPool.new(@client, user_flag)
|
297
295
|
end
|
298
296
|
|
299
297
|
def format_resource(vn, options = {})
|
300
298
|
vn_hash = vn.to_hash
|
301
299
|
|
302
|
-
str_h1=
|
303
|
-
CLIHelper.print_header(
|
304
|
-
|
305
|
-
|
306
|
-
str=
|
307
|
-
puts
|
308
|
-
puts
|
309
|
-
puts
|
310
|
-
puts
|
311
|
-
puts
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
puts
|
318
|
-
puts
|
319
|
-
puts
|
320
|
-
|
321
|
-
puts
|
322
|
-
puts format(str, 'AUTOMATIC VLAN ID',
|
323
|
-
vn['VLAN_ID_AUTOMATIC']=='1' ? 'YES' : 'NO')
|
324
|
-
puts format(str, 'OUTER VLAN ID',
|
325
|
-
vn['OUTER_VLAN_ID']) unless vn['OUTER_VLAN_ID']
|
326
|
-
puts format(str, 'AUTOMATIC OUTER VLAN ID',
|
327
|
-
vn['OUTER_VLAN_ID_AUTOMATIC']=='1' ? 'YES' : 'NO')
|
328
|
-
puts format(str, 'USED LEASES', vn['USED_LEASES'])
|
300
|
+
str_h1="%-80s"
|
301
|
+
CLIHelper.print_header(str_h1 %
|
302
|
+
["VIRTUAL NETWORK #{vn.id.to_s} INFORMATION"])
|
303
|
+
|
304
|
+
str="%-25s: %-20s"
|
305
|
+
puts str % ["ID", vn.id.to_s]
|
306
|
+
puts str % ["NAME", vn['NAME']]
|
307
|
+
puts str % ["USER", vn['UNAME']]
|
308
|
+
puts str % ["GROUP", vn['GNAME']]
|
309
|
+
puts str % ["LOCK", OpenNebulaHelper.level_lock_to_str(vn['LOCK/LOCKED'])]
|
310
|
+
puts str % ["CLUSTERS",
|
311
|
+
OpenNebulaHelper.clusters_str(vn.retrieve_elements("CLUSTERS/ID"))]
|
312
|
+
puts str % ["BRIDGE", vn["BRIDGE"]]
|
313
|
+
puts str % ["VN_MAD", vn['VN_MAD']] if !vn['VN_MAD'].empty?
|
314
|
+
puts str % ["PHYSICAL DEVICE", vn["PHYDEV"]] if !vn["PHYDEV"].empty?
|
315
|
+
puts str % ["VLAN ID", vn["VLAN_ID"]] if !vn["VLAN_ID"].empty?
|
316
|
+
puts str % ["AUTOMATIC VLAN ID", vn["VLAN_ID_AUTOMATIC"]=="1" ? "YES" : "NO"]
|
317
|
+
puts str % ["OUTER VLAN ID", vn["OUTER_VLAN_ID"]] if !vn["OUTER_VLAN_ID"]
|
318
|
+
puts str % ["AUTOMATIC OUTER VLAN ID", vn["OUTER_VLAN_ID_AUTOMATIC"]=="1" ? "YES" : "NO"]
|
319
|
+
puts str % ["USED LEASES", vn['USED_LEASES']]
|
329
320
|
puts
|
330
321
|
|
331
|
-
CLIHelper.print_header(str_h1 %
|
322
|
+
CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
|
332
323
|
|
333
|
-
|
334
|
-
mask =
|
335
|
-
mask[0] =
|
336
|
-
mask[1] =
|
337
|
-
mask[2] =
|
324
|
+
["OWNER", "GROUP", "OTHER"].each { |e|
|
325
|
+
mask = "---"
|
326
|
+
mask[0] = "u" if vn["PERMISSIONS/#{e}_U"] == "1"
|
327
|
+
mask[1] = "m" if vn["PERMISSIONS/#{e}_M"] == "1"
|
328
|
+
mask[2] = "a" if vn["PERMISSIONS/#{e}_A"] == "1"
|
338
329
|
|
339
|
-
puts
|
340
|
-
|
330
|
+
puts str % [e, mask]
|
331
|
+
}
|
341
332
|
|
342
333
|
puts
|
343
334
|
|
344
|
-
CLIHelper.print_header(
|
345
|
-
false)
|
335
|
+
CLIHelper.print_header(str_h1 % ["VIRTUAL NETWORK TEMPLATE"], false)
|
346
336
|
|
347
337
|
puts vn.template_str(false)
|
348
338
|
|
349
339
|
puts
|
350
340
|
|
351
|
-
CLIHelper.print_header(
|
341
|
+
CLIHelper.print_header(str_h1 % ["ADDRESS RANGE POOL"], false)
|
352
342
|
|
353
343
|
arlist = []
|
354
344
|
|
@@ -357,72 +347,70 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
357
347
|
end
|
358
348
|
|
359
349
|
arlist.each do |ar|
|
360
|
-
CLIHelper.print_header(format('%-80s', "AR #{ar['AR_ID']}"))
|
361
350
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
puts
|
366
|
-
puts
|
351
|
+
CLIHelper.print_header("%-80s" % "AR #{ar["AR_ID"]}")
|
352
|
+
|
353
|
+
str="%-15s: %-20s"
|
354
|
+
puts str % ["SIZE", ar["SIZE"]]
|
355
|
+
puts str % ["LEASES", ar["USED_LEASES"]]
|
356
|
+
puts str % ["VN_MAD", ar["VN_MAD"]] if ar["VN_MAD"]
|
357
|
+
puts str % ["IPAM_MAD", ar["IPAM_MAD"]] if ar["IPAM_MAD"]
|
367
358
|
puts
|
368
359
|
|
369
|
-
format =
|
370
|
-
CLIHelper.print_header(
|
371
|
-
format(format, 'RANGE', 'FIRST', 'LAST'), false
|
372
|
-
)
|
360
|
+
format = "%-10s %34s %34s"
|
361
|
+
CLIHelper.print_header(format % ["RANGE", "FIRST", "LAST"], false)
|
373
362
|
|
374
|
-
puts format
|
363
|
+
puts format % ["MAC", ar["MAC"], ar["MAC_END"]]
|
375
364
|
|
376
|
-
if !ar[
|
377
|
-
puts format
|
365
|
+
if !ar["IP"].nil?
|
366
|
+
puts format % ["IP", ar["IP"], ar["IP_END"]]
|
378
367
|
end
|
379
368
|
|
380
|
-
if !ar[
|
381
|
-
puts format
|
382
|
-
ar['IP6_GLOBAL_END'])
|
369
|
+
if !ar["IP6_GLOBAL"].nil?
|
370
|
+
puts format % ["IP6_GLOBAL", ar["IP6_GLOBAL"], ar["IP6_GLOBAL_END"]]
|
383
371
|
end
|
384
372
|
|
385
|
-
if !ar[
|
386
|
-
puts format
|
373
|
+
if !ar["IP6_ULA"].nil?
|
374
|
+
puts format % ["IP6_ULA", ar["IP6_ULA"], ar["IP6_ULA_END"]]
|
387
375
|
end
|
388
376
|
|
389
|
-
if !ar[
|
390
|
-
puts format
|
377
|
+
if !ar["IP6"].nil?
|
378
|
+
puts format % ["IP6", ar["IP6"], ar["IP6_END"]]
|
391
379
|
end
|
392
380
|
|
393
381
|
puts
|
394
382
|
end
|
395
383
|
|
396
384
|
puts
|
397
|
-
CLIHelper.print_header(
|
385
|
+
CLIHelper.print_header(str_h1 % ["LEASES"], false)
|
398
386
|
ar_list = []
|
399
387
|
|
400
388
|
if !vn_hash['VNET']['AR_POOL']['AR'].nil?
|
401
389
|
lease_list = [vn_hash['VNET']['AR_POOL']['AR']].flatten
|
402
|
-
leases =
|
390
|
+
leases = Array.new
|
403
391
|
|
404
392
|
lease_list.each do |ar|
|
405
393
|
id = ar['AR_ID']
|
406
394
|
ar_list << id
|
407
395
|
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
396
|
+
if ar['LEASES'] && !ar['LEASES']['LEASE'].nil?
|
397
|
+
lease = [ar['LEASES']['LEASE']].flatten
|
398
|
+
lease.each do |l|
|
399
|
+
l['AR_ID'] = id
|
400
|
+
end
|
401
|
+
leases << lease
|
413
402
|
end
|
414
|
-
leases << lease
|
415
403
|
end
|
416
404
|
|
417
405
|
leases.flatten!
|
418
406
|
end
|
419
407
|
|
420
408
|
CLIHelper::ShowTable.new(nil, self) do
|
421
|
-
column :AR,
|
409
|
+
column :AR, "", :left, :size=>3 do |d|
|
422
410
|
d['AR_ID']
|
423
411
|
end
|
424
412
|
|
425
|
-
column :OWNER,
|
413
|
+
column :OWNER, "", :left, :size=>15 do |d|
|
426
414
|
if d['VM']
|
427
415
|
"V:#{d['VM']}"
|
428
416
|
elsif d['VNET']
|
@@ -432,40 +420,31 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
432
420
|
end
|
433
421
|
end
|
434
422
|
|
435
|
-
column :MAC,
|
436
|
-
|
437
|
-
end
|
438
|
-
|
439
|
-
column :IP, '', :adjust do |d|
|
440
|
-
d['IP'] || '-'
|
423
|
+
column :MAC, "", :size=>17 do |d|
|
424
|
+
d["MAC"]
|
441
425
|
end
|
442
426
|
|
443
|
-
column :
|
444
|
-
|
445
|
-
"[#{d['EXTERNAL_PORT_RANGE']}]:" \
|
446
|
-
"[#{d['INTERNAL_PORT_RANGE'].split('/')[0]}]"
|
447
|
-
else
|
448
|
-
'-'
|
449
|
-
end
|
427
|
+
column :IP, "", :size=>15 do |d|
|
428
|
+
d["IP"]||"-"
|
450
429
|
end
|
451
430
|
|
452
|
-
column :IP6,
|
453
|
-
|
431
|
+
column :IP6, "", :adjust, :size=>26 do |d|
|
432
|
+
d["IP6"]||d["IP6_GLOBAL"]||"-"
|
454
433
|
end
|
455
434
|
end.show(leases, {})
|
456
435
|
|
457
436
|
puts
|
458
437
|
|
459
|
-
CLIHelper.print_header(
|
438
|
+
CLIHelper.print_header("%-15s" % "VIRTUAL ROUTERS")
|
460
439
|
vn.vrouter_ids.each do |id|
|
461
|
-
puts
|
440
|
+
puts "%-15s" % [id]
|
462
441
|
end
|
463
442
|
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
443
|
+
if options[:show_ar]
|
444
|
+
ar_list.each do |ar_id|
|
445
|
+
puts
|
446
|
+
show_ar(vn, ar_id)
|
447
|
+
end
|
469
448
|
end
|
470
449
|
end
|
471
450
|
|
@@ -480,5 +459,4 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
480
459
|
# in options hash
|
481
460
|
(add_ar_options-options.keys)!=add_ar_options
|
482
461
|
end
|
483
|
-
|
484
462
|
end
|