opennebula-cli 7.2.0 → 7.2.1

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/bin/onevm +1 -1
  3. data/lib/command_parser.rb +134 -125
  4. data/lib/load_opennebula_paths.rb +5 -0
  5. data/lib/ods_helper.rb +541 -0
  6. data/lib/one_helper/oneacct_helper.rb +116 -108
  7. data/lib/one_helper/onedatastore_helper.rb +86 -79
  8. data/lib/one_helper/onemarket_helper.rb +58 -57
  9. data/lib/one_helper/onequota_helper.rb +239 -189
  10. data/lib/one_helper/onesecgroup_helper.rb +86 -84
  11. data/lib/one_helper/onetemplate_helper.rb +63 -63
  12. data/lib/one_helper/onevdc_helper.rb +44 -44
  13. data/lib/one_helper/onevm_helper.rb +5 -7
  14. data/lib/one_helper/onevmgroup_helper.rb +64 -62
  15. data/lib/one_helper/onevntemplate_helper.rb +42 -39
  16. data/lib/one_helper/onevrouter_helper.rb +85 -86
  17. data/lib/one_helper/onezone_helper.rb +97 -100
  18. data/lib/one_helper.rb +88 -69
  19. data/share/schemas/xsd/acct.xsd +3 -104
  20. data/share/schemas/xsd/cluster.xsd +4 -21
  21. data/share/schemas/xsd/datastore.xsd +4 -29
  22. data/share/schemas/xsd/document.xsd +3 -25
  23. data/share/schemas/xsd/group.xsd +2 -14
  24. data/share/schemas/xsd/group_pool.xsd +2 -14
  25. data/share/schemas/xsd/hook.xsd +2 -0
  26. data/share/schemas/xsd/host.xsd +5 -7
  27. data/share/schemas/xsd/image.xsd +2 -25
  28. data/share/schemas/xsd/marketplace.xsd +3 -22
  29. data/share/schemas/xsd/marketplaceapp.xsd +3 -25
  30. data/share/schemas/xsd/opennebula_configuration.xsd +1 -0
  31. data/share/schemas/xsd/requirements.xsd +3 -21
  32. data/share/schemas/xsd/security_group.xsd +6 -43
  33. data/share/schemas/xsd/shared.xsd +3 -3
  34. data/share/schemas/xsd/vdc.xsd +2 -7
  35. data/share/schemas/xsd/vm_group.xsd +3 -25
  36. data/share/schemas/xsd/vm_pool.xsd +2 -0
  37. data/share/schemas/xsd/vmtemplate.xsd +3 -25
  38. data/share/schemas/xsd/vnet.xsd +9 -67
  39. data/share/schemas/xsd/vnet_pool.xsd +8 -57
  40. data/share/schemas/xsd/vntemplate.xsd +3 -25
  41. data/share/schemas/xsd/vrouter.xsd +4 -32
  42. metadata +6 -4
@@ -18,58 +18,57 @@ require 'one_helper'
18
18
  require 'opennebula/virtual_router'
19
19
  require 'opennebula/virtual_router_pool'
20
20
 
21
+ # Helper class for VRouter commands
21
22
  class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper
22
23
 
23
24
  ALL_TEMPLATE = {
24
- :name => "all",
25
- :large => "--all",
26
- :description => "Show all template data"
25
+ :name => 'all',
26
+ :large => '--all',
27
+ :description => 'Show all template data'
27
28
  }
28
29
 
29
30
  FLOAT = {
30
- :name => "float",
31
- :large => "--float",
32
- :description => "Makes this IP request a Floating one"
31
+ :name => 'float',
32
+ :large => '--float',
33
+ :description => 'Makes this IP request a Floating one'
33
34
  }
34
35
 
35
36
  def self.rname
36
- "VROUTER"
37
+ 'VROUTER'
37
38
  end
38
39
 
39
40
  def self.conf_file
