opennebula-cli 5.12.13 → 5.13.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 (102) hide show
  1. checksums.yaml +5 -5
  2. data/bin/oneacct +5 -14
  3. data/bin/oneacl +4 -15
  4. data/bin/onecluster +6 -17
  5. data/bin/onedatastore +6 -17
  6. data/bin/oneflow +81 -23
  7. data/bin/oneflow-template +51 -27
  8. data/bin/onegroup +6 -17
  9. data/bin/onehook +6 -17
  10. data/bin/onehost +4 -15
  11. data/bin/oneimage +95 -18
  12. data/bin/onemarket +6 -17
  13. data/bin/onemarketapp +113 -20
  14. data/bin/onesecgroup +9 -17
  15. data/bin/oneshowback +14 -20
  16. data/bin/onetemplate +8 -18
  17. data/bin/oneuser +26 -17
  18. data/bin/onevcenter +6 -28
  19. data/bin/onevdc +6 -17
  20. data/bin/onevm +142 -21
  21. data/bin/onevmgroup +9 -17
  22. data/bin/onevnet +4 -15
  23. data/bin/onevntemplate +7 -17
  24. data/bin/onevrouter +6 -17
  25. data/bin/onezone +6 -17
  26. data/lib/cli_helper.rb +7 -10
  27. data/lib/command_parser.rb +1 -1
  28. data/lib/one_helper/oneacct_helper.rb +9 -22
  29. data/lib/one_helper/oneacl_helper.rb +1 -1
  30. data/lib/one_helper/onecluster_helper.rb +1 -1
  31. data/lib/one_helper/onedatastore_helper.rb +11 -1
  32. data/lib/one_helper/oneflow_helper.rb +20 -5
  33. data/lib/one_helper/oneflowtemplate_helper.rb +28 -2
  34. data/lib/one_helper/onegroup_helper.rb +1 -1
  35. data/lib/one_helper/onehook_helper.rb +1 -1
  36. data/lib/one_helper/onehost_helper.rb +1 -5
  37. data/lib/one_helper/oneimage_helper.rb +7 -7
  38. data/lib/one_helper/onemarket_helper.rb +1 -1
  39. data/lib/one_helper/onemarketapp_helper.rb +494 -96
  40. data/lib/one_helper/onequota_helper.rb +1 -1
  41. data/lib/one_helper/onesecgroup_helper.rb +1 -1
  42. data/lib/one_helper/onetemplate_helper.rb +12 -1
  43. data/lib/one_helper/oneuser_helper.rb +11 -3
  44. data/lib/one_helper/onevcenter_helper.rb +176 -146
  45. data/lib/one_helper/onevdc_helper.rb +1 -1
  46. data/lib/one_helper/onevm_helper.rb +9 -9
  47. data/lib/one_helper/onevmgroup_helper.rb +1 -1
  48. data/lib/one_helper/onevnet_helper.rb +1 -1
  49. data/lib/one_helper/onevntemplate_helper.rb +1 -1
  50. data/lib/one_helper/onevrouter_helper.rb +1 -20
  51. data/lib/one_helper/onezone_helper.rb +12 -1
  52. data/lib/one_helper.rb +398 -37
  53. data/share/schemas/xsd/acct.xsd +179 -0
  54. data/share/schemas/xsd/acl_pool.xsd +22 -0
  55. data/share/schemas/xsd/api_info.xsd +43 -0
  56. data/share/schemas/xsd/cluster.xsd +34 -0
  57. data/share/schemas/xsd/cluster_pool.xsd +12 -0
  58. data/share/schemas/xsd/datastore.xsd +67 -0
  59. data/share/schemas/xsd/datastore_pool.xsd +12 -0
  60. data/share/schemas/xsd/document.xsd +42 -0
  61. data/share/schemas/xsd/document_pool.xsd +12 -0
  62. data/share/schemas/xsd/group.xsd +179 -0
  63. data/share/schemas/xsd/group_pool.xsd +194 -0
  64. data/share/schemas/xsd/hook.xsd +59 -0
  65. data/share/schemas/xsd/hook_message_api.xsd +14 -0
  66. data/share/schemas/xsd/hook_message_retry.xsd +12 -0
  67. data/share/schemas/xsd/hook_message_state.xsd +25 -0
  68. data/share/schemas/xsd/hook_pool.xsd +12 -0
  69. data/share/schemas/xsd/host.xsd +164 -0
  70. data/share/schemas/xsd/host_pool.xsd +12 -0
  71. data/share/schemas/xsd/image.xsd +123 -0
  72. data/share/schemas/xsd/image_pool.xsd +12 -0
  73. data/share/schemas/xsd/index.xsd +49 -0
  74. data/share/schemas/xsd/marketplace.xsd +44 -0
  75. data/share/schemas/xsd/marketplace_pool.xsd +12 -0
  76. data/share/schemas/xsd/marketplaceapp.xsd +56 -0
  77. data/share/schemas/xsd/marketplaceapp_pool.xsd +12 -0
  78. data/share/schemas/xsd/opennebula_configuration.xsd +412 -0
  79. data/share/schemas/xsd/raftstatus.xsd +18 -0
  80. data/share/schemas/xsd/security_group.xsd +74 -0
  81. data/share/schemas/xsd/security_group_pool.xsd +12 -0
  82. data/share/schemas/xsd/showback.xsd +29 -0
  83. data/share/schemas/xsd/user.xsd +186 -0
  84. data/share/schemas/xsd/user_pool.xsd +201 -0
  85. data/share/schemas/xsd/vdc.xsd +76 -0
  86. data/share/schemas/xsd/vdc_pool.xsd +12 -0
  87. data/share/schemas/xsd/vm.xsd +251 -0
  88. data/share/schemas/xsd/vm_group.xsd +59 -0
  89. data/share/schemas/xsd/vm_group_pool.xsd +12 -0
  90. data/share/schemas/xsd/vm_pool.xsd +114 -0
  91. data/share/schemas/xsd/vmtemplate.xsd +52 -0
  92. data/share/schemas/xsd/vmtemplate_pool.xsd +12 -0
  93. data/share/schemas/xsd/vnet.xsd +137 -0
  94. data/share/schemas/xsd/vnet_pool.xsd +85 -0
  95. data/share/schemas/xsd/vntemplate.xsd +50 -0
  96. data/share/schemas/xsd/vntemplate_pool.xsd +12 -0
  97. data/share/schemas/xsd/vrouter.xsd +49 -0
  98. data/share/schemas/xsd/vrouter_pool.xsd +12 -0
  99. data/share/schemas/xsd/zone.xsd +40 -0
  100. data/share/schemas/xsd/zone_pool.xsd +36 -0
  101. metadata +92 -30
  102. data/lib/one_helper/oneprovision_helper.rb +0 -362
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, 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-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, 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-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, 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 #
@@ -87,6 +87,17 @@ EOT
87
87
 
