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,78 +18,78 @@ require 'one_helper'
18
18
  require 'opennebula/security_group'
19
19
  require 'opennebula/security_group_pool'
20
20
 
21
+ # Helper class for Security Group commands
21
22
  class OneSecurityGroupHelper < OpenNebulaHelper::OneHelper
23
+
22
24
  RECOVER = {
23
- :name => "recover",
24
- :short => "-r",
25
- :large => "--recover" ,
26
- :description => "If set the commit operation will only operate on "\
27
- "outdated and error VMs. This is intended for retrying updates of "\
28
- "VMs or reinitialize the updating process if oned stopped or fail.",
25
+ :name => 'recover',
26
+ :short => '-r',
27
+ :large => '--recover',
28
+ :description => 'If set the commit operation will only operate on '\
29
+ 'outdated and error VMs. This is intended for retrying updates of '\
30
+ 'VMs or reinitialize the updating process if oned stopped or fail.'
29
31
  }
30
32
 
31
33
  def self.rname
32
- "SECURITY_GROUP"
34
+ 'SECURITY_GROUP'
33
35
  end
34
36
 
35
37
  def self.conf_file
36
- "onesecgroup.yaml"
38
+ 'onesecgroup.yaml'
37
39
  end
38
40
 
39
41
  def format_pool(options)
40
42
  config_file = self.class.table_conf
41
43
 
42
- table = CLIHelper::ShowTable.new(config_file, self) do
43
- column :ID, "ONE identifier for the Security Group", :size=>4 do |d|
44
- d["ID"]
44
+ CLIHelper::ShowTable.new(config_file, self) do
45
+ column :ID, 'ONE identifier for the Security Group', :size=>4 do |d|
46
+ d['ID']
45
47
  end
46
48
 
47
- column :NAME, "Name of the Security Group", :left, :size=>20 do |d|
48
- d["NAME"]
49
+ column :NAME, 'Name of the Security Group', :left, :size=>20 do |d|
50
+ d['NAME']
49
51
  end
50
52
 
51
- column :USER, "Username of the Security Group owner", :left,
52
- :size=>15 do |d|
53
+ column :USER, 'Username of the Security Group owner', :left,
54
+ :size=>15 do |d|
53
55
  helper.user_name(d, options)
54
56
  end
55
57
 
56
- column :GROUP, "Group of the Security Group", :left, :size=>15 do |d|
58
+ column :GROUP, 'Group of the Security Group', :left, :size=>15 do |d|
57
59
  helper.group_name(d, options)
58
60
  end
59
61
 
60
- column :UPDATED, "Number of VMs with updated rules", :size=>8 do |d|
61
- if d["UPDATED_VMS"]["ID"].nil?
62
- "0"
62
+ column :UPDATED, 'Number of VMs with updated rules', :size=>8 do |d|
63
+ if d['UPDATED_VMS']['ID'].nil?
64
+ '0'
63
65
  else
64
- [d["UPDATED_VMS"]["ID"]].flatten.size
66
+ [d['UPDATED_VMS']['ID']].flatten.size
65
67
  end
66
68
  end
67
69
 
68
- column :OUTDATED, "Number of VMs with outdated rules", :size=>8 do |d|
69
- if d["OUTDATED_VMS"]["ID"].nil?
70
- "0"
70
+ column :OUTDATED, 'Number of VMs with outdated rules', :size=>8 do |d|
71
+ if d['OUTDATED_VMS']['ID'].nil?
72
+ '0'
71
73
  else
72
- [d["OUTDATED_VMS"]["ID"]].flatten.size
74
+ [d['OUTDATED_VMS']['ID']].flatten.size
73
75
  end
74
76
  end
75
77
 
76
- column :ERROR, "Number of VMs that failed to update rules", :size=>8 do |d|
77
- if d["ERROR_VMS"]["ID"].nil?
78
- "0"
78
+ column :ERROR, 'Number of VMs that failed to update rules', :size=>8 do |d|
79
+ if d['ERROR_VMS']['ID'].nil?
80
+ '0'
79
81
  else
