opennebula-cli 5.4.15 → 5.5.80.pre

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/NOTICE +1 -1
  3. data/bin/oneacct +3 -3
  4. data/bin/oneacl +2 -2
  5. data/bin/onecluster +1 -1
  6. data/bin/onedatastore +1 -1
  7. data/bin/oneflow +1 -1
  8. data/bin/oneflow-template +1 -1
  9. data/bin/onegroup +1 -1
  10. data/bin/onehost +1 -1
  11. data/bin/oneimage +64 -1
  12. data/bin/onemarket +1 -1
  13. data/bin/onemarketapp +65 -2
  14. data/bin/onesecgroup +1 -1
  15. data/bin/oneshowback +2 -2
  16. data/bin/onetemplate +66 -3
  17. data/bin/oneuser +3 -3
  18. data/bin/onevcenter +95 -86
  19. data/bin/onevdc +1 -1
  20. data/bin/onevm +75 -11
  21. data/bin/onevmgroup +64 -1
  22. data/bin/onevnet +64 -1
  23. data/bin/onevrouter +64 -1
  24. data/bin/onezone +1 -1
  25. data/lib/cli_helper.rb +1 -1
  26. data/lib/command_parser.rb +9 -1
  27. data/lib/one_helper/oneacct_helper.rb +22 -18
  28. data/lib/one_helper/oneacl_helper.rb +1 -1
  29. data/lib/one_helper/onecluster_helper.rb +1 -1
  30. data/lib/one_helper/onedatastore_helper.rb +1 -1
  31. data/lib/one_helper/onegroup_helper.rb +1 -1
  32. data/lib/one_helper/onehost_helper.rb +32 -6
  33. data/lib/one_helper/oneimage_helper.rb +2 -1
  34. data/lib/one_helper/onemarket_helper.rb +1 -1
  35. data/lib/one_helper/onemarketapp_helper.rb +2 -1
  36. data/lib/one_helper/onequota_helper.rb +1 -1
  37. data/lib/one_helper/onesecgroup_helper.rb +1 -1
  38. data/lib/one_helper/onetemplate_helper.rb +2 -1
  39. data/lib/one_helper/oneuser_helper.rb +13 -1
  40. data/lib/one_helper/onevcenter_helper.rb +425 -0
  41. data/lib/one_helper/onevdc_helper.rb +5 -5
  42. data/lib/one_helper/onevm_helper.rb +100 -2
  43. data/lib/one_helper/onevmgroup_helper.rb +14 -9
  44. data/lib/one_helper/onevnet_helper.rb +7 -3
  45. data/lib/one_helper/onevrouter_helper.rb +2 -1
  46. data/lib/one_helper/onezone_helper.rb +22 -39
  47. data/lib/one_helper.rb +64 -8
  48. metadata +7 -6
data/bin/onevcenter CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2018, 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 #
@@ -31,46 +31,51 @@ $: << RUBY_LIB_LOCATION+"/cli"
31
31
  $: << REMOTES_LOCATION+"vmm/vcenter/"
32
32
 
33
33
  require 'command_parser'
34
- require 'one_helper/onehost_helper'
35
- require 'one_helper/onecluster_helper'
34
+ require 'one_helper/onevcenter_helper'
36
35
  require 'vcenter_driver'
37
36
 
38
- def connection_options(object_name, options)
39
- if options[:vuser].nil? ||
40
- options[:vcenter].nil?
41
- STDERR.puts "vCenter connection parameters are mandatory to import"\
42
- " #{object_name}:\n"\
43
- "\t --vcenter vCenter hostname\n"\
44
- "\t --vuser username to login in vcenter"
45
- exit -1
46
- end
47
-
48
- password = options[:vpass] || OpenNebulaHelper::OneHelper.get_password
49
-
50
- {
51
- :user => options[:vuser],
52
- :password => password,
53
- :host => options[:vcenter]
54
- }
55
- end
56
-
57
37
  cmd=CommandParser::CmdParser.new(ARGV) do
58
38
 
59
39
  usage "`onevcenter` <command> [<args>] [<options>]"