88
88
  if options[:xml]
89
89
  return 0, resource.to_xml(true)
90
+ elsif options[:json]
91
+ # If body is set, the resource contains a JSON inside
92
+ if options[:body]
93
+ return 0, check_resource_xsd(resource)
94
+ else
95
+ return 0, ::JSON.pretty_generate(
96
+ check_resource_xsd(resource)
97
+ )
98
+ end
99
+ elsif options[:yaml]
100
+ return 0, check_resource_xsd(resource).to_yaml(:indent => 4)
90
101
  else
91
102
  format_resource(resource, options)
92
103
  return 0
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, 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 #
@@ -284,6 +284,14 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
284
284
  d["NAME"]
285
285
  end
286
286
 
287
+ column :ENABLED, "User is enabled", :left, :size=>4 do |d|
288
+ if d["ENABLED"] == "1"
289
+ "yes"
290
+ else
291
+ "no"
292
+ end
293
+ end
294
+
287
295
  column :GROUP, "Group of the User", :left, :size=>10 do |d|
288
296
  helper.group_name(d, options)
289
297
  end
@@ -434,7 +442,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
434
442
  d['PASSWORD']
435
443
  end
436
444
 
437
- default :ID, :NAME, :GROUP, :AUTH, :VMS, :MEMORY, :CPU
445
+ default :ID, :NAME, :ENABLED, :GROUP, :AUTH, :VMS, :MEMORY, :CPU
438
446
  end