40
- "onevrouter.yaml"
41
+ 'onevrouter.yaml'
41
42
  end
42
43
 
43
44
  def format_pool(options)
44
45
  config_file = self.class.table_conf
45
46
 
46
- table = CLIHelper::ShowTable.new(config_file, self) do
47
- column :ID, "ONE identifier for the Virtual Router", :size=>4 do |d|
48
- d["ID"]
47
+ CLIHelper::ShowTable.new(config_file, self) do
48
+ column :ID, 'ONE identifier for the Virtual Router', :size=>4 do |d|
49
+ d['ID']
49
50
  end
50
51
 
51
- column :NAME, "Name of the Virtual Router", :left, :size=>27 do |d|
52
- d["NAME"]
52
+ column :NAME, 'Name of the Virtual Router', :left, :size=>27 do |d|
53
+ d['NAME']
53
54
  end
54
55
 
55
- column :USER, "Username of the Virtual Router owner", :left,
56
- :size=>15 do |d|
56
+ column :USER, 'Username of the Virtual Router owner', :left,
57
+ :size=>15 do |d|
57
58
  helper.user_name(d, options)
58
59
  end
59
60
 
60
- column :GROUP, "Group of the Virtual Router", :left, :size=>15 do |d|
61
+ column :GROUP, 'Group of the Virtual Router', :left, :size=>15 do |d|
61
62
  helper.group_name(d, options)
62
63
  end
63
64
 
64
65
  default :ID, :USER, :GROUP, :NAME
65
66
  end
66
-
67
- table
68
67
  end
69
68
 
70
69
  private
71
70
 
72
- def factory(id=nil)
71
+ def factory(id = nil)
73
72
  if id
74
73
  OpenNebula::VirtualRouter.new_with_id(id, @client)
75
74
  else
@@ -78,134 +77,134 @@ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper
78
77
  end
79
78
  end
80
79
 
81
- def factory_pool(user_flag=-2)
80
+ def factory_pool(user_flag = -2)
82
81
  OpenNebula::VirtualRouterPool.new(@client, user_flag)
83
82
  end
84
83
 
85
84
  def format_resource(obj, options = {})
86
- str="%-15s: %-20s"
87
- str_h1="%-80s"
85
+ str='%-15s: %-20s'
86
+ str_h1='%-80s'
88
87
 
89
88
  CLIHelper.print_header(
90
- str_h1 % "VIRTUAL ROUTER #{obj['ID']} INFORMATION")
91
- puts str % ["ID", obj.id.to_s]
92
- puts str % ["NAME", obj.name]
93
- puts str % ["USER", obj['UNAME']]
94
- puts str % ["GROUP", obj['GNAME']]
95
- puts str % ["LOCK", OpenNebulaHelper.level_lock_to_str(obj['LOCK/LOCKED'])]
89
+ str_h1 % "VIRTUAL ROUTER #{obj['ID']} INFORMATION"
90
+ )
91
+ puts format(str, 'ID', obj.id.to_s)
92
+ puts format(str, 'NAME', obj.name)
93
+ puts format(str, 'USER', obj['UNAME'])
94
+ puts format(str, 'GROUP', obj['GNAME'])
95
+ puts format(str, 'LOCK', OpenNebulaHelper.level_lock_to_str(obj['LOCK/LOCKED']))
96
96
  puts
97
97
 
98
- CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
98
+ CLIHelper.print_header(str_h1 % 'PERMISSIONS', false)
99
99
 