60
40
  version OpenNebulaHelper::ONE_VERSION
61
41
 
62
- helper = OneHostHelper.new
42
+ helper = OneVcenterHelper.new
63
43
 
64
44
  before_proc do
65
45
  helper.set_client(options)
66
46
  end
67
47
 
68
- ############################################################################
69
- # Global Options
70
- ############################################################################
71
- cmd_options=CommandParser::OPTIONS-[CommandParser::VERBOSE]
72
- set :option, cmd_options+OpenNebulaHelper::CLIENT_OPTIONS
73
48
 
49
+ OBJECT = {
50
+ :name => "object",
51
+ :short => "-o object",
52
+ :large => "--object object ",
53
+ :format => String,
54
+ :description => "vCenter object"
55
+ }
56
+
57
+ HOST = {
58
+ :name => "host",
59
+ :short => "-h host_id",
60
+ :large => "--host host_id",
61
+ :format => String,
62
+ :description => "OpenNebula host used to authenticate the operation"
63
+ }
64
+
65
+ DATASTORE = {
66
+ :name => "datastore",
67
+ :short => "-d datastore_id",
68
+ :large => "--datastore datastore_id",
69
+ :format => String,
70
+ :description => "OpenNebula datastore used"
71
+ }
72
+
73
+ CONFIG = {
74
+ :name => "configuration",
75
+ :large => "--config file",
76
+ :format => String,
77
+ :description => "Configuration file for custom options"
78
+ }
74
79
 
75
80
  VCENTER = {
76
81
  :name => "vcenter",
@@ -100,98 +105,102 @@ cmd=CommandParser::CmdParser.new(ARGV) do
100
105
  :format => String
101
106
  }
102
107
 
108
+ ALL = {
109
+ :name => "all",
110
+ :large => "--all",
111
+ :description => "Import all list",
112
+ :format => String
113
+ }
114
+
103
115
  ############################################################################
104
- # Import clusters
116
+ # Global Options
105
117
  ############################################################################
106
- hosts_desc = <<-EOT.unindent
107
- Import vCenter clusters as OpenNebula hosts
108
- EOT
109
-
110
- command :hosts, hosts_desc, :options=>[ VCENTER, USER, PASS, USE_DEFAULTS ] do
111
- con_ops = connection_options("Hosts", options)
118
+ cmd_options=CommandParser::OPTIONS-[CommandParser::VERBOSE]
119
+ set :option, cmd_options+OpenNebulaHelper::CLIENT_OPTIONS
112
120
 
113
- VCenterDriver::Importer.import_clusters(con_ops, options)
121
+ #format :oid, "vCenter Object identifier" do |arg|
122
+ # puts arg
123
+ #end
114
124
 
115
- exit 0
116
- end
117
125
 
118
126
  ############################################################################
119
- # Import templates
127
+ # list resources
120
128
  ############################################################################
121
- templates_desc = <<-EOT.unindent
122
- Import vCenter VM Templates into OpenNebula
129
+ list_desc = <<-EOT.unindent
130
+ Show a list with unimported vCenter objects
123
131
  EOT
124
132
 
125
- command :templates, templates_desc, :options=>[ VCENTER, USER, PASS, USE_DEFAULTS ] do
126
- con_ops = connection_options("VM Templates", options)
133
+ command :list, list_desc, :options=>[ OBJECT, HOST, DATASTORE, VCENTER, USER, PASS ] do
134
+ begin
135
+ args = helper.parse_opts(options)
136
+ vi_client = VCenterDriver::VIClient.new_from_host(options[:host])
137
+ importer = VCenterDriver::VcImporter.new_child(helper.client, vi_client, options[:object])
127
138
 
128
- VCenterDriver::Importer.import_templates(con_ops, options)
139
+ list = importer.retrieve_resources(args)
140
+
141
+ helper.list_object(options, list)
142
+ rescue Exception => e
143
+ puts e.message
144
+ end
129
145
 
130
146
  exit 0
131
147
  end
132
148
 