439
447
 
440
448
  table
@@ -556,7 +564,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
556
564
  CLIHelper::ShowTable.new(nil, self) do
557
565
  column :ID, "", :size=>7 do |d|
558
566
  d["TOKEN"]
559
- end
567
+ end
560
568
 
561
569
  column :EGID, "", :left, :size=>5 do |d|
562
570
  d["EGID"].to_i == -1 ? "*" + gid : d["EGID"]
@@ -1,6 +1,5 @@
1
-
2
1
  # -------------------------------------------------------------------------- #
3
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
4
3
  # #
5
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
6
5
  # not use this file except in compliance with the License. You may obtain #
@@ -17,16 +16,21 @@
17
16
 
18
17
  require 'one_helper'
19
18
 
19
+ ##############################################################################
20
+ # Module OneVcenterHelper
21
+ ##############################################################################
20
22
  class OneVcenterHelper < OpenNebulaHelper::OneHelper
21
23
 
22
24
  #
23
25
  # vCenter importer will divide rvmomi resources
24
26
  # in this group, makes parsing easier.
25
27
  module VOBJECT
26
- DATASTORE = 1
27
- TEMPLATE = 2
28
- NETWORK = 3
29
- IMAGE = 4
28
+
29
+ DATASTORE = 1
30
+ TEMPLATE = 2
31
+ NETWORK = 3
32
+ IMAGE = 4
33
+
30
34
  end
31
35
 
32
36
  #
@@ -37,45 +41,53 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
37
41
  # struct: [Array] LIST FORMAT for opennebula cli
38
42
  # related methods: * cli_format
39
43
  #
40
- # columns: [Hash(column => Integer)] Will be used in the list command, Integer represent nbytes
44
+ # columns: [Hash(column => Integer)] Will be used in the list command,
45
+ # Integer represent nbytes
41
46
  # related methods: * format_list
42
47
  #
43
- # cli: [Array] with mandatory args, for example image listing needs a datastore
48
+ # cli: [Array] with mandatory args, for example image
49
+ # listing needs a datastore
44
50
  # related methods: * parse_opts
45
51
  #
46
- # dialogue: [Lambda] Used only for Vobject that require a previous dialogue with the user, will be triggered
52
+ # dialogue: [Lambda] Used only for Vobject that require a previous
53
+ # dialogue with the user, will be triggered
47
54
  # on importation process
48
55
  # related methods: * network_dialogue
49
56
  # * template_dialogue
50
57
  #
51
58
  TABLE = {
52
59
  VOBJECT::DATASTORE => {
53
- :struct => ["DATASTORE_LIST", "DATASTORE"],
54
- :columns => {:IMID => 5, :REF => 15, :NAME => 50, :CLUSTERS => 10},
60
+ :struct => %w[DATASTORE_LIST DATASTORE],
61
+ :columns =>
62
+ { :IMID => 5, :REF => 15, :NAME => 50, :CLUSTERS => 10 },
55
63
  :cli => [:host],
56
- :dialogue => ->(arg){}
64
+ :dialogue => ->(arg) {}
57
65
  },
58
66
  VOBJECT::TEMPLATE => {
59
- :struct => ["TEMPLATE_LIST", "TEMPLATE"],
60
- :columns => {:IMID => 5, :REF => 10, :NAME => 50},
67
+ :struct => %w[TEMPLATE_LIST TEMPLATE],
68
+ :columns => { :IMID => 5, :REF => 10, :NAME => 50 },
61
69
  :cli => [:host],
62
- :dialogue => ->(arg){ OneVcenterHelper.template_dialogue(arg) }
70
+ :dialogue => ->(arg) { OneVcenterHelper.template_dialogue(arg) }
63
71
  },
64
72
  VOBJECT::NETWORK => {
65
- :struct => ["NETWORK_LIST", "NETWORK"],
66
- :columns => {:IMID => 5, :REF => 15, :NAME => 30, :CLUSTERS => 20},
73
+ :struct => %w[NETWORK_LIST NETWORK],
74
+ :columns => {
75
+ :IMID => 5,
76
+ :REF => 15,
77
+ :NAME => 30,
78
+ :CLUSTERS => 20
79
+ },
67
80
  :cli => [:host],
68
- :dialogue => ->(arg){ OneVcenterHelper.network_dialogue(arg) }
81
+ :dialogue => ->(arg) { OneVcenterHelper.network_dialogue(arg) }
69
82
  },
70
83
  VOBJECT::IMAGE => {
71
- :struct => ["IMAGE_LIST", "IMAGE"],
72
- :columns => {:IMID => 5,:REF => 35, :PATH => 60},
84
+ :struct => %w[IMAGE_LIST IMAGE],
85
+ :columns => { :IMID => 5, :REF => 35, :PATH => 60 },
73
86
  :cli => [:host, :datastore],
74
- :dialogue => ->(arg){}
87
+ :dialogue => ->(arg) {}
75
88
  }
76
89
  }