100
- ["OWNER", "GROUP", "OTHER"].each { |e|
101
- mask = "---"
102
- mask[0] = "u" if obj["PERMISSIONS/#{e}_U"] == "1"
103
- mask[1] = "m" if obj["PERMISSIONS/#{e}_M"] == "1"
104
- mask[2] = "a" if obj["PERMISSIONS/#{e}_A"] == "1"
100
+ ['OWNER', 'GROUP', 'OTHER'].each do |e|
101
+ mask = '---'
102
+ mask[0] = 'u' if obj["PERMISSIONS/#{e}_U"] == '1'
103
+ mask[1] = 'm' if obj["PERMISSIONS/#{e}_M"] == '1'
104
+ mask[2] = 'a' if obj["PERMISSIONS/#{e}_A"] == '1'
105
105
 
106
- puts str % [e, mask]
107
- }
106
+ puts format(str, e, mask)
107
+ end
108
108
 
109
- if obj.has_elements?("/VROUTER/TEMPLATE/NIC")
109
+ if obj.has_elements?('/VROUTER/TEMPLATE/NIC')
110
110
  puts
111
- CLIHelper.print_header(str_h1 % "VIRTUAL ROUTER NICS",false)
111
+ CLIHelper.print_header(str_h1 % 'VIRTUAL ROUTER NICS', false)
112
112
 
113
- nic_default = {"NETWORK" => "-",
114
- "IP" => "-"}
113
+ nic_default = { 'NETWORK' => '-',
114
+ 'IP' => '-' }
115
115
 
116
116
  array_id = 0
117
117
  vm_nics = [obj.to_hash['VROUTER']['TEMPLATE']['NIC']].flatten.compact
118
- vm_nics.each {|nic|
119
-
120
- next if nic.has_key?("CLI_DONE")
118
+ vm_nics.each do |nic|
119
+ next if nic.key?('CLI_DONE')
121
120
 
122
- floating = (nic.has_key?("FLOATING_IP") && nic["FLOATING_IP"].upcase() == "YES" )
121
+ floating = nic.key?('FLOATING_IP') && nic['FLOATING_IP'].upcase == 'YES'
123
122
 
124
123
  if floating
125
- if nic.has_key?("IP6_LINK")
126
- ip6_link = {"IP" => nic.delete("IP6_LINK"),
127
- "CLI_DONE" => true,
128
- "DOUBLE_ENTRY" => true}
129
- vm_nics.insert(array_id+1,ip6_link)
124
+ if nic.key?('IP6_LINK')
125
+ ip6_link = { 'IP' => nic.delete('IP6_LINK'),
126
+ 'CLI_DONE' => true,
127
+ 'DOUBLE_ENTRY' => true }
128
+ vm_nics.insert(array_id+1, ip6_link)
130
129
 
131
130
  array_id += 1
132
131
  end
133
132
 
134
- if nic.has_key?("IP6_ULA")
135
- ip6_link = {"IP" => nic.delete("IP6_ULA"),
136
- "CLI_DONE" => true,
137
- "DOUBLE_ENTRY" => true}
138
- vm_nics.insert(array_id+1,ip6_link)
133
+ if nic.key?('IP6_ULA')
134
+ ip6_link = { 'IP' => nic.delete('IP6_ULA'),
135
+ 'CLI_DONE' => true,
136
+ 'DOUBLE_ENTRY' => true }
137
+ vm_nics.insert(array_id+1, ip6_link)
139
138
 
140
139
  array_id += 1
141
140
  end
142
141
 
143
- if nic.has_key?("IP6_GLOBAL")
144
- ip6_link = {"IP" => nic.delete("IP6_GLOBAL"),
145
- "CLI_DONE" => true,
146
- "DOUBLE_ENTRY" => true}
147
- vm_nics.insert(array_id+1,ip6_link)
142
+ if nic.key?('IP6_GLOBAL')
143
+ ip6_link = { 'IP' => nic.delete('IP6_GLOBAL'),
144
+ 'CLI_DONE' => true,
145
+ 'DOUBLE_ENTRY' => true }
146
+ vm_nics.insert(array_id+1, ip6_link)
148
147
 
149
148
  array_id += 1
150
149
  end
151
150
  else
152
- nic.delete("IP")
151
+ nic.delete('IP')
153
152
  end
154
153
 
155
- nic.merge!(nic_default) {|k,v1,v2| v1}
154
+ nic.merge!(nic_default) {|_k, v1, _v2| v1 }
156
155
  array_id += 1
157
- }
156
+ end
158
157
 
