opennebula-cli 5.2.1 → 5.3.80.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/onehost +27 -6
- data/bin/onevcenter +35 -460
- data/bin/onevm +27 -0
- data/bin/onevmgroup +185 -0
- data/bin/onevnet +44 -6
- data/bin/onezone +37 -0
- data/lib/one_helper.rb +47 -0
- data/lib/one_helper/oneacct_helper.rb +1 -5
- data/lib/one_helper/oneacl_helper.rb +6 -4
- data/lib/one_helper/onehost_helper.rb +12 -7
- data/lib/one_helper/oneimage_helper.rb +27 -14
- data/lib/one_helper/onesecgroup_helper.rb +4 -0
- data/lib/one_helper/onevm_helper.rb +22 -9
- data/lib/one_helper/onevmgroup_helper.rb +170 -0
- data/lib/one_helper/onevnet_helper.rb +16 -3
- data/lib/one_helper/onezone_helper.rb +96 -0
- metadata +14 -12
@@ -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
|
@@ -80,6 +80,8 @@ private
|
|
80
80
|
mask[14] = "M"
|
81
81
|
when "MARKETPLACEAPP"
|
82
82
|
mask[15] = "A"
|
83
|
+
when "VMGROUP"
|
84
|
+
mask[16] = "P"
|
83
85
|
end
|
84
86
|
}
|
85
87
|
mask
|
@@ -119,8 +121,8 @@ private
|
|
119
121
|
d['STRING'].split(" ")[0]
|
120
122
|
end
|
121
123
|
|
122
|
-
column :
|
123
|
-
:size =>
|
124
|
+
column :RES_VHNIUTGDCOZSvRMAP, "Resource to which the rule applies",
|
125
|
+
:size => 21 do |d|
|
124
126
|
OneAclHelper::resource_mask d['STRING'].split(" ")[1]
|
125
127
|
end
|
126
128
|
|
@@ -137,7 +139,7 @@ private
|
|
137
139
|
OneAclHelper::right_mask d['STRING'].split(" ")[2]
|
138
140
|
end
|
139
141
|
|
140
|
-
default :ID, :USER, :
|
142
|
+
default :ID, :USER, :RES_VHNIUTGDCOZSvRMAP, :RID, :OPE_UMAC, :ZONE
|
141
143
|
end
|
142
144
|
|
143
145
|
table
|
@@ -382,14 +382,19 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
|
382
382
|
puts
|
383
383
|
|
384
384
|
CLIHelper.print_header(str_h1 % "HOST SHARES", false)
|
385
|
-
|
386
|
-
puts str % ["TOTAL MEM", OpenNebulaHelper.unit_to_str(host['HOST_SHARE/MAX_MEM'].to_i, {})]
|
387
|
-
puts str % ["USED MEM (REAL)", OpenNebulaHelper.unit_to_str(host['HOST_SHARE/USED_MEM'].to_i, {})]
|
388
|
-
puts str % ["USED MEM (ALLOCATED)", OpenNebulaHelper.unit_to_str(host['HOST_SHARE/MEM_USAGE'].to_i, {})]
|
389
|
-
puts str % ["TOTAL CPU", host['HOST_SHARE/MAX_CPU']]
|
390
|
-
puts str % ["USED CPU (REAL)", host['HOST_SHARE/USED_CPU']]
|
391
|
-
puts str % ["USED CPU (ALLOCATED)", host['HOST_SHARE/CPU_USAGE']]
|
392
385
|
puts str % ["RUNNING VMS", host['HOST_SHARE/RUNNING_VMS']]
|
386
|
+
|
387
|
+
CLIHelper.print_header(str_h1 % "MEMORY", false)
|
388
|
+
puts str % [" TOTAL", OpenNebulaHelper.unit_to_str(host['HOST_SHARE/TOTAL_MEM'].to_i, {})]
|
389
|
+
puts str % [" TOTAL +/- RESERVED", OpenNebulaHelper.unit_to_str(host['HOST_SHARE/MAX_MEM'].to_i, {})]
|
390
|
+
puts str % [" USED (REAL)", OpenNebulaHelper.unit_to_str(host['HOST_SHARE/USED_MEM'].to_i, {})]
|
391
|
+
puts str % [" USED (ALLOCATED)", OpenNebulaHelper.unit_to_str(host['HOST_SHARE/MEM_USAGE'].to_i, {})]
|
392
|
+
|
393
|
+
CLIHelper.print_header(str_h1 % "CPU", false)
|
394
|
+
puts str % [" TOTAL", host['HOST_SHARE/TOTAL_CPU']]
|
395
|
+
puts str % [" TOTAL +/- RESERVED", host['HOST_SHARE/MAX_CPU']]
|
396
|
+
puts str % [" USED (REAL)", host['HOST_SHARE/USED_CPU']]
|
397
|
+
puts str % [" USED (ALLOCATED)", host['HOST_SHARE/CPU_USAGE']]
|
393
398
|
puts
|
394
399
|
|
395
400
|
datastores = host.to_hash['HOST']['HOST_SHARE']['DATASTORES']['DS']
|
@@ -103,14 +103,22 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
|
103
103
|
:name => "disk_type",
|
104
104
|
:large => "--disk_type disk_type",
|
105
105
|
:description => "Type of the image \n"<<
|
106
|
-
" "*31<<"
|
107
|
-
" "*31<<"for vCenter: THIN, TICHK, ZEOREDTHICK " <<
|
106
|
+
" " * 31 << "BLOCK, CDROM, RBD or FILE \n" <<
|
108
107
|
"(for others, check the documentation) ",
|
109
108
|
:format => String
|
110
109
|
},
|
111
110
|
{
|
112
|
-
:name => "
|
113
|
-
:large => "--
|
111
|
+
:name => "vcenter_disk_type",
|
112
|
+
:large => "--vcenter_disk_type vcenter_disk_type",
|
113
|
+
:description => "The vCenter Disk Type of the image \n"<<
|
114
|
+
" " * 31 <<
|
115
|
+
"for vCenter: THIN, THICK, ZEROEDTHICK " <<
|
116
|
+
"(for others, check the documentation) ",
|
117
|
+
:format => String
|
118
|
+
},
|
119
|
+
{
|
120
|
+
:name => "vcenter_adapter_type",
|
121
|
+
:large => "--vcenter_adapter_type vcenter_adapter_type",
|
114
122
|
:description => "Controller that will handle this image in " <<
|
115
123
|
"vCenter (lsiLogic, ide, busLogic). For other "<<
|
116
124
|
"values check the documentation",
|
@@ -358,16 +366,16 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
|
358
366
|
end
|
359
367
|
|
360
368
|
def self.create_image_variables(options, name)
|
361
|
-
if Array===name
|
362
|
-
names=name
|
369
|
+
if Array === name
|
370
|
+
names = name
|
363
371
|
else
|
364
|
-
names=[name]
|
372
|
+
names = [name]
|
365
373
|
end
|
366
374
|
|
367
|
-
t=''
|
375
|
+
t = ''
|
368
376
|
names.each do |n|
|
369
377
|
if options[n]
|
370
|
-
t<<"#{n.to_s.upcase}=\"#{options[n]}\"\n"
|
378
|
+
t << "#{n.to_s.upcase}=\"#{options[n]}\"\n"
|
371
379
|
end
|
372
380
|
end
|
373
381
|
|
@@ -375,16 +383,21 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
|
375
383
|
end
|
376
384
|
|
377
385
|
def self.create_image_template(options)
|
378
|
-
template_options=TEMPLATE_OPTIONS.map do |o|
|
386
|
+
template_options = TEMPLATE_OPTIONS.map do |o|
|
379
387
|
o[:name].to_sym
|
380
388
|
end
|
381
389
|
|
382
|
-
template=create_image_variables(
|
383
|
-
|
390
|
+
template = create_image_variables(
|
391
|
+
options,
|
392
|
+
template_options - [:persistent, :dry, :prefix ]
|
393
|
+
)
|
394
|
+
|
395
|
+
if options[:persistent]
|
396
|
+
template << "PERSISTENT=YES\n"
|
397
|
+
end
|
384
398
|
|
385
|
-
template<<"PERSISTENT=YES\n" if options[:persistent]
|
386
399
|
if options[:prefix]
|
387
|
-
template<<"DEV_PREFIX=\"#{options[:prefix]}\"\n"
|
400
|
+
template << "DEV_PREFIX=\"#{options[:prefix]}\"\n"
|
388
401
|
end
|
389
402
|
|
390
403
|
[0, template]
|
@@ -153,6 +153,10 @@ class OneSecurityGroupHelper < OpenNebulaHelper::OneHelper
|
|
153
153
|
d["ICMP_TYPE"]
|
154
154
|
end
|
155
155
|
|
156
|
+
column :ICMVP6_TYPE, "", :left, :size=>11 do |d|
|
157
|
+
d["ICMPV6_TYPE"]
|
158
|
+
end
|
159
|
+
|
156
160
|
column :NETWORK, "", :left, :donottruncate, :size=>35 do |d|
|
157
161
|
network = ""
|
158
162
|
if(!d["NETWORK_ID"].nil? && d["NETWORK_ID"] != "")
|
@@ -169,7 +169,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
169
169
|
end
|
170
170
|
|
171
171
|
vm_nics.each do |nic|
|
172
|
-
["IP", "IP6_GLOBAL", "IP6_ULA",
|
172
|
+
["IP", "IP6_GLOBAL", "IP6_ULA", "IP6",
|
173
173
|
"VROUTER_IP", "VROUTER_IP6_GLOBAL", "VROUTER_IP6_ULA"].each do |attr|
|
174
174
|
if nic.has_key?(attr)
|
175
175
|
ips.push(nic[attr])
|
@@ -752,7 +752,7 @@ in the frontend machine.
|
|
752
752
|
|
753
753
|
next if nic.has_key?("CLI_DONE")
|
754
754
|
|
755
|
-
["IP6_LINK", "IP6_ULA", "IP6_GLOBAL"].each do |attr|
|
755
|
+
["IP6_LINK", "IP6_ULA", "IP6_GLOBAL", "IP6"].each do |attr|
|
756
756
|
if nic.has_key?(attr)
|
757
757
|
shown_ips << nic[attr]
|
758
758
|
|
@@ -1015,16 +1015,29 @@ in the frontend machine.
|
|
1015
1015
|
d["SEQ"]
|
1016
1016
|
end
|
1017
1017
|
|
1018
|
-
column :
|
1019
|
-
d
|
1018
|
+
column :UID, "UID of the user that performed the action",
|
1019
|
+
:left, :size=>4 do |d|
|
1020
|
+
if d["UID"] != "-1"
|
1021
|
+
d["UID"]
|
1022
|
+
else
|
1023
|
+
"-"
|
1024
|
+
end
|
1020
1025
|
end
|
1021
1026
|
|
1022
|
-
column :
|
1023
|
-
|
1027
|
+
column :REQ, "Request ID of the action", :left, :size=>5 do |d|
|
1028
|
+
if d["REQUEST_ID"] != "-1"
|
1029
|
+
d["REQUEST_ID"]
|
1030
|
+
else
|
1031
|
+
"-"
|
1032
|
+
end
|
1024
1033
|
end
|
1025
1034
|
|
1026
|
-
column :
|
1027
|
-
|
1035
|
+
column :HOST, "Host name of the VM container", :left, :size=>12 do |d|
|
1036
|
+
d["HOSTNAME"]
|
1037
|
+
end
|
1038
|
+
|
1039
|
+
column :"ACTION", "VM state change action", :left, :size=>10 do |d|
|
1040
|
+
VirtualMachine.get_history_action d["ACTION"]
|
1028
1041
|
end
|
1029
1042
|
|
1030
1043
|
column :DS, "System Datastore", :size=>4 do |d|
|
@@ -1053,7 +1066,7 @@ in the frontend machine.
|
|
1053
1066
|
OpenNebulaHelper.short_period_to_str(dtime)
|
1054
1067
|
end
|
1055
1068
|
|
1056
|
-
default :SEQ, :HOST, :ACTION, :DS, :START, :TIME, :PROLOG
|
1069
|
+
default :SEQ, :UID, :REQ, :HOST, :ACTION, :DS, :START, :TIME, :PROLOG
|
1057
1070
|
end
|
1058
1071
|
|
1059
1072
|
vm_hash=vm.to_hash
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
2
|
+
# Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
|
3
|
+
# #
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
|
+
# not use this file except in compliance with the License. You may obtain #
|
6
|
+
# a copy of the License at #
|
7
|
+
# #
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
+
# #
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
+
# See the License for the specific language governing permissions and #
|
14
|
+
# limitations under the License. #
|
15
|
+
#--------------------------------------------------------------------------- #
|
16
|
+
|
17
|
+
require 'one_helper'
|
18
|
+
|
19
|
+
class OneVMGroupHelper < OpenNebulaHelper::OneHelper
|
20
|
+
def self.rname
|
21
|
+
"VM_GROUP"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.conf_file
|
25
|
+
"onevmgroup.yaml"
|
26
|
+
end
|
27
|
+
|
28
|
+
def format_pool(options)
|
29
|
+
config_file = self.class.table_conf
|
30
|
+
|
31
|
+
table = CLIHelper::ShowTable.new(config_file, self) do
|
32
|
+
column :ID, "ONE identifier for the VM Group", :size=>4 do |d|
|
33
|
+
d["ID"]
|
34
|
+
end
|
35
|
+
|
36
|
+
column :NAME, "Name of the VM Group", :left, :size=>15 do |d|
|
37
|
+
d["NAME"]
|
38
|
+
end
|
39
|
+
|
40
|
+
column :USER, "Username of the VM Group owner", :left,
|
41
|
+
:size=>8 do |d|
|
42
|
+
helper.user_name(d, options)
|
43
|
+
end
|
44
|
+
|
45
|
+
column :GROUP, "Group of the VM Group", :left, :size=>8 do |d|
|
46
|
+
helper.group_name(d, options)
|
47
|
+
end
|
48
|
+
|
49
|
+
column :VMS, "Number of VMs in the VM Group", :left, :size=>4 do |d|
|
50
|
+
vms = 0
|
51
|
+
|
52
|
+
if !d["ROLES"]["ROLE"].nil?
|
53
|
+
roles = [d["ROLES"]["ROLE"]].flatten
|
54
|
+
roles.each { |r|
|
55
|
+
vms += r["VMS"].split(',').size if !r["VMS"].nil?
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
vms
|
60
|
+
end
|
61
|
+
|
62
|
+
column :ROLES, "Roles in the VM Group", :left, :size=>36 do |d|
|
63
|
+
roles = [d["ROLES"]["ROLE"]].flatten
|
64
|
+
roles_names = ""
|
65
|
+
|
66
|
+
if !roles.nil?
|
67
|
+
rnames = roles.collect { |i| i["NAME"] }
|
68
|
+
roles_names = rnames.join(", ") if !rnames.empty?
|
69
|
+
end
|
70
|
+
|
71
|
+
roles_names
|
72
|
+
end
|
73
|
+
|
74
|
+
default :ID, :USER, :GROUP, :NAME, :VMS, :ROLES
|
75
|
+
end
|
76
|
+
|
77
|
+
table
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def factory(id=nil)
|
83
|
+
if id
|
84
|
+
OpenNebula::VMGroup.new_with_id(id, @client)
|
85
|
+
else
|
86
|
+
xml=OpenNebula::VMGroup.build_xml
|
87
|
+
OpenNebula::VMGroup.new(xml, @client)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def factory_pool(user_flag=-2)
|
92
|
+
OpenNebula::VMGroupPool.new(@client, user_flag)
|
93
|
+
end
|
94
|
+
|
95
|
+
def format_resource(vmgroup, options = {})
|
96
|
+
str="%-15s: %-20s"
|
97
|
+
str_h1="%-80s"
|
98
|
+
|
99
|
+
CLIHelper.print_header(
|
100
|
+
str_h1 % "VM GROUP #{vmgroup['ID']} INFORMATION")
|
101
|
+
puts str % ["ID", vmgroup.id.to_s]
|
102
|
+
puts str % ["NAME", vmgroup.name]
|
103
|
+
puts str % ["USER", vmgroup['UNAME']]
|
104
|
+
puts str % ["GROUP", vmgroup['GNAME']]
|
105
|
+
|
106
|
+
CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
|
107
|
+
|
108
|
+
puts
|
109
|
+
|
110
|
+
["OWNER", "GROUP", "OTHER"].each { |e|
|
111
|
+
mask = "---"
|
112
|
+
mask[0] = "u" if vmgroup["PERMISSIONS/#{e}_U"] == "1"
|
113
|
+
mask[1] = "m" if vmgroup["PERMISSIONS/#{e}_M"] == "1"
|
114
|
+
mask[2] = "a" if vmgroup["PERMISSIONS/#{e}_A"] == "1"
|
115
|
+
|
116
|
+
puts str % [e, mask]
|
117
|
+
}
|
118
|
+
|
119
|
+
puts
|
120
|
+
|
121
|
+
CLIHelper.print_header(str_h1 % "ROLES", false)
|
122
|
+
|
123
|
+
if !vmgroup.to_hash['VM_GROUP']['ROLES']['ROLE'].nil?
|
124
|
+
roles = [vmgroup.to_hash['VM_GROUP']['ROLES']['ROLE']].flatten
|
125
|
+
end
|
126
|
+
|
127
|
+
CLIHelper::ShowTable.new(nil, self) do
|
128
|
+
column :ID, "", :left, :size=>4 do |d|
|
129
|
+
d["ID"]
|
130
|
+
end
|
131
|
+
|
132
|
+
column :NAME, "", :left, :size=>8 do |d|
|
133
|
+
d["NAME"]
|
134
|
+
end
|
135
|
+
|
136
|
+
column :POLICY, "", :left, :size=>12 do |d|
|
137
|
+
if d["POLICY"].nil?
|
138
|
+
'-'
|
139
|
+
else
|
140
|
+
d["POLICY"]
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
column :AFFINED_HOSTS, "", :left, :size=>18 do |d|
|
145
|
+
if d["HOST_AFFINED"].nil?
|
146
|
+
'-'
|
147
|
+
else
|
148
|
+
d["HOST_AFFINED"]
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
column :ANTI_AFFINED_HOST, "", :left, :size=>18 do |d|
|
153
|
+
if d["HOST_ANTI_AFFINED"].nil?
|
154
|
+
'-'
|
155
|
+
else
|
156
|
+
d["HOST_ANTI_AFFINED"]
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
column :VIRTUAL_MACHINES, "", :left, :size=>20 do |d|
|
161
|
+
d["VMS"]
|
162
|
+
end
|
163
|
+
end.show(roles, {})
|
164
|
+
|
165
|
+
puts
|
166
|
+
|
167
|
+
CLIHelper.print_header(str_h1 % "TEMPLATE CONTENTS",false)
|
168
|
+
puts vmgroup.template_str
|
169
|
+
end
|
170
|
+
end
|
@@ -48,6 +48,14 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
48
48
|
:description => "First IP address in . notation"
|
49
49
|
}
|
50
50
|
|
51
|
+
IP6 = {
|
52
|
+
:name => "ip6",
|
53
|
+
:short => "-6 ip6",
|
54
|
+
:large => "--ip6 ip6",
|
55
|
+
:format => String,
|
56
|
+
:description => "First IPv6 address, in CIDR notation e.g. 2001::1/48"
|
57
|
+
}
|
58
|
+
|
51
59
|
SIZE = {
|
52
60
|
:name => "size",
|
53
61
|
:short => "-s size",
|
@@ -117,7 +125,8 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
117
125
|
]
|
118
126
|
|
119
127
|
ADDAR_OPTIONS = [
|
120
|
-
SIZE, MAC, IP, IP6_GLOBAL, IP6_ULA, GATEWAY, NETMASK, VN_MAD,
|
128
|
+
SIZE, MAC, IP, IP6, IP6_GLOBAL, IP6_ULA, GATEWAY, NETMASK, VN_MAD,
|
129
|
+
VLAN_ID ]
|
121
130
|
|
122
131
|
def self.rname
|
123
132
|
"VNET"
|
@@ -274,6 +283,10 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
274
283
|
puts format % ["IP6_ULA", ar["IP6_ULA"], ar["IP6_ULA_END"]]
|
275
284
|
end
|
276
285
|
|
286
|
+
if !ar["IP6"].nil?
|
287
|
+
puts format % ["IP6", ar["IP6"], ar["IP6_END"]]
|
288
|
+
end
|
289
|
+
|
277
290
|
puts
|
278
291
|
end
|
279
292
|
|
@@ -325,8 +338,8 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
|
325
338
|
d["IP"]||"-"
|
326
339
|
end
|
327
340
|
|
328
|
-
column :
|
329
|
-
d["IP6_GLOBAL"]||"-"
|
341
|
+
column :IP6, "", :donottruncate, :size=>26 do |d|
|
342
|
+
d["IP6"]||d["IP6_GLOBAL"]||"-"
|
330
343
|
end
|
331
344
|
end.show(leases, {})
|
332
345
|
|
@@ -18,6 +18,22 @@ require 'one_helper'
|
|
18
18
|
|
19
19
|
class OneZoneHelper < OpenNebulaHelper::OneHelper
|
20
20
|
|
21
|
+
SERVER_NAME={
|
22
|
+
:name => "server_name",
|
23
|
+
:short => "-n server_name",
|
24
|
+
:large => "--name",
|
25
|
+
:format => String,
|
26
|
+
:description => "Zone server name"
|
27
|
+
}
|
28
|
+
|
29
|
+
SERVER_ENDPOINT={
|
30
|
+
:name => "server_rpc",
|
31
|
+
:short => "-r rpc endpoint",
|
32
|
+
:large => "--rpc",
|
33
|
+
:format => String,
|
34
|
+
:description => "Zone server RPC endpoint"
|
35
|
+
}
|
36
|
+
|
21
37
|
def self.rname
|
22
38
|
"ZONE"
|
23
39
|
end
|
@@ -98,6 +114,86 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
|
|
98
114
|
puts str % ["NAME", zone.name]
|
99
115
|
puts
|
100
116
|
|
117
|
+
zone_hash=zone.to_hash
|
118
|
+
|
119
|
+
if zone.has_elements?("/ZONE/SERVER_POOL/SERVER")
|
120
|
+
servers = zone_hash["ZONE"]["SERVER_POOL"]["SERVER"]
|
121
|
+
|
122
|
+
[servers].flatten.each { |s|
|
123
|
+
endpoint = s["ENDPOINT"]
|
124
|
+
|
125
|
+
next if endpoint.nil?
|
126
|
+
|
127
|
+
client = OpenNebula::Client.new(nil, endpoint)
|
128
|
+
|
129
|
+
xml_doc = client.call("zone.raftstatus")
|
130
|
+
|
131
|
+
if OpenNebula::is_error?(xml_doc)
|
132
|
+
s["STATE"] = "error"
|
133
|
+
s["TERM"] = "-"
|
134
|
+
s["VOTEDFOR"] = "-"
|
135
|
+
s["COMMIT" ] = "-"
|
136
|
+
s["LOG_INDEX"] = "-"
|
137
|
+
|
138
|
+
next
|
139
|
+
end
|
140
|
+
|
141
|
+
xml_doc = Nokogiri::XML(xml_doc)
|
142
|
+
|
143
|
+
s["STATE"] = case xml_doc.root.at_xpath("STATE").text
|
144
|
+
when "0" then "solo"
|
145
|
+
when "1" then "candidate"
|
146
|
+
when "2" then "follower"
|
147
|
+
when "3" then "leader"
|
148
|
+
else "-"
|
149
|
+
end
|
150
|
+
s["TERM"] = xml_doc.root.at_xpath("TERM").text
|
151
|
+
s["VOTEDFOR"] = xml_doc.root.at_xpath("VOTEDFOR").text
|
152
|
+
s["COMMIT"] = xml_doc.root.at_xpath("COMMIT").text
|
153
|
+
s["LOG_INDEX"] = xml_doc.root.at_xpath("LOG_INDEX").text
|
154
|
+
}
|
155
|
+
|
156
|
+
puts
|
157
|
+
CLIHelper.print_header(str_h1 % "SERVERS",false)
|
158
|
+
|
159
|
+
CLIHelper::ShowTable.new(nil, self) do
|
160
|
+
|
161
|
+
column :"ID", "", :size=>2 do |d|
|
162
|
+
d["ID"] if !d.nil?
|
163
|
+
end
|
164
|
+
|
165
|
+
column :"NAME", "", :left, :size=>15 do |d|
|
166
|
+
d["NAME"] if !d.nil?
|
167
|
+
end
|
168
|
+
|
169
|
+
column :"STATE", "", :left, :size=>10 do |d|
|
170
|
+
d["STATE"] if !d.nil?
|
171
|
+
end
|
172
|
+
|
173
|
+
column :"TERM", "", :left, :size=>10 do |d|
|
174
|
+
d["TERM"] if !d.nil?
|
175
|
+
end
|
176
|
+
|
177
|
+
column :"INDEX", "", :left, :size=>10 do |d|
|
178
|
+
d["LOG_INDEX"] if !d.nil?
|
179
|
+
end
|
180
|
+
|
181
|
+
column :"COMMIT", "", :left, :size=>10 do |d|
|
182
|
+
d["COMMIT"] if !d.nil?
|
183
|
+
end
|
184
|
+
|
185
|
+
column :"VOTE", "", :left, :size=>5 do |d|
|
186
|
+
d["VOTEDFOR"] if !d.nil?
|
187
|
+
end
|
188
|
+
|
189
|
+
column :"ENDPOINT", "", :left, :size=>18 do |d|
|
190
|
+
d["ENDPOINT"] if !d.nil?
|
191
|
+
end
|
192
|
+
end.show([zone_hash['ZONE']['SERVER_POOL']['SERVER']].flatten, {})
|
193
|
+
end
|
194
|
+
|
195
|
+
puts
|
196
|
+
|
101
197
|
CLIHelper.print_header(str_h1 % "ZONE TEMPLATE", false)
|
102
198
|
puts zone.template_str
|
103
199
|
end
|