133
- ############################################################################
134
- # Import vms (deprecated)
135
- ############################################################################
136
- vms_desc = <<-EOT.unindent
137
- Deprecated action in onevcenter, please use onehost importvm instead
149
+ import_desc = <<-EOT.unindent
150
+ Import the the desired vCenter object
138
151
  EOT
139
152
 
140
- command :vms, vms_desc, :options=>[ VCENTER, USER, PASS, USE_DEFAULTS ] do
141
- STDERR.puts "Deprecated action in onevcenter, please use onehost "\
142
- "importvm instead"
143
- exit -1
144
- end
153
+ command :import, import_desc, [:oid, nil], :options=>[ OBJECT, HOST, DATASTORE ] do
145
154
 
146
- ############################################################################
147
- # Import networks
148
- ############################################################################
149
- network_desc = <<-EOT.unindent
150
- Import vCenter networks into OpenNebula
151
- EOT
155
+ begin
156
+ vi_client = VCenterDriver::VIClient.new_from_host(options[:host])
157
+ importer = VCenterDriver::VcImporter.new_child(helper.client, vi_client, options[:object])
158
+
159
+ importer.retrieve_resources(helper.parse_opts(options))
160
+ indexes = importer.get_indexes(args.first)
152
161
 
153
- command :networks, network_desc, :options=>[ VCENTER, USER, PASS, USE_DEFAULTS ] do
154
- con_ops = connection_options("Networks", options)
162
+ importer.process_import(indexes) do |object_info|
163
+ helper.cli_dialogue(object_info)
164
+ end
155
165
 
156
- VCenterDriver::Importer.import_networks(con_ops, options)
166
+ importer.stdout
167
+ rescue Exception => e
168
+ puts e.message
169
+ end
157
170
 
158
171
  exit 0
159
172
  end
160
173
 
161
- ############################################################################
162
- # Import datastores
163
- ############################################################################
164
- datastores_desc = <<-EOT.unindent
165
- Import vCenter Datastores into OpenNebula
166
- EOT
174
+ command :import_defaults, import_desc, [:oid, nil] , :options=>[ OBJECT, HOST, DATASTORE, CONFIG ] do
167
175
 
168
- command :datastores, datastores_desc, :options=>[ VCENTER, USER, PASS, USE_DEFAULTS ] do
169
- con_ops = connection_options("Datastores", options)
176
+ begin
177
+ vi_client = VCenterDriver::VIClient.new_from_host(options[:host])
178
+ importer = VCenterDriver::VcImporter.new_child(helper.client, vi_client, options[:object])
179
+ importer.retrieve_resources(helper.parse_opts(options))
180
+ indexes = importer.get_indexes(args.first)
170
181
 
171
- VCenterDriver::Importer.import_datastore(con_ops, options)
182
+ importer.process_import(indexes)
183
+
184
+ importer.stdout
185
+ rescue Exception => e
186
+ puts e.message
187
+ end
172
188
 
173
189
  exit 0
174
190
  end
175
191
 
176
192
  ############################################################################
177
- # Import images
193
+ # Import clusters
178
194
  ############################################################################
179
- images_desc = <<-EOT.unindent
180
- Import vCenter Images into OpenNebula
195
+ host_desc = <<-EOT.unindent
196
+ Import vCenter clusters as OpenNebula hosts
181
197
  EOT
198
+ command :hosts, host_desc, :options=>[ VCENTER, USER, PASS, USE_DEFAULTS ] do
199
+ con_ops = helper.connection_options("Hosts", options)
182
200
 
183
- command :images, images_desc, :ds_name, :options=>[ VCENTER, USER, PASS, USE_DEFAULTS ] do
184
- ds_name = args[0]
185
-
186
- if !ds_name
187
- STDERR.puts "Datastore name needed to import images from"
188
- exit -1
189
- end
190
-
191
- con_ops = connection_options("Images", options)
192
-
193
- VCenterDriver::Importer.import_images(con_ops, ds_name, options)
201
+ VCenterDriver::Importer.import_clusters(con_ops, options)
194
202
 
195
203
  exit 0
196
204
  end
205
+
197
206
  end