159
158
  CLIHelper::ShowTable.new(nil, self) do
160
- column :ID, "", :size=>3 do |d|
161
- if d["DOUBLE_ENTRY"]
162
- ""
159
+ column :ID, '', :size=>3 do |d|
160
+ if d['DOUBLE_ENTRY']
161
+ ''
163
162
  else
164
- d["NIC_ID"]
163
+ d['NIC_ID']
165
164
  end
166
165
  end
167
166
 
168
- column :NETWORK, "", :left, :size=>20 do |d|
169
- if d["DOUBLE_ENTRY"]
170
- ""
167
+ column :NETWORK, '', :left, :size=>20 do |d|
168
+ if d['DOUBLE_ENTRY']
169
+ ''
171
170
  else
172
- d["NETWORK"]
171
+ d['NETWORK']
173
172
  end
174
173
  end
175
174
 
176
- column :MANAGEMENT, "", :left, :size=>10 do |d|
177
- if d["DOUBLE_ENTRY"]
178
- ""
175
+ column :MANAGEMENT, '', :left, :size=>10 do |d|
176
+ if d['DOUBLE_ENTRY']
177
+ ''
179
178
  else
180
- if !d["VROUTER_MANAGEMENT"].nil?
181
- d["VROUTER_MANAGEMENT"]
179
+ if !d['VROUTER_MANAGEMENT'].nil?
180
+ d['VROUTER_MANAGEMENT']
182
181
  else
183
- "NO"
182
+ 'NO'
184
183
  end
185
184
  end
186
185
  end
187
186
 
188
-
189
- column :IP, "",:left, :adjust, :size=>15 do |d|
190
- d["IP"]
187
+ column :IP, '', :left, :adjust, :size=>15 do |d|
188
+ d['IP']
191
189
  end
192
- end.show(vm_nics,{})
190
+ end.show(vm_nics, {})
193
191
  end
194
192
 
195
- while obj.has_elements?("/VROUTER/TEMPLATE/NIC")
196
- obj.delete_element("/VROUTER/TEMPLATE/NIC")
197
- end if !options[:all]
193
+ while obj.has_elements?('/VROUTER/TEMPLATE/NIC')
194
+ obj.delete_element('/VROUTER/TEMPLATE/NIC')
195
+ end unless options[:all]
198
196
 
199
197
  puts
200
198
 
201
- CLIHelper.print_header(str_h1 % "TEMPLATE CONTENTS",false)
199
+ CLIHelper.print_header(str_h1 % 'TEMPLATE CONTENTS', false)
202
200
  puts obj.template_str
203
201
 
204
202
  puts
205
203
 
206
- CLIHelper.print_header("%-15s" % "VIRTUAL MACHINES")
204
+ CLIHelper.print_header(format('%-15s', 'VIRTUAL MACHINES'))
207
205
  obj.vm_ids.each do |id|
208
- puts "%-15s" % [id]
206
+ puts format('%-15s', id)
209
207
  end
210
208
  end
209
+
211
210
  end
@@ -28,7 +28,7 @@ class Replicator
28
28
 
29
29
  SSH_OPTIONS = '-o stricthostkeychecking=no -o passwordauthentication=no'
30
30
  ONE_AUTH = '/var/lib/one/.one/one_auth'
31
- FED_ATTRS = %w[MODE ZONE_ID SERVER_ID MASTER_ONED]
31
+ FED_ATTRS = ['MODE', 'ZONE_ID', 'SERVER_ID', 'MASTER_ONED']
32
32
 