80
- [d["ERROR_VMS"]["ID"]].flatten.size
82
+ [d['ERROR_VMS']['ID']].flatten.size
81
83
  end
82
84
  end
83
85
 
84
86
  default :ID, :USER, :GROUP, :NAME, :UPDATED, :OUTDATED, :ERROR
85
87
  end
86
-
87
- table
88
88
  end
89
89
 
90
90
  private
91
91
 
92
- def factory(id=nil)
92
+ def factory(id = nil)
93
93
  if id
94
94
  OpenNebula::SecurityGroup.new_with_id(id, @client)
95
95
  else
@@ -98,107 +98,109 @@ class OneSecurityGroupHelper < OpenNebulaHelper::OneHelper
98
98
  end
99
99
  end
100
100
 
101
- def factory_pool(user_flag=-2)
101
+ def factory_pool(user_flag = -2)
102
102
  OpenNebula::SecurityGroupPool.new(@client, user_flag)
103
103
  end
104
104
 
105
- def format_resource(secgroup, options = {})
106
- str="%-15s: %-20s"
107
- str_h1="%-80s"
105
+ def format_resource(secgroup, _options = {})
106
+ str='%-15s: %-20s'
107
+ str_h1='%-80s'
108
108
 
109
109
  CLIHelper.print_header(
110
- str_h1 % "SECURITY GROUP #{secgroup['ID']} INFORMATION")
111
- puts str % ["ID", secgroup.id.to_s]
112
- puts str % ["NAME", secgroup.name]
113
- puts str % ["USER", secgroup['UNAME']]
114
- puts str % ["GROUP", secgroup['GNAME']]
115
-
116
- CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
117
-
118
- ["OWNER", "GROUP", "OTHER"].each { |e|
119
- mask = "---"
120
- mask[0] = "u" if secgroup["PERMISSIONS/#{e}_U"] == "1"
121
- mask[1] = "m" if secgroup["PERMISSIONS/#{e}_M"] == "1"
122
- mask[2] = "a" if secgroup["PERMISSIONS/#{e}_A"] == "1"
123
-
124
- puts str % [e, mask]
125
- }
110
+ str_h1 % "SECURITY GROUP #{secgroup['ID']} INFORMATION"
111
+ )
112
+ puts format(str, 'ID', secgroup.id.to_s)
113
+ puts format(str, 'NAME', secgroup.name)
114
+ puts format(str, 'USER', secgroup['UNAME'])
115
+ puts format(str, 'GROUP', secgroup['GNAME'])
116
+
117
+ CLIHelper.print_header(str_h1 % 'PERMISSIONS', false)
118
+
119
+ ['OWNER', 'GROUP', 'OTHER'].each do |e|
120
+ mask = '---'
121
+ mask[0] = 'u' if secgroup["PERMISSIONS/#{e}_U"] == '1'
122
+ mask[1] = 'm' if secgroup["PERMISSIONS/#{e}_M"] == '1'
123
+ mask[2] = 'a' if secgroup["PERMISSIONS/#{e}_A"] == '1'
124
+
125
+ puts format(str, e, mask)
126
+ end
126
127
 
127
128
  puts
128
129
 
129
- CLIHelper.print_header(str_h1 % "VIRTUAL MACHINES", false)
130
+ CLIHelper.print_header(str_h1 % 'VIRTUAL MACHINES', false)
130
131
 
131
132
  updated, outdated, error = secgroup.vm_ids
132
133
 
133
- puts str % ["UPDATED", updated.join(',') ]
134
- puts str % ["OUTDATED", outdated.join(',') ]
135
- puts str % ["ERROR", error.join(',') ]
134
+ puts format(str, 'UPDATED', updated.join(','))
135
+ puts format(str, 'OUTDATED', outdated.join(','))
136
+ puts format(str, 'ERROR', error.join(','))
136
137
 
137
138
  puts
138
139
 
139
- CLIHelper.print_header(str_h1 % ["RULES"], false)
140
+ CLIHelper.print_header(format(str_h1, 'RULES'), false)
140
141
 
141
142
  if !secgroup.to_hash['SECURITY_GROUP']['TEMPLATE']['RULE'].nil?
