opennebula-cli 6.0.3 → 6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d71d6197859d846259af7cb730330d8d29a03e89
4
- data.tar.gz: 515adb9afa80cf52f7ab93ac9a582af9bc38afc8
2
+ SHA256:
3
+ metadata.gz: c4908cbc17aac8f9c51ea753a53ae639ae001ffafd53e434de2607dbeca48a17
4
+ data.tar.gz: b8177017450198bf4c1a37a0239568c090c8ed8c1527cd5de04079ceb72a6f6a
5
5
  SHA512:
6
- metadata.gz: 02cfddcd26f6d496448f69653ad05f463eebf60cb5d40a956319faaed2f9b4829db13e75b9154168e3a0597a3cf2f20739229ce9758b2ce537f535c9f5a5e644
7
- data.tar.gz: 8409cabd907844035d833f9d37b37dc08c15bf0afd276a1772c303ffa6d1a6e004985f4eefa5d440590d93f5910f209fee68bef5238aa8e206c6f806d82865e4
6
+ metadata.gz: e1768f1cfaf3e35b24c0ea83e646d86fe4d02363ca9d9e96e8b9f7e41f8ca4405e81728d1b95284660579a02b01041253f4f1c56a93ef5ebc4a7fb4966730134
7
+ data.tar.gz: a089348845dc43030ae6e079c8d71d8a0abc1978dd369bddebaf718d42ad7be24e476308d622e47673d906e387a2465055a64d1117ff1cbc48d04abf9e35cb47
data/bin/oneflow CHANGED
@@ -82,6 +82,14 @@ CommandParser::CmdParser.new(ARGV) do
82
82
  :description => 'Force flow necover delete'
83
83
  }
84
84
 
85
+ APPEND = {
86
+ :name => 'append',
87
+ :large => '--append',
88
+ :description => 'Append template to the current one'
89
+ }
90
+
91
+ FORMAT = [OpenNebulaHelper::JSON, OpenNebulaHelper::YAML]
92
+
85
93
  # create helper object
86
94
  helper = OneFlowHelper.new
87
95
 
@@ -122,7 +130,7 @@ CommandParser::CmdParser.new(ARGV) do
122
130
  List the available services
123
131
  EOT
124
132
 
125
- command :list, list_desc, :options => OpenNebulaHelper::FORMAT do
133
+ command :list, list_desc, :options => FORMAT do
126
134
  helper.list_service_pool(helper.client(options), options)
127
135
  end
128
136
 
@@ -146,10 +154,7 @@ CommandParser::CmdParser.new(ARGV) do
146
154
  Show detailed information of a given service
147
155
  EOT
148
156
 
149
- command :show,
150
- show_desc,
151
- :service_id,
152
- :options => OpenNebulaHelper::FORMAT do
157
+ command :show, show_desc, :service_id, :options => FORMAT do
153
158
  helper.format_resource(helper.client(options), args[0], options)
154
159
  end
155
160
 
@@ -365,7 +370,11 @@ CommandParser::CmdParser.new(ARGV) do
365
370
  be launched to modify the current content.
366
371
  EOT
367
372
 
368
- command :update, update_desc, :service_id, [:file, nil] do
373
+ command :update,
374
+ update_desc,
375
+ :service_id,
376
+ [:file, nil],
377
+ :options => APPEND do
369
378
  service_id = args[0]
370
379
  client = helper.client(options)
371
380
 
@@ -383,8 +392,10 @@ CommandParser::CmdParser.new(ARGV) do
383
392
  tmp = Tempfile.new(service_id.to_s)
384
393
  path = tmp.path
385
394
 
386
- tmp.write(JSON.pretty_generate(template))
387
- tmp.flush
395
+ unless options[:append]
396
+ tmp.write(JSON.pretty_generate(template))
397
+ tmp.flush
398
+ end
388
399
 
389
400
  if ENV['EDITOR']
390
401
  editor_path = ENV['EDITOR']
@@ -403,7 +414,17 @@ CommandParser::CmdParser.new(ARGV) do
403
414
  end
404
415
  end
405
416
 
