opennebula-cli 5.10.5 → 5.12.0.1
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.
- checksums.yaml +4 -4
- data/bin/oneacct +4 -2
- data/bin/oneacl +4 -2
- data/bin/onecluster +4 -2
- data/bin/onedatastore +4 -2
- data/bin/oneflow +151 -552
- data/bin/oneflow-template +173 -293
- data/bin/onegroup +4 -2
- data/bin/onehook +4 -2
- data/bin/onehost +78 -10
- data/bin/oneimage +4 -2
- data/bin/onemarket +4 -2
- data/bin/onemarketapp +17 -4
- data/bin/onesecgroup +4 -2
- data/bin/oneshowback +4 -2
- data/bin/onetemplate +4 -2
- data/bin/oneuser +4 -2
- data/bin/onevcenter +4 -2
- data/bin/onevdc +4 -2
- data/bin/onevm +90 -17
- data/bin/onevmgroup +4 -2
- data/bin/onevnet +13 -4
- data/bin/onevntemplate +4 -2
- data/bin/onevrouter +4 -2
- data/bin/onezone +7 -2
- data/lib/cli_helper.rb +54 -30
- data/lib/command_parser.rb +33 -14
- data/lib/one_helper.rb +258 -6
- data/lib/one_helper/oneacct_helper.rb +1 -1
- data/lib/one_helper/oneacl_helper.rb +1 -1
- data/lib/one_helper/onecluster_helper.rb +4 -4
- data/lib/one_helper/onedatastore_helper.rb +1 -1
- data/lib/one_helper/oneflow_helper.rb +419 -0
- data/lib/one_helper/oneflowtemplate_helper.rb +312 -0
- data/lib/one_helper/onegroup_helper.rb +1 -1
- data/lib/one_helper/onehook_helper.rb +1 -1
- data/lib/one_helper/onehost_helper.rb +148 -68
- data/lib/one_helper/oneimage_helper.rb +2 -2
- data/lib/one_helper/onemarket_helper.rb +1 -1
- data/lib/one_helper/onemarketapp_helper.rb +1 -1
- data/lib/one_helper/oneprovision_helper.rb +104 -60
- data/lib/one_helper/onequota_helper.rb +1 -1
- data/lib/one_helper/onesecgroup_helper.rb +1 -1
- data/lib/one_helper/onetemplate_helper.rb +9 -180
- data/lib/one_helper/oneuser_helper.rb +1 -1
- data/lib/one_helper/onevcenter_helper.rb +2 -1
- data/lib/one_helper/onevdc_helper.rb +1 -1
- data/lib/one_helper/onevm_helper.rb +11 -6
- data/lib/one_helper/onevmgroup_helper.rb +1 -1
- data/lib/one_helper/onevnet_helper.rb +1 -1
- data/lib/one_helper/onevntemplate_helper.rb +1 -1
- data/lib/one_helper/onevrouter_helper.rb +1 -1
- data/lib/one_helper/onezone_helper.rb +3 -1
- metadata +15 -13
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -82,7 +82,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
|
82
82
|
:description => 'Path of the image file',
|
83
83
|
:format => String,
|
84
84
|
:proc => lambda do |o, _options|
|
85
|
-
next [0, o] if o.match(%r{^https
|
85
|
+
next [0, o] if o.match(%r{^(https?|docker)://})
|
86
86
|
|
87
87
|
if o[0, 1]=='/'
|
88
88
|
path=o
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -14,11 +14,23 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
+
require 'nokogiri'
|
17
18
|
require 'securerandom'
|
18
19
|
|
19
20
|
# OneProvision Helper
|
20
21
|
class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
21
22
|
|
23
|
+
RESOURCES = %w[
|
24
|
+
CLUSTERS
|
25
|
+
DATASTORES
|
26
|
+
HOSTS
|
27
|
+
NETWORKS
|
28
|
+
IMAGES
|
29
|
+
TEMPLATES
|
30
|
+
VNTEMPLATES
|
31
|
+
FLOWTEMPLATES
|
32
|
+
]
|
33
|
+
|
22
34
|
def self.rname
|
23
35
|
'PROVISION'
|
24
36
|
end
|
@@ -31,6 +43,7 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
|
31
43
|
OneProvision::OneProvisionLogger.get_logger(options)
|
32
44
|
OneProvision::Mode.get_run_mode(options)
|
33
45
|
OneProvision::Options.get_run_options(options)
|
46
|
+
OneProvision::ObjectOptions.get_obj_options(options)
|
34
47
|
end
|
35
48
|
|
36
49
|
def format_pool
|
@@ -46,26 +59,26 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
|
46
59
|
end
|
47
60
|
|
48
61
|
column :CLUSTERS, 'Number of Clusters', :size => 8 do |p|
|
49
|
-
p['CLUSTERS']['ID'].size
|
62
|
+
p['CLUSTERS']['ID'].size rescue 0
|
50
63
|
end
|
51
64
|
|
52
65
|
column :HOSTS, 'Number of Hosts', :size => 5 do |p|
|
53
|
-
p['HOSTS']['ID'].size
|
66
|
+
p['HOSTS']['ID'].size rescue 0
|
54
67
|
end
|
55
68
|
|
56
|
-
column :
|
57
|
-
p['
|
69
|
+
column :NETWORKS, 'Number of Networks', :size => 5 do |p|
|
70
|
+
p['NETWORKS']['ID'].size rescue 0
|
58
71
|
end
|
59
72
|
|
60
73
|
column :DATASTORES, 'Number of Datastores', :size => 10 do |p|
|
61
|
-
p['DATASTORES']['ID'].size
|
74
|
+
p['DATASTORES']['ID'].size rescue 0
|
62
75
|
end
|
63
76
|
|
64
77
|
column :STAT, 'Status of the Provision', :left, :size => 15 do |p|
|
65
|
-
p['STATUS']
|
78
|
+
p['STATUS'] rescue '-'
|
66
79
|
end
|
67
80
|
|
68
|
-
default :ID, :NAME, :CLUSTERS, :HOSTS, :
|
81
|
+
default :ID, :NAME, :CLUSTERS, :HOSTS, :NETWORKS, :DATASTORES, :STAT
|
69
82
|
end
|
70
83
|
|
71
84
|
table
|
@@ -75,14 +88,14 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
|
75
88
|
# Helper provision functions
|
76
89
|
#######################################################################
|
77
90
|
|
78
|
-
def create(config, cleanup, timeout)
|
91
|
+
def create(config, cleanup, timeout, virtual)
|
79
92
|
msg = 'OpenNebula is not running'
|
80
93
|
|
81
94
|
OneProvision::Utils.fail(msg) if OneProvision::Utils.one_running?
|
82
95
|
|
83
96
|
provision = OneProvision::Provision.new(SecureRandom.uuid)
|
84
97
|
|
85
|
-
provision.create(config, cleanup, timeout)
|
98
|
+
provision.create(config, cleanup, timeout, virtual)
|
86
99
|
end
|
87
100
|
|
88
101
|
def configure(provision_id, force)
|
@@ -105,8 +118,9 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
|
105
118
|
# Helper host functions
|
106
119
|
#######################################################################
|
107
120
|
|
108
|
-
def host_operation(
|
109
|
-
host = OneProvision::Host.new
|
121
|
+
def host_operation(id, operation, options, args)
|
122
|
+
host = OneProvision::Host.new
|
123
|
+
host.info(id)
|
110
124
|
|
111
125
|
case operation[:operation]
|
112
126
|
when 'resume'
|
@@ -140,17 +154,17 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
|
140
154
|
end
|
141
155
|
|
142
156
|
#######################################################################
|
143
|
-
# Helper
|
157
|
+
# Helper network functions
|
144
158
|
#######################################################################
|
145
159
|
|
146
|
-
def
|
160
|
+
def network_operation(network, operation)
|
147
161
|
case operation[:operation]
|
148
162
|
when 'delete'
|
149
|
-
msg = "Deleting
|
163
|
+
msg = "Deleting network #{network['ID']}"
|
150
164
|
|
151
165
|
OneProvision::OneProvisionLogger.info(msg)
|
152
166
|
|
153
|
-
|
167
|
+
network.delete
|
154
168
|
end
|
155
169
|
end
|
156
170
|
|
@@ -166,7 +180,7 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
|
166
180
|
case type
|
167
181
|
when 'HOST' then helper = OneHostHelper.new
|
168
182
|
when 'DATASTORE' then helper = OneDatastoreHelper.new
|
169
|
-
when '
|
183
|
+
when 'NETWORK' then helper = OneVNetHelper.new
|
170
184
|
end
|
171
185
|
|
172
186
|
objects = names_to_ids(args[0], type)
|
@@ -177,11 +191,11 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
|
177
191
|
operation[:message]) do |obj|
|
178
192
|
case type
|
179
193
|
when 'HOST'
|
180
|
-
host_operation(obj, operation, options, args[1])
|
194
|
+
host_operation(obj['ID'], operation, options, args[1])
|
181
195
|
when 'DATASTORE'
|
182
196
|
datastore_operation(obj, operation)
|
183
|
-
when '
|
184
|
-
|
197
|
+
when 'NETWORK'
|
198
|
+
network_operation(obj, operation)
|
185
199
|
end
|
186
200
|
end
|
187
201
|
end
|
@@ -221,7 +235,7 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
|
221
235
|
objects
|
222
236
|
end
|
223
237
|
|
224
|
-
def get_list(
|
238
|
+
def get_list(provision_list)
|
225
239
|
ret = []
|
226
240
|
ids = provision_ids
|
227
241
|
|
@@ -237,12 +251,16 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
|
237
251
|
element['NAME'] = provision.name
|
238
252
|
element['STATUS'] = provision.status
|
239
253
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
element[c.to_s.upcase]['ID'] << v['ID']
|
254
|
+
RESOURCES.each do |c|
|
255
|
+
obj = OneProvision::Resource.object(c)
|
256
|
+
obj_ids = obj.get(i).map do |o|
|
257
|
+
o['ID']
|
245
258
|
end
|
259
|
+
|
260
|
+
next if obj_ids.empty?
|
261
|
+
|
262
|
+
element[c.to_s.upcase] = { 'ID' => [] }
|
263
|
+
element[c.to_s.upcase]['ID'] = obj_ids
|
246
264
|
end
|
247
265
|
|
248
266
|
ret << element
|
@@ -252,14 +270,18 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
|
252
270
|
end
|
253
271
|
|
254
272
|
def list(options)
|
255
|
-
|
273
|
+
list = get_list(true)
|
256
274
|
|
257
|
-
|
275
|
+
if options.key? :xml
|
276
|
+
list.map {|e| to_xml(e) }
|
277
|
+
else
|
278
|
+
format_pool.show(list, options)
|
279
|
+
end
|
258
280
|
|
259
281
|
0
|
260
282
|
end
|
261
283
|
|
262
|
-
def show(provision_id)
|
284
|
+
def show(provision_id, xml)
|
263
285
|
provision = OneProvision::Provision.new(provision_id)
|
264
286
|
|
265
287
|
provision.refresh
|
@@ -267,56 +289,78 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper
|
|
267
289
|
OneProvision::Utils.fail('Provision not found.') unless provision.exists
|
268
290
|
|
269
291
|
ret = {}
|
270
|
-
ret['
|
271
|
-
ret['
|
272
|
-
ret['
|
292
|
+
ret['ID'] = provision_id
|
293
|
+
ret['NAME'] = provision.name
|
294
|
+
ret['STATUS'] = provision.status
|
273
295
|
|
274
|
-
|
275
|
-
|
296
|
+
RESOURCES.each do |r|
|
297
|
+
obj = OneProvision::Resource.object(r)
|
276
298
|
|
277
|
-
|
278
|
-
|
279
|
-
|
299
|
+
next unless obj
|
300
|
+
|
301
|
+
obj_ids = obj.get(provision_id).map {|o| o['ID'] }
|
302
|
+
|
303
|
+
next if obj_ids.empty?
|
304
|
+
|
305
|
+
ret[r] = obj_ids
|
280
306
|
end
|
281
307
|
|
282
|
-
|
308
|
+
if xml
|
309
|
+
to_xml(ret)
|
310
|
+
else
|
311
|
+
format_resource(ret)
|
312
|
+
end
|
283
313
|
|
284
314
|
0
|
285
315
|
end
|
286
316
|
|
287
317
|
def format_resource(provision)
|
288
318
|
str_h1 = '%-80s'
|
289
|
-
status = provision['
|
290
|
-
id = provision['
|
319
|
+
status = provision['STATUS']
|
320
|
+
id = provision['ID']
|
291
321
|
|
292
322
|
CLIHelper.print_header(str_h1 % "PROVISION #{id} INFORMATION")
|
293
323
|
puts format('ID : %<s>s', :s => id)
|
294
|
-
puts format('NAME : %<s>s', :s => provision['
|
324
|
+
puts format('NAME : %<s>s', :s => provision['NAME'])
|
295
325
|
puts format('STATUS : %<s>s', :s => CLIHelper.color_state(status))
|
296
326
|
|
297
|
-
|
298
|
-
|
299
|
-
provision['@clusters_ids'].each do |i|
|
300
|
-
puts format('%<s>s', :s => i)
|
301
|
-
end
|
327
|
+
RESOURCES.each do |r|
|
328
|
+
next unless provision[r]
|
302
329
|
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
330
|
+
puts
|
331
|
+
CLIHelper.print_header(format('%<s>s', :s => r.upcase))
|
332
|
+
provision[r].each do |i|
|
333
|
+
puts format('%<s>s', :s => i)
|
334
|
+
end
|
307
335
|
end
|
336
|
+
end
|
308
337
|
|
309
|
-
|
310
|
-
CLIHelper.print_header(format('%<s>s', :s => 'VNETS'))
|
311
|
-
provision['@vnets_ids'].each do |i|
|
312
|
-
puts format('%<s>s', :s => i)
|
313
|
-
end
|
338
|
+
private
|
314
339
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
340
|
+
def to_xml(provision)
|
341
|
+
xml = "<PROVISION>
|
342
|
+
<ID>#{provision['ID']}</ID>
|
343
|
+
<NAME>#{provision['NAME']}</NAME>
|
344
|
+
<STATUS>#{provision['STATUS']}</STATUS>
|
345
|
+
#{
|
346
|
+
RESOURCES.map do |r|
|
347
|
+
next unless provision[r]
|
348
|
+
|
349
|
+
provision[r] = provision[r]['ID'] if provision[r].is_a? Hash
|
350
|
+
|
351
|
+
ids = provision[r].map do |id|
|
352
|
+
"<ID>#{id}</ID>"
|
353
|
+
end.join("\n")
|
354
|
+
|
355
|
+
"<#{r.upcase}>
|
356
|
+
#{ids}
|
357
|
+
</#{r.upcase}"
|
358
|
+
end.join("\n")
|
359
|
+
}
|
360
|
+
</PROVISION>"
|
361
|
+
|
362
|
+
doc = Nokogiri.XML(xml) {|config| config.default_xml.noblanks }
|
363
|
+
puts doc.root.to_xml(:indent => 2)
|
320
364
|
end
|
321
365
|
|
322
366
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -------------------------------------------------------------------------- #
|
2
|
-
# Copyright 2002-
|
2
|
+
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
3
3
|
# #
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
5
|
# not use this file except in compliance with the License. You may obtain #
|
@@ -131,192 +131,21 @@ EOT
|
|
131
131
|
def self.get_user_inputs(template, get_defaults = false)
|
132
132
|
user_inputs = template['VMTEMPLATE']['TEMPLATE']['USER_INPUTS']
|
133
133
|
|
134
|
-
return
|
134
|
+
return '' unless user_inputs
|
135
135
|
|
136
|
-
answers =
|
137
|
-
|
138
|
-
unless get_defaults
|
139
|
-
puts 'There are some parameters that require user input. ' \
|
140
|
-
'Use the string <<EDITOR>> to launch an editor ' \
|
141
|
-
'(e.g. for multi-line inputs)'
|
142
|
-
end
|
143
|
-
|
144
|
-
user_inputs.each do |key, val|
|
145
|
-
input_cfg = val.split('|', -1)
|
146
|
-
|
147
|
-
if input_cfg.length < 3
|
148
|
-
STDERR.puts "Malformed user input. It should have at least 3 parts separated by '|':"
|
149
|
-
STDERR.puts " #{key}: #{val}"
|
150
|
-
exit(-1)
|
151
|
-
end
|
152
|
-
|
153
|
-
mandatory, type, description, params, initial = input_cfg
|
154
|
-
optional = mandatory.strip == "O"
|
155
|
-
type.strip!
|
156
|
-
description.strip!
|
157
|
-
|
158
|
-
if input_cfg.length > 3
|
159
|
-
if input_cfg.length != 5
|
160
|
-
STDERR.puts "Malformed user input. It should have 5 parts separated by '|':"
|
161
|
-
STDERR.puts " #{key}: #{val}"
|
162
|
-
exit(-1)
|
163
|
-
end
|
164
|
-
|
165
|
-
params.strip!
|
166
|
-
initial.strip!
|
167
|
-
end
|
168
|
-
|
169
|
-
if get_defaults
|
170
|
-
answers << "#{key}=\"#{initial}\"" unless mandatory == 'M'
|
171
|
-
next
|
172
|
-
end
|
173
|
-
|
174
|
-
puts " * (#{key}) #{description}"
|
175
|
-
|
176
|
-
header = " "
|
177
|
-
if initial != nil && initial != ""
|
178
|
-
header += "Press enter for default (#{initial}). "
|
179
|
-
end
|
180
|
-
|
181
|
-
case type
|
182
|
-
when 'text', 'text64'
|
183
|
-
print header
|
184
|
-
|
185
|
-
answer = STDIN.readline.chop
|
186
|
-
|
187
|
-
if answer == "<<EDITOR>>"
|
188
|
-
answer = OpenNebulaHelper.editor_input()
|
189
|
-
end
|
190
|
-
|
191
|
-
if type == 'text64'
|
192
|
-
answer = Base64::encode64(answer).strip.delete("\n")
|
193
|
-
end
|
194
|
-
|
195
|
-
when 'boolean'
|
196
|
-
print header
|
197
|
-
|
198
|
-
answer = STDIN.readline.chop
|
199
|
-
|
200
|
-
# use default in case it's empty
|
201
|
-
answer = initial if answer.empty?
|
202
|
-
|
203
|
-
unless %w[YES NO].include?(answer)
|
204
|
-
STDERR.puts "Invalid boolean '#{answer}'"
|
205
|
-
STDERR.puts 'Boolean has to be YES or NO'
|
206
|
-
exit(-1)
|
207
|
-
end
|
208
|
-
|
209
|
-
when 'password'
|
210
|
-
print header
|
211
|
-
|
212
|
-
answer = OpenNebulaHelper::OneHelper.get_password
|
213
|
-
|
214
|
-
when 'number', 'number-float'
|
215
|
-
if type == "number"
|
216
|
-
header += "Integer: "
|
217
|
-
exp = INT_EXP
|
218
|
-
else
|
219
|
-
header += "Float: "
|
220
|
-
exp = FLOAT_EXP
|
221
|
-
end
|
222
|
-
|
223
|
-
begin
|
224
|
-
print header
|
225
|
-
answer = STDIN.readline.chop
|
226
|
-
|
227
|
-
answer = initial if (answer == "")
|
228
|
-
|
229
|
-
noanswer = ((answer == "") && optional)
|
230
|
-
end while !noanswer && (answer =~ exp) == nil
|
231
|
-
|
232
|
-
if noanswer
|
233
|
-
next
|
234
|
-
end
|
235
|
-
|
236
|
-
when 'range', 'range-float'
|
237
|
-
min,max = params.split('..')
|
238
|
-
|
239
|
-
if min.nil? || max.nil?
|
240
|
-
STDERR.puts "Malformed user input. Parameters should be 'min..max':"
|
241
|
-
STDERR.puts " #{key}: #{val}"
|
242
|
-
exit(-1)
|
243
|
-
end
|
244
|
-
|
245
|
-
if type == "range"
|
246
|
-
exp = INT_EXP
|
247
|
-
min = min.to_i
|
248
|
-
max = max.to_i
|
249
|
-
|
250
|
-
header += "Integer in the range [#{min}..#{max}]: "
|
251
|
-
else
|
252
|
-
exp = FLOAT_EXP
|
253
|
-
min = min.to_f
|
254
|
-
max = max.to_f
|
255
|
-
|
256
|
-
header += "Float in the range [#{min}..#{max}]: "
|
257
|
-
end
|
258
|
-
|
259
|
-
begin
|
260
|
-
print header
|
261
|
-
answer = STDIN.readline.chop
|
262
|
-
|
263
|
-
answer = initial if (answer == "")
|
264
|
-
|
265
|
-
noanswer = ((answer == "") && optional)
|
266
|
-
end while !noanswer && ((answer =~ exp) == nil || answer.to_f < min || answer.to_f > max)
|
267
|
-
|
268
|
-
if noanswer
|
269
|
-
next
|
270
|
-
end
|
271
|
-
|
272
|
-
when 'list'
|
273
|
-
options = params.split(",")
|
274
|
-
|
275
|
-
options.each_with_index {|opt,i|
|
276
|
-
puts " #{i} #{opt}"
|
277
|
-
}
|
278
|
-
|
279
|
-
puts
|
280
|
-
|
281
|
-
header += "Please type the selection number: "
|
282
|
-
|
283
|
-
begin
|
284
|
-
print header
|
285
|
-
answer = STDIN.readline.chop
|
286
|
-
|
287
|
-
if (answer == "")
|
288
|
-
answer = initial
|
289
|
-
else
|
290
|
-
answer = options[answer.to_i]
|
291
|
-
end
|
292
|
-
|
293
|
-
noanswer = ((answer == "") && optional)
|
294
|
-
|
295
|
-
end while !noanswer && (!options.include?(answer))
|
296
|
-
|
297
|
-
if noanswer
|
298
|
-
next
|
299
|
-
end
|
300
|
-
|
301
|
-
when 'fixed'
|
302
|
-
puts " Fixed value of (#{initial}). Cannot be changed"
|
303
|
-
answer = initial
|
304
|
-
|
305
|
-
else
|
306
|
-
STDERR.puts "Wrong type for user input:"
|
307
|
-
STDERR.puts " #{key}: #{val}"
|
308
|
-
exit(-1)
|
309
|
-
end
|
136
|
+
answers = OpenNebulaHelper.parse_user_inputs(user_inputs, get_defaults)
|
310
137
|
|
138
|
+
answers_s = ''
|
139
|
+
answers.each do |key, val|
|
311
140
|
# Do not replace values that are equal to the ones already in the
|
312
141
|
# template. Useful for cpu, mem, vcpu
|
313
|
-
if
|
314
|
-
|
315
|
-
|
142
|
+
if key != template['VMTEMPLATE']['TEMPLATE'][key]
|
143
|
+
answers_s << "#{key} = \""
|
144
|
+
answers_s << val.gsub('"', "\\\"") << "\"\n"
|
316
145
|
end
|
317
146
|
end
|
318
147
|
|
319
|
-
|
148
|
+
answers_s
|
320
149
|
end
|
321
150
|
|
322
151
|
private
|