142
143
  rule_list = [secgroup.to_hash['SECURITY_GROUP']['TEMPLATE']['RULE']].flatten
143
144
  end
144
145
 
145
146
  CLIHelper::ShowTable.new(nil, self) do
146
- column :TYPE, "", :left, :size=>8 do |d|
147
- d["RULE_TYPE"]
147
+ column :TYPE, '', :left, :size=>8 do |d|
148
+ d['RULE_TYPE']
148
149
  end
149
150
 
150
- column :PROTOCOL, "", :left, :size=>8 do |d|
151
- d["PROTOCOL"]
151
+ column :PROTOCOL, '', :left, :size=>8 do |d|
152
+ d['PROTOCOL']
152
153
  end
153
154
 
154
- column :ICMP_TYPE, "", :left, :size=>9 do |d|
155
- d["ICMP_TYPE"]
155
+ column :ICMP_TYPE, '', :left, :size=>9 do |d|
156
+ d['ICMP_TYPE']
156
157
  end
157
158
 
158
- column :ICMVP6_TYPE, "", :left, :size=>11 do |d|
159
- d["ICMPV6_TYPE"]
159
+ column :ICMVP6_TYPE, '', :left, :size=>11 do |d|
160
+ d['ICMPV6_TYPE']
160
161
  end
161
162
 
162
- column :NETWORK, "", :left, :adjust, :size=>35 do |d|
163
- network = ""
164
- if(!d["NETWORK_ID"].nil? && d["NETWORK_ID"] != "")
165
- network += "VNet " + d["NETWORK_ID"]
163
+ column :NETWORK, '', :left, :adjust, :size=>35 do |d|
164
+ network = ''
165
+ if(!d['NETWORK_ID'].nil? && d['NETWORK_ID'] != '')
166
+ network += 'VNet ' + d['NETWORK_ID']
166
167
  end
167
168
 
168
- if(!d["SIZE"].nil? && d["SIZE"] != "")
169
- if(network != "")
170
- network += ": "
169
+ if(!d['SIZE'].nil? && d['SIZE'] != '')
170
+ if(network != '')
171
+ network += ': '
171
172
  end
172
173
 
173
- if(!d["IP"].nil? && d["IP"] != "")
174
- network += "Start: " + d["IP"] + ", "
175
- elsif(!d["MAC"] != undefined && d["MAC"] != "")
176
- network += "Start: " + d["MAC"] + ", "
174
+ if(!d['IP'].nil? && d['IP'] != '')
175
+ network += 'Start: ' + d['IP'] + ', '
176
+ elsif(!d['MAC'] != undefined && d['MAC'] != '')
177
+ network += 'Start: ' + d['MAC'] + ', '
177
178
  end
178
179
 
179
- network += "Size: " + d["SIZE"]
180
+ network += 'Size: ' + d['SIZE']
180
181
  end
181
182
 
182
- if(network == "")
183
- network = "Any"
183
+ if(network == '')
184
+ network = 'Any'
184
185
  end
185
186
 
186
- network += " "
187
+ network += ' '
187
188
  network
188
189
  end
189
190
 
190
- column :RANGE, "", :left, :adjust, :size=>16 do |d|
191
- d["RANGE"]
191
+ column :RANGE, '', :left, :adjust, :size=>16 do |d|
192
+ d['RANGE']
192
193
  end
193
194
  end.show(rule_list, {})
194
195
 
195
- while secgroup.has_elements?("/SECURITY_GROUP/TEMPLATE/RULE")
196
- secgroup.delete_element("/SECURITY_GROUP/TEMPLATE/RULE")
196
+ while secgroup.has_elements?('/SECURITY_GROUP/TEMPLATE/RULE')
197
+ secgroup.delete_element('/SECURITY_GROUP/TEMPLATE/RULE')
197
198
  end
198
199
 
199
200
  puts
200
201
 
201
- CLIHelper.print_header(str_h1 % "TEMPLATE CONTENTS",false)
202
+ CLIHelper.print_header(str_h1 % 'TEMPLATE CONTENTS', false)
202
203
  puts secgroup.template_str