33
33
  FILES = [
34
34
  { :name => 'monitord.conf',
@@ -64,7 +64,7 @@ class Replicator
64
64
  @l_fed_elements = { :raw => @l_config }
65
65
 
66
66
  if OpenNebula.is_error?(@l_config)
67
- STDERR.puts 'Unable to read OpenNebula configuration. ' \
67
+ STDERR.puts 'Unable to read local OpenNebula configuration. ' \
68
68
  'Is OpenNebula running?'
69
69
  exit(-1)
70
70
  end
@@ -81,6 +81,12 @@ class Replicator
81
81
  @r_config_elements = { :raw => @r_config }
82
82
  @r_fed_elements = { :raw => @r_config }
83
83
 
84
+ if OpenNebula.is_error?(@r_config)
85
+ STDERR.puts 'Unable to read remote OpenNebula configuration. ' \
86
+ "Is OpenNebula running on #{@remote_server}?"
87
+ exit(-1)
88
+ end
89
+
84
90
  fetch_db_config(@r_config_elements)
85
91
  fetch_fed_config(@r_fed_elements)
86
92
 
@@ -185,14 +191,12 @@ class Replicator
185
191
  "/etc/one/#{folder}/"
186
192
  )
187
193
 
188
- unless rc
189
- rc = run_command(
190
- "rsync -ai\
194
+ rc ||= run_command(
195
+ "rsync -ai\
191
196
  -e \"ssh #{SSH_OPTIONS} -i #{@oneadmin_identity_file}\" " \
192
- "oneadmin@#{@remote_server}:/etc/one/#{folder}/ " \
193
- "/etc/one/#{folder}/"
194
- )
195
- end
197
+ "oneadmin@#{@remote_server}:/etc/one/#{folder}/ " \
198
+ "/etc/one/#{folder}/"
199
+ )
196
200
 
197
201
  unless rc
198
202
  STDERR.puts 'ERROR'
@@ -361,13 +365,11 @@ class Replicator
361
365
  )
362
366
 
363
367
  # if default users doesn't work, try with oneadmin
364
- unless rc
365
- rc = run_command(
366
- "ssh -i #{@oneadmin_identity_file} " \
367
- "#{SSH_OPTIONS} oneadmin@#{@remote_server} " \
368
- "#{cmd}"
369
- )
370
- end
368
+ rc ||= run_command(
369
+ "ssh -i #{@oneadmin_identity_file} " \
370
+ "#{SSH_OPTIONS} oneadmin@#{@remote_server} " \
371
+ "#{cmd}"
372
+ )
371
373
 
372
374
  # if oneadmin doesn't work neither, fail
373
375
  unless rc
@@ -390,12 +392,10 @@ class Replicator
390
392
  )
391
393
 
392
394
  # if default users doesn't work, try with oneadmin
393
- unless rc
394
- rc = run_command(
395
- "scp -i #{@oneadmin_identity_file} " \
396
- "#{SSH_OPTIONS} oneadmin@#{@remote_server}:#{src} #{dest}"
397
- )
398
- end
395
+ rc ||= run_command(
396
+ "scp -i #{@oneadmin_identity_file} " \
397
+ "#{SSH_OPTIONS} oneadmin@#{@remote_server}:#{src} #{dest}"
398
+ )
399
399
 
400
400
  # if oneadmin doesn't work neither, fail
401
401
  unless rc
@@ -438,30 +438,31 @@ class Replicator
438
438
 
439
439
  end
440
440
 
441
+ # Helper class for Zone commands
441
442
  class OneZoneHelper < OpenNebulaHelper::OneHelper
442
443
 
443
444
  SERVER_NAME={
444
- :name => "server_name",
445
- :short => "-n server_name",
446
- :large => "--name",
445
+ :name => 'server_name',
446
+ :short => '-n server_name',
447
+ :large => '--name',
447
448
  :format => String,
448
- :description => "Zone server name"
449
+ :description => 'Zone server name'
449
450
  }
450
451
 
