opennebula-cli 5.10.5 → 5.12.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/bin/oneacct +4 -2
  3. data/bin/oneacl +4 -2
  4. data/bin/onecluster +4 -2
  5. data/bin/onedatastore +4 -2
  6. data/bin/oneflow +151 -552
  7. data/bin/oneflow-template +173 -293
  8. data/bin/onegroup +4 -2
  9. data/bin/onehook +4 -2
  10. data/bin/onehost +78 -10
  11. data/bin/oneimage +4 -2
  12. data/bin/onemarket +4 -2
  13. data/bin/onemarketapp +17 -4
  14. data/bin/onesecgroup +4 -2
  15. data/bin/oneshowback +4 -2
  16. data/bin/onetemplate +4 -2
  17. data/bin/oneuser +4 -2
  18. data/bin/onevcenter +4 -2
  19. data/bin/onevdc +4 -2
  20. data/bin/onevm +170 -17
  21. data/bin/onevmgroup +4 -2
  22. data/bin/onevnet +16 -41
  23. data/bin/onevntemplate +4 -2
  24. data/bin/onevrouter +4 -2
  25. data/bin/onezone +7 -2
  26. data/lib/cli_helper.rb +54 -30
  27. data/lib/command_parser.rb +53 -19
  28. data/lib/one_helper.rb +258 -6
  29. data/lib/one_helper/oneacct_helper.rb +1 -1
  30. data/lib/one_helper/oneacl_helper.rb +1 -1
  31. data/lib/one_helper/onecluster_helper.rb +4 -4
  32. data/lib/one_helper/onedatastore_helper.rb +1 -1
  33. data/lib/one_helper/oneflow_helper.rb +423 -0
  34. data/lib/one_helper/oneflowtemplate_helper.rb +312 -0
  35. data/lib/one_helper/onegroup_helper.rb +1 -1
  36. data/lib/one_helper/onehook_helper.rb +1 -1
  37. data/lib/one_helper/onehost_helper.rb +148 -68
  38. data/lib/one_helper/oneimage_helper.rb +2 -2
  39. data/lib/one_helper/onemarket_helper.rb +1 -1
  40. data/lib/one_helper/onemarketapp_helper.rb +1 -1
  41. data/lib/one_helper/oneprovision_helper.rb +104 -60
  42. data/lib/one_helper/onequota_helper.rb +1 -1
  43. data/lib/one_helper/onesecgroup_helper.rb +1 -1
  44. data/lib/one_helper/onetemplate_helper.rb +9 -180
  45. data/lib/one_helper/oneuser_helper.rb +1 -1
  46. data/lib/one_helper/onevcenter_helper.rb +5 -4
  47. data/lib/one_helper/onevdc_helper.rb +1 -1
  48. data/lib/one_helper/onevm_helper.rb +117 -21
  49. data/lib/one_helper/onevmgroup_helper.rb +1 -1
  50. data/lib/one_helper/onevnet_helper.rb +66 -2
  51. data/lib/one_helper/onevntemplate_helper.rb +1 -1
  52. data/lib/one_helper/onevrouter_helper.rb +1 -1
  53. data/lib/one_helper/onezone_helper.rb +3 -1
  54. metadata +8 -6
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,6 +1,6 @@
1
1
 
2
2
  # -------------------------------------------------------------------------- #
3
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
3
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
4
4
  # #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
6
6
  # not use this file except in compliance with the License. You may obtain #
@@ -96,6 +96,7 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
96
96
  end
97
97
 
98
98
  def host(arg)
99
+ return arg
99
100
  end
100
101
 
101
102
  ########################
@@ -236,11 +237,11 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
236
237
  d[:import_id]
237
238
  end
238
239
 
239
- column :REF, "ref", :left, :size=>config[:REF] || 15 do |d|
240
+ column :REF, "ref", :left, :adjust, :size=>config[:REF] || 15 do |d|
240
241
  d[:ref]
241
242
  end
242
243
 
243
- column :NAME, "Name", :left, :size=>config[:NAME] || 20 do |d|
244
+ column :NAME, "Name", :left, :expand, :size=>config[:NAME] || 20 do |d|
244
245
  d[:name] || d[:simple_name]
245
246
  end
246
247
 
@@ -249,7 +250,7 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
249
250
  d[:one_ids] || d[:cluster].to_s
250
251
  end
251
252
 
252
- column :PATH, "PATH", :left, :size=>config[:PATH] || 10 do |d|
253
+ column :PATH, "PATH", :left, :expand, :size=>config[:PATH] || 10 do |d|
253
254
  d[:path]
254
255
  end
255
256
 
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -345,16 +345,16 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
345
345
  OneVMHelper.state_to_str(d['STATE'], d['LCM_STATE'])