406
- response = client.put("#{RESOURCE_PATH}/#{service_id}", File.read(path))
417
+ if options[:append]
418
+ req = {}
419
+ req['append'] = true
420
+ req['template'] = File.read(path)
421
+
422
+ response = client.put("#{RESOURCE_PATH}/#{service_id}",
423
+ req.to_json)
424
+ else
425
+ response = client.put("#{RESOURCE_PATH}/#{service_id}",
426
+ File.read(path))
427
+ end
407
428
 
408
429
  if CloudClient.is_error?(response)
409
430
  [response.code.to_i, response.to_s]
data/bin/oneflow-template CHANGED
@@ -104,6 +104,8 @@ CommandParser::CmdParser.new(ARGV) do
104
104
  'deleting service template'
105
105
  }
106
106
 
107
+ FORMAT = [OpenNebulaHelper::JSON, OpenNebulaHelper::YAML]
108
+
107
109
  usage '`oneflow-template` <command> [<args>] [<options>]'
108
110
  version OpenNebulaHelper::ONE_VERSION
109
111
 
@@ -141,7 +143,7 @@ CommandParser::CmdParser.new(ARGV) do
141
143
  List the available Service Templates
142
144
  EOT
143
145
 
144
- command :list, list_desc, :options => OpenNebulaHelper::FORMAT do
146
+ command :list, list_desc, :options => FORMAT do
145
147
  helper.list_service_template_pool(helper.client(options), options)
146
148
  end
147
149
 
@@ -169,10 +171,7 @@ CommandParser::CmdParser.new(ARGV) do
169
171
  Show detailed information of a given Service Template
170
172
  EOT
171
173
 
172
- command :show,
173
- show_desc,
174
- :templateid,
175
- :options => OpenNebulaHelper::FORMAT do
174
+ command :show, show_desc, :templateid, :options => FORMAT do
176
175
  helper.format_resource(helper.client(options), args[0], options)
177
176
  end
178
177
 
data/bin/onehook CHANGED
@@ -256,8 +256,8 @@ CommandParser::CmdParser.new(ARGV) do
256
256
  end
257
257
 
258
258
  lock_desc = <<-EOT.unindent
259
- Locks a Hook with differents levels for lock any actions with this Hook,
260
- show and monitoring never will be locked.
259
+ Locks a Hook to prevent certain actions defined by different levels.
260
+ The show action will never be locked.
261
261
  Valid states are: All.
262
262
  Levels:
263
263
  [Use]: locks Admin, Manage and Use actions.
data/bin/oneimage CHANGED
@@ -159,9 +159,9 @@ CommandParser::CmdParser.new(ARGV) do
159
159
  - new persistent image, OS type and qcow2 format:
160
160
 
161
161
  oneimage create -d 1 --name ubuntu --path /tmp/ubuntu.qcow2 \\
162
- --prefix sd --type OS --driver qcow2 \\
163
- --description "A OS plain installation \\
164
- --persistent"
162
+ --prefix sd --type OS --format qcow2 \\
163
+ --description "A OS plain installation" \\
164
+ --persistent
165
165
 
166
166
  - a datablock image of 400MB:
167
167
 
@@ -436,8 +436,8 @@ CommandParser::CmdParser.new(ARGV) do
436
436
  end
437
437
 
438
438
  lock_desc = <<-EOT.unindent
439
- Locks a VM with differents levels for lock any actions with this VM, show and
440
- monitoring never will be locked.
439
+ Locks an Image to prevent certain actions defined by different levels.
440
+ The show action will never be locked.
441
441
  Valid states are: All.
442
442
  Levels:
443
443
  [Use]: locks Admin, Manage and Use actions.
@@ -464,7 +464,7 @@ CommandParser::CmdParser.new(ARGV) do
464
464
  end
465
465
 
466
466
  unlock_desc = <<-EOT.unindent
467
- Unlocks a VM for unlock any actions with this VM.
467
+ Unlocks an Image.
468
468
  Valid states are: All.
469
469
  EOT
470
470
 
data/bin/onemarketapp CHANGED
@@ -440,8 +440,8 @@ CommandParser::CmdParser.new(ARGV) do
440
440
  end
441
441
 
442
442
  lock_desc = <<-EOT.unindent