451
452
  SERVER_ENDPOINT={
452
- :name => "server_rpc",
453
- :short => "-r xml-rpc endpoint",
454
- :large => "--rpc",
453
+ :name => 'server_rpc',
454
+ :short => '-r xml-rpc endpoint',
455
+ :large => '--rpc',
455
456
  :format => String,
456
- :description => "Zone server XML-RPC endpoint"
457
+ :description => 'Zone server XML-RPC endpoint'
457
458
  }
458
459
 
459
460
  SERVER_ENDPOINT_GRPC={
460
- :name => "server_grpc",
461
- :short => "-g gRPC endpoint",
462
- :large => "--grpc-endpoint",
461
+ :name => 'server_grpc',
462
+ :short => '-g gRPC endpoint',
463
+ :large => '--grpc-endpoint',
463
464
  :format => String,
464
- :description => "Zone server gRPC endpoint"
465
+ :description => 'Zone server gRPC endpoint'
465
466
  }
466
467
 
467
468
  def show_resource(id, options)
@@ -490,11 +491,11 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
490
491
  end
491
492
 
492
493
  def self.rname
493
- "ZONE"
494
+ 'ZONE'
494
495
  end
495
496
 
496
497
  def self.conf_file
497
- "onezone.yaml"
498
+ 'onezone.yaml'
498
499
  end
499
500
 
500
501
  def self.state_to_str(id)
@@ -520,29 +521,29 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
520
521
  [0, ids[0].to_i]
521
522
  end
522
523
 
523
- def format_pool(options)
524
+ def format_pool(_options)
524
525
  config_file = self.class.table_conf
525
526
 
526
- table = CLIHelper::ShowTable.new(config_file, self) do
527
- column :CURRENT, "Active Zone", :size=>1 do |d|
528
- "*" if helper.client.one_endpoint.strip ==
529
- d["TEMPLATE"]['ENDPOINT'].strip
527
+ CLIHelper::ShowTable.new(config_file, self) do
528
+ column :CURRENT, 'Active Zone', :size=>1 do |d|
529
+ '*' if helper.client.one_endpoint.strip ==
530
+ d['TEMPLATE']['ENDPOINT'].strip
530
531
  end
531
532
 
532
- column :ID, "ONE identifier for the Zone", :size=>5 do |d|
533
- d["ID"]
533
+ column :ID, 'ONE identifier for the Zone', :size=>5 do |d|
534
+ d['ID']
534
535
  end
535
536
 
536
- column :NAME, "Name of the Zone", :left, :size=>25 do |d|
537
- d["NAME"]
537
+ column :NAME, 'Name of the Zone', :left, :size=>25 do |d|
538
+ d['NAME']
538
539
  end
539
540
 
540
- column :ENDPOINT, "Endpoint of the Zone", :left, :size=>45 do |d|
541
- d["TEMPLATE"]['ENDPOINT']
541
+ column :ENDPOINT, 'Endpoint of the Zone', :left, :size=>45 do |d|
542
+ d['TEMPLATE']['ENDPOINT']
542
543
  end
543
544
 
544
- column :FED_INDEX, "Federation index", :left, :size=>10 do |d|
545
- helper.get_fed_index(d["TEMPLATE"]['ENDPOINT'])
545
+ column :FED_INDEX, 'Federation index', :left, :size=>10 do |d|
546
+ helper.get_fed_index(d['TEMPLATE']['ENDPOINT'])
546
547
  end
547
548
 
548
549
  column :STAT, 'Zone status', :left, :size => 6 do |d|
@@ -551,8 +552,6 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
551
552
 
552
553
  default :CURRENT, :ID, :NAME, :ENDPOINT, :FED_INDEX, :STAT
553
554
  end
554
-
555
- table
556
555
  end
557
556
 
558
557
  def get_fed_index(endpoint)
@@ -585,11 +584,11 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
585
584
  if temporary_zone
586
585
  puts "Type: export ONE_XMLRPC=#{zone['TEMPLATE/ENDPOINT']}"