data/bin/onevdc CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2018, 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 #
data/bin/onevm CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2018, 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 #
@@ -137,6 +137,30 @@ cmd=CommandParser::CmdParser.new(ARGV) do
137
137
  :description => "Make the new images persistent"
138
138
  }
139
139
 
140
+ USE={
141
+ :name => "use",
142
+ :large => "--use",
143
+ :description => "lock use actions"
144
+ }
145
+
146
+ MANAGE={
147
+ :name => "manage",
148
+ :large => "--manage",
149
+ :description => "lock manage actions"
150
+ }
151
+
152
+ ADMIN={
153
+ :name => "admin",
154
+ :large => "--admin",
155
+ :description => "lock admin actions"
156
+ }
157
+
158
+ ALL={
159
+ :name => "all",
160
+ :large => "--all",
161
+ :description => "lock all actions"
162
+ }
163
+
140
164
  ########################################################################
141
165
  # Global Options
142
166
  ########################################################################
@@ -292,7 +316,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
292
316
  EOT
293
317
 
294
318
  command :hold, hold_desc, [:range,:vmid_list],
295
- :options => [OneVMHelper::SCHEDULE] do
319
+ :options => [OneVMHelper::SCHEDULE, OneVMHelper::WEEKLY, OneVMHelper::MONTHLY, OneVMHelper::YEARLY, OneVMHelper::HOURLY, OneVMHelper::END_TIME] do
296
320
  if (!options[:schedule].nil?)
297
321
  helper.schedule_actions(args[0], options, @comm_name)
298
322
  else
@@ -309,7 +333,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
309
333
  EOT
310
334
 
311
335
  command :release, release_desc, [:range,:vmid_list],
312
- :options => [OneVMHelper::SCHEDULE] do
336
+ :options => [OneVMHelper::SCHEDULE, OneVMHelper::WEEKLY, OneVMHelper::MONTHLY, OneVMHelper::YEARLY, OneVMHelper::HOURLY, OneVMHelper::END_TIME] do
313
337
  if (!options[:schedule].nil?)
314
338
  helper.schedule_actions(args[0], options, @comm_name)
315
339
  else
@@ -367,7 +391,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
367
391
  EOT
368
392
 
369
393
  command :terminate, terminate_desc, [:range,:vmid_list],
370
- :options => [OneVMHelper::SCHEDULE, OneVMHelper::HARD] do
394
+ :options => [OneVMHelper::SCHEDULE, OneVMHelper::WEEKLY, OneVMHelper::MONTHLY, OneVMHelper::YEARLY, OneVMHelper::HOURLY, OneVMHelper::END_TIME, OneVMHelper::HARD] do
371
395
 
372
396
  command_name='terminate'
373
397
  command_name<<'-hard' if options[:hard]
@@ -390,7 +414,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
390
414
  EOT
391
415
 
392
416
  command :undeploy, undeploy_desc, [:range,:vmid_list],
393
- :options => [OneVMHelper::SCHEDULE, OneVMHelper::HARD] do
417
+ :options => [OneVMHelper::SCHEDULE, OneVMHelper::WEEKLY, OneVMHelper::MONTHLY, OneVMHelper::YEARLY, OneVMHelper::HOURLY, OneVMHelper::END_TIME, OneVMHelper::HARD] do
394
418
 
395
419
  command_name='undeploy'
396
420
  command_name<<'-hard' if options[:hard]
@@ -412,7 +436,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
412
436
  EOT
413
437
 
414
438
  command :poweroff, poweroff_desc, [:range,:vmid_list],
415
- :options => [OneVMHelper::SCHEDULE, OneVMHelper::HARD] do
439
+ :options => [OneVMHelper::SCHEDULE, OneVMHelper::WEEKLY, OneVMHelper::MONTHLY, OneVMHelper::YEARLY, OneVMHelper::HOURLY, OneVMHelper::END_TIME, OneVMHelper::HARD] do
416
440
 
417
441
  command_name='poweroff'
418
442
  command_name<<'-hard' if options[:hard]
@@ -436,7 +460,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
436
460
  EOT