346
346
  end
347
347
 
348
- column :UCPU, 'CPU percentage used by the VM', :size => 4 do |d|
349
- cpu = d['MONITORING']['CPU']
348
+ column :CPU, 'CPU asigned to the VM', :size => 4 do |d|
349
+ cpu = d['TEMPLATE']['CPU']
350
350
  cpu = '0' if cpu.nil?
351
351
 
352
352
  cpu
353
353
  end
354
354
 
355
- column :UMEM, 'Memory used by the VM', :size => 7 do |d|
356
- OpenNebulaHelper.unit_to_str(d['MONITORING']['MEMORY'].to_i,
357
- options)
355
+ column :MEM, 'Memory asigned to the VM', :size => 7 do |d|
356
+ OpenNebulaHelper.unit_to_str(d['TEMPLATE']['MEMORY'].to_i,
357
+ options, 'M')
358
358
  end
359
359
 
360
360
  column :HOST, 'Host where the VM is running',
@@ -395,14 +395,14 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
395
395
  OneVMHelper.ip_str(d)
396
396
  end
397
397
 
398
- default :ID, :USER, :GROUP, :NAME, :STAT, :UCPU, :UMEM, :HOST,
398
+ default :ID, :USER, :GROUP, :NAME, :STAT, :CPU, :MEM, :HOST,
399
399
  :TIME
400
400
  end
401
401
 
402
402
  table
403
403
  end
404
404
 
405
- def schedule_actions(ids, options, action)
405
+ def schedule_actions(ids, options, action, warning = nil)
406
406
  # Verbose by default
407
407
  options[:verbose] = true
408
408
 
@@ -453,17 +453,74 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
453
453
  id = ids.max + 1
454
454
  end
455
455
 
456
+ sched = options[:schedule]
457
+
458
+ # If the action is set to be executed from VM start to an specific
459
+ # amount of time later, we should preserve the + symbol
460
+ if ((sched.is_a? String) && !sched.include?('+')) ||
461
+ !(sched.is_a? String)
462
+ sched = sched.to_i
463
+ end
464
+
456
465
  tmp_str = vm.user_template_str
457
466
 
458
467
  tmp_str << "\nSCHED_ACTION = "
459
468
  tmp_str << "[ID = #{id}, ACTION = #{action}, "
460
- tmp_str << "TIME = #{options[:schedule].to_i}"
469
+ tmp_str << "WARNING = #{warning}," if warning
470
+ tmp_str << "ARGS = \"#{options[:args]}\"," if options[:args]
471
+ tmp_str << "TIME = #{sched}"
461
472
  tmp_str << str_periodic << ']'
462
473
 
463
474
  vm.update(tmp_str)
464
475
  end
465
476
  end
466
477
 