203
204
  end
205
+
204
206
  end
@@ -18,57 +18,58 @@ require 'one_helper'
18
18
  require 'opennebula/template'
19
19
  require 'opennebula/template_pool'
20
20
 
21
+ # Helper class for Template commands
21
22
  class OneTemplateHelper < OpenNebulaHelper::OneHelper
23
+
22
24
  VM_NAME={
23
- :name => "name",
24
- :large => "--name name",
25
+ :name => 'name',
26
+ :large => '--name name',
25
27
  :format => String,
26
- :description => <<-EOT.strip
27
- Name of the new VM or TEMPLATE. When instantiating
28
- multiple VMs you can use the \"%i\" wildcard to produce
29
- different names such as vm-0, vm-1...
30
- EOT
28
+ :description => <<~EOT.strip
29
+ Name of the new VM or TEMPLATE. When instantiating
30
+ multiple VMs you can use the \"%i\" wildcard to produce
31
+ different names such as vm-0, vm-1...
32
+ EOT
31
33
  }
32
34
 
33
35
  MULTIPLE={
34
- :name => "multiple",
35
- :short => "-m x",
36
- :large => "--multiple x",
36
+ :name => 'multiple',
37
+ :short => '-m x',
38
+ :large => '--multiple x',
37
39
  :format => Integer,
38
- :description => "Instance multiple VMs"
40
+ :description => 'Instance multiple VMs'
39
41
  }
40
42
 
41
43
  EXTENDED={
42
- :name => "extended",
43
- :large => "--extended",
44
- :description => "Process the template and included extended "+
45
- "information, such as the SIZE for each DISK"
44
+ :name => 'extended',
45
+ :large => '--extended',
46
+ :description => 'Process the template and included extended '+
47
+ 'information, such as the SIZE for each DISK'
46
48
  }
47
49
 
48
50
  RECURSIVE={
49
- :name => "recursive",
50
- :short => "-R",
51
- :large => "--recursive",
52
- :description => "Applies the action to the template plus any "+
53
- "image defined in DISK"
51
+ :name => 'recursive',
52
+ :short => '-R',
53
+ :large => '--recursive',
54
+ :description => 'Applies the action to the template plus any '+
55
+ 'image defined in DISK'
54
56
  }
55
57
 
56
58
  PERSISTENT={
57
- :name => "persistent",
58
- :large => "--persistent",
59
- :description => "Creates a private persistent copy of the template "+
60
- "plus any image defined in DISK, and instantiates that copy"
59
+ :name => 'persistent',
60
+ :large => '--persistent',
61
+ :description => 'Creates a private persistent copy of the template '+
62
+ 'plus any image defined in DISK, and instantiates that copy'
61
63
  }
62
64
 
63
65
  def self.rname
64
- "VMTEMPLATE"
66
+ 'VMTEMPLATE'
65
67
  end
66
68
 
67
69
  def self.conf_file
68
- "onetemplate.yaml"
70
+ 'onetemplate.yaml'
69
71
  end
70
72
 
71
-
72
73
  def show_resource(id, options)
73
74
  resource = retrieve_resource(id)
74
75
 
@@ -102,33 +103,31 @@ EOT
102
103
  def format_pool(options)
103
104
  config_file = self.class.table_conf
104
105
 
105
- table = CLIHelper::ShowTable.new(config_file, self) do
106
- column :ID, "ONE identifier for the Template", :size=>4 do |d|
107
- d["ID"]
106
+ CLIHelper::ShowTable.new(config_file, self) do
107
+ column :ID, 'ONE identifier for the Template', :size=>4 do |d|
108
+ d['ID']
108
109
  end
109
110
 
110
- column :NAME, "Name of the Template", :left, :size=>27 do |d|
111
- d["NAME"]
111
+ column :NAME, 'Name of the Template', :left, :size=>27 do |d|
112
+ d['NAME']
112
113
  end
113
114
 
114
- column :USER, "Username of the Template owner", :left,
115
- :size=>15 do |d|
115
+ column :USER, 'Username of the Template owner', :left,
116
+ :size=>15 do |d|
116
117
  helper.user_name(d, options)