443
- Locks a VM with differents levels for lock any actions with this VM,
444
- show and monitoring never will be locked.
443
+ Locks a marketplace app to prevent certain actions defined by different levels.
444
+ The show action will never be locked.
445
445
  Valid states are: All.
446
446
  Levels:
447
447
  [Use]: locks Admin, Manage and Use actions.
@@ -470,7 +470,7 @@ CommandParser::CmdParser.new(ARGV) do
470
470
  end
471
471
 
472
472
  unlock_desc = <<-EOT.unindent
473
- Unlocks a VM for unlock any actions with this VM.
473
+ Unlocks a marketplace app.
474
474
  Valid states are: All.
475
475
  EOT
476
476
 
data/bin/onetemplate CHANGED
@@ -406,8 +406,8 @@ CommandParser::CmdParser.new(ARGV) do
406
406
  end
407
407
 
408
408
  lock_desc = <<-EOT.unindent
409
- Locks a VM with differents levels for lock any actions with this VM,
410
- show and monitoring never will be locked.
409
+ Locks a Template to prevent certain actions defined by different levels.
410
+ The show action will never be locked.
411
411
  Valid states are: All.
412
412
  Levels:
413
413
  [Use]: locks Admin, Manage and Use actions.
@@ -434,7 +434,7 @@ CommandParser::CmdParser.new(ARGV) do
434
434
  end
435
435
 
436
436
  unlock_desc = <<-EOT.unindent
437
- Unlocks a VM for unlock any actions with this VM.
437
+ Unlocks a Template.
438
438
  Valid states are: All.
439
439
  EOT
440
440
 
data/bin/oneuser CHANGED
@@ -573,7 +573,7 @@ CommandParser::CmdParser.new(ARGV) do
573
573
  EOT
574
574
 
575
575
  command :show, show_desc, [:userid, nil],
576
- :options => OpenNebulaHelper::FORMAT do
576
+ :options => [OpenNebulaHelper::FORMAT, OpenNebulaHelper::DECRYPT] do
577
577
  user = args[0] || OpenNebula::User::SELF
578
578
  helper.show_resource(user, options)
579
579
  end
data/bin/onevcenter CHANGED
@@ -165,7 +165,8 @@ CommandParser::CmdParser.new(ARGV) do
165
165
 
166
166
  command :list,
167
167
  list_desc,
168
- :options => [OBJECT, HOST, DATASTORE, VCENTER, USER, PASS] do
168
+ :options => [OBJECT, HOST, DATASTORE, VCENTER, USER, PASS,
169
+ CLIHelper::CSV_OPT] do
169
170
  begin
170
171
  args = helper.parse_opts(options)
171
172
  args[:filter] = true
@@ -178,7 +179,8 @@ CommandParser::CmdParser.new(ARGV) do
178
179
 
179
180
  helper.list_object(options, list)
180
181
  rescue StandardError => e
181
- puts e.message
182
+ STDERR.puts e.message
183
+ exit 1
182
184
  end
183
185
 
184
186
  exit 0
@@ -209,7 +211,8 @@ CommandParser::CmdParser.new(ARGV) do
209
211
 
210
212
  helper.list_object(options, list)
211
213
  rescue StandardError => e
212
- puts e.message
214
+ STDERR.puts e.message
215
+ exit 1
213
216
  end
214
217
 
215
218
  exit 0
@@ -256,7 +259,8 @@ CommandParser::CmdParser.new(ARGV) do
256
259
 
257
260
  importer.stdout
258
261
  rescue StandardError => e
259
- puts e.message
262
+ STDERR.puts e.message
263
+ exit 1
260
264
  end
261
265
 
262
266
  exit 0
@@ -283,7 +287,8 @@ CommandParser::CmdParser.new(ARGV) do
283
287
 
284
288
  importer.stdout
285
289
  rescue StandardError => e
286
- puts e.message
290
+ STDERR.puts e.message
291
+ exit 1
287
292
  end
288
293
 
289
294
  exit 0
@@ -305,7 +310,11 @@ CommandParser::CmdParser.new(ARGV) do
305
310
  :options => [VCENTER, USER, PASS, USE_DEFAULTS, PORT] do
306
311
  con_ops = helper.connection_options('Hosts', options)