478
+ # Update schedule action
479
+ #
480
+ # @param vm_id [Integer] Virtual Machine ID
481
+ # @param action_id [Integer] Sched action ID
482
+ # @param file [String] File path with update content
483
+ def update_schedule_action(vm_id, action_id, file)
484
+ perform_action(vm_id, {}, 'Sched action updated') do |vm|
485
+ rc = vm.info
486
+
487
+ if OpenNebula.is_error?(rc)
488
+ STDERR.puts "Error #{rc.message}"
489
+ exit(-1)
490
+ end
491
+
492
+ xpath = "USER_TEMPLATE/SCHED_ACTION[ID=#{action_id}]"
493
+
494
+ unless vm.retrieve_elements(xpath)
495
+ STDERR.puts "Sched action #{action_id} not found"
496
+ exit(-1)
497
+ end
498
+
499
+ # Get user information
500
+ if file
501
+ str = File.read(file)
502
+ else
503
+ str = OpenNebulaHelper.update_template(vm_id, vm, nil, xpath)
504
+ end
505
+
506
+ # Delete the current sched action
507
+ vm.delete_element(xpath)
508
+
509
+ # Add the modified sched action
510
+ tmp_str = vm.user_template_str
511
+ tmp_str << "\nSCHED_ACTION = ["
512
+ tmp_str << str.split("\n").join(',')
513
+ tmp_str << ']'
514
+
515
+ rc = vm.update(tmp_str)
516
+
517
+ if OpenNebula.is_error?(rc)
518
+ STDERR.puts "Error updating: #{rc.message}"
519
+ exit(-1)
520
+ end
521
+ end
522
+ end
523
+
467
524
  RECOVER_RETRY_STEPS = {
468
525
  :PROLOG_MIGRATE_FAILURE => :migrate,
469
526
  :PROLOG_MIGRATE_POWEROFF_FAILURE => :migrate,
@@ -601,6 +658,16 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
601
658
  end
602
659
  end
603
660
 
661
+ # Get charters configuration
662
+ #
663
+ # @return [Array]
664
+ # - action
665
+ # - time
666
+ # - warning
667
+ def get_charters
668
+ YAML.load_file(self.class.table_conf)[:charters]
669
+ end
670
+
604
671
  private
605
672
 
606
673
  def factory(id = nil)
@@ -1143,20 +1210,24 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
1143
1210
  CLIHelper.print_header(str_h1 % 'SCHEDULED ACTIONS', false)
1144
1211
 
1145
1212
  CLIHelper::ShowTable.new(nil, self) do
1146
- column :ID, '', :size => 2 do |d|
1213
+ column :ID, '', :adjust => true do |d|
1147
1214
  d['ID'] unless d.nil?
1148
1215
  end
1149
1216
 
1150
- column :ACTION, '', :left, :size => 15 do |d|
1217
+ column :ACTION, '', :adjust => true do |d|
1151
1218
  d['ACTION'] unless d.nil?
1152
1219
  end
1153
1220
 
1154
- column :SCHEDULED, '', :size => 12 do |d|
1221
+ column :ARGS, '', :adjust => true do |d|
1222
+ d['ARGS'] ? d['ARGS'] : '-'
1223
+ end
1224
+
1225
+ column :SCHEDULED, '', :adjust => true do |d|
1155
1226
  OpenNebulaHelper.time_to_str(d['TIME'], false) \
1156
1227
  unless d.nil?
1157
1228
  end
1158
1229
 
1159
- column :REPEAT, '', :size => 20 do |d|
1230
+ column :REPEAT, '', :adjust => true do |d|
1160
1231
  str_rep = ''
1161
1232
  if !d.nil? && d.key?('REPEAT')
1162
1233
  if d['REPEAT'] == '0'
@@ -1175,7 +1246,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
1175
1246
  str_rep unless d.nil?
1176
1247
  end
1177
1248
 
1178
- column :END, '', :size => 20 do |d|
1249
+ column :END, '', :adjust => true do |d|
1179
1250
  str_end = ''
1180
1251
  if !d.nil? && d.key?('END_TYPE')
1181
1252
  if d['END_TYPE'] == '0'
@@ -1192,25 +1263,50 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
1192
1263
  str_end unless d.nil?
1193
1264
  end
1194
1265
 
1195
- column :DONE, '', :size => 12 do |d|
1266
+ column :DONE, '', :adjust => true do |d|
1196
1267
  OpenNebulaHelper.time_to_str(d['DONE'], false) \
1197
1268
  unless d.nil?
1198
1269
  end
1199
1270
 
1200
- column :MESSAGE, '', :left, :adjust, :size => 35 do |d|
1201
- d['MESSAGE'] unless d.nil?
1271
+ column :MESSAGE, '', :size => 35 do |d|
1272
+ d['MESSAGE'] ? d['MESSAGE'] : '-'
1273
+ end
1274
+
1275
+ column :CHARTER, '', :left, :adjust, :size => 15 do |d|
1276
+ t1 = Time.now
1277
+ t2 = Time.at(vm['STIME'].to_i + d['TIME'].to_i)
1278
+
1279
+ days = ((t2 - t1) / (24 * 3600)).round(2)
1280
+ hours = ((t2 - t1) / 3600).round(2)
1281
+ minutes = ((t2 - t1) / 60).round(2)
1282
+
1283
+ if days > 1
1284
+ show = "In #{days} days"
1285
+ elsif days < 1 && hours > 1
1286
+ show = "In #{hours} hours"
1287
+ elsif minutes > 0
1288
+ show = "In #{minutes} minutes"
1289
+ else
1290
+ show = 'Already done'
1291
+ end
1292
+
1293
+ if (t1 - vm['STIME'].to_i).to_i > d['WARNING'].to_i
1294
+ "#{show} *"
1295
+ else
1296
+ show
1297
+ end
1202
1298
  end
1203
1299
  end.show([vm_hash['VM']['USER_TEMPLATE']['SCHED_ACTION']].flatten,
1204
1300
  {})
1205
1301
  end
1206
1302
 
1303
+ if !options[:all]
1304
+ vm.delete_element('/VM/USER_TEMPLATE/SCHED_ACTION')
1305
+ end
1306
+
1207
1307
  if vm.has_elements?('/VM/USER_TEMPLATE')
1208
1308
  puts
1209
1309
 
1210
- if !options[:all]
1211
- vm.delete_element('/VM/USER_TEMPLATE/SCHED_ACTION')
1212
- end
1213
-
1214
1310
  CLIHelper.print_header(str_h1 % 'USER TEMPLATE', false)
1215
1311
  puts vm.template_like_str('USER_TEMPLATE')
1216
1312
  end
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -13,7 +13,6 @@
13
13
  # See the License for the specific language governing permissions and #
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
-
17
16
  require 'one_helper'
18
17
  require 'one_helper/onevm_helper'
19
18
 
@@ -215,6 +214,71 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
215
214
  orphans
216
215
  end
217
216
 
217
+ # Update VNet address range
218
+ #
219
+ # @param vnet_id [Intenger] Virtual Network ID
220
+ # @param ar_id [Intenger] Address Range ID
221
+ # @param file [String] Path to file to read
222
+ # @param options [Hash] User CLI options
223
+ def update_ar(vnet_id, ar_id, file, options)
224
+ perform_action(vnet_id, options, 'AR updated') do |obj|
225
+ rc = obj.info
226
+
227
+ if OpenNebula.is_error?(rc)
228
+ STDERR.puts rc.message
229
+ exit(-1)
230
+ end
231
+
232
+ obj.delete_element("AR_POOL/AR[AR_ID!=#{ar_id}]")
233
+ obj.delete_element('AR_POOL/AR/LEASES')
234
+ obj.delete_element('AR_POOL/AR/USED_LEASES')
235
+ obj.delete_element('AR_POOL/AR/MAC_END')
236
+ obj.delete_element('AR_POOL/AR/IP_END')
237
+ obj.delete_element('AR_POOL/AR/IP6_ULA')
238
+ obj.delete_element('AR_POOL/AR/IP6_ULA_END')
239
+ obj.delete_element('AR_POOL/AR/IP6_GLOBAL')
240
+ obj.delete_element('AR_POOL/AR/IP6_GLOBAL_END')
241
+
242
+ if obj.template_like_str('AR_POOL').empty?
243
+ STDERR.puts "Address Range #{ar_id} does not exist for " \
244
+ "Virtual Network #{vnet_id}"
245
+ exit(-1)
246
+ end
247
+
248
+ xpath = "AR_POOL/AR[AR_ID=#{ar_id}]"
249
+
250
+ if options[:append]
251
+ str = OpenNebulaHelper.append_template(vnet_id,
252
+ obj,
253
+ file,
254
+ xpath)
255
+ else
256
+ str = OpenNebulaHelper.update_template(vnet_id,
257
+ obj,
258
+ file,
259
+ xpath)
260
+ end
261
+
262
+ if options[:append]
263
+ # Insert element in current template
264
+ parts = obj.template_like_str('AR_POOL').split("\n")
265
+
266
+ # Insert it in second position, OpenNebula will sort it
267
+ parts.insert(1, "#{str.strip},")
268
+
269
+ parts = parts.join("\n")
270
+ str = parts
271
+ else
272
+ # Use the information from user
273
+ unless str.gsub(' ', '').match(/AR=\[/)
274
+ str = "AR=[\n#{str.split("\n").join(",\n")}]"
275
+ end
276
+ end
277
+
278
+ obj.update_ar(str)
279
+ end
280
+ end
281
+
218
282
  private
219
283
 
220
284
  def factory(id=nil)
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -36,6 +36,8 @@ class Replicator
36
36
  :service => 'opennebula' },
37
37
  { :name => 'ec2_driver.default',
38
38
  :service => 'opennebula' },
39
+ { :name => 'monitord.conf',
40
+ :service => 'opennebula' },
39
41
  { :name => 'econe.conf',
40
42
  :service => 'opennebula-econe' },
41
43
  { :name => 'oneflow-server.conf',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opennebula-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.10.5
4
+ version: 5.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-05 00:00:00.000000000 Z
11
+ date: 2020-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opennebula
@@ -16,16 +16,16 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.10.5
19
+ version: 5.12.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.10.5
26
+ version: 5.12.1
27
27
  description: Commands used to talk to OpenNebula
28
- email: contact@opennebula.org
28
+ email: contact@opennebula.io
29
29
  executables:
30
30
  - oneacct
31
31
  - oneacl
@@ -85,6 +85,8 @@ files:
85
85
  - lib/one_helper/oneacl_helper.rb
86
86
  - lib/one_helper/onecluster_helper.rb
87
87
  - lib/one_helper/onedatastore_helper.rb
88
+ - lib/one_helper/oneflow_helper.rb
89
+ - lib/one_helper/oneflowtemplate_helper.rb
88
90
  - lib/one_helper/onegroup_helper.rb
89
91
  - lib/one_helper/onehook_helper.rb
90
92
  - lib/one_helper/onehost_helper.rb
@@ -106,7 +108,7 @@ files:
106
108
  - lib/one_helper/onezone_helper.rb
107
109
  - NOTICE
108
110
  - LICENSE
109
- homepage: http://opennebula.org
111
+ homepage: http://opennebula.io
110
112
  licenses:
111
113
  - Apache-2.0
112
114
  metadata: {}