77
90
 
78
-
79
91
  ################################################################
80
92
  # CLI ARGS
81
93
  ################################################################
@@ -83,28 +95,27 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
83
95
  # these methods will be used by table :cli property
84
96
  # the purpose is to inject code when -d option in this case is used
85
97
  #
86
- # @param arg [String] The parameter passed to the option:w
98
+ # @param arg [String] The parameter passed to the option:w
87
99
  #
88
100
 
89
101
  def datastore(arg)
90
102
  ds = VCenterDriver::VIHelper.one_item(OpenNebula::Datastore, arg)
91
103
 
92
104
  {
93
- ds_ref: ds['TEMPLATE/VCENTER_DS_REF'],
94
- one_item: ds
105
+ :ds_ref => ds['TEMPLATE/VCENTER_DS_REF'],
106
+ :one_item => ds
95
107
  }
96
108
  end
97
109
 
98
110
  def host(arg)
99
- return arg
111
+ arg
100
112
  end
101
113
 
102
114
  ########################
103
115
 
104
-
105
116
  # In list command you can use this method to print a header
106
117
  #
107
- # @param vcenter_host [String] this text will be displayed
118
+ # @param vcenter_host [String] this text will be displayed
108
119
  #
109
120
  def show_header(vcenter_host)
110
121
  CLIHelper.scr_bold
@@ -112,33 +123,33 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
112
123
  puts "# vCenter: #{vcenter_host}".ljust(50)
113
124
  CLIHelper.scr_restore
114
125
  puts
115
-
116
126
  end
117
127
 
118
128
  # Using for parse a String into a VOBJECT
119
129
  # We will use VOBJECT instances for handle any operatiion
120
130
  #
121
- # @param type [String] String representing the vCenter resource
131
+ # @param type [String] String representing the vCenter resource
122
132
  #
123
- def set_object(type)
124
- raise "you need to use -o option!" unless type
133
+ def object_update(type)
134
+ raise 'you need to use -o option!' unless type
125
135
 
126
136
  type = type.downcase
127
- if (type == "datastores")
137
+ case type
138
+ when 'datastores'
128
139
  @vobject = VOBJECT::DATASTORE
129
- elsif (type == "templates")
140
+ when 'templates'
130
141
  @vobject = VOBJECT::TEMPLATE
131
- elsif (type =="networks")
142
+ when 'networks'
132
143
  @vobject = VOBJECT::NETWORK
133
- elsif (type == "images")
144
+ when 'images'
134
145
  @vobject = VOBJECT::IMAGE
135
146
  else
136
147
  puts "unknown #{type} type option"
137
- puts " -o options:"
138
- puts " datastores"
139
- puts " templates"
140
- puts " networks"
141
- puts " images"
148
+ puts ' -o options:'
149
+ puts ' datastores'
150
+ puts ' templates'
151
+ puts ' networks'
152
+ puts ' images'
142
153
 
143
154
  exit 0
144
155
  end
@@ -146,11 +157,11 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
146
157
 
147
158
  # Handles connection to vCenter.
148
159
  #