437
461
 
438
462
  command :reboot, reboot_desc, [:range,:vmid_list],
439
- :options => [OneVMHelper::SCHEDULE, OneVMHelper::HARD] do
463
+ :options => [OneVMHelper::SCHEDULE, OneVMHelper::WEEKLY, OneVMHelper::MONTHLY, OneVMHelper::YEARLY, OneVMHelper::HOURLY, OneVMHelper::END_TIME, OneVMHelper::HARD] do
440
464
 
441
465
  command_name='reboot'
442
466
  command_name<<'-hard' if options[:hard]
@@ -501,7 +525,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
501
525
  EOT
502
526
 
503
527
  command :stop, stop_desc, [:range,:vmid_list],
504
- :options => [OneVMHelper::SCHEDULE] do
528
+ :options => [OneVMHelper::SCHEDULE, OneVMHelper::WEEKLY, OneVMHelper::MONTHLY, OneVMHelper::YEARLY, OneVMHelper::HOURLY, OneVMHelper::END_TIME] do
505
529
  if (!options[:schedule].nil?)
506
530
  helper.schedule_actions(args[0], options, @comm_name)
507
531
  else
@@ -521,7 +545,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
521
545
  EOT
522
546
 
523
547
  command :suspend, suspend_desc, [:range,:vmid_list],
524
- :options => [OneVMHelper::SCHEDULE] do
548
+ :options => [OneVMHelper::SCHEDULE, OneVMHelper::WEEKLY, OneVMHelper::MONTHLY, OneVMHelper::YEARLY, OneVMHelper::HOURLY, OneVMHelper::END_TIME] do
525
549
  if (!options[:schedule].nil?)
526
550
  helper.schedule_actions(args[0], options, @comm_name)
527
551
  else
@@ -538,7 +562,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
538
562
  EOT
539
563
 
540
564
  command :resume, resume_desc, [:range,:vmid_list],
541
- :options => [OneVMHelper::SCHEDULE] do
565
+ :options => [OneVMHelper::SCHEDULE, OneVMHelper::WEEKLY, OneVMHelper::MONTHLY, OneVMHelper::YEARLY, OneVMHelper::HOURLY, OneVMHelper::END_TIME] do
542
566
  if (!options[:schedule].nil?)
543
567
  helper.schedule_actions(args[0], options, @comm_name)
544
568
  else
@@ -780,7 +804,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
780
804
  EOT
781
805
 
782
806
  command :"snapshot-create", snapshot_create_desc, [:range,:vmid_list],
783
- [:name, nil], :options => [OneVMHelper::SCHEDULE] do
807
+ [:name, nil], :options => [OneVMHelper::SCHEDULE, OneVMHelper::WEEKLY, OneVMHelper::MONTHLY, OneVMHelper::YEARLY, OneVMHelper::HOURLY, OneVMHelper::END_TIME] do
784
808
 
785
809
  if (!options[:schedule].nil?)
786
810
  helper.schedule_actions(args[0], options, @comm_name)
@@ -855,6 +879,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do
855
879
 
856
880
  disk_resize_desc = <<-EOT.unindent
857
881
  Resizes a VM disk. The new size should be larger than the old one.
882
+ The valid units are:
883
+ - T: TiB
884
+ - G: GiB
885
+ - M: MiB
886
+ By default is MiB.
858
887
 
859
888
  States: RUNNING, POWEROFF
860
889
  EOT
@@ -996,6 +1025,41 @@ cmd=CommandParser::CmdParser.new(ARGV) do
996
1025
  end
997
1026
  end
998
1027
 