587
586
  else
588
- File.open(ENV['HOME']+"/.one/one_endpoint", 'w'){|f|
587
+ File.open(Dir.home+'/.one/one_endpoint', 'w') do |f|
589
588
  f.puts zone['TEMPLATE/ENDPOINT']
590
- }
589
+ end
591
590
  puts "Endpoint changed to \"#{zone['TEMPLATE/ENDPOINT']}\" in " <<
592
- "#{ENV['HOME']}/.one/one_endpoint"
591
+ "#{Dir.home}/.one/one_endpoint"
593
592
  end
594
593
 
595
594
  return 0 unless zone['TEMPLATE/ONEFLOW_ENDPOINT']
@@ -598,13 +597,13 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
598
597
  if temporary_zone
599
598
  puts "Type: export ONEFLOW_URL=#{zone['TEMPLATE/ONEFLOW_ENDPOINT']}"
600
599
  else
601
- File.open(ENV['HOME'] + '/.one/oneflow_endpoint', 'w') do |f|
600
+ File.open(Dir.home + '/.one/oneflow_endpoint', 'w') do |f|
602
601
  f.puts zone['TEMPLATE/ONEFLOW_ENDPOINT']
603
602
  end
604
603
 
605
604
  puts 'OneFlow Endpoint changed to ' \
606
605
  "\"#{zone['TEMPLATE/ONEFLOW_ENDPOINT']}\" in " <<
607
- "#{ENV['HOME']}/.one/oneflow_endpoint"
606
+ "#{Dir.home}/.one/oneflow_endpoint"
608
607
  end
609
608
 
610
609
  0
@@ -612,7 +611,7 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
612
611
 
613
612
  private
614
613
 
615
- def factory(id=nil)
614
+ def factory(id = nil)
616
615
  if id
617
616
  OpenNebula::Zone.new_with_id(id, @client)
618
617
  else
@@ -621,92 +620,90 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
621
620
  end
622
621
  end
623
622
 
624
- def factory_pool(user_flag=-2)
623
+ def factory_pool(_user_flag = -2)
625
624
  OpenNebula::ZonePool.new(@client)
626
625
  end
627
626
 
628
- def format_resource(zone, options = {})
629
- str="%-18s: %-20s"
630
- str_h1="%-80s"
627
+ def format_resource(zone, _options = {})
628
+ str='%-18s: %-20s'
629
+ str_h1='%-80s'
631
630
 
632
631
  CLIHelper.print_header(str_h1 % "ZONE #{zone['ID']} INFORMATION")
633
- puts str % ["ID", zone.id.to_s]
634
- puts str % ["NAME", zone.name]
635
- puts str % ["STATE",zone.state_str]
632
+ puts format(str, 'ID', zone.id.to_s)
633
+ puts format(str, 'NAME', zone.name)
634
+ puts format(str, 'STATE', zone.state_str)
636
635
  puts
637
636
 
638
637
  zone_hash=zone.to_hash
639
638
 
640
- if zone.has_elements?("/ZONE/SERVER_POOL/SERVER")
639
+ if zone.has_elements?('/ZONE/SERVER_POOL/SERVER')
641
640
 
642
641
  puts
643
- CLIHelper.print_header(str_h1 % "ZONE SERVERS",false)
642
+ CLIHelper.print_header(str_h1 % 'ZONE SERVERS', false)
644
643
 
645
644
  CLIHelper::ShowTable.new(nil, self) do
646
-
647
- column :"ID", "", :size=>2 do |d|
648
- d["ID"] if !d.nil?
645
+ column :ID, '', :size=>2 do |d|
646
+ d['ID'] unless d.nil?
649
647
  end
650
648
 
651
- column :"NAME", "", :left, :size=>15 do |d|
652
- d["NAME"] if !d.nil?
649
+ column :NAME, '', :left, :size=>15 do |d|
650
+ d['NAME'] unless d.nil?
653
651
  end