149
- # @param options [Hash] options for the connection
160
+ # @param options [Hash] options for the connection
150
161
  #
151
162
  def connection_options(object_name, options)
152
163
  if options[:vuser].nil? || options[:vcenter].nil?
153
- raise "vCenter connection parameters are mandatory to import"\
164
+ raise 'vCenter connection parameters are mandatory to import'\
154
165
  " #{object_name}:\n"\
155
166
  "\t --vcenter vCenter hostname\n"\
156
167
  "\t --vuser username to login in vcenter"
@@ -158,23 +169,29 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
158
169
 
159
170
  password = options[:vpass] || OpenNebulaHelper::OneHelper.get_password
160
171
  {
161
- :user => options[:vuser],
162
- :password => password,
163
- :host => options[:vcenter],
164
- :port => options[:port]
172
+ :user => options[:vuser],
173
+ :password => password,
174
+ :host => options[:vcenter],
175
+ :port => options[:port]
165
176
  }
166
177
  end
167
178
 
168
- def cli_format( hash)
169
- {TABLE[@vobject][:struct].first => {TABLE[@vobject][:struct].last => hash.values}}
179
+ def cli_format(hash)
180
+ {
181
+ TABLE[@vobject][:struct].first =>
182
+ {
183
+ TABLE[@vobject][:struct].last =>
184
+ hash.values
185
+ }
186
+ }
170
187
  end
171
188
 
172
189
  # This method will print a list for a vcenter_resource.
173
190
  #
174
- def list_object(options, list)
191
+ def list_object(_options, list)
175
192
  vcenter_host = list.keys[0]
176
193
  list = cli_format(list.values.first)
177
- table = format_list()
194
+ table = format_list
178
195
 
179
196
  show_header(vcenter_host)
180
197
 
@@ -184,11 +201,12 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
184
201
  # handles :cli section of TABLE
185
202
  # used for executing the dialogue in some VOBJECTS
186
203
  #
187
- # @param object_info [Hash] This is the object with all the info related to the object
204
+ # @param object_info [Hash] This is the object
205
+ # with all the info related to the object
188
206
  # that will be imported
189
207
  #
190
208
  def cli_dialogue(object_info)
191
- return TABLE[@vobject][:dialogue].(object_info)
209
+ TABLE[@vobject][:dialogue].call(object_info)
192
210
  end
193
211
 
194
212
  # This method iterates over the possible options for certain resources
@@ -197,17 +215,18 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
197
215
  # @param opts [Hash] options object passed to the onecenter tool
198
216
  #
199
217
  def parse_opts(opts)
200
- set_object(opts[:object])
218
+ object_update(opts[:object])
201
219
 
202
220
  res = {}
203
221
  TABLE[@vobject][:cli].each do |arg|
204
222
  raise "#{arg} it's mandadory for this op" if opts[arg].nil?
205
- res[arg] = self.method(arg).call(opts[arg])
223
+
224
+ res[arg] = method(arg).call(opts[arg])
206
225
  end
207
226
 
208
227
  res[:config] = parse_file(opts[:configuration]) if opts[:configuration]
209
228
 
210
- return res
229
+ res
211
230
  end
212
231
 
213
232
  # This method will parse a yaml
@@ -218,8 +237,8 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
218
237
  #
219
238
  def parse_file(path)
220
239
  begin
221
- config = YAML::load(File.read(path))
222
- rescue Exception => e
240
+ _config = YAML.safe_load(File.read(path))
241
+ rescue StandardError => _e
223
242
  str_error="Unable to read '#{path}'. Invalid YAML syntax:\n"
224
243
 
225
244
  raise str_error
@@ -230,42 +249,44 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
230
249
  # with the purpose of build a complete CLI list
231
250
  # OpenNebula way
232
251
  #
233
- def format_list()
252
+ def format_list
234
253
  config = TABLE[@vobject][:columns]
235
- table = CLIHelper::ShowTable.new() do
236
- column :IMID, "identifier for ...", :size=>config[:IMID] || 4 do |d|
254
+ CLIHelper::ShowTable.new do
255
+ column :IMID, 'identifier for ...', :size=>config[:IMID] || 4 do |d|
237
256
  d[:import_id]