1028
+ lock_desc = <<-EOT.unindent
1029
+ Locks a VM with differents levels for lock any actions with this VM, show and
1030
+ monitoring never will be locked.
1031
+ Aalid states are: All.
1032
+ EOT
1033
+
1034
+ command :lock, lock_desc, :vmid,
1035
+ :options => [USE, MANAGE, ADMIN, ALL] do
1036
+ helper.perform_action(args[0],options,"VM locked") do |vm|
1037
+ if !options[:use].nil?
1038
+ level = 1
1039
+ elsif !options[:manage].nil?
1040
+ level = 2
1041
+ elsif !options[:admin].nil?
1042
+ level = 3
1043
+ elsif !options[:all].nil?
1044
+ level = 4
1045
+ else
1046
+ level = 1
1047
+ end
1048
+ vm.lock(level)
1049
+ end
1050
+ end
1051
+
1052
+ unlock_desc = <<-EOT.unindent
1053
+ Unlocks a VM for unlock any actions with this VM.
1054
+ Valid states are: All.
1055
+ EOT
1056
+
1057
+ command :unlock, unlock_desc, :vmid do
1058
+ helper.perform_action(args[0],options,"VM unlocked") do |vm|
1059
+ vm.unlock
1060
+ end
1061
+ end
1062
+
999
1063
  # Deprecated commands
1000
1064
 
1001
1065
  deprecated_command(:shutdown, 'terminate')
data/bin/onevmgroup CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2018, 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 #
@@ -40,6 +40,30 @@ 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"
47
+ }
48
+
49
+ MANAGE={
50
+ :name => "manage",
51
+ :large => "--manage",
52
+ :description => "lock manage actions"
53
+ }
54
+
55
+ ADMIN={
56
+ :name => "admin",
57
+ :large => "--admin",
58
+ :description => "lock admin actions"
59
+ }
60
+
61
+ ALL={
62
+ :name => "all",
63
+ :large => "--all",
64
+ :description => "lock all actions"
65
+ }
66
+
43
67
  ########################################################################
44
68
  # Global Options
45
69
  ########################################################################
@@ -182,4 +206,43 @@ cmd=CommandParser::CmdParser.new(ARGV) do
182
206
  o.rename(args[1])
183
207
  end
184
208
  end
209
+
210
+ lock_desc = <<-EOT.unindent
211
+ Locks a VM with differents levels for lock any actions with this VM, show and
212
+ monitoring never will be locked.
213
+ Valid states are: All.
214
+ Levels:
215
+ [Use]: locks Admin, Manage and Use actions.
216
+ [Manage]: locks Manage and Use actions.
217
+ [Admin]: locks only Admin actions.
218
+ EOT
219
+
220
+ command :lock, lock_desc, :vmgroupid,
221
+ :options => [USE, MANAGE, ADMIN, ALL] do
222
+ helper.perform_action(args[0],options,"VMGroup locked") do |vmg|
223
+ if !options[:use].nil?
224
+ level = 1
225
+ elsif !options[:manage].nil?
226
+ level = 2
227
+ elsif !options[:admin].nil?
228
+ level = 3
229
+ elsif !options[:all].nil?
230
+ level = 4
231
+ else
232
+ level = 1
233
+ end
234
+ vmg.lock(level)
235
+ end
236
+ end
237
+
238
+ unlock_desc = <<-EOT.unindent
239
+ Unlocks a VM for unlock any actions with this VM.
240
+ Valid states are: All.
241
+ EOT
242
+
243
+ command :unlock, unlock_desc, :vmgroupid do
244
+ helper.perform_action(args[0],options,"VMGroup unlocked") do |vmg|
245
+ vmg.unlock
246
+ end
247
+ end
185
248
  end
data/bin/onevnet CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2018, 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 #
@@ -41,6 +41,30 @@ 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"
48
+ }
49
+
50
+ MANAGE={
51
+ :name => "manage",
52
+ :large => "--manage",
53
+ :description => "lock manage actions"
54
+ }
55
+
56
+ ADMIN={
57
+ :name => "admin",
58
+ :large => "--admin",
59
+ :description => "lock admin actions"
60
+ }
61
+
62
+ ALL={
63
+ :name => "all",
64
+ :large => "--all",
65
+ :description => "lock all actions"
66
+ }
67
+
44
68
  ########################################################################
45
69
  # Global Options
46
70
  ########################################################################
@@ -422,4 +446,43 @@ cmd=CommandParser::CmdParser.new(ARGV) do
422
446
  o.rename(args[1])
