opennebula-cli 5.6.2 → 5.7.80.pre

Sign up to get free protection for your applications and to get access to all the features.
data/bin/onevmgroup CHANGED
@@ -16,22 +16,22 @@
16
16
  # limitations under the License. #
17
17
  #--------------------------------------------------------------------------- #
18
18
 
19
- ONE_LOCATION=ENV["ONE_LOCATION"]
19
+ ONE_LOCATION = ENV['ONE_LOCATION']
20
20
 
21
21
  if !ONE_LOCATION
22
- RUBY_LIB_LOCATION="/usr/lib/one/ruby"
22
+ RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
23
23
  else
24
- RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
24
+ RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
25
25
  end
26
26
 
27
- $: << RUBY_LIB_LOCATION
28
- $: << RUBY_LIB_LOCATION+"/cli"
27
+ $LOAD_PATH << RUBY_LIB_LOCATION
28
+ $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
29
29
 
30
30
  require 'command_parser'
31
31
  require 'one_helper/onevmgroup_helper'
32
32
 
33
- cmd=CommandParser::CmdParser.new(ARGV) do
34
- usage "`onevmgroup` <command> [<args>] [<options>]"
33
+ CommandParser::CmdParser.new(ARGV) do
34
+ usage '`onevmgroup` <command> [<args>] [<options>]'
35
35
  version OpenNebulaHelper::ONE_VERSION
36
36
 
37
37
  helper = OneVMGroupHelper.new
@@ -40,34 +40,34 @@ cmd=CommandParser::CmdParser.new(ARGV) do
40
40
  helper.set_client(options)
41
41
  end
42
42
 