238
257
  end
239
258
 
240
- column :REF, "ref", :left, :adjust, :size=>config[:REF] || 15 do |d|
259
+ column :REF, 'ref', :left, :adjust, :size=>config[:REF] || 15 do |d|
241
260
  d[:ref]
242
261
  end
243
262
 
244
- column :NAME, "Name", :left, :expand, :size=>config[:NAME] || 20 do |d|
263
+ column :NAME, 'Name', :left, :expand,
264
+ :size=>config[:NAME] || 20 do |d|
245
265
  d[:name] || d[:simple_name]
246
266
  end
247
267
 
248
- column :CLUSTERS, "CLUSTERS", :left, :size=>config[:CLUSTERS] || 10 do |d|
268
+ column :CLUSTERS, 'CLUSTERS', :left,
269
+ :size=>config[:CLUSTERS] || 10 do |d|
249
270
  d = d[:clusters] if d[:clusters]
250
271
  d[:one_ids] || d[:cluster].to_s
251
272
  end
252
273
 
253
- column :PATH, "PATH", :left, :expand, :size=>config[:PATH] || 10 do |d|
274
+ column :PATH, 'PATH', :left, :expand,
275
+ :size=>config[:PATH] || 10 do |d|
254
276
  d[:path]
255
277
  end
256
278
 
257
279
  default(*config.keys)
258
280
  end
259
-
260
- table
261
281
  end
262
282
 
263
283
  ################################################################
264
284
  # CLI DIALOGUES
265
285
  ################################################################
266
286
  def self.template_dialogue(t)