423
447
  end
424
448
  end
449
+
450
+ lock_desc = <<-EOT.unindent
451
+ Locks a VM with differents levels for lock any actions with this VM, show and
452
+ monitoring never will be locked.
453
+ Valid states are: All.
454
+ Levels:
455
+ [Use]: locks Admin, Manage and Use actions.
456
+ [Manage]: locks Manage and Use actions.
457
+ [Admin]: locks only Admin actions.
458
+ EOT
459
+
460
+ command :lock, lock_desc, :vnetid,
461
+ :options => [USE, MANAGE, ADMIN, ALL] do
462
+ helper.perform_action(args[0],options,"VNet locked") do |vnet|
463
+ if !options[:use].nil?
464
+ level = 1
465
+ elsif !options[:manage].nil?
466
+ level = 2
467
+ elsif !options[:admin].nil?
468
+ level = 3
469
+ elsif !options[:all].nil?
470
+ level = 4
471
+ else
472
+ level = 1
473
+ end
474
+ vnet.lock(level)
475
+ end
476
+ end
477
+
478
+ unlock_desc = <<-EOT.unindent
479
+ Unlocks a VM for unlock any actions with this VM.
480
+ Valid states are: All.
481
+ EOT
482
+
483
+ command :unlock, unlock_desc, :vnetid do
484
+ helper.perform_action(args[0],options,"VNet unlocked") do |vnet|
485
+ vnet.unlock
486
+ end
487
+ end
425
488
  end
data/bin/onevrouter CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2018, 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 #
@@ -42,6 +42,30 @@ cmd=CommandParser::CmdParser.new(ARGV) do
42
42
  helper.set_client(options)
43
43
  end
44
44
 
45
+ USE={
46
+ :name => "use",
47
+ :large => "--use",
48
+ :description => "lock use actions"
49
+ }
50
+
51
+ MANAGE={
52
+ :name => "manage",
53
+ :large => "--manage",
54
+ :description => "lock manage actions"
55
+ }
56
+
57
+ ADMIN={
58
+ :name => "admin",
59
+ :large => "--admin",
60
+ :description => "lock admin actions"
61
+ }
62
+
63
+ ALL={
64
+ :name => "all",
65
+ :large => "--all",
66
+ :description => "lock all actions"
67
+ }
68
+
45
69
  ########################################################################
46
70
  # Global Options
47
71
  ########################################################################
@@ -314,4 +338,43 @@ cmd=CommandParser::CmdParser.new(ARGV) do
314
338
  command :top, top_desc, [:filterflag, nil], :options=>list_options do
315
339
  helper.list_pool(options, true, args[0])
316
340
  end
341
+
342
+ lock_desc = <<-EOT.unindent
343
+ Locks a VM with differents levels for lock any actions with this VM, show and
344
+ monitoring never will be locked.
345
+ Valid states are: All.
346
+ Levels:
347
+ [Use]: locks Admin, Manage and Use actions.
348
+ [Manage]: locks Manage and Use actions.
349
+ [Admin]: locks only Admin actions.
350
+ EOT
351
+
352
+ command :lock, lock_desc, :vrouterid,
353
+ :options => [USE, MANAGE, ADMIN, ALL] do
354
+ helper.perform_action(args[0],options,"VRouter locked") do |vr|
355
+ if !options[:use].nil?
356
+ level = 1
357
+ elsif !options[:manage].nil?
358
+ level = 2
359
+ elsif !options[:admin].nil?
360
+ level = 3
361
+ elsif !options[:all].nil?
362
+ level = 4
363
+ else
364
+ level = 1
365
+ end
366
+ vr.lock(level)
367
+ end
368
+ end
369
+
370
+ unlock_desc = <<-EOT.unindent
371
+ Unlocks a VM for unlock any actions with this VM.
372
+ valid states are: All.
373
+ EOT
374
+
375
+ command :unlock, unlock_desc, :vrouterid do
376
+ helper.perform_action(args[0],options,"VRouter unlocked") do |vr|
377
+ vr.unlock
378
+ end
379
+ end
317
380
  end