43
- USE={
44
- :name => "use",
45
- :large => "--use",
46
- :description => "lock use actions"
43
+ USE = {
44
+ :name => 'use',
45
+ :large => '--use',
46
+ :description => 'lock use actions'
47
47
  }
48
48
 
49
- MANAGE={
50
- :name => "manage",
51
- :large => "--manage",
52
- :description => "lock manage actions"
49
+ MANAGE = {
50
+ :name => 'manage',
51
+ :large => '--manage',
52
+ :description => 'lock manage actions'
53
53
  }
54
54
 
55
- ADMIN={
56
- :name => "admin",
57
- :large => "--admin",
58
- :description => "lock admin actions"
55
+ ADMIN = {
56
+ :name => 'admin',
57
+ :large => '--admin',
58
+ :description => 'lock admin actions'
59
59
  }
60
60
 
61
- ALL={
62
- :name => "all",
63
- :large => "--all",
64
- :description => "lock all actions"
61
+ ALL = {
62
+ :name => 'all',
63
+ :large => '--all',
64
+ :description => 'lock all actions'
65
65
  }
66
66
 
67
67
  ########################################################################
68
68
  # Global Options
69
69
  ########################################################################
70
- set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
70
+ set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
71
71
 
72
72
  list_options = CLIHelper::OPTIONS
73
73
  list_options << OpenNebulaHelper::XML
@@ -77,12 +77,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do
77
77
  ########################################################################
78
78
  # Formatters for arguments
79
79
  ########################################################################
80
- set :format, :groupid, OpenNebulaHelper.rname_to_id_desc("GROUP") do |arg|
81
- OpenNebulaHelper.rname_to_id(arg, "GROUP")
80
+ set :format, :groupid, OpenNebulaHelper.rname_to_id_desc('GROUP') do |arg|
81
+ OpenNebulaHelper.rname_to_id(arg, 'GROUP')
82
82
  end
83
83
 
84
- set :format, :userid, OpenNebulaHelper.rname_to_id_desc("USER") do |arg|
85
- OpenNebulaHelper.rname_to_id(arg, "USER")
84
+ set :format, :userid, OpenNebulaHelper.rname_to_id_desc('USER') do |arg|
85
+ OpenNebulaHelper.rname_to_id(arg, 'USER')
86
86
  end
87
87
 
88
88
  set :format, :vmgroupid, OneVMGroupHelper.to_id_desc do |arg|
@@ -111,9 +111,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
111
111
  template = File.read(args[0])
112
112
 
113
113
  obj.allocate(template)
114
- rescue => e
115
- STDERR.puts e.messsage
116
- exit -1
114
+ rescue StandardError => e
115
+ STDERR.puts "Error creating VM Group: #{e.messsage}"
116
+ exit(-1)
117
117
  end
118
118
  end
119
119
  end
@@ -123,7 +123,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
123
123
  EOT
124
124
 
125
125
  command :delete, delete_desc, [:range, :vmgroupid_list] do
126
- helper.perform_actions(args[0],options,"deleted") do |obj|
126
+ helper.perform_actions(args[0], options, 'deleted') do |obj|
127
127
  obj.delete
128
128
  end
129
129
  end
@@ -132,7 +132,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
132
132
  Lists VM Group in the pool
133
133
  EOT
134
134
 
135
- command :list, list_desc, [:filterflag, nil], :options=>list_options do
135
+ command :list, list_desc, [:filterflag, nil], :options => list_options do
136
136
  helper.list_pool(options, false, args[0])
137
137
  end
138
138
 
@@ -140,16 +140,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
140
140
  Shows information for the given VM Group
141
141
  EOT
142
142
 
143
- command :show, show_desc, :vmgroupid, :options=>OpenNebulaHelper::XML do
144
- helper.show_resource(args[0],options)
143
+ command :show, show_desc, :vmgroupid, :options => OpenNebulaHelper::XML do
144
+ helper.show_resource(args[0], options)
145
145
  end
146
146
 
147
147
  chgrp_desc = <<-EOT.unindent
148
148
  Changes the VM Group's group
149
149
  EOT
150
150
 
151
- command :chgrp, chgrp_desc,[:range, :vmgroupid_list], :groupid do
152
- helper.perform_actions(args[0],options,"Group changed") do |obj|
151
+ command :chgrp, chgrp_desc, [:range, :vmgroupid_list], :groupid do
152
+ helper.perform_actions(args[0], options, 'Group changed') do |obj|
153
153
  obj.chown(-1, args[1].to_i)
154
154
  end
155
155
  end
@@ -159,9 +159,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
159
159
  EOT
160
160
 
161
161
  command :chown, chown_desc, [:range, :vmgroupid_list], :userid,
162
- [:groupid,nil] do
163
- gid = args[2].nil? ? -1 : args[2].to_i
164
- helper.perform_actions(args[0],options,"Owner/Group changed") do |obj|
162
+ [:groupid, nil] do
163
+ args[2].nil? ? gid = -1 : gid = args[2].to_i
164
+ helper.perform_actions(args[0], options, 'Owner/Group changed') do |obj|
165
165
  obj.chown(args[1].to_i, gid)
166
166
  end
167
167
  end
@@ -171,7 +171,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
171
171
  EOT
172
172
 
173
173
  command :chmod, chmod_desc, [:range, :vmgroupid_list], :octet do
174
- helper.perform_actions(args[0],options, "Permissions changed") do |t|
174
+ helper.perform_actions(args[0], options, 'Permissions changed') do |t|
175
175
  t.chmod_octet(args[1])
176
176
  end
177
177
  end
@@ -182,8 +182,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
182
182
  EOT
183
183
 
184
184
  command :update, update_desc, :vmgroupid, [:file, nil],
185
- :options=>OpenNebulaHelper::APPEND do
186
- helper.perform_action(args[0],options,"modified") do |obj|
185
+ :options => OpenNebulaHelper::APPEND do
186
+ helper.perform_action(args[0], options, 'modified') do |obj|
187
187
  if options[:append]
188
188
  str = OpenNebulaHelper.append_template(args[0], obj, args[1])
189
189
  else
@@ -202,7 +202,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
202
202
  EOT
203
203
 
204
204
  command :rename, rename_desc, :vmgroupid, :name do
205
- helper.perform_action(args[0],options,"renamed") do |o|
205
+ helper.perform_action(args[0], options, 'renamed') do |o|
206
206
  o.rename(args[1])
207
207
  end
208
208
  end
@@ -218,8 +218,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
218
218
  EOT
219
219
 
220
220
  command :lock, lock_desc, :vmgroupid,
221
- :options => [USE, MANAGE, ADMIN, ALL] do
222
- helper.perform_action(args[0],options,"VMGroup locked") do |vmg|
221
+ :options => [USE, MANAGE, ADMIN, ALL] do
222
+ helper.perform_action(args[0], options, 'VMGroup locked') do |vmg|
223
223
  if !options[:use].nil?
224
224
  level = 1
225
225
  elsif !options[:manage].nil?
@@ -241,7 +241,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
241
241
  EOT
242
242
 
243
243
  command :unlock, unlock_desc, :vmgroupid do
244
- helper.perform_action(args[0],options,"VMGroup unlocked") do |vmg|
244
+ helper.perform_action(args[0], options, 'VMGroup unlocked') do |vmg|
245
245
  vmg.unlock
246
246
  end
247
247
  end
data/bin/onevnet CHANGED
@@ -16,23 +16,23 @@
16
16
  # limitations under the License. #
17
17
  #--------------------------------------------------------------------------- #
18
18
 
19
- ONE_LOCATION=ENV["ONE_LOCATION"]
19
+ ONE_LOCATION = ENV['ONE_LOCATION']
20
20
 
21
21
  if !ONE_LOCATION
22
- RUBY_LIB_LOCATION="/usr/lib/one/ruby"
22
+ RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
23
23
  else
24
- RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
24
+ RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
25
25
  end
26
26
 
27
- $: << RUBY_LIB_LOCATION
28
- $: << RUBY_LIB_LOCATION+"/cli"
27
+ $LOAD_PATH << RUBY_LIB_LOCATION
28
+ $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
29
29
 
30
30
  require 'command_parser'
31
31
  require 'one_helper/onevnet_helper'
32
32
  require 'one_helper/onecluster_helper'
33
33
 
34
- cmd=CommandParser::CmdParser.new(ARGV) do
35
- usage "`onevnet` <command> [<args>] [<options>]"
34
+ CommandParser::CmdParser.new(ARGV) do
35
+ usage '`onevnet` <command> [<args>] [<options>]'
36
36
  version OpenNebulaHelper::ONE_VERSION
37
37
 
38
38
  helper = OneVNetHelper.new
@@ -41,34 +41,34 @@ cmd=CommandParser::CmdParser.new(ARGV) do
41
41
  helper.set_client(options)
42
42
  end
43
43
 
44
- USE={
45
- :name => "use",
46
- :large => "--use",
47
- :description => "lock use actions"
44
+ USE = {
45
+ :name => 'use',
46
+ :large => '--use',
47
+ :description => 'lock use actions'
48
48
  }
49
49
 
50
- MANAGE={
51
- :name => "manage",
52
- :large => "--manage",
53
- :description => "lock manage actions"
50
+ MANAGE = {
51
+ :name => 'manage',
52
+ :large => '--manage',
53
+ :description => 'lock manage actions'
54
54
  }
55
55
 
56
- ADMIN={
57
- :name => "admin",
58
- :large => "--admin",
59
- :description => "lock admin actions"
56
+ ADMIN = {
57
+ :name => 'admin',
58
+ :large => '--admin',
59
+ :description => 'lock admin actions'
60
60
  }
61
61
 
62
- ALL={
63
- :name => "all",
64
- :large => "--all",
65
- :description => "lock all actions"
62
+ ALL = {
63
+ :name => 'all',
64
+ :large => '--all',
65
+ :description => 'lock all actions'
66
66
  }
67
67
 
68
68
  ########################################################################
69
69
  # Global Options
70
70
  ########################################################################
71
- set :option, CommandParser::OPTIONS+OpenNebulaHelper::CLIENT_OPTIONS
71
+ set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
72
72
 
73
73
  CREATE_OPTIONS = [OneClusterHelper::CLUSTER]
74
74
  STD_OPTIONS = CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
@@ -76,12 +76,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do
76
76
  ########################################################################
77
77
  # Formatters for arguments
78
78
  ########################################################################
79
- set :format, :groupid, OpenNebulaHelper.rname_to_id_desc("GROUP") do |arg|
80
- OpenNebulaHelper.rname_to_id(arg, "GROUP")
79
+ set :format, :groupid, OpenNebulaHelper.rname_to_id_desc('GROUP') do |arg|
80
+ OpenNebulaHelper.rname_to_id(arg, 'GROUP')
81
81
  end
82
82
 
83
- set :format, :userid, OpenNebulaHelper.rname_to_id_desc("USER") do |arg|
84
- OpenNebulaHelper.rname_to_id(arg, "USER")
83
+ set :format, :userid, OpenNebulaHelper.rname_to_id_desc('USER') do |arg|
84
+ OpenNebulaHelper.rname_to_id(arg, 'USER')
85
85
  end
86
86
 
87
87
  set :format, :vnetid, OneVNetHelper.to_id_desc do |arg|
@@ -96,7 +96,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
96
96
  helper.filterflag_to_i(arg)
97
97
  end
98
98
 
99
- set :format, :ar_id, "Integer" do |arg|
99
+ set :format, :ar_id, 'Integer' do |arg|
100
100
  format_int(arg)
101
101
  end
102
102
 
@@ -108,16 +108,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
108
108
  Creates a new Virtual Network from the given template file
109
109
  EOT
110
110
 
111
- command :create, create_desc, :file, :options=>CREATE_OPTIONS do
111
+ command :create, create_desc, :file, :options => CREATE_OPTIONS do
112
112
  cid = options[:cluster] || ClusterPool::NONE_CLUSTER_ID
113
113
 
114
114
  helper.create_resource(options) do |vn|
115
115
  begin
116
- template=File.read(args[0])
116
+ template = File.read(args[0])
117
117
  vn.allocate(template, cid)
118
- rescue => e
119
- STDERR.puts e.message
120
- exit -1
118
+ rescue StandardError => e
119
+ STDERR.puts "Error creating network: #{e.message}"
120
+ exit(-1)
121
121
  end
122
122
  end
123
123
  end
@@ -127,7 +127,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
127
127
  EOT
128
128
 
129
129
  command :delete, delete_desc, [:range, :vnetid_list] do
130
- helper.perform_actions(args[0],options,"deleted") do |vn|
130
+ helper.perform_actions(args[0], options, 'deleted') do |vn|
131
131
  vn.delete
132
132
  end
133
133
  end
@@ -138,81 +138,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do
138
138
 
139
139
  command :addar, addar_desc, :vnetid, [:file, nil],
140
140
  :options => STD_OPTIONS + OneVNetHelper::ADDAR_OPTIONS do
141
- helper.perform_action(args[0],options,"lease added") do |vn|
141
+ helper.perform_action(args[0], options, 'lease added') do |vn|
142
142
  if args[1]
143
143
  ar = File.read(args[1])
144
144
  else
145
- ar = "AR = [ "
146
-
147
- if options[:ip]
148
- if options[:ip6_global] || options[:ip6_ula]
149
- ar << "TYPE=\"IP4_6\""
150
- elsif options[:ip6]
151
- ar << "TYPE=\"IP4_6_STATIC\""
152
- else
153
- ar << "TYPE=\"IP4\""
154
- end
155
- elsif options[:ip6]
156
- ar << "TYPE=\"IP6_STATIC\""
157
- elsif options[:ip6_global] || options[:ip6_ula]
158
- ar << "TYPE=\"IP6\""
159
- else
160
- ar << "TYPE=\"ETHER\""
161
- end
162
-
163
- if options[:size]
164
- ar << ", SIZE = " << options[:size]
165
- else
166
- STDERR.puts "Address range needs to specify size (-s size)"
167
- exit -1
168
- end
169
-
170
- if options[:ip6]
171
- m = /([\h:]*)\/(\d.*)$/.match(options[:ip6])
172
-
173
- if m.nil? || m[1].nil?
174
- STDERR.puts "Missing or wrong IP6"
175
- exit -1
176
- else
177
- begin
178
- require 'ipaddr'
179
-
180
- ip = IPAddr.new(m[1])
181
-
182
- if !ip.ipv6?
183
- STDERR.puts "Wrong IP6 format address"
184
- exit -1
185
- end
186
- rescue
187
- STDERR.puts "Wrong IP6 format address"
188
- exit -1
189
- end
190
-
191
- end
192
-
193
- if m[2].nil?
194
- STDERR.puts "IP6 address need to set the prefix length"
195
- exit -1
196
- end
197
-
198
- ar << ", PREFIX_LENGTH=\"#{m[2]}\""
199
-
200
- options[:ip6] = m[1]
201
- end
202
-
203
- ar << ", IP = " << options[:ip] if options[:ip]
204
- ar << ", IP6 = " << options[:ip6] if options[:ip6]
205
- ar << ", MAC = " << options[:mac] if options[:mac]
206
- ar << ", GLOBAL_PREFIX = " <<
207
- options[:ip6_global] if options[:ip6_global]
208
- ar << ", ULA_PREFIX = " <<
209
- options[:ip6_ula] if options[:ip6_ula]
210
- ar << ", GATEWAY = " << options[:gateway] if options[:gateway]
211
- ar << ", MASK = " << options[:netmask] if options[:netmask]
212
- ar << ", VN_MAD = " << options[:vn_mad] if options[:vn_mad]
213
- ar << ", VLAN_ID = " << options[:vlanid] if options[:vlanid]
214
-
215
- ar << "]"
145
+ ar = OpenNebulaHelper.create_ar(options)
216
146
  end
217
147
 
218
148
  vn.add_ar(ar)
@@ -224,7 +154,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
224
154
  EOT
225
155
 
226
156
  command :addleases, addleases_desc, :vnetid, :ip, [:mac, nil] do
227
- helper.perform_action(args[0],options,"lease added") do |vn|
157
+ helper.perform_action(args[0], options, 'lease added') do |vn|
228
158
  vn.addleases(args[1], args[2])
229
159
  end
230
160
  end
@@ -234,7 +164,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
234
164
  EOT
235
165
 
236
166
  command :rmar, rmar_desc, :vnetid, :ar_id do
237
- helper.perform_action(args[0],options,"address range removed") do |vn|
167
+ helper.perform_action(args[0], options, 'address range removed') do |vn|
238
168
  vn.rm_ar(args[1])
239
169
  end
240
170
  end
@@ -244,7 +174,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
244
174
  EOT
245
175
 
246
176
  command :rmleases, rmleases_desc, :vnetid, :ip do
247
- helper.perform_action(args[0],options,"lease removed") do |vn|
177
+ helper.perform_action(args[0], options, 'lease removed') do |vn|
248
178
  vn.rmleases(args[1])
249
179
  end
250
180
  end
@@ -254,7 +184,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
254
184
  EOT
255
185
 
256
186
  command :free, free_desc, :vnetid, :ar_id do
257
- helper.perform_action(args[0],options,"address range freed") do |vn|
187
+ helper.perform_action(args[0], options, 'address range freed') do |vn|
258
188
  vn.free(args[1])
259
189
  end
260
190
  end
@@ -264,8 +194,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
264
194
  EOT
265
195
 
266
196
  command :hold, hold_desc, :vnetid, :ip,
267
- :options=>STD_OPTIONS + [OneVNetHelper::AR] do
268
- helper.perform_action(args[0],options,"lease on hold") do |vn|
197
+ :options => STD_OPTIONS + [OneVNetHelper::AR] do
198
+ helper.perform_action(args[0], options, 'lease on hold') do |vn|
269
199
  ar = options[:address_range] || -1
270
200
 
271
201
  vn.hold(args[1], ar)
@@ -277,9 +207,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
277
207
  EOT
278
208
 
279
209
  command :release, release_desc, :vnetid, :ip,
280
- :options=>STD_OPTIONS + [OneVNetHelper::AR] do
281
- helper.perform_action(args[0],options,"lease released") do |vn|
282
- ar = options[:address_range] || -1
210
+ :options => STD_OPTIONS + [OneVNetHelper::AR] do
211
+ helper.perform_action(args[0], options, 'lease released') do |vn|
212
+ ar = options[:address_range] || -1
283
213
 
284
214
  vn.release(args[1], ar)
285
215
  end
@@ -293,10 +223,13 @@ cmd=CommandParser::CmdParser.new(ARGV) do
293
223
  EOT
294
224
 
295
225
  command :reserve, reserve_desc, :vnetid, [:vnetid, nil],
296
- :options=>STD_OPTIONS + [OneVNetHelper::AR, OneVNetHelper::NAME,
297
- OneVNetHelper::SIZE, OneVNetHelper::MAC, OneVNetHelper::IP,
298
- OneVNetHelper::IP6 ] do
299
- helper.perform_action(args[0],options,"reservation made") do |vn|
226
+ :options => STD_OPTIONS + [OneVNetHelper::AR,
227
+ OneVNetHelper::NAME,
228
+ OneVNetHelper::SIZE,
229
+ OneVNetHelper::MAC,
230
+ OneVNetHelper::IP,
231
+ OneVNetHelper::IP6] do
232
+ helper.perform_action(args[0], options, 'reservation made') do |vn|
300
233
  size = options[:size] || -1
301
234
  name = options[:name] || -1
302
235
 
@@ -306,13 +239,13 @@ cmd=CommandParser::CmdParser.new(ARGV) do
306
239
  addr = options[:ip6] if options[:ip6]
307
240
 
308
241
  if size == -1
309
- STDERR.puts "Specify a size (-s size) for the reservation"
310
- exit -1
242
+ STDERR.puts 'Specify a size (-s size) for the reservation'
243
+ exit(-1)
311
244
  end
312
245
 
313
246
  if name == -1 && args[1].nil?
314
- STDERR.puts "Specify a name (-n name) for the reservation"
315
- exit -1
247
+ STDERR.puts 'Specify a name (-n name) for the reservation'
248
+ exit(-1)
316
249
  end
317
250
 
318
251
  res = vn.reserve(name, size, options[:address_range], addr, args[1])
@@ -325,13 +258,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do
325
258
  end
326
259
  end
327
260
 
328
-
329
261
  chgrp_desc = <<-EOT.unindent
330
262
  Changes the Virtual Network group
331
263
  EOT
332
264
 
333
- command :chgrp, chgrp_desc,[:range, :vnetid_list], :groupid do
334
- helper.perform_actions(args[0],options,"Group changed") do |vn|
265
+ command :chgrp, chgrp_desc, [:range, :vnetid_list], :groupid do
266
+ helper.perform_actions(args[0], options, 'Group changed') do |vn|
335
267
  vn.chown(-1, args[1].to_i)
336
268
  end
337
269
  end
@@ -341,9 +273,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
341
273
  EOT
342
274
 
343
275
  command :chown, chown_desc, [:range, :vnetid_list], :userid,
344
- [:groupid,nil] do
345
- gid = args[2].nil? ? -1 : args[2].to_i
346
- helper.perform_actions(args[0],options,"Owner/Group changed") do |vn|
276
+ [:groupid, nil] do
277
+ args[2].nil? ? gid = -1 : gid = args[2].to_i
278
+ helper.perform_actions(args[0], options, 'Owner/Group changed') do |vn|
347
279
  vn.chown(args[1].to_i, gid)
348
280
  end
349
281
  end
@@ -353,7 +285,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
353
285
  EOT
354
286
 
355
287
  command :chmod, chmod_desc, [:range, :vnetid_list], :octet do
356
- helper.perform_actions(args[0],options, "Permissions changed") do |vn|
288
+ helper.perform_actions(args[0], options, 'Permissions changed') do |vn|
357
289
  vn.chmod_octet(args[1])
358
290
  end
359
291
  end
@@ -363,8 +295,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
363
295
  EOT
364
296
 
365
297
  command :list, list_desc, [:filterflag, nil],
366
- :options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS+
367
- [OpenNebulaHelper::DESCRIBE] do
298
+ :options => CLIHelper::OPTIONS + OpenNebulaHelper::OPTIONS +
299
+ [OpenNebulaHelper::DESCRIBE] do
368
300
  helper.list_pool(options, false, args[0])
369
301
  end
370
302
 
@@ -373,8 +305,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
373
305
  EOT
374
306
 
375
307
  command :show, show_desc, :vnetid,
376
- :options=>[OpenNebulaHelper::XML, OneVNetHelper::SHOW_AR] do
377
- helper.show_resource(args[0],options)
308
+ :options => [OpenNebulaHelper::XML, OneVNetHelper::SHOW_AR] do
309
+ helper.show_resource(args[0], options)
378
310
  end
379
311
 
380
312
  update_desc = <<-EOT.unindent
@@ -383,8 +315,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
383
315
  EOT
384
316
 
385
317
  command :update, update_desc, :vnetid, [:file, nil],
386
- :options=>OpenNebulaHelper::APPEND do
387
- helper.perform_action(args[0],options,"modified") do |obj|
318
+ :options => OpenNebulaHelper::APPEND do
319
+ helper.perform_action(args[0], options, 'modified') do |obj|
388
320
  if options[:append]
389
321
  str = OpenNebulaHelper.append_template(args[0], obj, args[1])
390
322
  else
@@ -403,32 +335,36 @@ cmd=CommandParser::CmdParser.new(ARGV) do
403
335
  EOT
404
336
 
405
337
  command :updatear, update_ar_desc, :vnetid, :ar_id, [:file, nil] do
406
- helper.perform_action(args[0],options,"modified") do |obj|
338
+ helper.perform_action(args[0], options, 'modified') do |obj|
407
339
  rc = obj.info
408
340
 
409
341
  if OpenNebula.is_error?(rc)
410
342
  puts rc.message
411
- exit -1
343
+ exit(-1)
412
344
  end
413
345
 
414
346
  obj.delete_element("AR_POOL/AR[AR_ID!=#{args[1]}]")
415
- obj.delete_element("AR_POOL/AR/LEASES")
416
- obj.delete_element("AR_POOL/AR/USED_LEASES")
417
- obj.delete_element("AR_POOL/AR/MAC_END")
418
- obj.delete_element("AR_POOL/AR/IP_END")
419
- obj.delete_element("AR_POOL/AR/IP6_ULA")
420
- obj.delete_element("AR_POOL/AR/IP6_ULA_END")
421
- obj.delete_element("AR_POOL/AR/IP6_GLOBAL")
422
- obj.delete_element("AR_POOL/AR/IP6_GLOBAL_END")
423
-
424
- if obj.template_like_str("AR_POOL").empty?
425
- puts "Address Range #{args[1]} does not exist for "<<
426
- "Virtual Network #{args[0]}"
427
- exit -1
347
+ obj.delete_element('AR_POOL/AR/LEASES')
348
+ obj.delete_element('AR_POOL/AR/USED_LEASES')
349
+ obj.delete_element('AR_POOL/AR/MAC_END')
350
+ obj.delete_element('AR_POOL/AR/IP_END')
351
+ obj.delete_element('AR_POOL/AR/IP6_ULA')
352
+ obj.delete_element('AR_POOL/AR/IP6_ULA_END')
353
+ obj.delete_element('AR_POOL/AR/IP6_GLOBAL')
354
+ obj.delete_element('AR_POOL/AR/IP6_GLOBAL_END')
355
+
356
+ if obj.template_like_str('AR_POOL').empty?
357
+ puts "Address Range #{args[1]} does not exist for " \
358
+ "Virtual Network #{args[0]}"
359
+ exit(-1)
428
360
  end
429
361
 
430
- str = OpenNebulaHelper.update_template_helper(false, args[0], obj,
431
- args[2], "AR_POOL", false)
362
+ str = OpenNebulaHelper.update_template_helper(false,
363
+ args[0],
364
+ obj,
365
+ args[2],
366
+ 'AR_POOL',
367
+ false)
432
368
 
433
369
  helper.set_client(options)
434
370
  obj = helper.retrieve_resource(obj.id)
@@ -442,7 +378,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
442
378
  EOT
443
379
 
444
380
  command :rename, rename_desc, :vnetid, :name do
445
- helper.perform_action(args[0],options,"renamed") do |o|
381
+ helper.perform_action(args[0], options, 'renamed') do |o|
446
382
  o.rename(args[1])
447
383
  end
448
384
  end
@@ -458,8 +394,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
458
394
  EOT
459
395
 
460
396
  command :lock, lock_desc, :vnetid,
461
- :options => [USE, MANAGE, ADMIN, ALL] do
462
- helper.perform_action(args[0],options,"VNet locked") do |vnet|
397
+ :options => [USE, MANAGE, ADMIN, ALL] do
398
+ helper.perform_action(args[0], options, 'VNet locked') do |vnet|
463
399
  if !options[:use].nil?
464
400
  level = 1
465
401
  elsif !options[:manage].nil?
@@ -481,7 +417,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
481
417
  EOT
482
418
 
483
419
  command :unlock, unlock_desc, :vnetid do
484
- helper.perform_action(args[0],options,"VNet unlocked") do |vnet|
420
+ helper.perform_action(args[0], options, 'VNet unlocked') do |vnet|
485
421
  vnet.unlock
486
422
  end
487
423
  end