267
- rps_list = -> {
268
- return "" if t[:rp_list].empty?
287
+ rps_list = lambda {
288
+ return '' if t[:rp_list].empty?
289
+
269
290
  puts
270
291
  t[:rp_list].each do |rp|
271
292
  puts " #{rp[:name]}"
@@ -277,91 +298,96 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
277
298
 
278
299
  # default opts
279
300
  opts = {
280
- linked_clone: '0',
281
- copy: '0',
282
- name: '',
283
- folder: '',
284
- resourcepool: [],
285
- type: ''
301
+ :linked_clone => '0',
302
+ :copy => '0',
303
+ :name => '',
304
+ :folder => '',
305
+ :resourcepool => [],
306
+ :type => ''
286
307
  }
287
308
 
288
309
  STDOUT.print "\n- Template: \e[92m#{t[:template_name]}\e[39m\n\n"\
289
310
 
290
311
  # LINKED CLONE OPTION
291
312
  STDOUT.print "\n For faster deployment operations"\
292
- " and lower disk usage, OpenNebula"\
293
- " can create new VMs as linked clones."\
294
- "\n Would you like to use Linked Clones with VMs based on this template (y/[n])? "
313
+ ' and lower disk usage, OpenNebula'\
314
+ ' can create new VMs as linked clones.'\
315
+ "\n Would you like to use Linked Clones"\
316
+ ' with VMs based on this template (y/[n])? '
295
317
 
296
318
  if STDIN.gets.strip.downcase == 'y'
297
319
  opts[:linked_clone] = '1'
298
320
 
299
-
300
321
  # CREATE COPY OPTION
301
322
  STDOUT.print "\n Linked clones requires that delta"\
302
- " disks must be created for each disk in the template."\
303
- " This operation may change the template contents."\
304
- " \n Do you want OpenNebula to create a copy of the template,"\
305
- " so the original template remains untouched ([y]/n)? "
323
+ ' disks must be created for '\
324
+ 'each disk in the template.'\
325
+ ' This operation may change the template contents.'\
326
+ " \n Do you want OpenNebula to "\
327
+ 'create a copy of the template,'\
328
+ ' so the original template remains untouched ([y]/n)? '
306
329
 
307
330
  if STDIN.gets.strip.downcase != 'n'
308
331
  opts[:copy] = '1'
309
332
 
310
333
  # NAME OPTION
311
334
  STDOUT.print "\n The new template will be named"\
312
- " adding a one- prefix to the name"\
335
+ ' adding a one- prefix to the name'\
313
336
  " of the original template. \n"\
314
- " If you prefer a different name"\
315
- " please specify or press Enter"\
316
- " to use defaults: "
337
+ ' If you prefer a different name'\
338
+ ' please specify or press Enter'\
339
+ ' to use defaults: '
317
340
 
318
341
  template_name = STDIN.gets.strip.downcase
319
342
  opts[:name] = template_name
320
343
 
321
- STDOUT.print "\n WARNING!!! The cloning operation can take some time"\
344
+ STDOUT.print "\n WARNING!!! The cloning "\
345
+ 'operation can take some time'\
322
346
  " depending on the size of disks.\n"
323
347
  end
324
348
  end
325
349
 
326
- STDOUT.print "\n\n Do you want to specify a folder where"\
327
- " the deployed VMs based on this template will appear"\
328
- " in vSphere's VM and Templates section?"\
329
- "\n If no path is set, VMs will be placed in the same"\
330
- " location where the template lives."\
331
- "\n Please specify a path using slashes to separate folders"\
332
- " e.g /Management/VMs or press Enter to use defaults: "\
350
+ sdtout_print = "\n\n Do you want to specify a folder where"\
351
+ ' the deployed VMs based on this template will appear'\
352
+ " in vSphere's VM and Templates section?"\
353
+ "\n If no path is set, VMs will be placed in the same"\
354
+ ' location where the template lives.'\
355
+ "\n Please specify a path using slashes to separate folders"\
356
+ ' e.g /Management/VMs or press Enter to use defaults: '\
357
+
358
+ STDOUT.print sdtout_print
333
359
 
334
360
  vcenter_vm_folder = STDIN.gets.strip
335
361
  opts[:folder] = vcenter_vm_folder
336
362
 
337
363
  STDOUT.print "\n\n This template is currently set to "\
338
- "launch VMs in the default resource pool."\
364
+ 'launch VMs in the default resource pool.'\
339
365
  "\n Press y to keep this behaviour, n to select"\
340
- " a new resource pool or d to delegate the choice"\
341
- " to the user ([y]/n/d)? "
366
+ ' a new resource pool or d to delegate the choice'\
367
+ ' to the user ([y]/n/d)? '
342
368
 
343
- answer = STDIN.gets.strip.downcase
369
+ answer = STDIN.gets.strip.downcase
344
370
 
345
371
  case answer.downcase
346
372
  when 'd' || 'delegate'
347
373
  opts[:type]='list'
348
374
  puts "separate with commas ',' the list that you want to deleate:"
349
375
 
350
- opts[:resourcepool] = rps_list.call.gsub(/\s+/, "").split(",")
376
+ opts[:resourcepool] = rps_list.call.gsub(/\s+/, '').split(',')
351
377
 
352
378
  when 'n' || 'no'
353
379
  opts[:type]='fixed'
354
- puts "choose the proper name"
380
+ puts 'choose the proper name'
355
381
  opts[:resourcepool] = rps_list.call
356
382
  else
357
383
  opts[:type]='default'
358
384
  end
359
385
 
360
- return opts
386
+ opts
361
387
  end
362
388
 
363
389
  def self.network_dialogue(n)
364
- ask = ->(question, default = ""){
390
+ ask = lambda {|question, default = ''|
365
391
  STDOUT.print question
366
392
  answer = STDIN.gets.strip
367
393
 
@@ -372,59 +398,63 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
372
398
 
373
399
  STDOUT.print "\n- Network: \e[92m#{n[:name]}\e[39m\n\n"\
374
400
 
375
- opts = { size: "255", type: "ether" }
401
+ opts = { :size => '255', :type => 'ether' }
376
402
 
377
- question = " How many VMs are you planning"\
378
- " to fit into this network [255]? "
379
- opts[:size] = ask.call(question, "255")
403
+ question = ' How many VMs are you planning'\
404
+ ' to fit into this network [255]? '
405
+ opts[:size] = ask.call(question, '255')
380
406
 
381
- question = " What type of Virtual Network"\
382
- " do you want to create (IPv[4],IPv[6], [E]thernet)? "
383
- type_answer = ask.call(question, "ether")
407
+ question = ' What type of Virtual Network'\
408
+ ' do you want to create (IPv[4],IPv[6], [E]thernet)? '
409
+ type_answer = ask.call(question, 'ether')
384
410
 
385
- supported_types = ["4","6","ether", "e", "ip4", "ip6" ]
411
+ supported_types = %w[4 6 ether e ip4 ip6]
386
412
  if !supported_types.include?(type_answer)
387
- type_answer = 'e'
388
- STDOUT.puts " Type [#{type_answer}] not supported,"\
389
- " defaulting to Ethernet."
413
+ type_answer = 'e'
414
+ STDOUT.puts " Type [#{type_answer}] not supported,"\
415
+ ' defaulting to Ethernet.'
390
416
  end
391
- question_ip = " Please input the first IP in the range: "
392
- question_mac = " Please input the first MAC in the range [Enter for default]: "
417
+ question_ip =
418
+ ' Please input the first IP in the range: '
419
+ question_mac =
420
+ ' Please input the first MAC in the range [Enter for default]: '
393
421
 
394
422
  case type_answer.downcase
395
- when "4", "ip4"
396
- opts[:ip] = ask.call(question_ip)
397
- opts[:mac] = ask.call(question_mac)
398
- opts[:type] = "ip"
399
- when "6", "ip6"
400
- opts[:mac] = ask.call(question_mac)
401
-
402
- question = " Do you want to use SLAAC "\
403
- "Stateless Address Autoconfiguration? ([y]/n): "
423
+ when '4', 'ip4'
424
+ opts[:ip] = ask.call(question_ip)
425
+ opts[:mac] = ask.call(question_mac)
426
+ opts[:type] = 'ip'
427
+ when '6', 'ip6'
428
+ opts[:mac] = ask.call(question_mac)
429
+
430
+ question = ' Do you want to use SLAAC '\
431
+ 'Stateless Address Autoconfiguration? ([y]/n): '
404
432
  slaac_answer = ask.call(question, 'y').downcase
405
433
 
406
- if slaac_answer == 'n'
407
- question = " Please input the IPv6 address (cannot be empty): "
408
- opts[:ip6] = ask.call(question)
434
+ if slaac_answer == 'n'
435
+ question =
436
+ ' Please input the IPv6 address (cannot be empty): '
437
+ opts[:ip6] = ask.call(question)
409
438
 
410
- question = " Please input the Prefix length (cannot be empty): "
411
- opts[:prefix_length] = ask.call(question)
439
+ question =
440
+ ' Please input the Prefix length (cannot be empty): '
441
+ opts[:prefix_length] = ask.call(question)
412
442
  opts[:type] = 'ip6_static'
413
- else
414
- question = " Please input the GLOBAL PREFIX "\
415
- "[Enter for default]: "
416
- opts[:global_prefix] = ask.call(question)
417
-
418
- question= " Please input the ULA PREFIX "\
419
- "[Enter for default]: "
420
- opts[:ula_prefix] = ask.call(question)
421
- opts[:type] = 'ip6'
422
- end
423
- when "e", "ether"
424
- opts[:mac] = ask.call(question_mac)
425
- end
426
-
427
- return opts
443
+ else
444
+ question = ' Please input the GLOBAL PREFIX '\
445
+ '[Enter for default]: '
446
+ opts[:global_prefix] = ask.call(question)
447
+
448
+ question= ' Please input the ULA PREFIX '\
449
+ '[Enter for default]: '
450
+ opts[:ula_prefix] = ask.call(question)
451
+ opts[:type] = 'ip6'
452
+ end
453
+ when 'e', 'ether'
454
+ opts[:mac] = ask.call(question_mac)
455
+ end
456
+
457
+ opts
428
458
  end
429
459
 
430
460
  def clear_tags(vmid)
@@ -469,7 +499,7 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
469
499
  end
470
500
  end
471
501
 
472
- return vm, keys_to_remove
502
+ [vm, keys_to_remove]
473
503
  end
474
504
 
475
505
  def remove_keys(vm, keys_to_remove)