307
312
 
308
- VCenterDriver::VcImporter.import_clusters(con_ops, options)
313
+ begin
314
+ VCenterDriver::VcImporter.import_clusters(con_ops, options)
315
+ rescue StandardError
316
+ exit 1
317
+ end
309
318
 
310
319
  exit 0
311
320
  end
data/bin/onevm CHANGED
@@ -1305,7 +1305,8 @@ CommandParser::CmdParser.new(ARGV) do
1305
1305
  CONTEXT (any value, **variable substitution will be made**)
1306
1306
  EOT
1307
1307
 
1308
- command :updateconf, updateconf_desc, :vmid, [:file, nil] do
1308
+ command :updateconf, updateconf_desc, :vmid, [:file, nil],
1309
+ :options => OpenNebulaHelper::APPEND do
1309
1310
  template = ''
1310
1311
 
1311
1312
  begin
@@ -1332,14 +1333,17 @@ CommandParser::CmdParser.new(ARGV) do
1332
1333
  template = OpenNebulaHelper.editor_input(template)
1333
1334
  end
1334
1335
 
1335
- vm.updateconf(template)
1336
+ vm.updateconf(template, options[:append])
1336
1337
  end
1337
1338
  end
1338
1339
 
1339
1340
  lock_desc = <<-EOT.unindent
1340
- Locks a VM with differents levels for lock any actions with this VM, show and
1341
- monitoring never will be locked.
1341
+ Locks a VM to prevent certain actions defined by different levels.
1342
+ The show and monitoring action will never be locked.
1342
1343
  Valid states are: All.
1344
+ [Use]: locks Admin, Manage and Use actions.
1345
+ [Manage]: locks Manage and Use actions.
1346
+ [Admin]: locks only Admin actions.
1343
1347
  EOT
1344
1348
 
1345
1349
  command :lock, lock_desc, [:range, :vmid_list],
@@ -1361,7 +1365,7 @@ CommandParser::CmdParser.new(ARGV) do
1361
1365
  end
1362
1366
 
1363
1367
  unlock_desc = <<-EOT.unindent
1364
- Unlocks a VM for unlock any actions with this VM.
1368
+ Unlocks a Virtual Machine.
1365
1369
  Valid states are: All.
1366
1370
  EOT
1367
1371
 
@@ -1411,22 +1415,7 @@ CommandParser::CmdParser.new(ARGV) do
1411
1415
 
1412
1416
  command :'delete-chart', delete_chart_desc, :vmid, :sched_id do
1413
1417
  helper.perform_action(args[0], {}, 'Charter deleted') do |vm|
1414
- rc = vm.info
1415
-
1416
- if OpenNebula.is_error?(rc)
1417
- STDERR.puts "Error #{rc.message}"
1418
- exit(-1)
1419
- end
1420
-
1421
- xpath = "USER_TEMPLATE/SCHED_ACTION[ID=#{args[1]}]"
1422
-
1423
- unless vm.retrieve_elements(xpath)
1424
- STDERR.puts "Sched action #{args[1]} not found"
1425
- exit(-1)
1426
- end
1427
-
1428
- vm.delete_element(xpath)
1429
- rc = vm.update(vm.user_template_str)
1418
+ rc = vm.sched_action_delete(args[1])
1430
1419
 
1431
1420
  if OpenNebula.is_error?(rc)
1432
1421
  STDERR.puts "Error deleting: #{rc.message}"
@@ -1571,54 +1560,7 @@ CommandParser::CmdParser.new(ARGV) do
1571
1560
  :vmid,
1572
1561
  [:login, nil],
1573
1562
  :options => [NIC_ID, CMD, SSH_OPTS] do
