opennebula-cli 4.14.2 → 4.90.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NOTICE +1 -1
- data/bin/oneacct +1 -1
- data/bin/oneacl +1 -1
- data/bin/onecluster +4 -1
- data/bin/onedatastore +4 -1
- data/bin/oneflow +26 -1
- data/bin/oneflow-template +57 -1
- data/bin/onegroup +4 -1
- data/bin/onehost +24 -15
- data/bin/oneimage +5 -3
- data/bin/onemarket +178 -0
- data/bin/onemarketapp +282 -0
- data/bin/onesecgroup +18 -1
- data/bin/oneshowback +1 -1
- data/bin/onetemplate +30 -21
- data/bin/oneuser +12 -6
- data/bin/oneuser.backup +522 -0
- data/bin/onevcenter +287 -1
- data/bin/onevdc +4 -1
- data/bin/onevm +78 -56
- data/bin/onevnet +10 -4
- data/bin/onevrouter +305 -0
- data/bin/onezone +4 -1
- data/lib/cli_helper.rb +1 -1
- data/lib/command_parser.rb +1 -1
- data/lib/one_helper/oneacct_helper.rb +1 -1
- data/lib/one_helper/oneacl_helper.rb +11 -5
- data/lib/one_helper/onecluster_helper.rb +1 -1
- data/lib/one_helper/onedatastore_helper.rb +17 -7
- data/lib/one_helper/onegroup_helper.rb +1 -1
- data/lib/one_helper/onehost_helper.rb +2 -5
- data/lib/one_helper/oneimage_helper.rb +1 -15
- data/lib/one_helper/onemarket_helper.rb +152 -0
- data/lib/one_helper/onemarketapp_helper.rb +223 -0
- data/lib/one_helper/onequota_helper.rb +1 -1
- data/lib/one_helper/onesecgroup_helper.rb +46 -3
- data/lib/one_helper/onetemplate_helper.rb +146 -11
- data/lib/one_helper/oneuser_helper.rb +1 -1
- data/lib/one_helper/onevdc_helper.rb +1 -1
- data/lib/one_helper/onevm_helper.rb +37 -53
- data/lib/one_helper/onevnet_helper.rb +23 -11
- data/lib/one_helper/onevrouter_helper.rb +221 -0
- data/lib/one_helper/onezone_helper.rb +1 -1
- data/lib/one_helper.rb +193 -25
- metadata +21 -10
data/bin/onevcenter
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# -------------------------------------------------------------------------- #
|
4
|
-
# Copyright 2002-
|
4
|
+
# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
|
5
5
|
# #
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
7
7
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -195,6 +195,148 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
195
195
|
|
196
196
|
next if STDIN.gets.strip.downcase != 'y'
|
197
197
|
|
198
|
+
ds_input = ""
|
199
|
+
rp_input = ""
|
200
|
+
|
201
|
+
# Datastores
|
202
|
+
|
203
|
+
STDOUT.print "\n This template is currently set to be "\
|
204
|
+
"deployed in datastore #{t[:default_ds]}."\
|
205
|
+
"\n Press y to keep the default, n to select"\
|
206
|
+
" a new datastore or d to delegate the choice"\
|
207
|
+
" to the user [y/n/d]? "
|
208
|
+
|
209
|
+
answer = STDIN.gets.strip.downcase
|
210
|
+
|
211
|
+
case answer
|
212
|
+
when 'd'
|
213
|
+
ds_split = t[:ds].split("|")
|
214
|
+
list_of_ds = ds_split[-2]
|
215
|
+
default_ds = ds_split[-1]
|
216
|
+
ds_input = ds_split[0] + "|" + ds_split[1] + "|" +
|
217
|
+
ds_split[2] + "|"
|
218
|
+
|
219
|
+
# Available list of datastores
|
220
|
+
|
221
|
+
input_str = " The list of available datastores to be"\
|
222
|
+
" presented to the user are \"#{list_of_ds}\""
|
223
|
+
input_str+= "\n Press y to agree, or input a comma"\
|
224
|
+
" separated list of datastores to edit "\
|
225
|
+
"[y/comma separated list] "
|
226
|
+
STDOUT.print input_str
|
227
|
+
|
228
|
+
answer = STDIN.gets.strip
|
229
|
+
|
230
|
+
if answer.downcase == 'y'
|
231
|
+
ds_input += ds_split[3] + "|"
|
232
|
+
else
|
233
|
+
ds_input += answer + "|"
|
234
|
+
end
|
235
|
+
|
236
|
+
# Default
|
237
|
+
input_str = " The default datastore presented to "\
|
238
|
+
"the end user is set to \"#{default_ds}\"."
|
239
|
+
input_str+= "\n Press y to agree, or input a new "\
|
240
|
+
"datastore [y/datastore name] "
|
241
|
+
STDOUT.print input_str
|
242
|
+
|
243
|
+
answer = STDIN.gets.strip
|
244
|
+
|
245
|
+
if answer.downcase == 'y'
|
246
|
+
ds_input += ds_split[4]
|
247
|
+
else
|
248
|
+
ds_input += answer
|
249
|
+
end
|
250
|
+
when 'n'
|
251
|
+
ds_split = t[:ds].split("|")
|
252
|
+
list_of_ds = ds_split[-2]
|
253
|
+
|
254
|
+
input_str = " The list of available datastores is"\
|
255
|
+
" \"#{list_of_ds}\"."
|
256
|
+
input_str+= "\n Please input the new default datastore: "
|
257
|
+
STDOUT.print input_str
|
258
|
+
|
259
|
+
answer = STDIN.gets.strip
|
260
|
+
|
261
|
+
t[:one] += "VCENTER_DATASTORE=\"#{answer}\"\n"
|
262
|
+
end
|
263
|
+
|
264
|
+
# Resource Pools
|
265
|
+
|
266
|
+
rp_split = t[:rp].split("|")
|
267
|
+
|
268
|
+
if rp_split.size > 3
|
269
|
+
STDOUT.print "\n This template is currently set to "\
|
270
|
+
"launch VMs in the default resource pool."\
|
271
|
+
"\n Press y to keep this behaviour, n to select"\
|
272
|
+
" a new resource pool or d to delegate the choice"\
|
273
|
+
" to the user [y/n/d]? "
|
274
|
+
|
275
|
+
answer = STDIN.gets.strip.downcase
|
276
|
+
|
277
|
+
case answer
|
278
|
+
when 'd'
|
279
|
+
list_of_rp = rp_split[-2]
|
280
|
+
default_rp = rp_split[-1]
|
281
|
+
rp_input = rp_split[0] + "|" + rp_split[1] + "|" +
|
282
|
+
rp_split[2] + "|"
|
283
|
+
|
284
|
+
# Available list of resource pools
|
285
|
+
|
286
|
+
input_str = " The list of available resource pools "\
|
287
|
+
"to be presented to the user are "\
|
288
|
+
"\"#{list_of_rp}\""
|
289
|
+
input_str+= "\n Press y to agree, or input a comma"\
|
290
|
+
" separated list of resource pools to edit "\
|
291
|
+
"[y/comma separated list] "
|
292
|
+
STDOUT.print input_str
|
293
|
+
|
294
|
+
answer = STDIN.gets.strip
|
295
|
+
|
296
|
+
if answer.downcase == 'y'
|
297
|
+
rp_input += rp_split[3] + "|"
|
298
|
+
else
|
299
|
+
rp_input += answer + "|"
|
300
|
+
end
|
301
|
+
|
302
|
+
# Default
|
303
|
+
input_str = " The default resource pool presented "\
|
304
|
+
"to the end user is set to"\
|
305
|
+
" \"#{default_rp}\"."
|
306
|
+
input_str+= "\n Press y to agree, or input a new "\
|
307
|
+
"resource pool [y/resource pool name] "
|
308
|
+
STDOUT.print input_str
|
309
|
+
|
310
|
+
answer = STDIN.gets.strip
|
311
|
+
|
312
|
+
if answer.downcase == 'y'
|
313
|
+
rp_input += rp_split[4]
|
314
|
+
else
|
315
|
+
rp_input += answer
|
316
|
+
end
|
317
|
+
when 'n'
|
318
|
+
list_of_rp = rp_split[-2]
|
319
|
+
|
320
|
+
input_str = " The list of available resource pools is"\
|
321
|
+
" \"#{list_of_rp}\"."
|
322
|
+
input_str+= "\n Please input the new default resource pool: "
|
323
|
+
STDOUT.print input_str
|
324
|
+
|
325
|
+
answer = STDIN.gets.strip
|
326
|
+
|
327
|
+
t[:one] += "RESOURCE_POOL=\"#{answer}\"\n"
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
if ds_input != "" ||
|
332
|
+
rp_input != ""
|
333
|
+
t[:one] += "USER_INPUTS=["
|
334
|
+
t[:one] += "VCENTER_DATASTORE=\"#{ds_input}\"," if ds_input != ""
|
335
|
+
t[:one] += "RESOURCE_POOL=\"#{rp_input}\"," if rp_input != ""
|
336
|
+
t[:one] = t[:one][0..-2]
|
337
|
+
t[:one] += "]"
|
338
|
+
end
|
339
|
+
|
198
340
|
one_t = ::OpenNebula::Template.new(
|
199
341
|
::OpenNebula::Template.build_xml, vc.one)
|
200
342
|
|
@@ -368,4 +510,148 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
368
510
|
|
369
511
|
exit 0
|
370
512
|
end
|
513
|
+
|
514
|
+
datastores_desc = <<-EOT.unindent
|
515
|
+
Import vCenter Datastores into OpenNebula
|
516
|
+
EOT
|
517
|
+
|
518
|
+
command :datastores, datastores_desc, :options=>[ VCENTER, USER, PASS ] do
|
519
|
+
if options[:vuser].nil? ||
|
520
|
+
options[:vpass].nil? ||
|
521
|
+
options[:vcenter].nil?
|
522
|
+
STDERR.puts "vCenter connection parameters are mandatory to import"\
|
523
|
+
" Datastores:\n"\
|
524
|
+
"\t --vcenter vCenter hostname\n"\
|
525
|
+
"\t --vuser username to login in vcenter\n"\
|
526
|
+
"\t --vpass password for the user"
|
527
|
+
exit -1
|
528
|
+
end
|
529
|
+
|
530
|
+
begin
|
531
|
+
STDOUT.print "\nConnecting to vCenter: #{options[:vcenter]}..."
|
532
|
+
|
533
|
+
vc = VCenterDriver::VIClient.new_connection(
|
534
|
+
:user => options[:vuser],
|
535
|
+
:password => options[:vpass],
|
536
|
+
:host => options[:vcenter])
|
537
|
+
|
538
|
+
STDOUT.print "done!\n\n"
|
539
|
+
|
540
|
+
STDOUT.print "Looking for Datastores..."
|
541
|
+
|
542
|
+
rs = vc.vcenter_datastores
|
543
|
+
|
544
|
+
STDOUT.print "done!\n"
|
545
|
+
|
546
|
+
rs.each {|dc, tmps|
|
547
|
+
STDOUT.print "\nDo you want to process datacenter #{dc} [y/n]? "
|
548
|
+
|
549
|
+
next if STDIN.gets.strip.downcase != 'y'
|
550
|
+
|
551
|
+
if tmps.empty?
|
552
|
+
STDOUT.print " No new Datastores found in #{dc}...\n\n"
|
553
|
+
next
|
554
|
+
end
|
555
|
+
|
556
|
+
tmps.each{ |d|
|
557
|
+
STDOUT.print "\n * Datastore found:\n"\
|
558
|
+
" - Name : #{d[:name]}\n"\
|
559
|
+
" - Total MB : #{d[:total_mb]}\n"\
|
560
|
+
" - Free MB : #{d[:free_mb]}\n"\
|
561
|
+
" - Cluster : #{d[:cluster]}\n"\
|
562
|
+
" Import this Datastore [y/n]? "
|
563
|
+
|
564
|
+
next if STDIN.gets.strip.downcase != 'y'
|
565
|
+
|
566
|
+
one_d = ::OpenNebula::Datastore.new(
|
567
|
+
::OpenNebula::Datastore.build_xml, vc.one)
|
568
|
+
|
569
|
+
rc = one_d.allocate(d[:one])
|
570
|
+
|
571
|
+
if ::OpenNebula.is_error?(rc)
|
572
|
+
STDOUT.puts " Error creating datastore: #{rc.message}\n"\
|
573
|
+
" One datastore can exist only once, and "\
|
574
|
+
"can be used in any vCenter Cluster that "\
|
575
|
+
"has access to it. Also, no spaces allowed "\
|
576
|
+
"in datastore name (rename it in vCenter "\
|
577
|
+
"and try again)"
|
578
|
+
else
|
579
|
+
STDOUT.puts " OpenNebula datastore #{one_d.id} created!\n"
|
580
|
+
end
|
581
|
+
}
|
582
|
+
}
|
583
|
+
rescue Exception => e
|
584
|
+
STDOUT.puts "error: #{e.message}"
|
585
|
+
exit -1
|
586
|
+
end
|
587
|
+
|
588
|
+
exit 0
|
589
|
+
end
|
590
|
+
|
591
|
+
images_desc = <<-EOT.unindent
|
592
|
+
Import vCenter Images into OpenNebula
|
593
|
+
EOT
|
594
|
+
|
595
|
+
command :images, images_desc, :ds_name, :options=>[ VCENTER, USER, PASS ] do
|
596
|
+
ds_name = args[0]
|
597
|
+
|
598
|
+
if !ds_name
|
599
|
+
STDERR.puts "Datastore name needed to import images from"
|
600
|
+
exit -1
|
601
|
+
end
|
602
|
+
|
603
|
+
if options[:vuser].nil? ||
|
604
|
+
options[:vpass].nil? ||
|
605
|
+
options[:vcenter].nil?
|
606
|
+
STDERR.puts "vCenter connection parameters are mandatory to import"\
|
607
|
+
" Datastores:\n"\
|
608
|
+
"\t --vcenter vCenter hostname\n"\
|
609
|
+
"\t --vuser username to login in vcenter\n"\
|
610
|
+
"\t --vpass password for the user"
|
611
|
+
exit -1
|
612
|
+
end
|
613
|
+
|
614
|
+
begin
|
615
|
+
STDOUT.print "\nConnecting to vCenter: #{options[:vcenter]}..."
|
616
|
+
|
617
|
+
vc = VCenterDriver::VIClient.new_connection(
|
618
|
+
:user => options[:vuser],
|
619
|
+
:password => options[:vpass],
|
620
|
+
:host => options[:vcenter])
|
621
|
+
|
622
|
+
STDOUT.print "done!\n\n"
|
623
|
+
|
624
|
+
STDOUT.print "Looking for Images..."
|
625
|
+
|
626
|
+
images = vc.vcenter_images(ds_name)
|
627
|
+
|
628
|
+
STDOUT.print "done!\n"
|
629
|
+
|
630
|
+
images.each{ |i|
|
631
|
+
STDOUT.print "\n * Image found:\n"\
|
632
|
+
" - Name : #{i[:name]}\n"\
|
633
|
+
" - Path : #{i[:path]}\n"\
|
634
|
+
" - Type : #{i[:type]}\n"\
|
635
|
+
" Import this Image [y/n]? "
|
636
|
+
|
637
|
+
next if STDIN.gets.strip.downcase != 'y'
|
638
|
+
|
639
|
+
one_i = ::OpenNebula::Image.new(
|
640
|
+
::OpenNebula::Image.build_xml, vc.one)
|
641
|
+
|
642
|
+
rc = one_i.allocate(i[:one], i[:dsid].to_i)
|
643
|
+
|
644
|
+
if ::OpenNebula.is_error?(rc)
|
645
|
+
STDOUT.puts " Error creating image: #{rc.message}\n"
|
646
|
+
else
|
647
|
+
STDOUT.puts " OpenNebula image #{one_i.id} created!\n"
|
648
|
+
end
|
649
|
+
}
|
650
|
+
rescue Exception => e
|
651
|
+
STDOUT.puts "error: #{e.message}"
|
652
|
+
exit -1
|
653
|
+
end
|
654
|
+
|
655
|
+
exit 0
|
656
|
+
end
|
371
657
|
end
|
data/bin/onevdc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# -------------------------------------------------------------------------- #
|
4
|
-
# Copyright 2002-
|
4
|
+
# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
|
5
5
|
# #
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
7
7
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -148,6 +148,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
148
148
|
str = OpenNebulaHelper.update_template(args[0], obj, args[1])
|
149
149
|
end
|
150
150
|
|
151
|
+
helper.set_client(options)
|
152
|
+
obj = helper.retrieve_resource(obj.id)
|
153
|
+
|
151
154
|
obj.update(str, options[:append])
|
152
155
|
end
|
153
156
|
end
|
data/bin/onevm
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# -------------------------------------------------------------------------- #
|
4
|
-
# Copyright 2002-
|
4
|
+
# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
|
5
5
|
# #
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
7
7
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -63,14 +63,6 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
63
63
|
:description => "Overrides the DEV_PREFIX of the image"
|
64
64
|
}
|
65
65
|
|
66
|
-
IP={
|
67
|
-
:name => "ip",
|
68
|
-
:short => "-i ip",
|
69
|
-
:large => "--ip ip",
|
70
|
-
:format => String,
|
71
|
-
:description => "IP address for the new NIC"
|
72
|
-
}
|
73
|
-
|
74
66
|
CACHE={
|
75
67
|
:name => "cache",
|
76
68
|
:large => "--cache cache_mode",
|
@@ -112,6 +104,18 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
112
104
|
:description => "Recover a VM by retrying the last failed action"
|
113
105
|
}
|
114
106
|
|
107
|
+
DELETE={
|
108
|
+
:name => "delete",
|
109
|
+
:large => "--delete",
|
110
|
+
:description => "No recover action possible, delete the VM"
|
111
|
+
}
|
112
|
+
|
113
|
+
RECREATE={
|
114
|
+
:name => "recreate",
|
115
|
+
:large => "--recreate",
|
116
|
+
:description => "No recover action possible, delete and recreate the VM"
|
117
|
+
}
|
118
|
+
|
115
119
|
INTERACTIVE={
|
116
120
|
:name => "interactive",
|
117
121
|
:large => "--interactive",
|
@@ -263,32 +267,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
263
267
|
str = OpenNebulaHelper.update_template(args[0], obj, args[1], 'USER_TEMPLATE')
|
264
268
|
end
|
265
269
|
|
266
|
-
|
267
|
-
|
268
|
-
end
|
269
|
-
|
270
|
-
delete_desc = <<-EOT.unindent
|
271
|
-
Deletes the given VM. Using --recreate resubmits the VM.
|
270
|
+
helper.set_client(options)
|
271
|
+
obj = helper.retrieve_resource(obj.id)
|
272
272
|
|
273
|
-
|
274
|
-
transient state. To re-deploy a fresh copy of the same VM, create a
|
275
|
-
Template and instantiate it, see 'onetemplate instantiate'
|
276
|
-
|
277
|
-
States: ANY
|
278
|
-
EOT
|
279
|
-
|
280
|
-
command :delete, delete_desc, [:range, :vmid_list],
|
281
|
-
:options => [OneVMHelper::SCHEDULE, OneVMHelper::RECREATE] do
|
282
|
-
|
283
|
-
command_name="delete"
|
284
|
-
command_name<<"-recreate" if options[:recreate]
|
285
|
-
|
286
|
-
if (!options[:schedule].nil?)
|
287
|
-
helper.schedule_actions(args[0], options, command_name)
|
288
|
-
else
|
289
|
-
helper.perform_actions(args[0],options,"deleted") do |vm|
|
290
|
-
vm.delete(options[:recreate]==true)
|
291
|
-
end
|
273
|
+
obj.update(str, options[:append])
|
292
274
|
end
|
293
275
|
end
|
294
276
|
|
@@ -366,25 +348,25 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
366
348
|
end
|
367
349
|
end
|
368
350
|
|
369
|
-
|
370
|
-
|
351
|
+
terminate_desc = <<-EOT.unindent
|
352
|
+
Terminates the given VM. The VM life cycle will end.
|
371
353
|
|
372
354
|
With --hard it unplugs the VM.
|
373
355
|
|
374
|
-
States:
|
356
|
+
States: valid if no operation is being performed on the VM
|
375
357
|
EOT
|
376
358
|
|
377
|
-
command :
|
359
|
+
command :terminate, terminate_desc, [:range,:vmid_list],
|
378
360
|
:options => [OneVMHelper::SCHEDULE, OneVMHelper::HARD] do
|
379
361
|
|
380
|
-
command_name='
|
362
|
+
command_name='terminate'
|
381
363
|
command_name<<'-hard' if options[:hard]
|
382
364
|
|
383
365
|
if (!options[:schedule].nil?)
|
384
366
|
helper.schedule_actions(args[0], options, command_name)
|
385
367
|
else
|
386
|
-
helper.perform_actions(args[0],options,"
|
387
|
-
vm.
|
368
|
+
helper.perform_actions(args[0],options,"terminated") do |vm|
|
369
|
+
vm.terminate(options[:hard]==true)
|
388
370
|
end
|
389
371
|
end
|
390
372
|
end
|
@@ -558,9 +540,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
558
540
|
|
559
541
|
recover_desc = <<-EOT.unindent
|
560
542
|
Recovers a stuck VM that is waiting for a driver operation. The recovery
|
561
|
-
may be done by failing, succeeding or retrying the current operation.
|
562
|
-
TO MANUALLY CHECK THE VM STATUS ON THE HOST, to decide if the
|
563
|
-
was successful or not, or if it can be retried.
|
543
|
+
may be done by failing, succeeding or retrying the current operation.
|
544
|
+
YOU NEED TO MANUALLY CHECK THE VM STATUS ON THE HOST, to decide if the
|
545
|
+
operation was successful or not, or if it can be retried.
|
564
546
|
|
565
547
|
Example: A VM is stuck in "migrate" because of a hardware failure. You
|
566
548
|
need to check if the VM is running in the new host or not to recover
|
@@ -568,21 +550,29 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
568
550
|
|
569
551
|
States for success/failure recovers: Any ACTIVE state.
|
570
552
|
States for a retry recover: Any *FAILURE state
|
553
|
+
States for delete: Any
|
554
|
+
States for delete-recreate: Any but STOP/UNDEPLOYED
|
571
555
|
EOT
|
572
556
|
|
573
557
|
command :recover, recover_desc, [:range,:vmid_list],
|
574
|
-
:options => [SUCCESS, FAILURE, RETRY, INTERACTIVE] do
|
558
|
+
:options => [SUCCESS, FAILURE, RETRY, INTERACTIVE, DELETE, RECREATE] do
|
575
559
|
if !options[:success].nil?
|
576
560
|
result = 1
|
577
561
|
elsif !options[:failure].nil?
|
578
562
|
result = 0
|
579
563
|
elsif !options[:retry].nil?
|
580
564
|
result = 2
|
565
|
+
elsif !options[:delete].nil?
|
566
|
+
result = 3
|
567
|
+
elsif !options[:recreate].nil?
|
568
|
+
result = 4
|
581
569
|
else
|
582
570
|
STDERR.puts "Need to specify the result of the pending action."
|
583
571
|
STDERR.puts "\t--success recover the VM by succeeding the missing action."
|
584
572
|
STDERR.puts "\t--failure recover the VM by failing the missing action."
|
585
573
|
STDERR.puts "\t--retry recover the VM by retrying the last failed action."
|
574
|
+
STDERR.puts "\t--delete no recover possible, delete the VM."
|
575
|
+
STDERR.puts "\t--recreate no recover possible, delete and recreate the VM."
|
586
576
|
exit -1
|
587
577
|
end
|
588
578
|
|
@@ -666,7 +656,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
666
656
|
EOT
|
667
657
|
|
668
658
|
command :"nic-attach", nic_attach_desc, :vmid,
|
669
|
-
:options => [OneVMHelper::FILE, OneVMHelper::NETWORK, IP] do
|
659
|
+
:options => [OneVMHelper::FILE, OneVMHelper::NETWORK, OneVMHelper::IP] do
|
670
660
|
|
671
661
|
if options[:file].nil? and options[:network].nil?
|
672
662
|
STDERR.puts "Provide a template file or a network:"
|
@@ -831,7 +821,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
831
821
|
disk_snapshot_revert_desc = <<-EOT.unindent
|
832
822
|
Reverts disk state to a previously taken snapshot.
|
833
823
|
|
834
|
-
States:
|
824
|
+
States: POWEROFF, SUSPENDED
|
835
825
|
EOT
|
836
826
|
|
837
827
|
command :"disk-snapshot-revert", disk_snapshot_revert_desc,
|
@@ -934,15 +924,47 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
934
924
|
end
|
935
925
|
end
|
936
926
|
|
927
|
+
updateconf_desc = <<-EOT.unindent
|
928
|
+
Updates the configuration of a VM. The VM cannot be in a active (running)
|
929
|
+
state, valid states are: pending, failure, poweroff, undeploy, hold or
|
930
|
+
clonning.
|
931
|
+
|
932
|
+
This command accepts a template file or opens an editor, the full list of
|
933
|
+
configuration attributes are:
|
934
|
+
|
935
|
+
OS = ["ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT"]
|
936
|
+
FEATURES = ["ACPI", "PAE", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT"]
|
937
|
+
INPUT = ["TYPE", "BUS"]
|
938
|
+
GRAPHICS = ["TYPE", "LISTEN", "PASSWD", "KEYMAP" ]
|
939
|
+
RAW = ["DATA", "DATA_VMX", "TYPE"]
|
940
|
+
CONTEXT (any value, **variable substitution will be made**)
|
941
|
+
EOT
|
942
|
+
|
943
|
+
command :updateconf, updateconf_desc, :vmid, [:file, nil] do
|
944
|
+
template = ""
|
945
|
+
|
946
|
+
begin
|
947
|
+
template=File.read(args[1]) if args[1]
|
948
|
+
rescue Exception => e
|
949
|
+
STDERR.puts "Error reading template."
|
950
|
+
exit -1
|
951
|
+
end
|
952
|
+
|
953
|
+
helper.perform_action(args[0], options, "Updating VM configuration") do |vm|
|
954
|
+
if template.empty?
|
955
|
+
vm.info
|
956
|
+
|
957
|
+
template = vm.template_like_str('TEMPLATE', true,
|
958
|
+
'OS | FEATURES | INPUT | GRAPHICS | RAW | CONTEXT')
|
959
|
+
template = OpenNebulaHelper::editor_input(template)
|
960
|
+
end
|
961
|
+
|
962
|
+
vm.updateconf(template)
|
963
|
+
end
|
964
|
+
end
|
965
|
+
|
937
966
|
# Deprecated commands
|
938
967
|
|
939
|
-
deprecated_command(:
|
940
|
-
deprecated_command(:
|
941
|
-
deprecated_command(:'disk-snapshot', 'disk-saveas')
|
942
|
-
deprecated_command(:livemigrate, 'migrate --live')
|
943
|
-
deprecated_command(:cancel, 'shutdown --hard')
|
944
|
-
deprecated_command(:reset, 'reboot --hard')
|
945
|
-
deprecated_command(:restart, 'recover --retry')
|
946
|
-
deprecated_command(:boot, 'recover --retry')
|
947
|
-
deprecated_command(:resubmit, 'delete --recreate')
|
968
|
+
deprecated_command(:shutdown, 'terminate')
|
969
|
+
deprecated_command(:delete, 'recover')
|
948
970
|
end
|
data/bin/onevnet
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# -------------------------------------------------------------------------- #
|
4
|
-
# Copyright 2002-
|
4
|
+
# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
|
5
5
|
# #
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
7
7
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -148,9 +148,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
148
148
|
ar << ", ULA_PREFIX = " <<
|
149
149
|
options[:ip6_ula] if options[:ip6_ula]
|
150
150
|
ar << ", GATEWAY = " << options[:gateway] if options[:gateway]
|
151
|
-
ar << ", MASK = "
|
152
|
-
ar << ",
|
153
|
-
ar << ", VLAN_ID = " << options[:vlanid]
|
151
|
+
ar << ", MASK = " << options[:netmask] if options[:netmask]
|
152
|
+
ar << ", VN_MAD = " << options[:vn_mad] if options[:vn_mad]
|
153
|
+
ar << ", VLAN_ID = " << options[:vlanid] if options[:vlanid]
|
154
154
|
|
155
155
|
ar << "]"
|
156
156
|
end
|
@@ -329,6 +329,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
329
329
|
str = OpenNebulaHelper.update_template(args[0], obj, args[1])
|
330
330
|
end
|
331
331
|
|
332
|
+
helper.set_client(options)
|
333
|
+
obj = helper.retrieve_resource(obj.id)
|
334
|
+
|
332
335
|
obj.update(str, options[:append])
|
333
336
|
end
|
334
337
|
end
|
@@ -365,6 +368,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
365
368
|
str = OpenNebulaHelper.update_template_helper(false, args[0], obj,
|
366
369
|
args[2], "AR_POOL", false)
|
367
370
|
|
371
|
+
helper.set_client(options)
|
372
|
+
obj = helper.retrieve_resource(obj.id)
|
373
|
+
|
368
374
|
obj.update_ar(str)
|
369
375
|
end
|
370
376
|
end
|