654
652
 
655
- column :"ENDPOINT", "", :left, :size=>63 do |d|
656
- d["ENDPOINT"] if !d.nil?
653
+ column :ENDPOINT, '', :left, :size=>63 do |d|
654
+ d['ENDPOINT'] unless d.nil?
657
655
  end
658
656
  end.show([zone_hash['ZONE']['SERVER_POOL']['SERVER']].flatten, {})
659
657
 
660
658
  puts
661
- CLIHelper.print_header(str_h1 % "HA & FEDERATION SYNC STATUS",false)
659
+ CLIHelper.print_header(str_h1 % 'HA & FEDERATION SYNC STATUS', false)
662
660
 
663
661
  CLIHelper::ShowTable.new(nil, self) do
664
-
665
- column :"ID", "", :size=>2 do |d|
666
- d["ID"] if !d.nil?
662
+ column :ID, '', :size=>2 do |d|
663
+ d['ID'] unless d.nil?
667
664
  end
668
665
 
669
- column :"NAME", "", :left, :size=>15 do |d|
670
- d["NAME"] if !d.nil?
666
+ column :NAME, '', :left, :size=>15 do |d|
667
+ d['NAME'] unless d.nil?
671
668
  end
672
669
 
673
- column :"STATE", "", :left, :size=>10 do |d|
674
- d["STATE"] = case d["STATE"]
675
- when "0" then "solo"
676
- when "1" then "candidate"
677
- when "2" then "follower"
678
- when "3" then "leader"
679
- else "error"
680
- end
681
- d["STATE"] if !d.nil?
670
+ column :STATE, '', :left, :size=>10 do |d|
671
+ d['STATE'] = case d['STATE']
672
+ when '0' then 'solo'
673
+ when '1' then 'candidate'
674
+ when '2' then 'follower'
675
+ when '3' then 'leader'
676
+ else 'error'
677
+ end
678
+ d['STATE'] unless d.nil?
682
679
  end
683
680
 
684
- column :"TERM", "", :left, :size=>10 do |d|
685
- d["TERM"] if !d.nil?
681
+ column :TERM, '', :left, :size=>10 do |d|
682
+ d['TERM'] unless d.nil?
686
683
  end
687
684
 
688
- column :"INDEX", "", :left, :size=>10 do |d|
689
- d["LOG_INDEX"] if !d.nil?
685
+ column :INDEX, '', :left, :size=>10 do |d|
686
+ d['LOG_INDEX'] unless d.nil?
690
687
  end
691
688
 
692
- column :"COMMIT", "", :left, :size=>10 do |d|
693
- d["COMMIT"] if !d.nil?
689
+ column :COMMIT, '', :left, :size=>10 do |d|
690
+ d['COMMIT'] unless d.nil?
694
691
  end
695
692
 
696
- column :"VOTE", "", :left, :size=>5 do |d|
697
- d["VOTEDFOR"] if !d.nil?
693
+ column :VOTE, '', :left, :size=>5 do |d|
694
+ d['VOTEDFOR'] unless d.nil?
698
695
  end
699
696
 
700
- column :"FED_INDEX", "", :left, :size=>10 do |d|
701
- d["FEDLOG_INDEX"] if !d.nil?
697
+ column :FED_INDEX, '', :left, :size=>10 do |d|
698
+ d['FEDLOG_INDEX'] unless d.nil?
702
699
  end
703
-
704
700
  end.show([zone_hash['ZONE']['SERVER_POOL']['SERVER']].flatten, {})
705
701
  end
706
702
 
707
703
  puts
708
704
 
709
- CLIHelper.print_header(str_h1 % "ZONE TEMPLATE", false)
705
+ CLIHelper.print_header(str_h1 % 'ZONE TEMPLATE', false)
710
706
  puts zone.template_str
711
707
  end
708
+
712
709
  end