opennebula-cli 5.8.5 → 5.9.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 +6 -0
- data/bin/oneacl +8 -1
- data/bin/onecluster +8 -1
- data/bin/onedatastore +8 -1
- data/bin/oneflow +28 -17
- data/bin/oneflow-template +6 -0
- data/bin/onegroup +6 -0
- data/bin/onehook +303 -0
- data/bin/onehost +9 -3
- data/bin/oneimage +16 -0
- data/bin/onemarket +6 -0
- data/bin/onemarketapp +6 -0
- data/bin/onesecgroup +6 -0
- data/bin/oneshowback +6 -0
- data/bin/onetemplate +6 -0
- data/bin/oneuser +11 -6
- data/bin/onevcenter +17 -3
- data/bin/onevdc +6 -0
- data/bin/onevm +18 -5
- data/bin/onevmgroup +6 -0
- data/bin/onevnet +19 -1
- data/bin/onevntemplate +6 -0
- data/bin/onevrouter +6 -0
- data/bin/onezone +6 -0
- data/lib/cli_helper.rb +589 -195
- data/lib/one_helper.rb +37 -2
- data/lib/one_helper/oneacl_helper.rb +99 -84
- data/lib/one_helper/onehook_helper.rb +250 -0
- data/lib/one_helper/onehost_helper.rb +200 -0
- data/lib/one_helper/oneimage_helper.rb +23 -0
- data/lib/one_helper/onesecgroup_helper.rb +2 -2
- data/lib/one_helper/oneuser_helper.rb +3 -3
- data/lib/one_helper/onevcenter_helper.rb +2 -1
- data/lib/one_helper/onevm_helper.rb +729 -599
- data/lib/one_helper/onevnet_helper.rb +24 -2
- data/lib/one_helper/onevrouter_helper.rb +1 -1
- metadata +9 -6
@@ -636,6 +636,17 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
|
636
636
|
print_pcis(pcis)
|
637
637
|
end
|
638
638
|
|
639
|
+
begin
|
640
|
+
numa_nodes =
|
641
|
+
host.to_hash['HOST']['HOST_SHARE']['NUMA_NODES']['NODE']
|
642
|
+
rescue StandardError
|
643
|
+
numa_nodes = nil
|
644
|
+
end
|
645
|
+
|
646
|
+
if numa_nodes && !numa_nodes.empty?
|
647
|
+
print_numa_nodes(numa_nodes)
|
648
|
+
end
|
649
|
+
|
639
650
|
puts
|
640
651
|
CLIHelper.print_header('WILD VIRTUAL MACHINES', false)
|
641
652
|
puts
|
@@ -718,4 +729,193 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
|
718
729
|
table.show(pcis)
|
719
730
|
end
|
720
731
|
|
732
|
+
def print_numa_nodes(numa_nodes)
|
733
|
+
numa_nodes = get_numa_data(numa_nodes)
|
734
|
+
|
735
|
+
print_numa_cores(numa_nodes)
|
736
|
+
print_numa_memory(numa_nodes)
|
737
|
+
print_numa_hugepages(numa_nodes)
|
738
|
+
end
|
739
|
+
|
740
|
+
def get_numa_data(numa_nodes)
|
741
|
+
numa_nodes = [numa_nodes] if numa_nodes.class == Hash
|
742
|
+
|
743
|
+
numa_nodes.map! do |core|
|
744
|
+
cores = core['CORE']
|
745
|
+
|
746
|
+
free, used, cores_str = get_numa_cores(cores)
|
747
|
+
|
748
|
+
core['CORE'] = {}
|
749
|
+
core['CORE']['CORES'] = cores_str
|
750
|
+
core['CORE']['FREE'] = free
|
751
|
+
core['CORE']['USED'] = used
|
752
|
+
|
753
|
+
core
|
754
|
+
end
|
755
|
+
|
756
|
+
numa_nodes
|
757
|
+
end
|
758
|
+
|
759
|
+
def get_numa_cores(cores)
|
760
|
+
ret = ''
|
761
|
+
free = 0
|
762
|
+
used = 0
|
763
|
+
|
764
|
+
[cores].flatten.each do |info|
|
765
|
+
core = info['CPUS'].split(',')
|
766
|
+
|
767
|
+
core.uniq! do |c|
|
768
|
+
c = c.split(':')
|
769
|
+
c[0]
|
770
|
+
end
|
771
|
+
|
772
|
+
core.each do |c|
|
773
|
+
c = c.split(':')
|
774
|
+
|
775
|
+
if c[1] == '-1'
|
776
|
+
ret += '-'
|
777
|
+
free += 1
|
778
|
+
elsif c[1] == '-2'
|
779
|
+
ret += 'I'
|
780
|
+
used += 1
|
781
|
+
elsif c[1] != '-1' && info['FREE'] == '0'
|
782
|
+
ret += 'X'
|
783
|
+
used += 1
|
784
|
+
else
|
785
|
+
ret += 'x'
|
786
|
+
used += 1
|
787
|
+
end
|
788
|
+
end
|
789
|
+
|
790
|
+
ret += ' '
|
791
|
+
end
|
792
|
+
|
793
|
+
[free, used, ret]
|
794
|
+
end
|
795
|
+
|
796
|
+
def print_numa_cores(numa_nodes)
|
797
|
+
puts
|
798
|
+
CLIHelper.print_header('NUMA NODES', false)
|
799
|
+
puts
|
800
|
+
|
801
|
+
table = CLIHelper::ShowTable.new(nil, self) do
|
802
|
+
column :ID, 'Node ID', :size => 4, :left => false do |d|
|
803
|
+
d['NODE_ID']
|
804
|
+
end
|
805
|
+
|
806
|
+
column :CORES, 'Cores usage',
|
807
|
+
:left => true,
|
808
|
+
:adjust => true do |d|
|
809
|
+
d['CORE']['CORES']
|
810
|
+
end
|
811
|
+
|
812
|
+
column :USED, 'Used CPUs', :size => 4, :left => true do |d|
|
813
|
+
d['CORE']['USED']
|
814
|
+
end
|
815
|
+
|
816
|
+
column :FREE, 'Free CPUs', :size => 4, :left => true do |d|
|
817
|
+
d['CORE']['FREE']
|
818
|
+
end
|
819
|
+
|
820
|
+
default :ID, :CORES, :USED, :FREE
|
821
|
+
end
|
822
|
+
|
823
|
+
table.show(numa_nodes)
|
824
|
+
end
|
825
|
+
|
826
|
+
def print_numa_memory(numa_nodes)
|
827
|
+
nodes = numa_nodes.clone
|
828
|
+
|
829
|
+
nodes.reject! do |node|
|
830
|
+
node['MEMORY'].nil? || node['MEMORY'].empty?
|
831
|
+
end
|
832
|
+
|
833
|
+
return if nodes.empty?
|
834
|
+
|
835
|
+
puts
|
836
|
+
CLIHelper.print_header('NUMA MEMORY', false)
|
837
|
+
puts
|
838
|
+
|
839
|
+
table = CLIHelper::ShowTable.new(nil, self) do
|
840
|
+
column :NODE_ID, 'Node ID', :size => 8, :left => false do |d|
|
841
|
+
d['NODE_ID']
|
842
|
+
end
|
843
|
+
|
844
|
+
column :TOTAL, 'Total memory', :size => 8, :left => true do |d|
|
845
|
+
OpenNebulaHelper.unit_to_str(d['MEMORY']['TOTAL'].to_i, {})
|
846
|
+
end
|
847
|
+
|
848
|
+
column :USED_REAL, 'Used memory', :size => 20, :left => true do |d|
|
849
|
+
OpenNebulaHelper.unit_to_str(d['MEMORY']['USED'].to_i, {})
|
850
|
+
end
|
851
|
+
|
852
|
+
column :USED_ALLOCATED, 'U memory',
|
853
|
+
:size => 20, :left => true do |d|
|
854
|
+
OpenNebulaHelper.unit_to_str(d['MEMORY']['USAGE'].to_i, {})
|
855
|
+
end
|
856
|
+
|
857
|
+
column :FREE, 'Free memory', :size => 8, :left => true do |d|
|
858
|
+
OpenNebulaHelper.unit_to_str(d['MEMORY']['FREE'].to_i, {})
|
859
|
+
end
|
860
|
+
|
861
|
+
default :NODE_ID, :TOTAL, :USED_REAL, :USED_ALLOCATED, :FREE
|
862
|
+
end
|
863
|
+
|
864
|
+
table.show(nodes)
|
865
|
+
end
|
866
|
+
|
867
|
+
def print_numa_hugepages(numa_nodes)
|
868
|
+
nodes = numa_nodes.clone
|
869
|
+
|
870
|
+
nodes.reject! do |node|
|
871
|
+
node['HUGEPAGE'].nil? || node['HUGEPAGE'].empty?
|
872
|
+
end
|
873
|
+
|
874
|
+
return if nodes.empty?
|
875
|
+
|
876
|
+
puts
|
877
|
+
CLIHelper.print_header('NUMA HUGEPAGES', false)
|
878
|
+
puts
|
879
|
+
|
880
|
+
table = CLIHelper::ShowTable.new(nil, self) do
|
881
|
+
column :NODE_ID, 'Node ID', :size => 8, :left => false do |d|
|
882
|
+
d['NODE_ID']
|
883
|
+
end
|
884
|
+
|
885
|
+
column :TOTAL, 'Total pages', :size => 8, :left => true do |d|
|
886
|
+
d['HUGEPAGE']['PAGES']
|
887
|
+
end
|
888
|
+
|
889
|
+
column :SIZE, 'Pages size', :size => 8, :left => true do |d|
|
890
|
+
OpenNebulaHelper.unit_to_str(d['HUGEPAGE']['SIZE'].to_i / 1024,
|
891
|
+
{},
|
892
|
+
'M')
|
893
|
+
end
|
894
|
+
|
895
|
+
column :FREE, 'Free pages', :size => 8, :left => true do |d|
|
896
|
+
d['HUGEPAGE']['FREE']
|
897
|
+
end
|
898
|
+
|
899
|
+
column :USED, 'allocated pages', :size => 8, :left => true do |d|
|
900
|
+
d['HUGEPAGE']['USAGE']
|
901
|
+
end
|
902
|
+
|
903
|
+
default :NODE_ID, :SIZE, :TOTAL, :FREE, :USED
|
904
|
+
end
|
905
|
+
|
906
|
+
hugepages = []
|
907
|
+
|
908
|
+
nodes.each do |node|
|
909
|
+
[node['HUGEPAGE']].flatten.each do |hugepage|
|
910
|
+
h = {}
|
911
|
+
h['NODE_ID'] = node['NODE_ID']
|
912
|
+
h['HUGEPAGE'] = hugepage
|
913
|
+
|
914
|
+
hugepages << h
|
915
|
+
end
|
916
|
+
end
|
917
|
+
|
918
|
+
table.show(hugepages)
|
919
|
+
end
|
920
|
+
|
721
921
|
end
|
@@ -249,6 +249,29 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
|
249
249
|
table
|
250
250
|
end
|
251
251
|
|
252
|
+
def check_orphans
|
253
|
+
orphans = []
|
254
|
+
xpath = '/VMTEMPLATE_POOL/VMTEMPLATE/TEMPLATE/DISK'
|
255
|
+
|
256
|
+
pool = factory_pool
|
257
|
+
tmpl_pool = OpenNebula::TemplatePool.new(@client, -2)
|
258
|
+
|
259
|
+
pool.info
|
260
|
+
tmpl_pool.info
|
261
|
+
|
262
|
+
pool.each do |img|
|
263
|
+
attrs = { :id => img['ID'],
|
264
|
+
:name => img['NAME'],
|
265
|
+
:uname => img['UNAME'] }
|
266
|
+
|
267
|
+
orphans << img['ID'] if check_orphan(tmpl_pool,
|
268
|
+
xpath,
|
269
|
+
'IMAGE', attrs)
|
270
|
+
end
|
271
|
+
|
272
|
+
orphans
|
273
|
+
end
|
274
|
+
|
252
275
|
private
|
253
276
|
|
254
277
|
def factory(id=nil)
|
@@ -157,7 +157,7 @@ class OneSecurityGroupHelper < OpenNebulaHelper::OneHelper
|
|
157
157
|
d["ICMPV6_TYPE"]
|
158
158
|
end
|
159
159
|
|
160
|
-
column :NETWORK, "", :left, :
|
160
|
+
column :NETWORK, "", :left, :adjust, :size=>35 do |d|
|
161
161
|
network = ""
|
162
162
|
if(!d["NETWORK_ID"].nil? && d["NETWORK_ID"] != "")
|
163
163
|
network += "VNet " + d["NETWORK_ID"]
|
@@ -185,7 +185,7 @@ class OneSecurityGroupHelper < OpenNebulaHelper::OneHelper
|
|
185
185
|
network
|
186
186
|
end
|
187
187
|
|
188
|
-
column :RANGE, "", :left, :
|
188
|
+
column :RANGE, "", :left, :adjust, :size=>16 do |d|
|
189
189
|
d["RANGE"]
|
190
190
|
end
|
191
191
|
end.show(rule_list, {})
|
@@ -65,9 +65,9 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
|
65
65
|
password = OpenNebula::X509Auth.escape_dn(password)
|
66
66
|
end
|
67
67
|
|
68
|
-
if options[:
|
69
|
-
require 'digest/
|
70
|
-
password = Digest::
|
68
|
+
if options[:sha256] || options[:driver] == OpenNebula::User::CIPHER_AUTH
|
69
|
+
require 'digest/sha2'
|
70
|
+
password = Digest::SHA256.hexdigest(password)
|
71
71
|
end
|
72
72
|
|
73
73
|
return 0, password
|
@@ -13,23 +13,26 @@
|
|
13
13
|
# See the License for the specific language governing permissions and #
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
|
+
# rubocop:disable Naming/UncommunicativeMethodParamName
|
16
17
|
|
17
18
|
if !ONE_LOCATION
|
18
|
-
MAD_LOCATION =
|
19
|
-
VAR_LOCATION =
|
19
|
+
MAD_LOCATION = '/usr/lib/one/mads'
|
20
|
+
VAR_LOCATION = '/var/lib/one'
|
20
21
|
else
|
21
|
-
MAD_LOCATION = ONE_LOCATION +
|
22
|
-
VAR_LOCATION = ONE_LOCATION +
|
22
|
+
MAD_LOCATION = ONE_LOCATION + '/lib/mads'
|
23
|
+
VAR_LOCATION = ONE_LOCATION + '/var'
|
23
24
|
end
|
24
25
|
|
25
|
-
VMS_LOCATION = VAR_LOCATION +
|
26
|
+
VMS_LOCATION = VAR_LOCATION + '/vms'
|
26
27
|
|
27
|
-
|
28
|
+
$LOAD_PATH << MAD_LOCATION
|
28
29
|
|
29
30
|
require 'one_helper'
|
30
31
|
require 'optparse/time'
|
31
32
|
|
33
|
+
# colored strings
|
32
34
|
class String
|
35
|
+
|
33
36
|
def red
|
34
37
|
colorize(31)
|
35
38
|
end
|
@@ -38,183 +41,185 @@ class String
|
|
38
41
|
colorize(32)
|
39
42
|
end
|
40
43
|
|
41
|
-
private
|
44
|
+
private
|
42
45
|
|
43
46
|
def colorize(color_code)
|
44
47
|
"\e[#{color_code}m#{self}\e[0m"
|
45
48
|
end
|
46
|
-
end
|
47
49
|
|
50
|
+
end
|
48
51
|
|
52
|
+
# Helper methods for OneVM
|
49
53
|
class OneVMHelper < OpenNebulaHelper::OneHelper
|
50
|
-
|
51
|
-
|
52
|
-
:
|
53
|
-
:
|
54
|
+
|
55
|
+
MULTIPLE = {
|
56
|
+
:name => 'multiple',
|
57
|
+
:short => '-m x',
|
58
|
+
:large => '--multiple x',
|
54
59
|
:format => Integer,
|
55
|
-
:description =>
|
60
|
+
:description => 'Instance multiple VMs'
|
56
61
|
}
|
57
62
|
|
58
63
|
IMAGE = {
|
59
|
-
:name
|
60
|
-
:short
|
61
|
-
:large
|
62
|
-
:description =>
|
64
|
+
:name => 'image',
|
65
|
+
:short => '-i id|name',
|
66
|
+
:large => '--image id|name',
|
67
|
+
:description => 'Selects the image',
|
63
68
|
:format => String,
|
64
|
-
:proc
|
65
|
-
OpenNebulaHelper.rname_to_id(o,
|
69
|
+
:proc => lambda {|o, _options|
|
70
|
+
OpenNebulaHelper.rname_to_id(o, 'IMAGE')
|
66
71
|
}
|
67
72
|
}
|
68
73
|
|
69
74
|
NETWORK = {
|
70
|
-
:name
|
71
|
-
:short
|
72
|
-
:large
|
73
|
-
:description =>
|
75
|
+
:name => 'network',
|
76
|
+
:short => '-n id|name',
|
77
|
+
:large => '--network id|name',
|
78
|
+
:description => 'Selects the virtual network',
|
74
79
|
:format => String,
|
75
|
-
:proc
|
76
|
-
OpenNebulaHelper.rname_to_id(o,
|
80
|
+
:proc => lambda {|o, _options|
|
81
|
+
OpenNebulaHelper.rname_to_id(o, 'VNET')
|
77
82
|
}
|
78
83
|
}
|
79
84
|
|
80
|
-
IP={
|
81
|
-
:name =>
|
82
|
-
:short =>
|
83
|
-
:large =>
|
85
|
+
IP = {
|
86
|
+
:name => 'ip',
|
87
|
+
:short => '-i ip',
|
88
|
+
:large => '--ip ip',
|
84
89
|
:format => String,
|
85
|
-
:description =>
|
90
|
+
:description => 'IP address for the new NIC'
|
86
91
|
}
|
87
92
|
|
88
93
|
FILE = {
|
89
|
-
:name
|
90
|
-
:short
|
91
|
-
:large
|
92
|
-
:description =>
|
94
|
+
:name => 'file',
|
95
|
+
:short => '-f file',
|
96
|
+
:large => '--file file',
|
97
|
+
:description => 'Selects the template file',
|
93
98
|
:format => String,
|
94
|
-
:proc
|
99
|
+
:proc => lambda {|o, options|
|
95
100
|
if File.file?(o)
|
96
101
|
options[:file] = o
|
97
102
|
else
|
98
|
-
exit -1
|
103
|
+
exit - 1
|
99
104
|
end
|
100
105
|
}
|
101
106
|
}
|
102
107
|
|
103
108
|
HOLD = {
|
104
|
-
:name
|
105
|
-
:large =>
|
106
|
-
:description =>
|
109
|
+
:name => 'hold',
|
110
|
+
:large => '--hold',
|
111
|
+
:description => 'Creates the new VM on hold state instead of pending'
|
107
112
|
}
|
108
113
|
|
109
114
|
SCHEDULE = {
|
110
|
-
:name
|
111
|
-
:large
|
112
|
-
:description =>
|
113
|
-
|
114
|
-
:format
|
115
|
+
:name => 'schedule',
|
116
|
+
:large => '--schedule TIME',
|
117
|
+
:description => 'Schedules this action to be executed after' \
|
118
|
+
'the given time. For example: onevm resume 0 --schedule "09/23 14:15"',
|
119
|
+
:format => Time
|
115
120
|
}
|
116
121
|
|
117
122
|
WEEKLY = {
|
118
|
-
:name
|
119
|
-
:large
|
120
|
-
:description =>
|
121
|
-
|
122
|
-
|
123
|
-
:format
|
123
|
+
:name => 'weekly',
|
124
|
+
:large => '--weekly days',
|
125
|
+
:description => 'Repeats the schedule action the days of the week ' \
|
126
|
+
'specified, it can be a number between 0,6 separated with commas.' \
|
127
|
+
'For example: onevm resume 0 --schedule "09/23 14:15" --weekly 0,2,4',
|
128
|
+
:format => String
|
124
129
|
}
|
125
130
|
|
126
131
|
MONTHLY = {
|
127
|
-
:name
|
128
|
-
:large
|
129
|
-
:description =>
|
130
|
-
|
131
|
-
|
132
|
-
:format
|
132
|
+
:name => 'monthly',
|
133
|
+
:large => '--monthly days',
|
134
|
+
:description => 'Repeats the schedule action the days of the month ' \
|
135
|
+
'specified, it can be a number between 0,31 separated with commas.' \
|
136
|
+
'For example: onevm resume 0 --schedule "09/23 14:15" --monthly 0,14',
|
137
|
+
:format => String
|
133
138
|
}
|
134
139
|
|
135
140
|
YEARLY = {
|
136
|
-
:name
|
137
|
-
:large
|
138
|
-
:description =>
|
139
|
-
|
140
|
-
|
141
|
-
:format
|
141
|
+
:name => 'yearly',
|
142
|
+
:large => '--yearly days',
|
143
|
+
:description => 'Repeats the schedule action the days of the year ' \
|
144
|
+
'specified, it can be a number between 0,365 separated with commas.' \
|
145
|
+
'For example: onevm resume 0 --schedule "09/23 14:15" --yearly 30,60',
|
146
|
+
:format => String
|
142
147
|
}
|
143
148
|
|
144
149
|
HOURLY = {
|
145
|
-
:name
|
146
|
-
:large
|
147
|
-
:description =>
|
148
|
-
|
149
|
-
|
150
|
-
:format
|
150
|
+
:name => 'hourly',
|
151
|
+
:large => '--hourly hour',
|
152
|
+
:description => 'Repeats the schedule action each hours specified,' \
|
153
|
+
'it can be a number between 0,168 separated with commas.' \
|
154
|
+
'For example: onevm resume 0 --schedule "09/23 14:15" --hourly 1,5',
|
155
|
+
:format => Numeric
|
151
156
|
}
|
152
157
|
|
153
158
|
END_TIME = {
|
154
|
-
:name
|
155
|
-
:large
|
156
|
-
:description =>
|
157
|
-
:format
|
159
|
+
:name => 'end',
|
160
|
+
:large => '--end number|TIME',
|
161
|
+
:description => '----',
|
162
|
+
:format => String
|
158
163
|
}
|
159
164
|
|
160
165
|
ALL_TEMPLATE = {
|
161
|
-
:name
|
162
|
-
:large
|
163
|
-
:description =>
|
166
|
+
:name => 'all',
|
167
|
+
:large => '--all',
|
168
|
+
:description => 'Show all template data'
|
164
169
|
}
|
165
170
|
|
166
171
|
LIVE = {
|
167
|
-
:name
|
168
|
-
:large
|
169
|
-
:description =>
|
172
|
+
:name => 'live',
|
173
|
+
:large => '--live',
|
174
|
+
:description => 'Do the action with the VM running'
|
170
175
|
}
|
171
176
|
|
172
177
|
HARD = {
|
173
|
-
:name
|
174
|
-
:large
|
175
|
-
:description=>
|
178
|
+
:name => 'hard',
|
179
|
+
:large => '--hard',
|
180
|
+
:description => 'Does not communicate with the guest OS'
|
176
181
|
}
|
177
182
|
|
178
183
|
POFF = {
|
179
|
-
:name
|
180
|
-
:large
|
181
|
-
:description =>
|
184
|
+
:name => 'poweroff',
|
185
|
+
:large => '--poff',
|
186
|
+
:description => 'Do the migrate by poweringoff the vm'
|
182
187
|
}
|
183
188
|
|
184
189
|
POFFHARD = {
|
185
|
-
:name
|
186
|
-
:large
|
187
|
-
:description =>
|
190
|
+
:name => 'poweroff_hard',
|
191
|
+
:large => '--poff-hard',
|
192
|
+
:description => 'Do the migrate by poweringoff hard the vm'
|
188
193
|
}
|
189
194
|
|
190
195
|
ALIAS = {
|
191
|
-
:name
|
192
|
-
:short
|
193
|
-
:large
|
194
|
-
:description=>
|
195
|
-
:format
|
196
|
+
:name => 'alias',
|
197
|
+
:short => '-a alias',
|
198
|
+
:large => '--alias alias',
|
199
|
+
:description => 'Attach the NIC as an ALIAS',
|
200
|
+
:format => String
|
196
201
|
}
|
197
202
|
|
198
203
|
NIC_NAME = {
|
199
|
-
:name
|
200
|
-
:large
|
201
|
-
:description=>
|
202
|
-
:format
|
204
|
+
:name => 'nic_name',
|
205
|
+
:large => '--nic_name name',
|
206
|
+
:description => 'Name of the NIC',
|
207
|
+
:format => String
|
203
208
|
}
|
204
209
|
|
205
210
|
SEARCH = {
|
206
|
-
:name
|
207
|
-
:large
|
208
|
-
:description=>
|
209
|
-
:format
|
211
|
+
:name => 'search',
|
212
|
+
:large => '--search search',
|
213
|
+
:description => 'query in KEY=VALUE format',
|
214
|
+
:format => String
|
210
215
|
}
|
211
216
|
|
212
217
|
def self.rname
|
213
|
-
|
218
|
+
'VM'
|
214
219
|
end
|
215
220
|
|
216
221
|
def self.conf_file
|
217
|
-
|
222
|
+
'onevm.yaml'
|
218
223
|
end
|
219
224
|
|
220
225
|
def self.state_to_str(id, lcm_id)
|
@@ -222,13 +227,13 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
222
227
|
state_str = VirtualMachine::VM_STATE[id]
|
223
228
|
short_state_str = VirtualMachine::SHORT_VM_STATES[state_str]
|
224
229
|
|
225
|
-
if short_state_str==
|
230
|
+
if short_state_str == 'actv'
|
226
231
|
lcm_id = lcm_id.to_i
|
227
232
|
lcm_state_str = VirtualMachine::LCM_STATE[lcm_id]
|
228
233
|
return VirtualMachine::SHORT_LCM_STATES[lcm_state_str]
|
229
234
|
end
|
230
235
|
|
231
|
-
|
236
|
+
short_state_str
|
232
237
|
end
|
233
238
|
|
234
239
|
# Return the IP or several IPs of a VM
|
@@ -237,48 +242,61 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
237
242
|
|
238
243
|
vm_nics = []
|
239
244
|
|
240
|
-
if !vm[
|
241
|
-
vm_nics = [vm[
|
245
|
+
if !vm['TEMPLATE']['NIC'].nil?
|
246
|
+
vm_nics = [vm['TEMPLATE']['NIC']].flatten
|
242
247
|
end
|
243
248
|
|
244
|
-
if !vm[
|
245
|
-
vm_nics = [vm_nics, vm[
|
249
|
+
if !vm['TEMPLATE']['PCI'].nil?
|
250
|
+
vm_nics = [vm_nics, vm['TEMPLATE']['PCI']].flatten
|
246
251
|
end
|
247
252
|
|
248
253
|
vm_nics.each do |nic|
|
249
|
-
[
|
250
|
-
|
251
|
-
if nic.
|
254
|
+
%w[IP IP6_GLOBAL IP6_ULA IP6
|
255
|
+
VROUTER_IP VROUTER_IP6_GLOBAL VROUTER_IP6_ULA].each do |attr|
|
256
|
+
if nic.key?(attr)
|
252
257
|
ips.push(nic[attr])
|
253
258
|
end
|
254
259
|
end
|
255
260
|
end
|
256
261
|
|
257
262
|
VirtualMachine::EXTERNAL_IP_ATTRS.each do |attr|
|
258
|
-
external_ip = vm[
|
263
|
+
external_ip = vm['MONITORING'][attr]
|
259
264
|
|
260
265
|
if !external_ip.nil? && !ips.include?(external_ip)
|
261
266
|
ips.push(external_ip)
|
262
267
|
end
|
263
268
|
end
|
264
269
|
|
265
|
-
if ips.empty?
|
266
|
-
|
267
|
-
|
268
|
-
return ips.join(",")
|
269
|
-
end
|
270
|
+
return '--' if ips.empty?
|
271
|
+
|
272
|
+
ips.join(',')
|
270
273
|
end
|
271
274
|
|
272
275
|
def retrieve_snapshot_id(vm_id, id)
|
276
|
+
return [0, id.to_i] if id =~ /\A\d+\z/
|
277
|
+
|
273
278
|
vm = retrieve_resource(vm_id)
|
274
279
|
vm.info
|
275
280
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
281
|
+
ids = vm.retrieve_elements(
|
282
|
+
"/VM/TEMPLATE/SNAPSHOT[NAME='#{id}']/SNAPSHOT_ID"
|
283
|
+
)
|
284
|
+
|
285
|
+
return [-1, "#{id} not found or duplicated"] \
|
286
|
+
if ids.nil? || ids.size > 1
|
287
|
+
|
288
|
+
[0, ids[0].to_i]
|
289
|
+
end
|
290
|
+
|
291
|
+
def retrieve_disk_snapshot_id(vm_id, id)
|
292
|
+
return [0, id.to_i] if id =~ /\A\d+\z/
|
293
|
+
|
294
|
+
vm = retrieve_resource(vm_id)
|
295
|
+
vm.info
|
296
|
+
ids = vm.retrieve_elements("/VM/SNAPSHOTS/SNAPSHOT[NAME='#{id}']/ID")
|
297
|
+
|
298
|
+
return [-1, "#{id} not found or duplicated"] \
|
299
|
+
if ids.nil? || ids.size > 1
|
282
300
|
|
283
301
|
[0, ids[0].to_i]
|
284
302
|
end
|
@@ -291,67 +309,69 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
291
309
|
rc = cluster_pool.info
|
292
310
|
|
293
311
|
cluster_names = {}
|
294
|
-
cluster_names[
|
312
|
+
cluster_names['-1'] = 'default'
|
295
313
|
|
296
314
|
if !OpenNebula.is_error?(rc)
|
297
315
|
cluster_pool.each do |c|
|
298
|
-
cluster_names[c[
|
316
|
+
cluster_names[c['ID']] = c['NAME']
|
299
317
|
end
|
300
318
|
end
|
301
319
|
|
302
320
|
table = CLIHelper::ShowTable.new(config_file, self) do
|
303
|
-
column :ID,
|
304
|
-
d[
|
321
|
+
column :ID, 'ONE identifier for Virtual Machine', :size => 6 do |d|
|
322
|
+
d['ID']
|
305
323
|
end
|
306
324
|
|
307
|
-
column :NAME,
|
308
|
-
|
309
|
-
if d[
|
310
|
-
"*#{d[
|
325
|
+
column :NAME, 'Name of the Virtual Machine', :left,
|
326
|
+
:size => 15 do |d|
|
327
|
+
if d['RESCHED'] == '1'
|
328
|
+
"*#{d['NAME']}"
|
311
329
|
else
|
312
|
-
d[
|
330
|
+
d['NAME']
|
313
331
|
end
|
314
332
|
end
|
315
333
|
|
316
|
-
column :USER,
|
317
|
-
|
334
|
+
column :USER, 'Username of the Virtual Machine owner', :left,
|
335
|
+
:size => 8 do |d|
|
318
336
|
helper.user_name(d, options)
|
319
337
|
end
|
320
338
|
|
321
|
-
column :GROUP,
|
322
|
-
|
339
|
+
column :GROUP, 'Group of the Virtual Machine', :left,
|
340
|
+
:size => 8 do |d|
|
323
341
|
helper.group_name(d, options)
|
324
342
|
end
|
325
343
|
|
326
|
-
column :STAT,
|
327
|
-
OneVMHelper.state_to_str(d[
|
344
|
+
column :STAT, 'Actual status', :size => 4 do |d, _e|
|
345
|
+
OneVMHelper.state_to_str(d['STATE'], d['LCM_STATE'])
|
328
346
|
end
|
329
347
|
|
330
|
-
column :UCPU,
|
331
|
-
cpu = d[
|
332
|
-
cpu =
|
348
|
+
column :UCPU, 'CPU percentage used by the VM', :size => 4 do |d|
|
349
|
+
cpu = d['MONITORING']['CPU']
|
350
|
+
cpu = '0' if cpu.nil?
|
333
351
|
|
334
352
|
cpu
|
335
353
|
end
|
336
354
|
|
337
|
-
column :UMEM,
|
338
|
-
OpenNebulaHelper.unit_to_str(d[
|
355
|
+
column :UMEM, 'Memory used by the VM', :size => 7 do |d|
|
356
|
+
OpenNebulaHelper.unit_to_str(d['MONITORING']['MEMORY'].to_i,
|
357
|
+
options)
|
339
358
|
end
|
340
359
|
|
341
|
-
column :HOST,
|
360
|
+
column :HOST, 'Host where the VM is running',
|
361
|
+
:left, :size => 10 do |d|
|
342
362
|
if d['HISTORY_RECORDS'] && d['HISTORY_RECORDS']['HISTORY']
|
343
363
|
state_str = VirtualMachine::VM_STATE[d['STATE'].to_i]
|
344
|
-
if %w
|
364
|
+
if %w[ACTIVE SUSPENDED POWEROFF].include? state_str
|
345
365
|
d['HISTORY_RECORDS']['HISTORY']['HOSTNAME']
|
346
366
|
end
|
347
367
|
end
|
348
368
|
end
|
349
369
|
|
350
|
-
column :CLUSTER,
|
351
|
-
|
352
|
-
if d[
|
353
|
-
history = [d[
|
354
|
-
cluster_id = history.last[
|
370
|
+
column :CLUSTER, 'Cluster where the VM is running', :left,
|
371
|
+
:size => 10 do |d|
|
372
|
+
if d['HISTORY_RECORDS']['HISTORY']
|
373
|
+
history = [d['HISTORY_RECORDS']['HISTORY']].flatten
|
374
|
+
cluster_id = history.last['CID']
|
355
375
|
cluster = cluster_names[cluster_id]
|
356
376
|
|
357
377
|
if !cluster
|
@@ -360,38 +380,38 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
360
380
|
cluster
|
361
381
|
end
|
362
382
|
else
|
363
|
-
|
383
|
+
'NONE'
|
364
384
|
end
|
365
385
|
end
|
366
386
|
|
367
|
-
column :TIME,
|
368
|
-
stime = d[
|
369
|
-
etime = d[
|
370
|
-
dtime = etime-stime
|
387
|
+
column :TIME, 'Time since the VM was submitted', :size => 10 do |d|
|
388
|
+
stime = d['STIME'].to_i
|
389
|
+
etime = d['ETIME'] == '0' ? Time.now.to_i : d['ETIME'].to_i
|
390
|
+
dtime = etime - stime
|
371
391
|
OpenNebulaHelper.period_to_str(dtime, false)
|
372
392
|
end
|
373
393
|
|
374
|
-
column :IP,
|
394
|
+
column :IP, 'VM IP addresses', :left, :adjust, :size => 15 do |d|
|
375
395
|
OneVMHelper.ip_str(d)
|
376
396
|
end
|
377
397
|
|
378
398
|
default :ID, :USER, :GROUP, :NAME, :STAT, :UCPU, :UMEM, :HOST,
|
379
|
-
|
399
|
+
:TIME
|
380
400
|
end
|
381
401
|
|
382
402
|
table
|
383
403
|
end
|
384
404
|
|
385
|
-
|
386
|
-
def schedule_actions(ids,options,action)
|
405
|
+
def schedule_actions(ids, options, action)
|
387
406
|
# Verbose by default
|
388
407
|
options[:verbose] = true
|
389
408
|
|
390
409
|
perform_actions(
|
391
410
|
ids, options,
|
392
|
-
"#{action} scheduled at #{options[:schedule]}"
|
411
|
+
"#{action} scheduled at #{options[:schedule]}"
|
412
|
+
) do |vm|
|
393
413
|
|
394
|
-
str_periodic =
|
414
|
+
str_periodic = ''
|
395
415
|
|
396
416
|
if options.key?(:weekly)
|
397
417
|
str_periodic << ", REPEAT = 0, DAYS = \"#{options[:weekly]}\""
|
@@ -400,56 +420,61 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
400
420
|
elsif options.key?(:yearly)
|
401
421
|
str_periodic << ", REPEAT = 2, DAYS = \"#{options[:yearly]}\""
|
402
422
|
elsif options.key?(:hourly)
|
403
|
-
str_periodic << ", REPEAT = 3, DAYS = \"#{options[:hourly]
|
423
|
+
str_periodic << ", REPEAT = 3, DAYS = \"#{options[:hourly]}\""
|
404
424
|
end
|
405
425
|
|
406
426
|
if options.key?(:end)
|
407
427
|
begin
|
408
428
|
end_date = Date.parse(options[:end])
|
409
|
-
str_periodic <<
|
429
|
+
str_periodic << ', END_TYPE = 2, ' \
|
430
|
+
"END_VALUE = #{end_date.to_time.to_i}"
|
410
431
|
rescue ArgumentError
|
411
432
|
if options[:end].to_i > 0
|
412
|
-
str_periodic <<
|
433
|
+
str_periodic << ', END_TYPE = 1, ' \
|
434
|
+
"END_VALUE = #{options[:end].to_i}"
|
413
435
|
end
|
414
436
|
end
|
415
|
-
elsif str_periodic !=
|
416
|
-
str_periodic <<
|
437
|
+
elsif str_periodic != ''
|
438
|
+
str_periodic << ', END_TYPE = 0'
|
417
439
|
end
|
418
440
|
|
419
441
|
rc = vm.info
|
420
442
|
|
421
443
|
if OpenNebula.is_error?(rc)
|
422
444
|
puts rc.message
|
423
|
-
exit
|
445
|
+
exit(-1)
|
424
446
|
end
|
425
447
|
|
426
448
|
ids = vm.retrieve_elements('USER_TEMPLATE/SCHED_ACTION/ID')
|
427
449
|
|
428
450
|
id = 0
|
429
|
-
if
|
451
|
+
if !ids.nil? && !ids.empty?
|
430
452
|
ids.map! {|e| e.to_i }
|
431
453
|
id = ids.max + 1
|
432
454
|
end
|
433
455
|
|
434
456
|
tmp_str = vm.user_template_str
|
435
457
|
|
436
|
-
tmp_str << "\nSCHED_ACTION =
|
458
|
+
tmp_str << "\nSCHED_ACTION = "
|
459
|
+
tmp_str << "[ID = #{id}, ACTION = #{action}, "
|
460
|
+
tmp_str << "TIME = #{options[:schedule].to_i}"
|
461
|
+
tmp_str << str_periodic << ']'
|
437
462
|
|
438
463
|
vm.update(tmp_str)
|
439
464
|
end
|
440
465
|
end
|
441
466
|
|
442
467
|
RECOVER_RETRY_STEPS = {
|
443
|
-
:PROLOG_MIGRATE_FAILURE
|
468
|
+
:PROLOG_MIGRATE_FAILURE => :migrate,
|
444
469
|
:PROLOG_MIGRATE_POWEROFF_FAILURE => :migrate,
|
445
|
-
:PROLOG_MIGRATE_SUSPEND_FAILURE
|
446
|
-
:PROLOG_MIGRATE_UNKNOWN_FAILURE
|
447
|
-
:PROLOG_FAILURE
|
448
|
-
:PROLOG_RESUME_FAILURE
|
449
|
-
:PROLOG_UNDEPLOY_FAILURE
|
450
|
-
:EPILOG_FAILURE
|
451
|
-
:EPILOG_STOP_FAILURE
|
452
|
-
:EPILOG_UNDEPLOY_FAILURE
|
470
|
+
:PROLOG_MIGRATE_SUSPEND_FAILURE => :migrate,
|
471
|
+
:PROLOG_MIGRATE_UNKNOWN_FAILURE => :migrate,
|
472
|
+
:PROLOG_FAILURE => :prolog,
|
473
|
+
:PROLOG_RESUME_FAILURE => :resume,
|
474
|
+
:PROLOG_UNDEPLOY_FAILURE => :resume,
|
475
|
+
:EPILOG_FAILURE => :epilog,
|
476
|
+
:EPILOG_STOP_FAILURE => :stop,
|
477
|
+
:EPILOG_UNDEPLOY_FAILURE => :stop
|
453
478
|
}
|
454
479
|
|
455
480
|
def recover_retry_interactive(vm)
|
@@ -457,32 +482,32 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
457
482
|
require 'one_tm'
|
458
483
|
rescue LoadError
|
459
484
|
STDERR.puts <<-EOT
|
460
|
-
one_tm library not found. Make sure you execute recover --interactive
|
461
|
-
in the frontend machine.
|
485
|
+
one_tm library not found. Make sure you execute recover --interactive
|
486
|
+
in the frontend machine.
|
462
487
|
EOT
|
463
488
|
exit(-1)
|
464
489
|
end
|
465
490
|
|
466
491
|
# Disable CTRL-C in the menu
|
467
|
-
trap(
|
492
|
+
trap('SIGINT') {}
|
468
493
|
|
469
|
-
if !File.readable?(VAR_LOCATION+
|
470
|
-
STDERR.puts "Error reading #{VAR_LOCATION+'/config'}. The "
|
471
|
-
|
472
|
-
|
473
|
-
exit
|
494
|
+
if !File.readable?(VAR_LOCATION + '/config')
|
495
|
+
STDERR.puts "Error reading #{VAR_LOCATION + '/config'}. The TM " \
|
496
|
+
'Debug Interactive Environment must be executed as ' \
|
497
|
+
'oneadmin in the frontend.'
|
498
|
+
exit(-1)
|
474
499
|
end
|
475
500
|
|
476
501
|
rc = vm.info
|
477
502
|
if OpenNebula.is_error?(rc)
|
478
503
|
STDERR.puts rc.message
|
479
|
-
exit
|
504
|
+
exit(-1)
|
480
505
|
end
|
481
506
|
|
482
507
|
if !RECOVER_RETRY_STEPS.include?(vm.lcm_state_str.to_sym)
|
483
|
-
STDERR.puts "Current LCM STATE '#{vm.lcm_state_str}' not "
|
484
|
-
|
485
|
-
exit
|
508
|
+
STDERR.puts "Current LCM STATE '#{vm.lcm_state_str}' not " \
|
509
|
+
'compatible with RECOVER RETRY action.'
|
510
|
+
exit(-1)
|
486
511
|
end
|
487
512
|
|
488
513
|
seq = vm['/VM/HISTORY_RECORDS/HISTORY[last()]/SEQ']
|
@@ -493,27 +518,27 @@ in the frontend machine.
|
|
493
518
|
|
494
519
|
if !File.readable?(tm_file)
|
495
520
|
STDERR.puts "Cannot read #{tm_file}"
|
496
|
-
exit
|
521
|
+
exit(-1)
|
497
522
|
end
|
498
523
|
|
499
524
|
@tm_action_list = File.read(tm_file)
|
500
525
|
|
501
|
-
puts
|
526
|
+
puts 'TM Debug Interactive Environment.'.green
|
502
527
|
puts
|
503
528
|
print_tm_action_list
|
504
529
|
|
505
530
|
@tm = TransferManagerDriver.new(nil)
|
506
|
-
i=0
|
531
|
+
i = 0
|
507
532
|
@tm_action_list.lines.each do |tm_command|
|
508
|
-
i+=1
|
509
|
-
success=false
|
533
|
+
i += 1
|
534
|
+
success = false
|
510
535
|
|
511
|
-
|
536
|
+
until success
|
512
537
|
puts "Current action (#{i}):".green
|
513
538
|
puts tm_command
|
514
539
|
puts
|
515
540
|
|
516
|
-
puts <<-EOF.gsub(/^\s+/,
|
541
|
+
puts <<-EOF.gsub(/^\s+/, '')
|
517
542
|
Choose action:
|
518
543
|
(r) Run action
|
519
544
|
(n) Skip to next action
|
@@ -521,47 +546,46 @@ in the frontend machine.
|
|
521
546
|
(q) Quit
|
522
547
|
EOF
|
523
548
|
|
524
|
-
ans =
|
525
|
-
|
526
|
-
printf
|
549
|
+
ans = ''
|
550
|
+
until %w[n a r q].include?(ans)
|
551
|
+
printf '> '
|
527
552
|
ans = STDIN.gets.strip.downcase
|
528
553
|
|
529
554
|
puts
|
530
555
|
|
531
556
|
case ans
|
532
|
-
when
|
557
|
+
when 'n'
|
533
558
|
success = true
|
534
|
-
when
|
559
|
+
when 'a'
|
535
560
|
print_tm_action_list
|
536
|
-
when
|
537
|
-
exit
|
538
|
-
when
|
539
|
-
result,
|
561
|
+
when 'q'
|
562
|
+
exit(-1)
|
563
|
+
when 'r'
|
564
|
+
result, = @tm.do_transfer_action(@id, tm_command.split)
|
540
565
|
|
541
|
-
if result ==
|
566
|
+
if result == 'SUCCESS'
|
542
567
|
success = true
|
543
|
-
puts
|
544
|
-
puts
|
568
|
+
puts result.to_s
|
545
569
|
else
|
546
570
|
puts
|
547
571
|
puts "#{result}. Repeat command.".red
|
548
|
-
puts
|
549
572
|
end
|
573
|
+
puts
|
550
574
|
end
|
551
575
|
end
|
552
576
|
end
|
553
577
|
end
|
554
578
|
|
555
|
-
puts
|
556
|
-
puts
|
557
|
-
puts "$ onevm recover #{vm.id} --success"
|
579
|
+
puts 'If all the TM actions have been successful and you want to'
|
580
|
+
puts 'recover the Virtual Machine to the RUNNING state execute this '
|
581
|
+
puts "command $ onevm recover #{vm.id} --success"
|
558
582
|
end
|
559
583
|
|
560
584
|
def print_tm_action_list
|
561
|
-
puts
|
562
|
-
i=0
|
585
|
+
puts 'TM Action list:'.green
|
586
|
+
i = 0
|
563
587
|
@tm_action_list.lines.each do |line|
|
564
|
-
i+=1
|
588
|
+
i += 1
|
565
589
|
puts "(#{i}) #{line}"
|
566
590
|
end
|
567
591
|
puts
|
@@ -569,96 +593,102 @@ in the frontend machine.
|
|
569
593
|
|
570
594
|
def get_migration_type(options)
|
571
595
|
if options[:poweroff]
|
572
|
-
|
596
|
+
1
|
573
597
|
elsif options[:poweroff_hard]
|
574
|
-
|
598
|
+
2
|
575
599
|
else
|
576
|
-
|
600
|
+
0
|
577
601
|
end
|
578
602
|
end
|
579
603
|
|
580
604
|
private
|
581
605
|
|
582
|
-
def factory(id=nil)
|
606
|
+
def factory(id = nil)
|
583
607
|
if id
|
584
608
|
OpenNebula::VirtualMachine.new_with_id(id, @client)
|
585
609
|
else
|
586
|
-
xml=OpenNebula::VirtualMachine.build_xml
|
610
|
+
xml = OpenNebula::VirtualMachine.build_xml
|
587
611
|
OpenNebula::VirtualMachine.new(xml, @client)
|
588
612
|
end
|
589
613
|
end
|
590
614
|
|
591
|
-
def factory_pool(user_flag
|
615
|
+
def factory_pool(user_flag = -2)
|
592
616
|
OpenNebula::VirtualMachinePool.new(@client, user_flag)
|
593
617
|
end
|
594
618
|
|
595
619
|
def format_resource(vm, options = {})
|
596
|
-
str_h1=
|
597
|
-
str=
|
620
|
+
str_h1 = '%-80s'
|
621
|
+
str = '%-20s: %-20s'
|
598
622
|
|
599
623
|
cluster = nil
|
600
624
|
|
601
625
|
vm_hash = vm.to_hash
|
602
626
|
|
603
|
-
if %w
|
627
|
+
if %w[ACTIVE SUSPENDED POWEROFF].include? vm.state_str
|
604
628
|
cluster_id = vm['/VM/HISTORY_RECORDS/HISTORY[last()]/CID']
|
605
629
|
else
|
606
630
|
cluster_id = nil
|
607
631
|
end
|
608
632
|
|
609
633
|
if cluster_id
|
610
|
-
if cluster_id ==
|
611
|
-
cluster =
|
634
|
+
if cluster_id == '-1'
|
635
|
+
cluster = 'default'
|
612
636
|
else
|
613
|
-
clu = OpenNebula::Cluster.new(
|
637
|
+
clu = OpenNebula::Cluster.new(
|
638
|
+
OpenNebula::Cluster.build_xml(cluster_id), @client
|
639
|
+
)
|
614
640
|
rc = clu.info
|
615
641
|
if OpenNebula.is_error?(rc)
|
616
|
-
cluster =
|
642
|
+
cluster = 'ERROR'
|
617
643
|
else
|
618
|
-
cluster = clu[
|
644
|
+
cluster = clu['NAME']
|
619
645
|
end
|
620
646
|
end
|
621
647
|
end
|
622
648
|
|
623
649
|
CLIHelper.print_header(
|
624
|
-
str_h1 % "VIRTUAL MACHINE #{vm['ID']} INFORMATION"
|
625
|
-
|
626
|
-
puts str
|
627
|
-
puts str
|
628
|
-
puts str
|
629
|
-
puts str
|
630
|
-
puts str
|
631
|
-
puts str
|
632
|
-
puts str
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
puts str
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
650
|
+
str_h1 % "VIRTUAL MACHINE #{vm['ID']} INFORMATION"
|
651
|
+
)
|
652
|
+
puts format(str, 'ID', vm.id.to_s)
|
653
|
+
puts format(str, 'NAME', vm.name)
|
654
|
+
puts format(str, 'USER', vm['UNAME'])
|
655
|
+
puts format(str, 'GROUP', vm['GNAME'])
|
656
|
+
puts format(str, 'STATE', vm.state_str)
|
657
|
+
puts format(str, 'LCM_STATE', vm.lcm_state_str)
|
658
|
+
puts format(str, 'LOCK',
|
659
|
+
OpenNebulaHelper.level_lock_to_str(vm['LOCK/LOCKED']))
|
660
|
+
puts format(str, 'RESCHED',
|
661
|
+
OpenNebulaHelper.boolean_to_str(vm['RESCHED']))
|
662
|
+
if %w[ACTIVE SUSPENDED POWEROFF].include? vm.state_str
|
663
|
+
puts format(str, 'HOST',
|
664
|
+
vm['/VM/HISTORY_RECORDS/HISTORY[last()]/HOSTNAME'])
|
665
|
+
end
|
666
|
+
puts format(str, 'CLUSTER ID', cluster_id) if cluster_id
|
667
|
+
puts format(str, 'CLUSTER', cluster) if cluster
|
668
|
+
puts format(str, 'START TIME',
|
669
|
+
OpenNebulaHelper.time_to_str(vm['/VM/STIME']))
|
670
|
+
puts format(str, 'END TIME',
|
671
|
+
OpenNebulaHelper.time_to_str(vm['/VM/ETIME']))
|
672
|
+
value = vm['DEPLOY_ID']
|
673
|
+
puts format(str, 'DEPLOY ID', value == '' ? '-' : value)
|
674
|
+
value = vm['TEMPLATE/VROUTER_ID']
|
675
|
+
puts format(str, 'VIRTUAL ROUTER ID', value) if value
|
646
676
|
|
647
677
|
puts
|
648
678
|
|
649
|
-
CLIHelper.print_header(str_h1 %
|
679
|
+
CLIHelper.print_header(str_h1 % 'VIRTUAL MACHINE MONITORING', false)
|
650
680
|
|
651
681
|
vm_monitoring = vm_hash['VM']['MONITORING']
|
652
682
|
|
653
|
-
#
|
654
|
-
|
655
|
-
vm_monitoring.each
|
683
|
+
# Find out if it is a hybrid VM to avoid showing local IPs
|
684
|
+
is_hybrid = false
|
685
|
+
vm_monitoring.each do |key, _value|
|
656
686
|
if VirtualMachine::EXTERNAL_IP_ATTRS.include? key
|
657
|
-
|
687
|
+
is_hybrid = true
|
658
688
|
end
|
659
|
-
|
689
|
+
end
|
660
690
|
|
661
|
-
order_attrs
|
691
|
+
order_attrs = %w[CPU MEMORY NETTX NETRX]
|
662
692
|
|
663
693
|
vm_monitoring_sort = []
|
664
694
|
order_attrs.each do |key|
|
@@ -667,156 +697,159 @@ in the frontend machine.
|
|
667
697
|
end
|
668
698
|
end
|
669
699
|
|
670
|
-
vm_monitoring_sort.
|
700
|
+
vm_monitoring_sort.sort_by {|a| a[0] }
|
671
701
|
|
672
|
-
filter_attrs = %w
|
702
|
+
filter_attrs = %w[STATE DISK_SIZE SNAPSHOT_SIZE]
|
673
703
|
vm_monitoring.each do |key, val|
|
674
704
|
if !filter_attrs.include?(key)
|
675
705
|
vm_monitoring_sort << [key, val]
|
676
706
|
end
|
677
707
|
end
|
678
708
|
|
679
|
-
vm_monitoring_sort.each do |k,v|
|
680
|
-
if k ==
|
681
|
-
puts str
|
682
|
-
elsif k
|
683
|
-
puts str
|
709
|
+
vm_monitoring_sort.each do |k, v|
|
710
|
+
if k == 'MEMORY'
|
711
|
+
puts format(str, k, OpenNebulaHelper.unit_to_str(v.to_i, {}))
|
712
|
+
elsif k =~ /NET.X/
|
713
|
+
puts format(str, k,
|
714
|
+
OpenNebulaHelper.unit_to_str(v.to_i / 1024, {}))
|
684
715
|
else
|
685
|
-
puts str
|
716
|
+
puts format(str, k, v)
|
686
717
|
end
|
687
718
|
end
|
688
719
|
|
689
720
|
puts
|
690
721
|
|
691
|
-
CLIHelper.print_header(str_h1 %
|
722
|
+
CLIHelper.print_header(str_h1 % 'PERMISSIONS', false)
|
692
723
|
|
693
|
-
[
|
694
|
-
mask =
|
695
|
-
mask[0] =
|
696
|
-
mask[1] =
|
697
|
-
mask[2] =
|
724
|
+
%w[OWNER GROUP OTHER].each do |e|
|
725
|
+
mask = '---'
|
726
|
+
mask[0] = 'u' if vm["PERMISSIONS/#{e}_U"] == '1'
|
727
|
+
mask[1] = 'm' if vm["PERMISSIONS/#{e}_M"] == '1'
|
728
|
+
mask[2] = 'a' if vm["PERMISSIONS/#{e}_A"] == '1'
|
698
729
|
|
699
|
-
puts str
|
700
|
-
|
730
|
+
puts format(str, e, mask)
|
731
|
+
end
|
701
732
|
|
702
733
|
vm_disks = []
|
703
734
|
|
704
|
-
if vm.has_elements?(
|
735
|
+
if vm.has_elements?('/VM/TEMPLATE/DISK')
|
705
736
|
vm_disks = [vm_hash['VM']['TEMPLATE']['DISK']].flatten
|
706
737
|
end
|
707
738
|
|
708
|
-
if vm.has_elements?(
|
739
|
+
if vm.has_elements?('/VM/TEMPLATE/CONTEXT') \
|
740
|
+
&& vm['/VM/HISTORY_RECORDS/HISTORY[1]/VM_MAD'] != 'vcenter'
|
709
741
|
context_disk = vm_hash['VM']['TEMPLATE']['CONTEXT']
|
710
742
|
|
711
|
-
context_disk[
|
712
|
-
context_disk[
|
713
|
-
context_disk[
|
714
|
-
context_disk[
|
715
|
-
context_disk[
|
716
|
-
context_disk[
|
717
|
-
context_disk[
|
743
|
+
context_disk['IMAGE'] = 'CONTEXT'
|
744
|
+
context_disk['DATASTORE'] = '-'
|
745
|
+
context_disk['TYPE'] = '-'
|
746
|
+
context_disk['READONLY'] = '-'
|
747
|
+
context_disk['SAVE'] = '-'
|
748
|
+
context_disk['CLONE'] = '-'
|
749
|
+
context_disk['SAVE_AS'] = '-'
|
718
750
|
|
719
751
|
vm_disks.push(context_disk)
|
720
752
|
end
|
721
753
|
|
722
754
|
# get monitoring data
|
723
755
|
vm_disks.each do |disk|
|
724
|
-
disk_id = disk[
|
725
|
-
disk[
|
756
|
+
disk_id = disk['DISK_ID']
|
757
|
+
disk['MONITOR_SIZE'] = \
|
758
|
+
vm["MONITORING/DISK_SIZE[ID='#{disk_id}']/SIZE"]
|
726
759
|
end
|
727
760
|
|
728
761
|
if !vm_disks.empty?
|
729
762
|
puts
|
730
|
-
CLIHelper.print_header(str_h1 %
|
763
|
+
CLIHelper.print_header(str_h1 % 'VM DISKS', false)
|
731
764
|
CLIHelper::ShowTable.new(nil, self) do
|
732
|
-
column :ID,
|
733
|
-
d[
|
765
|
+
column :ID, '', :size => 3 do |d|
|
766
|
+
d['DISK_ID']
|
734
767
|
end
|
735
768
|
|
736
|
-
column :DATASTORE,
|
737
|
-
d[
|
769
|
+
column :DATASTORE, '', :left, :size => 10 do |d|
|
770
|
+
d['DATASTORE']
|
738
771
|
end
|
739
772
|
|
740
|
-
column :TARGET,
|
741
|
-
d[
|
773
|
+
column :TARGET, '', :left, :size => 6 do |d|
|
774
|
+
d['TARGET']
|
742
775
|
end
|
743
776
|
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
end
|
758
|
-
end
|
777
|
+
# rubocop:disable Metrics/LineLength
|
778
|
+
column :IMAGE, '', :left, :size => 35 do |d|
|
779
|
+
d['IMAGE'] || case d['TYPE'].upcase
|
780
|
+
when 'FS'
|
781
|
+
"#{d['FORMAT']} - " <<
|
782
|
+
OpenNebulaHelper.unit_to_str(d['SIZE'].to_i,
|
783
|
+
{}, 'M')
|
784
|
+
when 'SWAP'
|
785
|
+
OpenNebulaHelper.unit_to_str(d['SIZE'].to_i,
|
786
|
+
{}, 'M')
|
787
|
+
|
788
|
+
end
|
759
789
|
end
|
790
|
+
# rubocop:enable Metrics/LineLength
|
760
791
|
|
761
|
-
column :SIZE,
|
762
|
-
if d[
|
792
|
+
column :SIZE, '', :left, :size => 9 do |d|
|
793
|
+
if d['SIZE']
|
763
794
|
size = OpenNebulaHelper.unit_to_str(
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
795
|
+
d['SIZE'].to_i,
|
796
|
+
{},
|
797
|
+
'M'
|
798
|
+
)
|
768
799
|
else
|
769
|
-
size =
|
800
|
+
size = '-'
|
770
801
|
end
|
771
802
|
|
772
|
-
if d[
|
803
|
+
if d['MONITOR_SIZE']
|
773
804
|
monitor_size = OpenNebulaHelper.unit_to_str(
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
805
|
+
d['MONITOR_SIZE'].to_i,
|
806
|
+
{},
|
807
|
+
'M'
|
808
|
+
)
|
778
809
|
else
|
779
|
-
monitor_size =
|
810
|
+
monitor_size = '-'
|
780
811
|
end
|
781
812
|
|
782
813
|
"#{monitor_size}/#{size}"
|
783
814
|
end
|
784
815
|
|
785
|
-
column :TYPE,
|
786
|
-
d[
|
816
|
+
column :TYPE, '', :left, :size => 4 do |d|
|
817
|
+
d['TYPE'].downcase
|
787
818
|
end
|
788
819
|
|
789
|
-
column :"R/O",
|
790
|
-
d[
|
820
|
+
column :"R/O", '', :size => 3 do |d|
|
821
|
+
d['READONLY']
|
791
822
|
end
|
792
823
|
|
793
|
-
column :
|
794
|
-
d[
|
824
|
+
column :SAVE, '', :size => 4 do |d|
|
825
|
+
d['SAVE'] || 'NO'
|
795
826
|
end
|
796
827
|
|
797
|
-
column :
|
798
|
-
d[
|
828
|
+
column :CLONE, '', :size => 5 do |d|
|
829
|
+
d['CLONE']
|
799
830
|
end
|
800
831
|
|
801
832
|
default :ID, :DATASTORE, :TARGET, :IMAGE, :SIZE, :TYPE,
|
802
|
-
|
833
|
+
:SAVE
|
803
834
|
end.show(vm_disks, {})
|
804
835
|
|
805
|
-
|
806
|
-
vm.
|
807
|
-
|
836
|
+
if !options[:all]
|
837
|
+
while vm.has_elements?('/VM/TEMPLATE/DISK')
|
838
|
+
vm.delete_element('/VM/TEMPLATE/DISK')
|
839
|
+
end
|
840
|
+
end
|
808
841
|
end
|
809
842
|
|
810
|
-
if vm.has_elements?(
|
843
|
+
if vm.has_elements?('/VM/SNAPSHOTS')
|
811
844
|
puts
|
812
|
-
CLIHelper.print_header(str_h1 %
|
845
|
+
CLIHelper.print_header(str_h1 % 'VM DISK SNAPSHOTS', false)
|
813
846
|
format_snapshots(vm)
|
814
847
|
end
|
815
848
|
|
816
849
|
sg_nics = []
|
817
850
|
|
818
|
-
if
|
819
|
-
|
851
|
+
if vm.has_elements?('/VM/TEMPLATE/NIC/SECURITY_GROUPS') ||
|
852
|
+
vm.has_elements?('/VM/TEMPLATE/PCI[NIC_ID>-1]/SECURITY_GROUPS')
|
820
853
|
|
821
854
|
sg_nics = [vm_hash['VM']['TEMPLATE']['NIC']]
|
822
855
|
|
@@ -838,465 +871,558 @@ in the frontend machine.
|
|
838
871
|
# array. Duplicate IPs are not shown.
|
839
872
|
extra_ips = []
|
840
873
|
|
841
|
-
if val=vm[
|
874
|
+
if (val = vm['/VM/MONITORING/GUEST_IP'])
|
842
875
|
extra_ips << val if val && !val.empty?
|
843
876
|
end
|
844
877
|
|
845
|
-
if val=vm[
|
878
|
+
if (val = vm['/VM/MONITORING/GUEST_IP_ADDRESSES'])
|
846
879
|
extra_ips += val.split(',') if val && !val.empty?
|
847
880
|
end
|
848
881
|
|
849
882
|
extra_ips.uniq!
|
850
883
|
|
851
|
-
[
|
852
|
-
|
853
|
-
|
884
|
+
%w[NIC NIC_ALIAS].each do |type|
|
885
|
+
next unless vm.has_elements?("/VM/TEMPLATE/#{type}") ||
|
886
|
+
vm.has_elements?('/VM/TEMPLATE/PCI[NIC_ID>-1]') ||
|
887
|
+
!extra_ips.empty?
|
854
888
|
|
855
|
-
|
856
|
-
|
889
|
+
puts
|
890
|
+
CLIHelper.print_header(
|
891
|
+
str_h1 % "VM #{type == 'NIC' ? 'NICS' : 'ALIAS'}", false
|
892
|
+
)
|
857
893
|
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
894
|
+
nic_default = { 'NETWORK' => '-',
|
895
|
+
'IP' => '-',
|
896
|
+
'MAC' => '-',
|
897
|
+
'BRIDGE' => '-' }
|
862
898
|
|
863
|
-
|
899
|
+
shown_ips = []
|
864
900
|
|
865
|
-
|
866
|
-
|
901
|
+
array_id = 0
|
902
|
+
vm_nics = [vm_hash['VM']['TEMPLATE'][type]]
|
867
903
|
|
868
|
-
|
869
|
-
|
904
|
+
if type == 'NIC'
|
905
|
+
vm_pcis = [vm_hash['VM']['TEMPLATE']['PCI']].flatten.compact
|
870
906
|
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
end
|
907
|
+
vm_pcis.each do |pci|
|
908
|
+
if !pci['NIC_ID'].nil?
|
909
|
+
vm_nics << pci
|
875
910
|
end
|
876
911
|
end
|
912
|
+
end
|
877
913
|
|
878
|
-
|
879
|
-
|
914
|
+
vm_nics.flatten!
|
915
|
+
vm_nics.compact!
|
880
916
|
|
881
|
-
|
917
|
+
vm_nics.each do |nic|
|
918
|
+
next if nic.key?('CLI_DONE')
|
882
919
|
|
883
|
-
|
920
|
+
%w[IP6_LINK IP6_ULA IP6_GLOBAL IP6].each do |attr|
|
921
|
+
next unless nic.key?(attr)
|
884
922
|
|
885
|
-
|
886
|
-
if nic.has_key?(attr)
|
887
|
-
shown_ips << nic[attr]
|
923
|
+
shown_ips << nic[attr]
|
888
924
|
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
925
|
+
ipstr = { 'IP' => nic.delete(attr),
|
926
|
+
'CLI_DONE' => true,
|
927
|
+
'DOUBLE_ENTRY' => true }
|
928
|
+
vm_nics.insert(array_id + 1, ipstr)
|
893
929
|
|
894
|
-
|
895
|
-
|
896
|
-
end
|
930
|
+
array_id += 1
|
931
|
+
end
|
897
932
|
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
shown_ips << nic[attr]
|
933
|
+
%w[VROUTER_IP VROUTER_IP6_LINK
|
934
|
+
VROUTER_IP6_ULA VROUTER_IP6_GLOBAL].each do |attr|
|
935
|
+
next unless nic.key?(attr)
|
902
936
|
|
903
|
-
|
904
|
-
"CLI_DONE" => true,
|
905
|
-
"DOUBLE_ENTRY" => true}
|
906
|
-
vm_nics.insert(array_id+1,ipstr)
|
937
|
+
shown_ips << nic[attr]
|
907
938
|
|
908
|
-
|
909
|
-
|
910
|
-
|
939
|
+
ipstr = { 'IP' => nic.delete(attr) + ' (VRouter)',
|
940
|
+
'CLI_DONE' => true,
|
941
|
+
'DOUBLE_ENTRY' => true }
|
942
|
+
vm_nics.insert(array_id + 1, ipstr)
|
911
943
|
|
912
|
-
shown_ips << nic["IP"] if nic.has_key?("IP")
|
913
|
-
|
914
|
-
nic.merge!(nic_default) {|k,v1,v2| v1}
|
915
944
|
array_id += 1
|
916
|
-
|
945
|
+
end
|
917
946
|
|
918
|
-
|
947
|
+
shown_ips << nic['IP'] if nic.key?('IP')
|
919
948
|
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
"NIC_ID" => "-",
|
924
|
-
"IP" => ip,
|
925
|
-
"NETWORK" => "Additional IP",
|
926
|
-
"BRIDGE" => "-"
|
927
|
-
}
|
928
|
-
end
|
949
|
+
nic.merge!(nic_default) {|_k, v1, _v2| v1 }
|
950
|
+
array_id += 1
|
951
|
+
end
|
929
952
|
|
930
|
-
|
931
|
-
column :ID, "", :size=>3 do |d|
|
932
|
-
if d["DOUBLE_ENTRY"]
|
933
|
-
""
|
934
|
-
else
|
935
|
-
d["NIC_ID"]
|
936
|
-
end
|
937
|
-
end
|
953
|
+
extra_ips -= shown_ips
|
938
954
|
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
955
|
+
# Add extra IPs to the VM NICS table
|
956
|
+
extra_ips.each do |ip|
|
957
|
+
vm_nics << {
|
958
|
+
'NIC_ID' => '-',
|
959
|
+
'IP' => ip,
|
960
|
+
'NETWORK' => 'Additional IP',
|
961
|
+
'BRIDGE' => '-'
|
962
|
+
}
|
963
|
+
end
|
964
|
+
|
965
|
+
CLIHelper::ShowTable.new(nil, self) do
|
966
|
+
column :ID, '', :size => 3 do |d|
|
967
|
+
if d['DOUBLE_ENTRY']
|
968
|
+
''
|
969
|
+
else
|
970
|
+
d['NIC_ID']
|
945
971
|
end
|
972
|
+
end
|
946
973
|
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
end
|
974
|
+
column :NETWORK, '', :left, :size => 20 do |d|
|
975
|
+
if d['DOUBLE_ENTRY']
|
976
|
+
''
|
977
|
+
else
|
978
|
+
d['NETWORK']
|
953
979
|
end
|
980
|
+
end
|
954
981
|
|
955
|
-
|
956
|
-
|
982
|
+
column :BRIDGE, '', :left, :size => 12 do |d|
|
983
|
+
if d['DOUBLE_ENTRY']
|
984
|
+
''
|
985
|
+
else
|
986
|
+
d['BRIDGE']
|
957
987
|
end
|
988
|
+
end
|
958
989
|
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
990
|
+
column :IP, '', :left, :adjust, :size => 15 do |d|
|
991
|
+
d['IP']
|
992
|
+
end
|
993
|
+
|
994
|
+
column :MAC, '', :left, :size => 17 do |d|
|
995
|
+
if d['DOUBLE_ENTRY']
|
996
|
+
''
|
997
|
+
else
|
998
|
+
d['MAC']
|
965
999
|
end
|
1000
|
+
end
|
966
1001
|
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
end
|
1002
|
+
if type == 'NIC'
|
1003
|
+
column :PCI_ID, '', :left, :size => 8 do |d|
|
1004
|
+
if d['DOUBLE_ENTRY']
|
1005
|
+
''
|
1006
|
+
else
|
1007
|
+
d['PCI_ID']
|
974
1008
|
end
|
975
1009
|
end
|
1010
|
+
end
|
1011
|
+
end.show(vm_nics, {})
|
976
1012
|
|
977
|
-
|
1013
|
+
next if options[:all]
|
978
1014
|
|
979
|
-
|
980
|
-
|
981
|
-
end if !options[:all]
|
1015
|
+
while vm.has_elements?("/VM/TEMPLATE/#{type}")
|
1016
|
+
vm.delete_element("/VM/TEMPLATE/#{type}")
|
982
1017
|
end
|
983
1018
|
end
|
984
1019
|
|
985
|
-
|
986
|
-
vm.
|
987
|
-
|
1020
|
+
if !options[:all]
|
1021
|
+
while vm.has_elements?('/VM/TEMPLATE/NIC')
|
1022
|
+
vm.delete_element('/VM/TEMPLATE/NIC')
|
1023
|
+
end
|
1024
|
+
end
|
988
1025
|
|
989
|
-
if vm.has_elements?(
|
1026
|
+
if vm.has_elements?('/VM/TEMPLATE/SECURITY_GROUP_RULE') && !is_hybrid
|
990
1027
|
puts
|
991
|
-
CLIHelper.print_header(str_h1 %
|
1028
|
+
CLIHelper.print_header(str_h1 % 'SECURITY', false)
|
992
1029
|
puts
|
993
1030
|
|
994
1031
|
CLIHelper::ShowTable.new(nil, self) do
|
995
|
-
column :NIC_ID,
|
996
|
-
d[
|
1032
|
+
column :NIC_ID, '', :size => 6 do |d|
|
1033
|
+
d['NIC_ID']
|
997
1034
|
end
|
998
1035
|
|
999
|
-
column :NETWORK,
|
1000
|
-
d[
|
1036
|
+
column :NETWORK, '', :left, :size => 25 do |d|
|
1037
|
+
d['NETWORK']
|
1001
1038
|
end
|
1002
1039
|
|
1003
|
-
column :SECURITY_GROUPS,
|
1004
|
-
d[
|
1040
|
+
column :SECURITY_GROUPS, '', :left, :size => 47 do |d|
|
1041
|
+
d['SECURITY_GROUPS']
|
1005
1042
|
end
|
1006
|
-
end.show(sg_nics,{})
|
1043
|
+
end.show(sg_nics, {})
|
1007
1044
|
|
1008
1045
|
puts
|
1009
1046
|
|
1010
|
-
|
1047
|
+
# rubocop:disable Metrics/LineLength
|
1048
|
+
CLIHelper.print_header(str_h1 % 'SECURITY GROUP TYPE PROTOCOL NETWORK RANGE ', false)
|
1011
1049
|
|
1012
1050
|
CLIHelper::ShowTable.new(nil, self) do
|
1013
|
-
column :ID,
|
1014
|
-
d[
|
1051
|
+
column :ID, '', :size => 4 do |d|
|
1052
|
+
d['SECURITY_GROUP_ID']
|
1015
1053
|
end
|
1016
1054
|
|
1017
|
-
column :NAME,
|
1018
|
-
d[
|
1055
|
+
column :NAME, '', :left, :size => 11 do |d|
|
1056
|
+
d['SECURITY_GROUP_NAME']
|
1019
1057
|
end
|
1020
1058
|
|
1021
|
-
column :" ",
|
1022
|
-
d[
|
1059
|
+
column :" ", '', :left, :size => 8 do |d|
|
1060
|
+
d['RULE_TYPE']
|
1023
1061
|
end
|
1024
1062
|
|
1025
|
-
column :" ",
|
1026
|
-
protocol = d[
|
1063
|
+
column :" ", '', :left, :size => 8 do |d|
|
1064
|
+
protocol = d['PROTOCOL']
|
1027
1065
|
|
1028
|
-
if
|
1029
|
-
|
1066
|
+
if protocol.casecmp('ICMP').zero?
|
1067
|
+
d['ICMP_TYPE'].nil? ? icmp = '' : icmp = "-#{d['ICMP_TYPE']}"
|
1030
1068
|
protocol += icmp
|
1031
1069
|
end
|
1032
1070
|
|
1033
1071
|
protocol
|
1034
1072
|
end
|
1035
1073
|
|
1036
|
-
column :VNET,
|
1037
|
-
d[
|
1074
|
+
column :VNET, '', :size => 4 do |d|
|
1075
|
+
d['NETWORK_ID']
|
1038
1076
|
end
|
1039
1077
|
|
1040
|
-
column :START,
|
1041
|
-
network =
|
1078
|
+
column :START, '', :left, :adjust, :size => 17 do |d|
|
1079
|
+
network = ''
|
1042
1080
|
|
1043
|
-
if
|
1044
|
-
network = d[
|
1045
|
-
elsif
|
1046
|
-
network = d[
|
1081
|
+
if !d['IP'].nil? && d['IP'] != ''
|
1082
|
+
network = d['IP']
|
1083
|
+
elsif !d['MAC'].nil? && d['MAC'] != ''
|
1084
|
+
network = d['MAC']
|
1047
1085
|
end
|
1048
1086
|
|
1049
1087
|
network
|
1050
1088
|
end
|
1051
1089
|
|
1052
|
-
column :SIZE,
|
1053
|
-
d[
|
1090
|
+
column :SIZE, '', :left, :adjust, :size => 6 do |d|
|
1091
|
+
d['SIZE']
|
1054
1092
|
end
|
1055
1093
|
|
1056
|
-
column :" ",
|
1057
|
-
d[
|
1094
|
+
column :" ", '', :left, :adjust, :size => 15 do |d|
|
1095
|
+
d['RANGE']
|
1058
1096
|
end
|
1097
|
+
end.show(
|
1098
|
+
[vm_hash['VM']['TEMPLATE']['SECURITY_GROUP_RULE']].flatten, {}
|
1099
|
+
)
|
1100
|
+
# rubocop:enable Metrics/LineLength
|
1059
1101
|
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
end
|
1102
|
+
if !options[:all]
|
1103
|
+
while vm.has_elements?('/VM/TEMPLATE/SECURITY_GROUP_RULE')
|
1104
|
+
vm.delete_element('/VM/TEMPLATE/SECURITY_GROUP_RULE')
|
1105
|
+
end
|
1106
|
+
end
|
1065
1107
|
end
|
1066
1108
|
|
1067
|
-
if vm.has_elements?(
|
1109
|
+
if vm.has_elements?('/VM/TEMPLATE/SNAPSHOT')
|
1068
1110
|
puts
|
1069
|
-
CLIHelper.print_header(str_h1 %
|
1111
|
+
CLIHelper.print_header(str_h1 % 'SNAPSHOTS', false)
|
1070
1112
|
|
1071
1113
|
CLIHelper::ShowTable.new(nil, self) do
|
1072
|
-
|
1073
|
-
|
1074
|
-
d["SNAPSHOT_ID"] if !d.nil?
|
1114
|
+
column :ID, '', :size => 4 do |d|
|
1115
|
+
d['SNAPSHOT_ID'] unless d.nil?
|
1075
1116
|
end
|
1076
1117
|
|
1077
|
-
column :
|
1078
|
-
OpenNebulaHelper.time_to_str(d[
|
1118
|
+
column :TIME, '', :size => 12 do |d|
|
1119
|
+
OpenNebulaHelper.time_to_str(d['TIME'], false) unless d.nil?
|
1079
1120
|
end
|
1080
1121
|
|
1081
|
-
column :
|
1082
|
-
d[
|
1122
|
+
column :NAME, '', :left, :size => 46 do |d|
|
1123
|
+
d['NAME'] unless d.nil?
|
1083
1124
|
end
|
1084
1125
|
|
1085
|
-
column :
|
1086
|
-
d[
|
1126
|
+
column :HYPERVISOR_ID, '', :left, :size => 15 do |d|
|
1127
|
+
d['HYPERVISOR_ID'] unless d.nil?
|
1087
1128
|
end
|
1088
|
-
|
1089
1129
|
end.show([vm_hash['VM']['TEMPLATE']['SNAPSHOT']].flatten, {})
|
1090
1130
|
|
1091
|
-
vm.delete_element(
|
1131
|
+
vm.delete_element('/VM/TEMPLATE/SNAPSHOT')
|
1092
1132
|
end
|
1093
1133
|
|
1094
|
-
if vm.has_elements?(
|
1134
|
+
if vm.has_elements?('/VM/HISTORY_RECORDS')
|
1095
1135
|
puts
|
1096
1136
|
|
1097
|
-
CLIHelper.print_header(str_h1 %
|
1137
|
+
CLIHelper.print_header(str_h1 % 'VIRTUAL MACHINE HISTORY', false)
|
1098
1138
|
format_history(vm)
|
1099
1139
|
end
|
1100
1140
|
|
1101
|
-
if vm.has_elements?(
|
1141
|
+
if vm.has_elements?('/VM/USER_TEMPLATE/SCHED_ACTION')
|
1102
1142
|
puts
|
1103
|
-
CLIHelper.print_header(str_h1 %
|
1143
|
+
CLIHelper.print_header(str_h1 % 'SCHEDULED ACTIONS', false)
|
1104
1144
|
|
1105
1145
|
CLIHelper::ShowTable.new(nil, self) do
|
1106
|
-
|
1107
|
-
|
1108
|
-
d["ID"] if !d.nil?
|
1146
|
+
column :ID, '', :size => 2 do |d|
|
1147
|
+
d['ID'] unless d.nil?
|
1109
1148
|
end
|
1110
1149
|
|
1111
|
-
column :
|
1112
|
-
d[
|
1150
|
+
column :ACTION, '', :left, :size => 15 do |d|
|
1151
|
+
d['ACTION'] unless d.nil?
|
1113
1152
|
end
|
1114
1153
|
|
1115
|
-
column :
|
1116
|
-
OpenNebulaHelper.time_to_str(d[
|
1154
|
+
column :SCHEDULED, '', :size => 12 do |d|
|
1155
|
+
OpenNebulaHelper.time_to_str(d['TIME'], false) \
|
1156
|
+
unless d.nil?
|
1117
1157
|
end
|
1118
1158
|
|
1119
|
-
column :
|
1120
|
-
str_rep =
|
1121
|
-
if !d.nil? && d.key?(
|
1122
|
-
if d[
|
1123
|
-
str_rep <<
|
1124
|
-
elsif d[
|
1125
|
-
str_rep <<
|
1126
|
-
elsif d[
|
1127
|
-
str_rep <<
|
1128
|
-
elsif d[
|
1129
|
-
str_rep <<
|
1159
|
+
column :REPEAT, '', :size => 20 do |d|
|
1160
|
+
str_rep = ''
|
1161
|
+
if !d.nil? && d.key?('REPEAT')
|
1162
|
+
if d['REPEAT'] == '0'
|
1163
|
+
str_rep << 'Weekly '
|
1164
|
+
elsif d['REPEAT'] == '1'
|
1165
|
+
str_rep << 'Monthly '
|
1166
|
+
elsif d['REPEAT'] == '2'
|
1167
|
+
str_rep << 'Yearly '
|
1168
|
+
elsif d['REPEAT'] == '3'
|
1169
|
+
str_rep << 'Each ' << d['DAYS'] << ' hours'
|
1130
1170
|
end
|
1131
|
-
if d[
|
1132
|
-
str_rep << d[
|
1171
|
+
if d['REPEAT'] != '3'
|
1172
|
+
str_rep << d['DAYS']
|
1133
1173
|
end
|
1134
1174
|
end
|
1135
|
-
str_rep
|
1175
|
+
str_rep unless d.nil?
|
1136
1176
|
end
|
1137
1177
|
|
1138
|
-
column :
|
1139
|
-
str_end =
|
1140
|
-
if !d.nil? && d.key?(
|
1141
|
-
if d[
|
1142
|
-
str_end <<
|
1143
|
-
elsif d[
|
1144
|
-
str_end <<
|
1145
|
-
elsif d[
|
1146
|
-
str_end <<
|
1178
|
+
column :END, '', :size => 20 do |d|
|
1179
|
+
str_end = ''
|
1180
|
+
if !d.nil? && d.key?('END_TYPE')
|
1181
|
+
if d['END_TYPE'] == '0'
|
1182
|
+
str_end << 'None'
|
1183
|
+
elsif d['END_TYPE'] == '1'
|
1184
|
+
str_end << 'After ' << d['END_VALUE'] << ' times'
|
1185
|
+
elsif d['END_TYPE'] == '2'
|
1186
|
+
str_end << 'On ' << \
|
1187
|
+
OpenNebulaHelper.time_to_str(d['END_VALUE'],
|
1188
|
+
false, false,
|
1189
|
+
true)
|
1147
1190
|
end
|
1148
1191
|
end
|
1149
|
-
str_end
|
1192
|
+
str_end unless d.nil?
|
1150
1193
|
end
|
1151
1194
|
|
1152
|
-
column :
|
1153
|
-
OpenNebulaHelper.time_to_str(d[
|
1195
|
+
column :DONE, '', :size => 12 do |d|
|
1196
|
+
OpenNebulaHelper.time_to_str(d['DONE'], false) \
|
1197
|
+
unless d.nil?
|
1154
1198
|
end
|
1155
1199
|
|
1156
|
-
column :
|
1157
|
-
d[
|
1200
|
+
column :MESSAGE, '', :left, :adjust, :size => 35 do |d|
|
1201
|
+
d['MESSAGE'] unless d.nil?
|
1158
1202
|
end
|
1159
|
-
end.show([vm_hash['VM']['USER_TEMPLATE']['SCHED_ACTION']].flatten,
|
1203
|
+
end.show([vm_hash['VM']['USER_TEMPLATE']['SCHED_ACTION']].flatten,
|
1204
|
+
{})
|
1160
1205
|
end
|
1161
1206
|
|
1162
|
-
if vm.has_elements?(
|
1207
|
+
if vm.has_elements?('/VM/USER_TEMPLATE')
|
1163
1208
|
puts
|
1164
1209
|
|
1165
1210
|
if !options[:all]
|
1166
|
-
vm.delete_element(
|
1211
|
+
vm.delete_element('/VM/USER_TEMPLATE/SCHED_ACTION')
|
1167
1212
|
end
|
1168
1213
|
|
1169
|
-
CLIHelper.print_header(str_h1 %
|
1214
|
+
CLIHelper.print_header(str_h1 % 'USER TEMPLATE', false)
|
1170
1215
|
puts vm.template_like_str('USER_TEMPLATE')
|
1171
1216
|
end
|
1172
1217
|
|
1218
|
+
if vm.has_elements?('/VM/TEMPLATE/NUMA_NODE')
|
1219
|
+
print_numa_nodes([vm.to_hash['VM']['TEMPLATE']['NUMA_NODE']]
|
1220
|
+
.flatten)
|
1221
|
+
end
|
1222
|
+
|
1223
|
+
if vm.has_elements?('/VM/TEMPLATE/TOPOLOGY')
|
1224
|
+
print_topology([vm.to_hash['VM']['TEMPLATE']['TOPOLOGY']])
|
1225
|
+
end
|
1226
|
+
|
1227
|
+
if !options[:all]
|
1228
|
+
while vm.has_elements?('/VM/TEMPLATE/NUMA_NODE')
|
1229
|
+
vm.delete_element('/VM/TEMPLATE/NUMA_NODE')
|
1230
|
+
end
|
1231
|
+
end
|
1232
|
+
|
1233
|
+
if !options[:all]
|
1234
|
+
while vm.has_elements?('/VM/TEMPLATE/TOPOLOGY')
|
1235
|
+
vm.delete_element('/VM/TEMPLATE/TOPOLOGY')
|
1236
|
+
end
|
1237
|
+
end
|
1238
|
+
|
1173
1239
|
puts
|
1174
|
-
CLIHelper.print_header(str_h1 %
|
1240
|
+
CLIHelper.print_header(str_h1 % 'VIRTUAL MACHINE TEMPLATE', false)
|
1175
1241
|
puts vm.template_str
|
1176
1242
|
end
|
1177
1243
|
|
1244
|
+
def print_numa_nodes(numa_nodes)
|
1245
|
+
puts
|
1246
|
+
CLIHelper.print_header('NUMA NODES', false)
|
1247
|
+
puts
|
1248
|
+
|
1249
|
+
# rubocop:disable Metrics/LineLength
|
1250
|
+
table = CLIHelper::ShowTable.new(nil, self) do
|
1251
|
+
column :ID, 'Node ID', :size => 4, :left => false do |d|
|
1252
|
+
d['NODE_ID']
|
1253
|
+
end
|
1254
|
+
|
1255
|
+
column :CPUS_IDS, 'Cpus used', :adjust => true, :left => false do |d|
|
1256
|
+
d['CPUS']
|
1257
|
+
end
|
1258
|
+
|
1259
|
+
column :MEMORY, 'Memory used', :size => 10, :left => false do |d|
|
1260
|
+
OpenNebulaHelper.unit_to_str(d['MEMORY'].to_i, {})
|
1261
|
+
end
|
1262
|
+
|
1263
|
+
column :TOTAL_CPUS, 'Total CPUs', :size => 10, :left => false do |d|
|
1264
|
+
d['TOTAL_CPUS']
|
1265
|
+
end
|
1266
|
+
|
1267
|
+
default :ID, :CPUS_IDS, :MEMORY, :TOTAL_CPUS
|
1268
|
+
end
|
1269
|
+
# rubocop:enable Metrics/LineLength
|
1270
|
+
|
1271
|
+
table.show(numa_nodes)
|
1272
|
+
end
|
1273
|
+
|
1274
|
+
def print_topology(topology)
|
1275
|
+
puts
|
1276
|
+
CLIHelper.print_header('TOPOLOGY', false)
|
1277
|
+
puts
|
1278
|
+
|
1279
|
+
table = CLIHelper::ShowTable.new(nil, self) do
|
1280
|
+
column :CORES, 'Cores', :size => 6, :left => false do |d|
|
1281
|
+
d['CORES']
|
1282
|
+
end
|
1283
|
+
|
1284
|
+
column :SOCKETS, 'Sockets', :size => 8, :left => false do |d|
|
1285
|
+
d['SOCKETS']
|
1286
|
+
end
|
1287
|
+
|
1288
|
+
column :THREADS, 'Threads', :size => 8, :left => false do |d|
|
1289
|
+
d['THREADS']
|
1290
|
+
end
|
1291
|
+
|
1292
|
+
default :CORES, :SOCKETS, :THREADS
|
1293
|
+
end
|
1294
|
+
|
1295
|
+
table.show(topology)
|
1296
|
+
end
|
1297
|
+
|
1178
1298
|
def format_history(vm)
|
1179
|
-
table=CLIHelper::ShowTable.new(nil, self) do
|
1180
|
-
column :SEQ,
|
1181
|
-
d[
|
1299
|
+
table = CLIHelper::ShowTable.new(nil, self) do
|
1300
|
+
column :SEQ, 'Sequence number', :size => 3 do |d|
|
1301
|
+
d['SEQ']
|
1182
1302
|
end
|
1183
1303
|
|
1184
|
-
column :UID,
|
1185
|
-
|
1186
|
-
if d[
|
1187
|
-
d[
|
1304
|
+
column :UID, 'UID of the user that performed the action',
|
1305
|
+
:left, :size => 4 do |d|
|
1306
|
+
if d['UID'] != '-1'
|
1307
|
+
d['UID']
|
1188
1308
|
else
|
1189
|
-
|
1309
|
+
'-'
|
1190
1310
|
end
|
1191
1311
|
end
|
1192
1312
|
|
1193
|
-
column :REQ,
|
1194
|
-
if d[
|
1195
|
-
d[
|
1313
|
+
column :REQ, 'Request ID of the action', :left, :size => 5 do |d|
|
1314
|
+
if d['REQUEST_ID'] != '-1'
|
1315
|
+
d['REQUEST_ID']
|
1196
1316
|
else
|
1197
|
-
|
1317
|
+
'-'
|
1198
1318
|
end
|
1199
1319
|
end
|
1200
1320
|
|
1201
|
-
column :HOST,
|
1202
|
-
|
1321
|
+
column :HOST, 'Host name of the VM container',
|
1322
|
+
:left, :size => 12 do |d|
|
1323
|
+
d['HOSTNAME']
|
1203
1324
|
end
|
1204
1325
|
|
1205
|
-
column :
|
1206
|
-
VirtualMachine.get_history_action d[
|
1326
|
+
column :ACTION, 'VM state change action', :left, :size => 10 do |d|
|
1327
|
+
VirtualMachine.get_history_action d['ACTION']
|
1207
1328
|
end
|
1208
1329
|
|
1209
|
-
column :DS,
|
1210
|
-
d[
|
1330
|
+
column :DS, 'System Datastore', :size => 4 do |d|
|
1331
|
+
d['DS_ID']
|
1211
1332
|
end
|
1212
1333
|
|
1213
|
-
column :START,
|
1334
|
+
column :START, 'Time when the state changed', :size => 15 do |d|
|
1214
1335
|
OpenNebulaHelper.time_to_str(d['STIME'])
|
1215
1336
|
end
|
1216
1337
|
|
1217
|
-
column :TIME,
|
1218
|
-
stime = d[
|
1219
|
-
etime = d[
|
1220
|
-
dtime = etime-stime
|
1338
|
+
column :TIME, 'Total time in this state', :size => 11 do |d|
|
1339
|
+
stime = d['STIME'].to_i
|
1340
|
+
etime = d['ETIME'] == '0' ? Time.now.to_i : d['ETIME'].to_i
|
1341
|
+
dtime = etime - stime
|
1221
1342
|
OpenNebulaHelper.period_to_str(dtime, false)
|
1222
1343
|
end
|
1223
1344
|
|
1224
|
-
column :PROLOG,
|
1225
|
-
stime = d[
|
1226
|
-
if d[
|
1227
|
-
etime=0
|
1345
|
+
column :PROLOG, 'Prolog time for this state', :size => 10 do |d|
|
1346
|
+
stime = d['PSTIME'].to_i
|
1347
|
+
if d['PSTIME'] == '0'
|
1348
|
+
etime = 0
|
1228
1349
|
else
|
1229
|
-
|
1350
|
+
if d['PETIME'] == '0'
|
1351
|
+
etime = Time.now.to_i
|
1352
|
+
else
|
1353
|
+
etime = d['PETIME'].to_i
|
1354
|
+
end
|
1230
1355
|
end
|
1231
|
-
dtime = etime-stime
|
1356
|
+
dtime = etime - stime
|
1232
1357
|
OpenNebulaHelper.short_period_to_str(dtime)
|
1233
1358
|
end
|
1234
1359
|
|
1235
|
-
default :SEQ, :UID, :REQ, :HOST, :ACTION,
|
1360
|
+
default :SEQ, :UID, :REQ, :HOST, :ACTION, \
|
1361
|
+
:DS, :START, :TIME, :PROLOG
|
1236
1362
|
end
|
1237
1363
|
|
1238
|
-
vm_hash=vm.to_hash
|
1364
|
+
vm_hash = vm.to_hash
|
1239
1365
|
|
1240
|
-
history=[vm_hash['VM']['HISTORY_RECORDS']['HISTORY']].flatten
|
1366
|
+
history = [vm_hash['VM']['HISTORY_RECORDS']['HISTORY']].flatten
|
1241
1367
|
|
1242
1368
|
table.show(history)
|
1243
1369
|
end
|
1244
1370
|
|
1245
1371
|
def format_snapshots(vm)
|
1246
|
-
table=CLIHelper::ShowTable.new(nil, self) do
|
1247
|
-
column :AC
|
1248
|
-
if d[
|
1249
|
-
|
1372
|
+
table = CLIHelper::ShowTable.new(nil, self) do
|
1373
|
+
column :AC, 'Is active', :left, :size => 2 do |d|
|
1374
|
+
if d['ACTIVE'] == 'YES'
|
1375
|
+
'=>'
|
1250
1376
|
else
|
1251
|
-
|
1377
|
+
''
|
1252
1378
|
end
|
1253
1379
|
end
|
1254
|
-
column :ID,
|
1255
|
-
d[
|
1380
|
+
column :ID, 'Snapshot ID', :size => 3 do |d|
|
1381
|
+
d['ID']
|
1256
1382
|
end
|
1257
1383
|
|
1258
|
-
column :DISK,
|
1259
|
-
d[
|
1384
|
+
column :DISK, 'Disk ID', :size => 4 do |d|
|
1385
|
+
d['DISK_ID']
|
1260
1386
|
end
|
1261
1387
|
|
1262
|
-
column :PARENT,
|
1263
|
-
d[
|
1388
|
+
column :PARENT, 'Snapshot Parent ID', :size => 6 do |d|
|
1389
|
+
d['PARENT']
|
1264
1390
|
end
|
1265
1391
|
|
1266
|
-
column :CHILDREN,
|
1267
|
-
d[
|
1392
|
+
column :CHILDREN, 'Snapshot Children IDs', :size => 10 do |d|
|
1393
|
+
d['CHILDREN']
|
1268
1394
|
end
|
1269
1395
|
|
1270
|
-
column :SIZE,
|
1271
|
-
if d[
|
1396
|
+
column :SIZE, '', :left, :size => 12 do |d|
|
1397
|
+
if d['SIZE']
|
1272
1398
|
size = OpenNebulaHelper.unit_to_str(
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1399
|
+
d['SIZE'].to_i,
|
1400
|
+
{},
|
1401
|
+
'M'
|
1402
|
+
)
|
1277
1403
|
else
|
1278
|
-
size =
|
1404
|
+
size = '-'
|
1279
1405
|
end
|
1280
1406
|
|
1281
|
-
if d[
|
1407
|
+
if d['MONITOR_SIZE']
|
1282
1408
|
monitor_size = OpenNebulaHelper.unit_to_str(
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1409
|
+
d['MONITOR_SIZE'].to_i,
|
1410
|
+
{},
|
1411
|
+
'M'
|
1412
|
+
)
|
1287
1413
|
else
|
1288
|
-
monitor_size =
|
1414
|
+
monitor_size = '-'
|
1289
1415
|
end
|
1290
1416
|
|
1291
1417
|
"#{monitor_size}/#{size}"
|
1292
1418
|
end
|
1293
1419
|
|
1294
|
-
column :NAME,
|
1295
|
-
d[
|
1420
|
+
column :NAME, 'Snapshot Name', :left, :size => 32 do |d|
|
1421
|
+
d['NAME']
|
1296
1422
|
end
|
1297
1423
|
|
1298
|
-
column :DATE,
|
1299
|
-
OpenNebulaHelper.time_to_str(d[
|
1424
|
+
column :DATE, 'Snapshot creation date', :size => 15 do |d|
|
1425
|
+
OpenNebulaHelper.time_to_str(d['DATE'])
|
1300
1426
|
end
|
1301
1427
|
|
1302
1428
|
default :AC, :ID, :DISK, :PARENT, :DATE, :SIZE, :NAME
|
@@ -1313,19 +1439,23 @@ in the frontend machine.
|
|
1313
1439
|
|
1314
1440
|
sshots = [disk['SNAPSHOT']].flatten
|
1315
1441
|
sshots.each do |snapshot|
|
1316
|
-
data = snapshot.merge(
|
1442
|
+
data = snapshot.merge('DISK_ID' => disk_id)
|
1317
1443
|
snapshots << data
|
1318
1444
|
end
|
1319
1445
|
end
|
1320
1446
|
|
1321
1447
|
# get monitoring data
|
1322
1448
|
snapshots.each do |snapshot|
|
1323
|
-
disk_id = snapshot[
|
1324
|
-
snap_id = snapshot[
|
1325
|
-
xpath = "MONITORING/SNAPSHOT_SIZE[ID='#{snap_id}'
|
1326
|
-
|
1449
|
+
disk_id = snapshot['DISK_ID']
|
1450
|
+
snap_id = snapshot['ID']
|
1451
|
+
xpath = "MONITORING/SNAPSHOT_SIZE[ID='#{snap_id}' " \
|
1452
|
+
"and DISK_ID='#{disk_id}']/SIZE"
|
1453
|
+
snapshot['MONITOR_SIZE'] = vm[xpath]
|
1327
1454
|
end
|
1328
1455
|
|
1329
1456
|
table.show(snapshots)
|
1330
1457
|
end
|
1458
|
+
|
1331
1459
|
end
|
1460
|
+
|
1461
|
+
# rubocop:enable Naming/UncommunicativeMethodParamName
|