117
118
  end
118
119
 
119
- column :GROUP, "Group of the Template", :left, :size=>15 do |d|
120
+ column :GROUP, 'Group of the Template', :left, :size=>15 do |d|
120
121
  helper.group_name(d, options)
121
122
  end
122
123
 
123
- column :REGTIME, "Registration time of the Template",
124
- :size=>15 do |d|
125
- OpenNebulaHelper.time_to_str(d["REGTIME"])
124
+ column :REGTIME, 'Registration time of the Template',
125
+ :size=>15 do |d|
126
+ OpenNebulaHelper.time_to_str(d['REGTIME'])
126
127
  end
127
128
 
128
129
  default :ID, :USER, :GROUP, :NAME, :REGTIME
129
130
  end
130
-
131
- table
132
131
  end
133
132
 
134
133
  INT_EXP = /^-?\d+$/
@@ -153,7 +152,7 @@ EOT
153
152
  # template. Useful for cpu, mem, vcpu
154
153
  if key != template['VMTEMPLATE']['TEMPLATE'][key]
155
154
  answers_s << "#{key} = \""
156
- answers_s << val.gsub('"', "\\\"") << "\"\n"
155
+ answers_s << val.gsub('"', '\"') << "\"\n"
157
156
  end
158
157
  end
159
158
 
@@ -162,7 +161,7 @@ EOT
162
161
 
163
162
  private
164
163
 
165
- def factory(id=nil)
164
+ def factory(id = nil)
166
165
  if id
167
166
  OpenNebula::Template.new_with_id(id, @client)
168
167
  else
@@ -171,38 +170,39 @@ EOT
171
170
  end
172
171
  end
173
172
 
174
- def factory_pool(user_flag=-2)
173
+ def factory_pool(user_flag = -2)
175
174
  OpenNebula::TemplatePool.new(@client, user_flag)
176
175
  end
177
176
 
178
- def format_resource(template, options = {})
179
- str="%-15s: %-20s"
180
- str_h1="%-80s"
177
+ def format_resource(template, _options = {})
178
+ str='%-15s: %-20s'
179
+ str_h1='%-80s'
181
180
 
182
181
  CLIHelper.print_header(
183
- str_h1 % "TEMPLATE #{template['ID']} INFORMATION")
184
- puts str % ["ID", template.id.to_s]
185
- puts str % ["NAME", template.name]
186
- puts str % ["USER", template['UNAME']]
187
- puts str % ["GROUP", template['GNAME']]
188
- puts str % ["LOCK", OpenNebulaHelper.level_lock_to_str(template['LOCK/LOCKED'])]
189
- puts str % ["REGISTER TIME",
190
- OpenNebulaHelper.time_to_str(template['REGTIME'])]
182
+ str_h1 % "TEMPLATE #{template['ID']} INFORMATION"
183
+ )
184
+ puts format(str, 'ID', template.id.to_s)
185
+ puts format(str, 'NAME', template.name)
186
+ puts format(str, 'USER', template['UNAME'])
187
+ puts format(str, 'GROUP', template['GNAME'])
188
+ puts format(str, 'LOCK', OpenNebulaHelper.level_lock_to_str(template['LOCK/LOCKED']))
189
+ puts format(str, 'REGISTER TIME', OpenNebulaHelper.time_to_str(template['REGTIME']))
191
190
  puts
192
191
 
193
- CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
192
+ CLIHelper.print_header(str_h1 % 'PERMISSIONS', false)
194
193
 
195
- ["OWNER", "GROUP", "OTHER"].each { |e|
196
- mask = "---"
197
- mask[0] = "u" if template["PERMISSIONS/#{e}_U"] == "1"
198
- mask[1] = "m" if template["PERMISSIONS/#{e}_M"] == "1"
199
- mask[2] = "a" if template["PERMISSIONS/#{e}_A"] == "1"
194
+ ['OWNER', 'GROUP', 'OTHER'].each do |e|
195
+ mask = '---'
196
+ mask[0] = 'u' if template["PERMISSIONS/#{e}_U"] == '1'
197
+ mask[1] = 'm' if template["PERMISSIONS/#{e}_M"] == '1'
198
+ mask[2] = 'a' if template["PERMISSIONS/#{e}_A"] == '1'
200
199
 
201
- puts str % [e, mask]
202
- }
200
+ puts format(str, e, mask)
201
+ end
203
202
  puts
