opennebula-cli 6.6.3 → 6.7.80.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/onebackupjob +373 -0
- data/bin/onedatastore +6 -3
- data/bin/oneflow-template +24 -6
- data/bin/oneimage +8 -3
- data/bin/onemarket +5 -3
- data/bin/onemarketapp +5 -1
- data/bin/onetemplate +15 -8
- data/bin/onevm +113 -144
- data/bin/onevmgroup +64 -1
- data/bin/onevnet +6 -3
- data/bin/onevrouter +21 -15
- data/lib/command_parser.rb +2 -9
- data/lib/one_helper/oneacl_helper.rb +6 -4
- data/lib/one_helper/onebackupjob_helper.rb +284 -0
- data/lib/one_helper/onevm_helper.rb +7 -188
- data/lib/one_helper/onevmgroup_helper.rb +15 -0
- data/lib/one_helper.rb +301 -0
- data/share/schemas/xsd/acct.xsd +2 -19
- data/share/schemas/xsd/backupjob.xsd +42 -0
- data/share/schemas/xsd/backupjob_pool.xsd +12 -0
- data/share/schemas/xsd/index.xsd +3 -0
- data/share/schemas/xsd/opennebula_configuration.xsd +3 -0
- data/share/schemas/xsd/shared.xsd +46 -0
- data/share/schemas/xsd/vm.xsd +18 -47
- data/share/schemas/xsd/vm_group.xsd +1 -0
- metadata +12 -6
data/bin/onevm
CHANGED
@@ -349,7 +349,9 @@ CommandParser::CmdParser.new(ARGV) do
|
|
349
349
|
number = options[:multiple] || 1
|
350
350
|
exit_code = nil
|
351
351
|
|
352
|
-
if args[0]
|
352
|
+
if (args[0] || STDIN.wait_readable(0)) &&
|
353
|
+
OpenNebulaHelper.create_template_options_used?(options)
|
354
|
+
|
353
355
|
STDERR.puts 'You can not use both template file and template'\
|
354
356
|
' creation options.'
|
355
357
|
exit(-1)
|
@@ -358,6 +360,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
358
360
|
begin
|
359
361
|
if args[0]
|
360
362
|
template = File.read(args[0])
|
363
|
+
elsif STDIN.wait_readable(0)
|
364
|
+
template = STDIN.read
|
361
365
|
else
|
362
366
|
res = OpenNebulaHelper.create_template(options)
|
363
367
|
|
@@ -422,12 +426,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
422
426
|
EOT
|
423
427
|
|
424
428
|
command :hold, hold_desc, [:range, :vmid_list],
|
425
|
-
:options =>
|
426
|
-
OneVMHelper::WEEKLY,
|
427
|
-
OneVMHelper::MONTHLY,
|
428
|
-
OneVMHelper::YEARLY,
|
429
|
-
OneVMHelper::HOURLY,
|
430
|
-
OneVMHelper::END_TIME] do
|
429
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS do
|
431
430
|
if !options[:schedule].nil?
|
432
431
|
helper.schedule_actions(args[0], options, @comm_name)
|
433
432
|
else
|
@@ -444,12 +443,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
444
443
|
EOT
|
445
444
|
|
446
445
|
command :release, release_desc, [:range, :vmid_list],
|
447
|
-
:options =>
|
448
|
-
OneVMHelper::WEEKLY,
|
449
|
-
OneVMHelper::MONTHLY,
|
450
|
-
OneVMHelper::YEARLY,
|
451
|
-
OneVMHelper::HOURLY,
|
452
|
-
OneVMHelper::END_TIME] do
|
446
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS do
|
453
447
|
if !options[:schedule].nil?
|
454
448
|
helper.schedule_actions(args[0], options, @comm_name)
|
455
449
|
else
|
@@ -512,13 +506,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
512
506
|
EOT
|
513
507
|
|
514
508
|
command :terminate, terminate_desc, [:range, :vmid_list],
|
515
|
-
:options =>
|
516
|
-
|
517
|
-
OneVMHelper::MONTHLY,
|
518
|
-
OneVMHelper::YEARLY,
|
519
|
-
OneVMHelper::HOURLY,
|
520
|
-
OneVMHelper::END_TIME,
|
521
|
-
OneVMHelper::HARD] do
|
509
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS +
|
510
|
+
[OneVMHelper::HARD] do
|
522
511
|
command_name = 'terminate'
|
523
512
|
command_name << '-hard' if options[:hard]
|
524
513
|
|
@@ -540,13 +529,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
540
529
|
EOT
|
541
530
|
|
542
531
|
command :undeploy, undeploy_desc, [:range, :vmid_list],
|
543
|
-
:options =>
|
544
|
-
|
545
|
-
OneVMHelper::MONTHLY,
|
546
|
-
OneVMHelper::YEARLY,
|
547
|
-
OneVMHelper::HOURLY,
|
548
|
-
OneVMHelper::END_TIME,
|
549
|
-
OneVMHelper::HARD] do
|
532
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS +
|
533
|
+
[OneVMHelper::HARD] do
|
550
534
|
command_name = 'undeploy'
|
551
535
|
command_name << '-hard' if options[:hard]
|
552
536
|
|
@@ -567,13 +551,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
567
551
|
EOT
|
568
552
|
|
569
553
|
command :poweroff, poweroff_desc, [:range, :vmid_list],
|
570
|
-
:options =>
|
571
|
-
|
572
|
-
OneVMHelper::MONTHLY,
|
573
|
-
OneVMHelper::YEARLY,
|
574
|
-
OneVMHelper::HOURLY,
|
575
|
-
OneVMHelper::END_TIME,
|
576
|
-
OneVMHelper::HARD] do
|
554
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS +
|
555
|
+
[OneVMHelper::HARD] do
|
577
556
|
command_name = 'poweroff'
|
578
557
|
command_name << '-hard' if options[:hard]
|
579
558
|
|
@@ -596,13 +575,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
596
575
|
EOT
|
597
576
|
|
598
577
|
command :reboot, reboot_desc, [:range, :vmid_list],
|
599
|
-
:options =>
|
600
|
-
|
601
|
-
OneVMHelper::MONTHLY,
|
602
|
-
OneVMHelper::YEARLY,
|
603
|
-
OneVMHelper::HOURLY,
|
604
|
-
OneVMHelper::END_TIME,
|
605
|
-
OneVMHelper::HARD] do
|
578
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS +
|
579
|
+
[OneVMHelper::HARD] do
|
606
580
|
command_name = 'reboot'
|
607
581
|
command_name << '-hard' if options[:hard]
|
608
582
|
|
@@ -620,6 +594,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
620
594
|
deployment, in a standard installation the Scheduler is in charge
|
621
595
|
of this decision
|
622
596
|
|
597
|
+
#{OpenNebulaHelper::TEMPLATE_INPUT}
|
598
|
+
|
623
599
|
States: PENDING, HOLD, STOPPED, UNDEPLOYED
|
624
600
|
EOT
|
625
601
|
|
@@ -628,7 +604,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
628
604
|
[:range, :vmid_list],
|
629
605
|
:hostid,
|
630
606
|
[:datastoreid, nil],
|
631
|
-
:options => [ENFORCE,
|
607
|
+
:options => [ENFORCE, OpenNebulaHelper::FILE] do
|
632
608
|
host_id = args[1]
|
633
609
|
verbose = "deploying in host #{host_id}"
|
634
610
|
|
@@ -639,6 +615,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
639
615
|
|
640
616
|
if options[:file]
|
641
617
|
extra_template = File.read(options[:file])
|
618
|
+
elsif STDIN.wait_readable(0)
|
619
|
+
extra_template = STDIN.read
|
642
620
|
end
|
643
621
|
|
644
622
|
helper.perform_actions(args[0], options, verbose) do |vm|
|
@@ -680,12 +658,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
680
658
|
EOT
|
681
659
|
|
682
660
|
command :stop, stop_desc, [:range, :vmid_list],
|
683
|
-
:options =>
|
684
|
-
OneVMHelper::WEEKLY,
|
685
|
-
OneVMHelper::MONTHLY,
|
686
|
-
OneVMHelper::YEARLY,
|
687
|
-
OneVMHelper::HOURLY,
|
688
|
-
OneVMHelper::END_TIME] do
|
661
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS do
|
689
662
|
if !options[:schedule].nil?
|
690
663
|
helper.schedule_actions(args[0], options, @comm_name)
|
691
664
|
else
|
@@ -705,12 +678,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
705
678
|
EOT
|
706
679
|
|
707
680
|
command :suspend, suspend_desc, [:range, :vmid_list],
|
708
|
-
:options =>
|
709
|
-
OneVMHelper::WEEKLY,
|
710
|
-
OneVMHelper::MONTHLY,
|
711
|
-
OneVMHelper::YEARLY,
|
712
|
-
OneVMHelper::HOURLY,
|
713
|
-
OneVMHelper::END_TIME] do
|
681
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS do
|
714
682
|
if !options[:schedule].nil?
|
715
683
|
helper.schedule_actions(args[0], options, @comm_name)
|
716
684
|
else
|
@@ -727,12 +695,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
727
695
|
EOT
|
728
696
|
|
729
697
|
command :resume, resume_desc, [:range, :vmid_list],
|
730
|
-
:options =>
|
731
|
-
OneVMHelper::WEEKLY,
|
732
|
-
OneVMHelper::MONTHLY,
|
733
|
-
OneVMHelper::YEARLY,
|
734
|
-
OneVMHelper::HOURLY,
|
735
|
-
OneVMHelper::END_TIME] do
|
698
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS do
|
736
699
|
if !options[:schedule].nil?
|
737
700
|
helper.schedule_actions(args[0], options, @comm_name)
|
738
701
|
else
|
@@ -799,25 +762,21 @@ CommandParser::CmdParser.new(ARGV) do
|
|
799
762
|
end
|
800
763
|
|
801
764
|
disk_attach_desc = <<-EOT.unindent
|
802
|
-
Attaches a disk to a running VM.
|
803
|
-
|
765
|
+
Attaches a disk to a running VM.
|
766
|
+
|
767
|
+
#{OneVMHelper.template_input_help('DISK')}
|
804
768
|
|
805
769
|
States: RUNNING, POWEROFF
|
806
770
|
EOT
|
807
771
|
|
808
772
|
command :"disk-attach", disk_attach_desc, :vmid,
|
809
|
-
:options => [
|
773
|
+
:options => [OpenNebulaHelper::FILE, OneVMHelper::IMAGE,
|
810
774
|
TARGET, CACHE, DISCARD, PREFIX] do
|
811
|
-
if options[:file].nil? && options[:image].nil?
|
812
|
-
STDERR.puts 'Provide a template file or an image:'
|
813
|
-
STDERR.puts '\t--file <file>'
|
814
|
-
STDERR.puts '\t--image <image>'
|
815
|
-
exit(-1)
|
816
|
-
end
|
817
|
-
|
818
775
|
if options[:file]
|
819
776
|
template = File.read(options[:file])
|
820
|
-
|
777
|
+
elsif STDIN.wait_readable(0)
|
778
|
+
template = STDIN.read
|
779
|
+
elsif options[:image]
|
821
780
|
image_id = options[:image]
|
822
781
|
target = options[:target]
|
823
782
|
prefix = options[:prefix]
|
@@ -839,6 +798,11 @@ CommandParser::CmdParser.new(ARGV) do
|
|
839
798
|
end
|
840
799
|
|
841
800
|
template << ' ]'
|
801
|
+
else
|
802
|
+
STDERR.puts 'Provide a template or an image:'
|
803
|
+
STDERR.puts '\t--file <file>'
|
804
|
+
STDERR.puts '\t--image <image>'
|
805
|
+
exit(-1)
|
842
806
|
end
|
843
807
|
|
844
808
|
helper.perform_action(args[0], options, 'Attaching disk') do |vm|
|
@@ -861,37 +825,35 @@ CommandParser::CmdParser.new(ARGV) do
|
|
861
825
|
end
|
862
826
|
|
863
827
|
nic_attach_desc = <<-EOT.unindent
|
864
|
-
Attaches a NIC to a VM.
|
828
|
+
Attaches a NIC to a VM.
|
829
|
+
|
830
|
+
To attach a nic alias
|
831
|
+
#{OneVMHelper.template_input_help('NIC')}
|
865
832
|
|
866
833
|
To hotplug a PCI device and use it as a NIC interface in the VM select
|
867
834
|
it with --pci (short_address) or --pci_device (device ID),
|
868
835
|
--pci_class (class ID) and/or --pci_vendor (vendor ID).
|
869
836
|
|
870
|
-
To attach a nic alias, use --file or --alias option.
|
871
|
-
|
872
837
|
States: RUNNING, POWEROFF
|
873
838
|
EOT
|
874
839
|
|
875
840
|
command :"nic-attach", nic_attach_desc, :vmid,
|
876
|
-
:options => [
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
STDERR.puts "\t--file <file>"
|
888
|
-
STDERR.puts "\t--network <network>"
|
889
|
-
exit(-1)
|
890
|
-
end
|
891
|
-
|
841
|
+
:options => [
|
842
|
+
OpenNebulaHelper::FILE,
|
843
|
+
OneVMHelper::NETWORK,
|
844
|
+
OneVMHelper::IP,
|
845
|
+
OneVMHelper::ALIAS,
|
846
|
+
OneVMHelper::NIC_NAME,
|
847
|
+
PCI,
|
848
|
+
PCI_CLASS,
|
849
|
+
PCI_VENDOR,
|
850
|
+
PCI_DEVICE
|
851
|
+
] do
|
892
852
|
if options[:file]
|
893
853
|
template = File.read(options[:file])
|
894
|
-
|
854
|
+
elsif STDIN.wait_readable(0)
|
855
|
+
template = STDIN.read
|
856
|
+
elsif options[:network]
|
895
857
|
network_id = options[:network]
|
896
858
|
ip = options[:ip]
|
897
859
|
nic_alias = options[:alias]
|
@@ -923,6 +885,11 @@ CommandParser::CmdParser.new(ARGV) do
|
|
923
885
|
template << ", IP = #{ip}" if ip
|
924
886
|
template << ", NAME = #{nic_name}" if nic_name
|
925
887
|
template << ']'
|
888
|
+
else
|
889
|
+
STDERR.puts 'Provide a network or a template:'
|
890
|
+
STDERR.puts "\t--file <file>"
|
891
|
+
STDERR.puts "\t--network <network>"
|
892
|
+
exit(-1)
|
926
893
|
end
|
927
894
|
|
928
895
|
helper.perform_action(args[0], options, 'Attaching NIC') do |vm|
|
@@ -1084,12 +1051,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1084
1051
|
EOT
|
1085
1052
|
|
1086
1053
|
command :"snapshot-create", snapshot_create_desc, [:range, :vmid_list],
|
1087
|
-
[:name, nil], :options =>
|
1088
|
-
OneVMHelper::WEEKLY,
|
1089
|
-
OneVMHelper::MONTHLY,
|
1090
|
-
OneVMHelper::YEARLY,
|
1091
|
-
OneVMHelper::HOURLY,
|
1092
|
-
OneVMHelper::END_TIME] do
|
1054
|
+
[:name, nil], :options => OpenNebulaHelper::SCHEDULE_OPTIONS do
|
1093
1055
|
if !options[:schedule].nil?
|
1094
1056
|
# add name as an argument
|
1095
1057
|
options[:args] = args[1]
|
@@ -1108,12 +1070,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1108
1070
|
EOT
|
1109
1071
|
|
1110
1072
|
command :"snapshot-revert", snapshot_revert_desc, :vmid, :snapshot_id,
|
1111
|
-
:options =>
|
1112
|
-
OneVMHelper::WEEKLY,
|
1113
|
-
OneVMHelper::MONTHLY,
|
1114
|
-
OneVMHelper::YEARLY,
|
1115
|
-
OneVMHelper::HOURLY,
|
1116
|
-
OneVMHelper::END_TIME] do
|
1073
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS do
|
1117
1074
|
if !options[:schedule].nil?
|
1118
1075
|
# add snap ID as an argument
|
1119
1076
|
options[:args] = args[1]
|
@@ -1132,12 +1089,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1132
1089
|
EOT
|
1133
1090
|
|
1134
1091
|
command :"snapshot-delete", snapshot_delete_desc, :vmid, :snapshot_id,
|
1135
|
-
:options =>
|
1136
|
-
OneVMHelper::WEEKLY,
|
1137
|
-
OneVMHelper::MONTHLY,
|
1138
|
-
OneVMHelper::YEARLY,
|
1139
|
-
OneVMHelper::HOURLY,
|
1140
|
-
OneVMHelper::END_TIME] do
|
1092
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS do
|
1141
1093
|
if !options[:schedule].nil?
|
1142
1094
|
# add snap ID as an argument
|
1143
1095
|
options[:args] = args[1]
|
@@ -1159,12 +1111,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1159
1111
|
|
1160
1112
|
command :"disk-snapshot-create", disk_snapshot_create_desc,
|
1161
1113
|
:vmid, :diskid, :name,
|
1162
|
-
:options =>
|
1163
|
-
OneVMHelper::WEEKLY,
|
1164
|
-
OneVMHelper::MONTHLY,
|
1165
|
-
OneVMHelper::YEARLY,
|
1166
|
-
OneVMHelper::HOURLY,
|
1167
|
-
OneVMHelper::END_TIME] do
|
1114
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS do
|
1168
1115
|
if !options[:schedule].nil?
|
1169
1116
|
# add disk ID and name as arguments
|
1170
1117
|
options[:args] = "#{args[1]},#{args[2]}"
|
@@ -1186,12 +1133,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1186
1133
|
|
1187
1134
|
command :"disk-snapshot-revert", disk_snapshot_revert_desc,
|
1188
1135
|
:vmid, :diskid, :disk_snapshot_id,
|
1189
|
-
:options =>
|
1190
|
-
OneVMHelper::WEEKLY,
|
1191
|
-
OneVMHelper::MONTHLY,
|
1192
|
-
OneVMHelper::YEARLY,
|
1193
|
-
OneVMHelper::HOURLY,
|
1194
|
-
OneVMHelper::END_TIME] do
|
1136
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS do
|
1195
1137
|
if !options[:schedule].nil?
|
1196
1138
|
# add disk ID and snap ID as arguments
|
1197
1139
|
options[:args] = "#{args[1]},#{args[2]}"
|
@@ -1213,12 +1155,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1213
1155
|
|
1214
1156
|
command :"disk-snapshot-delete", disk_snapshot_delete_desc,
|
1215
1157
|
:vmid, :diskid, :disk_snapshot_id,
|
1216
|
-
:options =>
|
1217
|
-
OneVMHelper::WEEKLY,
|
1218
|
-
OneVMHelper::MONTHLY,
|
1219
|
-
OneVMHelper::YEARLY,
|
1220
|
-
OneVMHelper::HOURLY,
|
1221
|
-
OneVMHelper::END_TIME] do
|
1158
|
+
:options => OpenNebulaHelper::SCHEDULE_OPTIONS do
|
1222
1159
|
if !options[:schedule].nil?
|
1223
1160
|
# add disk ID and snap ID as arguments
|
1224
1161
|
options[:args] = "#{args[1]},#{args[2]}"
|
@@ -1333,13 +1270,15 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1333
1270
|
Resizes the capacity of a Virtual Machine (offline, the VM cannot be
|
1334
1271
|
RUNNING)
|
1335
1272
|
|
1273
|
+
#{OpenNebulaHelper::TEMPLATE_INPUT}
|
1336
1274
|
EOT
|
1337
1275
|
|
1338
1276
|
command :resize, resize_desc, :vmid,
|
1339
|
-
:options => OpenNebulaHelper::CAPACITY_OPTIONS_VM +
|
1340
|
-
[ENFORCE, OneVMHelper::FILE] do
|
1277
|
+
:options => OpenNebulaHelper::CAPACITY_OPTIONS_VM + [ENFORCE, OpenNebulaHelper::FILE] do
|
1341
1278
|
if options[:file]
|
1342
1279
|
template = File.read(options[:file])
|
1280
|
+
elsif STDIN.wait_readable(0)
|
1281
|
+
template = STDIN.read
|
1343
1282
|
else
|
1344
1283
|
template = ''
|
1345
1284
|
|
@@ -1392,13 +1331,16 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1392
1331
|
In running state only changes in CONTEXT and BACKUP_CONFIG take effect
|
1393
1332
|
immediately, other values may need a VM restart.
|
1394
1333
|
|
1395
|
-
This command accepts a template
|
1396
|
-
|
1334
|
+
This command accepts a template or opens an editor.
|
1335
|
+
#{OpenNebulaHelper::TEMPLATE_INPUT}
|
1336
|
+
|
1337
|
+
The full list of configuration attributes are:
|
1397
1338
|
|
1398
1339
|
OS = ["ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT", "UUID"]
|
1399
1340
|
FEATURES = ["ACPI", "PAE", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT", "IOTHREADS"]
|
1400
1341
|
INPUT = ["TYPE", "BUS"]
|
1401
1342
|
GRAPHICS = ["TYPE", "LISTEN", "PASSWD", "KEYMAP" ]
|
1343
|
+
VIDEO = ["TYPE", "IOMMU", "ATS", "VRAM", "RESOLUTION"]
|
1402
1344
|
RAW = ["DATA", "DATA_VMX", "TYPE", "VALIDATE"]
|
1403
1345
|
CPU_MODEL = ["MODEL"]
|
1404
1346
|
BACKUP_CONFIG = ["FS_FREEZE", "KEEP_LAST", "BACKUP_VOLATILE", "MODE"]
|
@@ -1411,6 +1353,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1411
1353
|
|
1412
1354
|
begin
|
1413
1355
|
template = File.read(args[1]) if args[1]
|
1356
|
+
template = STDIN.read if STDIN.wait_readable(0)
|
1414
1357
|
rescue StandardError => e
|
1415
1358
|
STDERR.puts "Error reading template: #{e.message}."
|
1416
1359
|
exit(-1)
|
@@ -1430,8 +1373,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1430
1373
|
'BACKUP_CONFIG')
|
1431
1374
|
template = vm.template_like_str('TEMPLATE', true,
|
1432
1375
|
'OS | FEATURES | INPUT | '\
|
1433
|
-
'GRAPHICS |
|
1434
|
-
'CPU_MODEL')
|
1376
|
+
'GRAPHICS | VIDEO | RAW | '\
|
1377
|
+
'CONTEXT | CPU_MODEL')
|
1435
1378
|
|
1436
1379
|
template << "\n" << backup
|
1437
1380
|
|
@@ -1548,7 +1491,38 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1548
1491
|
:vmid,
|
1549
1492
|
:sched_id,
|
1550
1493
|
[:file, nil] do
|
1551
|
-
helper.update_schedule_action(args[0], args[1], args[2])
|
1494
|
+
helper.update_schedule_action(args[0], args[1], args[2], options)
|
1495
|
+
|
1496
|
+
0
|
1497
|
+
end
|
1498
|
+
|
1499
|
+
sched_delete_desc = <<-EOT.unindent
|
1500
|
+
Deletes a Scheduled Action from the VM
|
1501
|
+
EOT
|
1502
|
+
|
1503
|
+
command :'sched-delete', sched_delete_desc, :vmid, :sched_id do
|
1504
|
+
helper.perform_action(args[0], {}, 'Scheduled Action deleted') do |vm|
|
1505
|
+
rc = vm.sched_action_delete(args[1])
|
1506
|
+
|
1507
|
+
if OpenNebula.is_error?(rc)
|
1508
|
+
STDERR.puts "Error deleting: #{rc.message}"
|
1509
|
+
exit(-1)
|
1510
|
+
end
|
1511
|
+
end
|
1512
|
+
|
1513
|
+
0
|
1514
|
+
end
|
1515
|
+
|
1516
|
+
sched_update_desc = <<-EOT.unindent
|
1517
|
+
Updates a Scheduled Action from a VM
|
1518
|
+
EOT
|
1519
|
+
|
1520
|
+
command :'sched-update',
|
1521
|
+
sched_update_desc,
|
1522
|
+
:vmid,
|
1523
|
+
:sched_id,
|
1524
|
+
[:file, nil] do
|
1525
|
+
helper.update_schedule_action(args[0], args[1], args[2], options)
|
1552
1526
|
|
1553
1527
|
0
|
1554
1528
|
end
|
@@ -1563,13 +1537,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1563
1537
|
backup_vm_desc,
|
1564
1538
|
:vmid,
|
1565
1539
|
:options => [RESET_BACKUP,
|
1566
|
-
OneDatastoreHelper::DATASTORE
|
1567
|
-
|
1568
|
-
OneVMHelper::WEEKLY,
|
1569
|
-
OneVMHelper::MONTHLY,
|
1570
|
-
OneVMHelper::YEARLY,
|
1571
|
-
OneVMHelper::HOURLY,
|
1572
|
-
OneVMHelper::END_TIME] do
|
1540
|
+
OneDatastoreHelper::DATASTORE] +
|
1541
|
+
OpenNebulaHelper::SCHEDULE_OPTIONS do
|
1573
1542
|
options[:datastore] = -1 if options[:datastore].nil?
|
1574
1543
|
|
1575
1544
|
reset = options[:reset] == true
|
@@ -1713,8 +1682,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
1713
1682
|
end
|
1714
1683
|
end
|
1715
1684
|
|
1716
|
-
# Deprecated commands
|
1685
|
+
# Deprecated commands, remove these commands in release 8.x
|
1717
1686
|
|
1718
|
-
deprecated_command(:
|
1719
|
-
deprecated_command(:
|
1687
|
+
deprecated_command(:'delete-chart', 'sched-delete')
|
1688
|
+
deprecated_command(:'update-chart', 'sched-update')
|
1720
1689
|
end
|
data/bin/onevmgroup
CHANGED
@@ -108,7 +108,9 @@ CommandParser::CmdParser.new(ARGV) do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
set :format, :vmgroupid, OneVMGroupHelper.to_id_desc do |arg|
|
111
|
-
helper.to_id(arg)
|
111
|
+
tmp = helper.to_id(arg)
|
112
|
+
@current_vmg = tmp[1]
|
113
|
+
tmp
|
112
114
|
end
|
113
115
|
|
114
116
|
set :format, :vmgroupid_list, OneVMGroupHelper.list_to_id_desc do |arg|
|
@@ -119,6 +121,10 @@ CommandParser::CmdParser.new(ARGV) do
|
|
119
121
|
helper.filterflag_to_i(arg)
|
120
122
|
end
|
121
123
|
|
124
|
+
format :roleid, 'Role identifier' do |arg|
|
125
|
+
helper.retrieve_role_id(@current_vmg, arg)
|
126
|
+
end
|
127
|
+
|
122
128
|
########################################################################
|
123
129
|
# Commands
|
124
130
|
########################################################################
|
@@ -270,4 +276,61 @@ CommandParser::CmdParser.new(ARGV) do
|
|
270
276
|
vmg.unlock
|
271
277
|
end
|
272
278
|
end
|
279
|
+
|
280
|
+
role_add_desc = <<-EOT.unindent
|
281
|
+
Add role to VM Group.
|
282
|
+
EOT
|
283
|
+
|
284
|
+
command :"role-add", role_add_desc, :vmgroupid, [:file, nil] do
|
285
|
+
begin
|
286
|
+
template = File.read(args[1]) if args[1]
|
287
|
+
template = STDIN.read if STDIN.wait_readable(0)
|
288
|
+
rescue StandardError => e
|
289
|
+
STDERR.puts "Error reading template: #{e.message}."
|
290
|
+
exit(-1)
|
291
|
+
end
|
292
|
+
|
293
|
+
# Ensure the template attributes are in ROLE section
|
294
|
+
unless template.gsub(' ', '').match(/ROLE=\[/)
|
295
|
+
template = "ROLE=[\n#{template.split("\n").join(",\n")}]"
|
296
|
+
end
|
297
|
+
|
298
|
+
helper.perform_action(args[0], options, 'Role added') do |vmg|
|
299
|
+
vmg.role_add(template)
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
role_delete_desc = <<-EOT.unindent
|
304
|
+
Deletes role from VM Group.
|
305
|
+
EOT
|
306
|
+
|
307
|
+
command :"role-delete", role_delete_desc, :vmgroupid, :roleid do
|
308
|
+
roleid = args[1].to_i
|
309
|
+
|
310
|
+
helper.perform_action(args[0], options, 'Role removed') do |vmg|
|
311
|
+
vmg.role_delete(roleid)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
role_update_desc = <<-EOT.unindent
|
316
|
+
Update VM Group role
|
317
|
+
EOT
|
318
|
+
|
319
|
+
command :"role-update", role_update_desc, :vmgroupid, :roleid, [:file, nil] do
|
320
|
+
vmg_id = args[0].to_i
|
321
|
+
role_id = args[1].to_i
|
322
|
+
file = args[2]
|
323
|
+
|
324
|
+
helper.perform_action(vmg_id, options, 'Role updated') do |vmg|
|
325
|
+
str = OpenNebulaHelper.update_template(vmg_id, vmg, file,
|
326
|
+
"ROLES/ROLE[ID=#{role_id}]")
|
327
|
+
|
328
|
+
# Ensure the updated attributes are in ROLE section
|
329
|
+
unless str.gsub(' ', '').match(/ROLE=\[/)
|
330
|
+
str = "ROLE=[\n#{str.split("\n").join(",\n")}]"
|
331
|
+
end
|
332
|
+
|
333
|
+
vmg.role_update(role_id, str)
|
334
|
+
end
|
335
|
+
end
|
273
336
|
end
|
data/bin/onevnet
CHANGED
@@ -161,15 +161,18 @@ CommandParser::CmdParser.new(ARGV) do
|
|
161
161
|
########################################################################
|
162
162
|
|
163
163
|
create_desc = <<-EOT.unindent
|
164
|
-
Creates a new Virtual Network from the given template
|
164
|
+
Creates a new Virtual Network from the given template
|
165
|
+
|
166
|
+
#{OpenNebulaHelper::TEMPLATE_INPUT}
|
165
167
|
EOT
|
166
168
|
|
167
|
-
command :create, create_desc, :file, :options => CREATE_OPTIONS do
|
169
|
+
command :create, create_desc, [:file, nil], :options => CREATE_OPTIONS do
|
168
170
|
cid = options[:cluster] || ClusterPool::NONE_CLUSTER_ID
|
169
171
|
|
170
172
|
helper.create_resource(options) do |vn|
|
171
173
|
begin
|
172
|
-
template = File.read(args[0])
|
174
|
+
template = File.read(args[0]) if args[0]
|
175
|
+
template = STDIN.read if STDIN.wait_readable(0)
|
173
176
|
vn.allocate(template, cid)
|
174
177
|
rescue StandardError => e
|
175
178
|
STDERR.puts "Error creating network: #{e.message}"
|
data/bin/onevrouter
CHANGED
@@ -134,13 +134,14 @@ CommandParser::CmdParser.new(ARGV) do
|
|
134
134
|
|
135
135
|
create_desc = <<-EOT.unindent
|
136
136
|
Creates a new Virtual Router from the given description
|
137
|
+
#{OpenNebulaHelper::TEMPLATE_INPUT}
|
137
138
|
EOT
|
138
139
|
|
139
|
-
command :create, create_desc, :file do
|
140
|
+
command :create, create_desc, [:file, nil] do
|
140
141
|
helper.create_resource(options) do |obj|
|
141
142
|
begin
|
142
|
-
template = File.read(args[0])
|
143
|
-
|
143
|
+
template = File.read(args[0]) if args[0]
|
144
|
+
template = STDIN.read if STDIN.wait_readable(0)
|
144
145
|
obj.allocate(template)
|
145
146
|
rescue StandardError => e
|
146
147
|
STDERR.puts e.message
|
@@ -153,6 +154,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
153
154
|
Creates a new VM instance from the given Template. This VM can be
|
154
155
|
managed with the 'onevm' command.
|
155
156
|
|
157
|
+
#{OpenNebulaHelper::TEMPLATE_INPUT}
|
158
|
+
|
156
159
|
The NIC elements defined in the Virtual Router will be used. The
|
157
160
|
source Template can be modified adding or replacing attributes with
|
158
161
|
the optional file argument, or with the options.
|
@@ -168,9 +171,10 @@ CommandParser::CmdParser.new(ARGV) do
|
|
168
171
|
:vrouterid, :templateid, [:file, nil],
|
169
172
|
:options => instantiate_options +
|
170
173
|
OpenNebulaHelper::TEMPLATE_OPTIONS do
|
171
|
-
if args[2]
|
172
|
-
|
173
|
-
|
174
|
+
if (args[2] || STDIN.wait_readable(0)) &&
|
175
|
+
OpenNebulaHelper.create_template_options_used?(options)
|
176
|
+
|
177
|
+
STDERR.puts 'You cannot use both template and template creation options.'
|
174
178
|
exit(-1)
|
175
179
|
end
|
176
180
|
|
@@ -194,6 +198,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
194
198
|
|
195
199
|
if args[2]
|
196
200
|
extra_template = File.read(args[2])
|
201
|
+
elsif STDIN.wait_readable(0)
|
202
|
+
extra_template = STDIN.read
|
197
203
|
else
|
198
204
|
res = OpenNebulaHelper.create_template(options, t)
|
199
205
|
|
@@ -292,20 +298,15 @@ CommandParser::CmdParser.new(ARGV) do
|
|
292
298
|
EOT
|
293
299
|
|
294
300
|
command :"nic-attach", nic_attach_desc, :vrouterid,
|
295
|
-
:options => [
|
301
|
+
:options => [OpenNebulaHelper::FILE,
|
296
302
|
OneVMHelper::NETWORK,
|
297
303
|
OneVMHelper::IP,
|
298
304
|
OneVirtualRouterHelper::FLOAT] do
|
299
|
-
if options[:file].nil? && options[:network].nil?
|
300
|
-
STDERR.puts 'Provide a template file or a network:'
|
301
|
-
STDERR.puts "\t--file <file>"
|
302
|
-
STDERR.puts "\t--network <network>"
|
303
|
-
exit(-1)
|
304
|
-
end
|
305
|
-
|
306
305
|
if options[:file]
|
307
306
|
template = File.read(options[:file])
|
308
|
-
|
307
|
+
elsif STDIN.wait_readable(0)
|
308
|
+
template = STDIN.read
|
309
|
+
elsif options[:network]
|
309
310
|
network_id = options[:network]
|
310
311
|
ip = options[:ip]
|
311
312
|
float = options[:float]
|
@@ -321,6 +322,11 @@ CommandParser::CmdParser.new(ARGV) do
|
|
321
322
|
end
|
322
323
|
|
323
324
|
template += ' ]'
|
325
|
+
else
|
326
|
+
STDERR.puts 'Provide a template or a network:'
|
327
|
+
STDERR.puts "\t--file <file>"
|
328
|
+
STDERR.puts "\t--network <network>"
|
329
|
+
exit(-1)
|
324
330
|
end
|
325
331
|
|
326
332
|
helper.perform_action(args[0], options, 'Attach NIC') do |vr|
|