1574
- helper.perform_action(args[0], options, 'SSH') do |vm|
1575
- rc = vm.info
1576
-
1577
- if OpenNebula.is_error?(rc)
1578
- STDERR.puts rc.message
1579
- exit(-1)
1580
- end
1581
-
1582
- # Get user to login
1583
- args[1].nil? ? login = 'root' : login = args[1]
1584
-
1585
- # Get CMD to run
1586
- options[:cmd].nil? ? cmd = '' : cmd = options[:cmd]
1587
-
1588
- # Get NIC to connect
1589
- if options[:nic_id]
1590
- nic = vm.retrieve_xmlelements(
1591
- "//TEMPLATE/NIC[NIC_ID=\"#{options[:nic_id]}\"]"
1592
- )[0]
1593
- else
1594
- nic = vm.retrieve_xmlelements('//TEMPLATE/NIC[SSH="YES"]')[0]
1595
- end
1596
-
1597
- nic = vm.retrieve_xmlelements('//TEMPLATE/NIC[1]')[0] if nic.nil?
1598
-
1599
- if nic.nil?
1600
- STDERR.puts 'No NIC found'
1601
- exit(-1)
1602
- end
1603
-
1604
- # If there is node port
1605
- if nic['EXTERNAL_PORT_RANGE']
1606
- ip = vm.to_hash['VM']['HISTORY_RECORDS']['HISTORY']
1607
- ip = [ip].flatten[-1]['HOSTNAME']
1608
- port = Integer(nic['EXTERNAL_PORT_RANGE'].split(':')[0]) + 21
1609
- else
1610
- ip = nic['IP']
1611
- port = 22
1612
- end
1613
-
1614
- options[:ssh_opts].nil? ? opts = '' : opts = options[:ssh_opts]
1615
-
1616
- system("ssh #{opts} #{login}@#{ip} -p #{port} #{cmd}")
1617
- end
1618
-
1619
- # rubocop:disable Style/SpecialGlobalVars
1620
- $?.exitstatus
1621
- # rubocop:enable Style/SpecialGlobalVars
1563
+ helper.ssh(args, options)
1622
1564
  end
1623
1565
 
1624
1566
  port_desc = <<-EOT.unindent
data/bin/onevmgroup CHANGED
@@ -233,8 +233,8 @@ CommandParser::CmdParser.new(ARGV) do
233
233
  end
234
234
 
235
235
  lock_desc = <<-EOT.unindent
236
- Locks a VM with differents levels for lock any actions with this VM, show and
237
- monitoring never will be locked.
236
+ Locks a VM Group to prevent certain actions defined by different levels.
237
+ The show action will never be locked.
238
238
  Valid states are: All.
239
239
  Levels:
240
240
  [Use]: locks Admin, Manage and Use actions.
@@ -261,7 +261,7 @@ CommandParser::CmdParser.new(ARGV) do
261
261
  end
262
262
 
263
263
  unlock_desc = <<-EOT.unindent
264
- Unlocks a VM for unlock any actions with this VM.
264
+ Unlocks a VM Group.
265
265
  Valid states are: All.
266
266
  EOT
267
267
 
data/bin/onevnet CHANGED
@@ -381,8 +381,8 @@ CommandParser::CmdParser.new(ARGV) do
381
381
  end
382
382
 
383
383
  lock_desc = <<-EOT.unindent
384
- Locks a VM with differents levels for lock any actions with this VM, show and
385
- monitoring never will be locked.
384
+ Locks a Virtual Network to prevent certain actions defined by different levels.
385
+ The show action will never be locked.
386
386
  Valid states are: All.
387
387
  Levels:
388
388
  [Use]: locks Admin, Manage and Use actions.
@@ -409,7 +409,7 @@ CommandParser::CmdParser.new(ARGV) do
409
409
  end
410
410
 
411
411
  unlock_desc = <<-EOT.unindent
412
- Unlocks a VM for unlock any actions with this VM.
412
+ Unlocks a Virtual Network.
413
413
  Valid states are: All.
414
414
  EOT
415
415
 
data/bin/onevntemplate CHANGED
@@ -341,8 +341,8 @@ CommandParser::CmdParser.new(ARGV) do
341
341
  end
342
342
 
343
343
  lock_desc = <<-EOT.unindent
344
- Locks a VN template with differents levels for lock any actions with this VN template,
345
- show and monitoring never will be locked.
344
+ Locks a VN Template to prevent certain actions defined by different levels.
345
+ The show action will never be locked.
346
346
  Valid states are: All.
347
347
  Levels:
348
348
  [Use]: locks Admin, Manage and Use actions.
@@ -369,7 +369,7 @@ CommandParser::CmdParser.new(ARGV) do
369
369
  end