204
203
 
205
- CLIHelper.print_header(str_h1 % "TEMPLATE CONTENTS",false)
204
+ CLIHelper.print_header(str_h1 % 'TEMPLATE CONTENTS', false)
206
205
  puts template.template_str
207
206
  end
207
+
208
208
  end
@@ -18,14 +18,15 @@ require 'one_helper'
18
18
  require 'opennebula/vdc'
19
19
  require 'opennebula/vdc_pool'
20
20
 
21
+ # Helper class for VDC commands
21
22
  class OneVdcHelper < OpenNebulaHelper::OneHelper
22
23
 
23
24
  def self.rname
24
- "VDC"
25
+ 'VDC'
25
26
  end
26
27
 
27
28
  def self.conf_file
28
- "onevdc.yaml"
29
+ 'onevdc.yaml'
29
30
  end
30
31
 
31
32
  def id_list_size(list, resource)
@@ -39,20 +40,20 @@ class OneVdcHelper < OpenNebulaHelper::OneHelper
39
40
  end
40
41
  end
41
42
 
42
- def format_pool(options)
43
+ def format_pool(_options)
43
44
  config_file = self.class.table_conf
44
45
 
45
- table = CLIHelper::ShowTable.new(config_file, self) do
46
- column :ID, "ONE identifier for the VDC", :size=>5 do |d|
47
- d["ID"]
46
+ CLIHelper::ShowTable.new(config_file, self) do
47
+ column :ID, 'ONE identifier for the VDC', :size=>5 do |d|
48
+ d['ID']
48
49
  end
49
50
 
50
- column :NAME, "Name of the VDC", :left, :size=>30 do |d|
51
- d["NAME"]
51
+ column :NAME, 'Name of the VDC', :left, :size=>30 do |d|
52
+ d['NAME']
52
53
  end
53
54
 
54
- column :GROUPS, "Number of Groups", :size=>6 do |d|
55
- ids = d["GROUPS"]["ID"]
55
+ column :GROUPS, 'Number of Groups', :size=>6 do |d|
56
+ ids = d['GROUPS']['ID']
56
57
  case ids
57
58
  when String
58
59
  1
@@ -63,31 +64,29 @@ class OneVdcHelper < OpenNebulaHelper::OneHelper
63
64
  end
64
65
  end
65
66
 
66
- column :CLUSTERS, "Number of Clusters", :size=>8 do |d|
67
- @ext.id_list_size(d["CLUSTERS"]["CLUSTER"], "CLUSTER") rescue "-"
67
+ column :CLUSTERS, 'Number of Clusters', :size=>8 do |d|
68
+ @ext.id_list_size(d['CLUSTERS']['CLUSTER'], 'CLUSTER') rescue '-'
68
69
  end
69
70
 
70
- column :HOSTS, "Number of Hosts", :size=>5 do |d|
71
- @ext.id_list_size(d["HOSTS"]["HOST"], "HOST") rescue "-"
71
+ column :HOSTS, 'Number of Hosts', :size=>5 do |d|
72
+ @ext.id_list_size(d['HOSTS']['HOST'], 'HOST') rescue '-'
72
73
  end
73
74
 
74
- column :VNETS, "Number of Networks", :size=>5 do |d|
75
- @ext.id_list_size(d["VNETS"]["VNET"], "VNET") rescue "-"
75
+ column :VNETS, 'Number of Networks', :size=>5 do |d|
76
+ @ext.id_list_size(d['VNETS']['VNET'], 'VNET') rescue '-'
76
77
  end
77
78
 
78
- column :DATASTORES, "Number of Datastores", :size=>10 do |d|
79
- @ext.id_list_size(d["DATASTORES"]["DATASTORE"], "DATASTORE") rescue "-"
79
+ column :DATASTORES, 'Number of Datastores', :size=>10 do |d|
80
+ @ext.id_list_size(d['DATASTORES']['DATASTORE'], 'DATASTORE') rescue '-'
80
81
  end
81
82
 
82
83
  default :ID, :NAME, :GROUPS, :CLUSTERS, :HOSTS, :VNETS, :DATASTORES
83
84
  end
84
-
85
- table
86
85
  end
87
86
 
88
87
  private
89
88
 
90
- def factory(id=nil)
89
+ def factory(id = nil)
91
90
  if id
92
91
  OpenNebula::Vdc.new_with_id(id, @client)
93
92
  else
@@ -96,26 +95,26 @@ class OneVdcHelper < OpenNebulaHelper::OneHelper
96
95
  end
97
96
  end
98
97
 
99
- def factory_pool(user_flag=-2)
98
+ def factory_pool(_user_flag = -2)
100
99
  OpenNebula::VdcPool.new(@client)
101
100
  end
102
101
 
103
- def format_resource(vdc, options = {})
104
- str="%-18s: %-20s"
105
- str_h1="%-80s"
102
+ def format_resource(vdc, _options = {})
103
+ str='%-18s: %-20s'
104
+ str_h1='%-80s'
106
105
 
107
106
  CLIHelper.print_header(str_h1 % "VDC #{vdc['ID']} INFORMATION")
108
- puts str % ["ID", vdc.id.to_s]
109
- puts str % ["NAME", vdc.name]
107
+ puts format(str, 'ID', vdc.id.to_s)
108
+ puts format(str, 'NAME', vdc.name)
110
109
 
111
110
  vdc_hash = vdc.to_hash
112
111
 
113
112
  groups = vdc_hash['VDC']['GROUPS']['ID']
114
- if(groups != nil)
113
+ if(!groups.nil?)
115
114
  puts
116
115
 
117
116
  CLIHelper::ShowTable.new(nil, self) do
118
- column :"GROUPS", "", :right, :size=>7 do |d|
117
+ column :GROUPS, '', :right, :size=>7 do |d|
119
118
  d
120
119
  end
121
120
  end.show([groups].flatten, {})
@@ -123,24 +122,25 @@ class OneVdcHelper < OpenNebulaHelper::OneHelper
123
122
 
124
123
  ['CLUSTER', 'HOST', 'DATASTORE', 'VNET'].each do |resource|
125
124
  res_array = vdc_hash['VDC']["#{resource}S"][resource]
126
- if(res_array != nil)
127
- puts
128
- CLIHelper.print_header(str_h1 % "#{resource}S", false)
129
-
130
- CLIHelper::ShowTable.new(nil, self) do
131
- column :"ZONE", "", :right, :size=>7 do |d|
132
- d['ZONE_ID']
133
- end
134
-
135
- column :"#{resource}", "", :right, :size=>9 do |d|
136
- d["#{resource}_ID"] == Vdc::ALL_RESOURCES ? 'ALL' : d["#{resource}_ID"]
137
- end
138
- end.show([res_array].flatten, {})
139
- end
125
+ next if res_array.nil?
126
+
127
+ puts
128
+ CLIHelper.print_header(str_h1 % "#{resource}S", false)
129
+
130
+ CLIHelper::ShowTable.new(nil, self) do
131
+ column :ZONE, '', :right, :size=>7 do |d|
132
+ d['ZONE_ID']
133
+ end
134
+
135
+ column :"#{resource}", '', :right, :size=>9 do |d|
136
+ d["#{resource}_ID"] == Vdc::ALL_RESOURCES ? 'ALL' : d["#{resource}_ID"]
137
+ end
138
+ end.show([res_array].flatten, {})
140
139
  end
141
140
 
142
141
  puts
143
- CLIHelper.print_header(str_h1 % "VDC TEMPLATE", false)
142
+ CLIHelper.print_header(str_h1 % 'VDC TEMPLATE', false)
144
143
  puts vdc.template_str
145
144
  end
145
+
146
146
  end