370
370
 
371
371
  unlock_desc = <<-EOT.unindent
372
- Unlocks a VN template for unlock any actions with this VN template.
372
+ Unlocks a VN Template.
373
373
  Valid states are: All.
374
374
  EOT
375
375
 
data/bin/onevrouter CHANGED
@@ -366,8 +366,8 @@ CommandParser::CmdParser.new(ARGV) do
366
366
  end
367
367
 
368
368
  lock_desc = <<-EOT.unindent
369
- Locks a VM with differents levels for lock any actions with this VM, show and
370
- monitoring never will be locked.
369
+ Locks a Virtual Router to prevent certain actions defined by different levels.
370
+ The show action will never be locked.
371
371
  Valid states are: All.
372
372
  Levels:
373
373
  [Use]: locks Admin, Manage and Use actions.
@@ -394,7 +394,7 @@ CommandParser::CmdParser.new(ARGV) do
394
394
  end
395
395
 
396
396
  unlock_desc = <<-EOT.unindent
397
- Unlocks a VM for unlock any actions with this VM.
397
+ Unlocks a Virtual Router.
398
398
  valid states are: All.
399
399
  EOT
400
400
 
data/bin/onezone CHANGED
@@ -269,4 +269,24 @@ CommandParser::CmdParser.new(ARGV) do
269
269
 
270
270
  0
271
271
  end
272
+
273
+ enable_desc = <<-EOT.unindent
274
+ Enable zone
275
+ EOT
276
+
277
+ command :enable, enable_desc, [:range, :zoneid_list] do
278
+ helper.perform_actions(args[0], options, 'enable zone') do |o|
279
+ o.enable
280
+ end
281
+ end
282
+
283
+ disable_desc = <<-EOT.unindent
284
+ Disable zone, disabled zones can execute only readonly commands
285
+ EOT
286
+
287
+ command :disable, disable_desc, [:range, :zoneid_list] do
288
+ helper.perform_actions(args[0], options, 'disable zone') do |o|
289
+ o.disable
290
+ end
291
+ end
272
292
  end
@@ -216,11 +216,15 @@ class AcctHelper < OpenNebulaHelper::OneHelper
216
216
  d["HOURS"]
217
217
  end
218
218
 
219
+ column :RUNNING_HOURS, "Running hours", :size=>7 do |d|
220
+ d["RHOURS"] || '-'
221
+ end
222
+
219
223
  column :COST, "Cost", :size=>15 do |d|
220
224
  d["TOTAL_COST"]
221
225
  end
222
226
 
223
- default :USER_NAME, :GROUP_NAME, :VM_ID, :VM_NAME, :MONTH, :YEAR, :HOURS, :COST
227
+ default :USER_NAME, :GROUP_NAME, :VM_ID, :VM_NAME, :MONTH, :YEAR, :HOURS, :RUNNING_HOURS, :COST
224
228
  end
225
229
 
226
230
  def self.print_start_end_time_header(start_time, end_time)
@@ -188,14 +188,14 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
188
188
 
189
189
  # This method will print a list for a vcenter_resource.
190
190
  #
191
- def list_object(_options, list)
191
+ def list_object(options, list)
192
192
  vcenter_host = list.keys[0]
193
193
  list = cli_format(list.values.first)
194
194
  table = format_list
195
195
 
196
196
  show_header(vcenter_host)
197
197
 
198
- table.show(list)
198
+ table.show(list, options)
199
199
  end
200
200
 
201
201
  # handles :cli section of TABLE
@@ -493,10 +493,11 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
493
493
 
494
494
  keys_to_remove = []
495
495
  vm['config.extraConfig'].each do |extraconfig|
496
- if extraconfig.key.include?('opennebula.disk') ||
497
- extraconfig.key.include?('opennebula.vm')
498
- keys_to_remove << extraconfig.key
499
- end
496
+ next unless extraconfig.key.include?('opennebula.disk') ||
497
+ extraconfig.key.include?('opennebula.vm') ||
498
+ extraconfig.key.downcase.include?('remotedisplay')
499
+
500
+ keys_to_remove << extraconfig.key
500
501
  end
501
502
 
502
503
  [vm, keys_to_remove]