opennebula-cli 5.6.2 → 5.7.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.
- checksums.yaml +4 -4
- data/bin/oneacct +37 -35
- data/bin/oneacl +15 -15
- data/bin/onecluster +31 -31
- data/bin/onedatastore +35 -35
- data/bin/oneflow +274 -237
- data/bin/oneflow-template +161 -138
- data/bin/onegroup +32 -30
- data/bin/onehost +68 -63
- data/bin/oneimage +92 -81
- data/bin/onemarket +31 -29
- data/bin/onemarketapp +83 -75
- data/bin/onesecgroup +37 -33
- data/bin/oneshowback +40 -43
- data/bin/onetemplate +73 -70
- data/bin/oneuser +171 -158
- data/bin/onevcenter +70 -64
- data/bin/onevdc +61 -45
- data/bin/onevm +396 -260
- data/bin/onevmgroup +47 -47
- data/bin/onevnet +94 -158
- data/bin/onevntemplate +361 -0
- data/bin/onevrouter +76 -70
- data/bin/onezone +30 -31
- data/lib/one_helper.rb +106 -22
- data/lib/one_helper/oneacl_helper.rb +6 -4
- data/lib/one_helper/onevcenter_helper.rb +1 -1
- data/lib/one_helper/onevm_helper.rb +134 -91
- data/lib/one_helper/onevnet_helper.rb +20 -8
- data/lib/one_helper/onevntemplate_helper.rb +104 -0
- metadata +9 -6
data/bin/oneflow-template
CHANGED
@@ -16,26 +16,26 @@
|
|
16
16
|
# limitations under the License. #
|
17
17
|
#--------------------------------------------------------------------------- #
|
18
18
|
|
19
|
-
ONE_LOCATION=ENV[
|
19
|
+
ONE_LOCATION = ENV['ONE_LOCATION']
|
20
20
|
|
21
21
|
if !ONE_LOCATION
|
22
|
-
RUBY_LIB_LOCATION=
|
22
|
+
RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
|
23
23
|
else
|
24
|
-
RUBY_LIB_LOCATION=ONE_LOCATION+
|
24
|
+
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
$LOAD_PATH << RUBY_LIB_LOCATION
|
28
|
+
$LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
|
29
29
|
|
30
30
|
require 'command_parser'
|
31
31
|
require 'opennebula/oneflow_client'
|
32
|
-
|
32
|
+
require 'English'
|
33
33
|
require 'cli_helper'
|
34
34
|
require 'one_helper'
|
35
35
|
|
36
36
|
require 'json'
|
37
37
|
|
38
|
-
USER_AGENT =
|
38
|
+
USER_AGENT = 'CLI'
|
39
39
|
|
40
40
|
# Base Path representing the resource to be used in the requests
|
41
41
|
RESOURCE_PATH = '/service_template'
|
@@ -45,26 +45,25 @@ RESOURCE_PATH = '/service_template'
|
|
45
45
|
#
|
46
46
|
|
47
47
|
TABLE = CLIHelper::ShowTable.new(nil, self) do
|
48
|
-
column :ID,
|
49
|
-
d[
|
48
|
+
column :ID, 'ID', :size => 10 do |d|
|
49
|
+
d['ID']
|
50
50
|
end
|
51
51
|
|
52
|
-
column :USER,
|
53
|
-
d[
|
52
|
+
column :USER, 'Username', :left, :size => 15 do |d|
|
53
|
+
d['UNAME']
|
54
54
|
end
|
55
55
|
|
56
|
-
column :GROUP,
|
57
|
-
d[
|
56
|
+
column :GROUP, 'Group', :left, :size => 15 do |d|
|
57
|
+
d['GNAME']
|
58
58
|
end
|
59
59
|
|
60
|
-
column :NAME,
|
61
|
-
d[
|
60
|
+
column :NAME, 'Name', :left, :size => 37 do |d|
|
61
|
+
d['NAME']
|
62
62
|
end
|
63
63
|
|
64
64
|
default :ID, :USER, :GROUP, :NAME
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
67
|
# Show the service template information. This method is used in top and
|
69
68
|
# show commands
|
70
69
|
# @param [Service::Client] client
|
@@ -75,43 +74,45 @@ end
|
|
75
74
|
def show_service_template(client, args, options)
|
76
75
|
response = client.get("#{RESOURCE_PATH}/#{args[0]}")
|
77
76
|
|
78
|
-
if CloudClient
|
77
|
+
if CloudClient.is_error?(response)
|
79
78
|
[response.code.to_i, response.to_s]
|
80
79
|
else
|
81
|
-
#[0,response.body]
|
80
|
+
# [0,response.body]
|
82
81
|
if options[:json]
|
83
|
-
[0,response.body]
|
82
|
+
[0, response.body]
|
84
83
|
else
|
85
|
-
str=
|
86
|
-
str_h1=
|
84
|
+
str = '%-20s: %-20s'
|
85
|
+
str_h1 = '%-80s'
|
87
86
|
|
88
87
|
document_hash = JSON.parse(response.body)
|
89
88
|
template = document_hash['DOCUMENT']['TEMPLATE']['BODY']
|
90
89
|
|
91
90
|
CLIHelper.print_header(str_h1 %
|
92
|
-
"SERVICE TEMPLATE #{document_hash['DOCUMENT']['ID']}
|
91
|
+
"SERVICE TEMPLATE #{document_hash['DOCUMENT']['ID']} "\
|
92
|
+
'INFORMATION')
|
93
93
|
|
94
|
-
puts str
|
95
|
-
puts str
|
96
|
-
puts str
|
97
|
-
puts str
|
94
|
+
puts format(str, ['ID', document_hash['DOCUMENT']['ID']])
|
95
|
+
puts format(str, ['NAME', document_hash['DOCUMENT']['NAME']])
|
96
|
+
puts format(str, ['USER', document_hash['DOCUMENT']['UNAME']])
|
97
|
+
puts format(str, ['GROUP', document_hash['DOCUMENT']['GNAME']])
|
98
98
|
|
99
99
|
puts
|
100
100
|
|
101
|
-
CLIHelper.print_header(str_h1 %
|
101
|
+
CLIHelper.print_header(str_h1 % 'PERMISSIONS', false)
|
102
102
|
|
103
|
-
[
|
104
|
-
mask =
|
105
|
-
|
106
|
-
mask[
|
107
|
-
mask[
|
103
|
+
%w[OWNER GROUP OTHER].each do |e|
|
104
|
+
mask = '---'
|
105
|
+
permissions_hash = document_hash['DOCUMENT']['PERMISSIONS']
|
106
|
+
mask[0] = 'u' if permissions_hash["#{e}_U"] == '1'
|
107
|
+
mask[1] = 'm' if permissions_hash["#{e}_M"] == '1'
|
108
|
+
mask[2] = 'a' if permissions_hash["#{e}_A"] == '1'
|
108
109
|
|
109
|
-
puts str
|
110
|
-
|
110
|
+
puts format(str, [e, mask])
|
111
|
+
end
|
111
112
|
|
112
113
|
puts
|
113
114
|
|
114
|
-
CLIHelper.print_header(str_h1 %
|
115
|
+
CLIHelper.print_header(str_h1 % 'TEMPLATE CONTENTS', false)
|
115
116
|
puts JSON.pretty_generate(template)
|
116
117
|
|
117
118
|
0
|
@@ -121,19 +122,18 @@ end
|
|
121
122
|
|
122
123
|
# List the services. This method is used in top and list commands
|
123
124
|
# @param [Service::Client] client
|
124
|
-
# @param [Array] args
|
125
125
|
# @param [Hash] options
|
126
126
|
# @return [[Integer, String], Integer] Returns the exit_code and optionally
|
127
127
|
# a String to be printed
|
128
|
-
def list_service_templates(client,
|
128
|
+
def list_service_templates(client, options)
|
129
129
|
response = client.get(RESOURCE_PATH)
|
130
130
|
|
131
|
-
if CloudClient
|
131
|
+
if CloudClient.is_error?(response)
|
132
132
|
[response.code.to_i, response.to_s]
|
133
133
|
else
|
134
|
-
#[0,response.body]
|
134
|
+
# [0,response.body]
|
135
135
|
if options[:json]
|
136
|
-
[0,response.body]
|
136
|
+
[0, response.body]
|
137
137
|
else
|
138
138
|
array_list = JSON.parse(response.body)
|
139
139
|
TABLE.show(array_list['DOCUMENT_POOL']['DOCUMENT'])
|
@@ -146,8 +146,8 @@ end
|
|
146
146
|
# Commands
|
147
147
|
#
|
148
148
|
|
149
|
-
|
150
|
-
usage
|
149
|
+
CommandParser::CmdParser.new(ARGV) do
|
150
|
+
usage '`oneflow-template` <command> [<args>] [<options>]'
|
151
151
|
version OpenNebulaHelper::ONE_VERSION
|
152
152
|
|
153
153
|
set :option, Service::DEFAULT_OPTIONS
|
@@ -157,20 +157,22 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
157
157
|
#
|
158
158
|
# Formatters for arguments
|
159
159
|
#
|
160
|
-
set :format, :groupid, OpenNebulaHelper.rname_to_id_desc(
|
161
|
-
OpenNebulaHelper.rname_to_id(arg,
|
160
|
+
set :format, :groupid, OpenNebulaHelper.rname_to_id_desc('GROUP') do |arg|
|
161
|
+
OpenNebulaHelper.rname_to_id(arg, 'GROUP')
|
162
162
|
end
|
163
163
|
|
164
|
-
set :format, :userid, OpenNebulaHelper.rname_to_id_desc(
|
165
|
-
OpenNebulaHelper.rname_to_id(arg,
|
164
|
+
set :format, :userid, OpenNebulaHelper.rname_to_id_desc('USER') do |arg|
|
165
|
+
OpenNebulaHelper.rname_to_id(arg, 'USER')
|
166
166
|
end
|
167
167
|
|
168
|
-
set :format, :templateid,
|
169
|
-
Service.
|
168
|
+
set :format, :templateid,
|
169
|
+
Service.rname_to_id_desc('SERVICE TEMPLATE') do |arg|
|
170
|
+
Service.rname_to_id(arg, 'SERVICE TEMPLATE')
|
170
171
|
end
|
171
172
|
|
172
|
-
set :format, :templateid_list,
|
173
|
-
Service.
|
173
|
+
set :format, :templateid_list,
|
174
|
+
Service.list_to_id_desc('SERVICE TEMPLATE') do |arg|
|
175
|
+
Service.list_to_id(arg, 'SERVICE TEMPLATE')
|
174
176
|
end
|
175
177
|
|
176
178
|
#
|
@@ -183,12 +185,13 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
183
185
|
|
184
186
|
command :list, list_desc, :options => Service::JSON_FORMAT do
|
185
187
|
client = Service::Client.new(
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
188
|
+
:username => options[:username],
|
189
|
+
:password => options[:password],
|
190
|
+
:url => options[:server],
|
191
|
+
:user_agent => USER_AGENT
|
192
|
+
)
|
190
193
|
|
191
|
-
list_service_templates(client,
|
194
|
+
list_service_templates(client, options)
|
192
195
|
end
|
193
196
|
|
194
197
|
#
|
@@ -200,21 +203,24 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
200
203
|
EOT
|
201
204
|
|
202
205
|
command :top, top_desc,
|
203
|
-
:options => [Service::JSON_FORMAT,
|
206
|
+
:options => [Service::JSON_FORMAT,
|
207
|
+
Service::TOP,
|
208
|
+
CLIHelper::DELAY] do
|
204
209
|
client = Service::Client.new(
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
210
|
+
:username => options[:username],
|
211
|
+
:password => options[:password],
|
212
|
+
:url => options[:server],
|
213
|
+
:user_agent => USER_AGENT
|
214
|
+
)
|
209
215
|
|
210
|
-
|
216
|
+
options[:delay] ? delay = options[:delay] : delay = 3
|
211
217
|
|
212
218
|
begin
|
213
|
-
|
219
|
+
loop do
|
214
220
|
CLIHelper.scr_cls
|
215
|
-
CLIHelper.scr_move(0,0)
|
221
|
+
CLIHelper.scr_move(0, 0)
|
216
222
|
|
217
|
-
rc, message = list_service_templates(client,
|
223
|
+
rc, message = list_service_templates(client, options)
|
218
224
|
|
219
225
|
if rc != 0
|
220
226
|
raise message
|
@@ -222,7 +228,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
222
228
|
|
223
229
|
sleep delay
|
224
230
|
end
|
225
|
-
rescue
|
231
|
+
rescue StandardError => e
|
226
232
|
puts e.message
|
227
233
|
-1
|
228
234
|
end
|
@@ -238,18 +244,19 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
238
244
|
|
239
245
|
command :create, create_desc, :file, :options => Service::JSON_FORMAT do
|
240
246
|
client = Service::Client.new(
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
247
|
+
:username => options[:username],
|
248
|
+
:password => options[:password],
|
249
|
+
:url => options[:server],
|
250
|
+
:user_agent => USER_AGENT
|
251
|
+
)
|
245
252
|
|
246
253
|
response = client.post(RESOURCE_PATH, File.read(args[0]))
|
247
254
|
|
248
|
-
if CloudClient
|
255
|
+
if CloudClient.is_error?(response)
|
249
256
|
[response.code.to_i, response.to_s]
|
250
257
|
else
|
251
258
|
if options[:json]
|
252
|
-
[0,response.body]
|
259
|
+
[0, response.body]
|
253
260
|
else
|
254
261
|
template = JSON.parse(response.body)
|
255
262
|
puts "ID: #{template['DOCUMENT']['ID']}"
|
@@ -268,10 +275,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
268
275
|
|
269
276
|
command :show, show_desc, :templateid, :options => Service::JSON_FORMAT do
|
270
277
|
client = Service::Client.new(
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
278
|
+
:username => options[:username],
|
279
|
+
:password => options[:password],
|
280
|
+
:url => options[:server],
|
281
|
+
:user_agent => USER_AGENT
|
282
|
+
)
|
275
283
|
|
276
284
|
show_service_template(client, args, options)
|
277
285
|
end
|
@@ -286,14 +294,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
286
294
|
|
287
295
|
command :delete, delete_desc, [:range, :templateid_list] do
|
288
296
|
client = Service::Client.new(
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
297
|
+
:username => options[:username],
|
298
|
+
:password => options[:password],
|
299
|
+
:url => options[:server],
|
300
|
+
:user_agent => USER_AGENT
|
301
|
+
)
|
293
302
|
|
294
|
-
Service.perform_actions(args[0])
|
303
|
+
Service.perform_actions(args[0]) do |template_id|
|
295
304
|
client.delete("#{RESOURCE_PATH}/#{template_id}")
|
296
|
-
|
305
|
+
end
|
297
306
|
end
|
298
307
|
|
299
308
|
#
|
@@ -307,14 +316,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
307
316
|
command :instantiate, instantiate_desc, :templateid, [:file, nil],
|
308
317
|
:options => [Service::JSON_FORMAT, Service::TOP] do
|
309
318
|
client = Service::Client.new(
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
319
|
+
:username => options[:username],
|
320
|
+
:password => options[:password],
|
321
|
+
:url => options[:server],
|
322
|
+
:user_agent => USER_AGENT
|
323
|
+
)
|
314
324
|
|
315
|
-
params =
|
325
|
+
params = {}
|
316
326
|
|
317
|
-
if
|
327
|
+
if args[1]
|
318
328
|
params['merge_template'] = JSON.parse(File.read(args[1]))
|
319
329
|
end
|
320
330
|
|
@@ -322,11 +332,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
322
332
|
|
323
333
|
response = client.post("#{RESOURCE_PATH}/#{args[0]}/action", json_str)
|
324
334
|
|
325
|
-
if CloudClient
|
335
|
+
if CloudClient.is_error?(response)
|
326
336
|
[response.code.to_i, response.to_s]
|
327
337
|
else
|
328
338
|
if options[:json]
|
329
|
-
[0,response.body]
|
339
|
+
[0, response.body]
|
330
340
|
else
|
331
341
|
template = JSON.parse(response.body)
|
332
342
|
puts "ID: #{template['DOCUMENT']['ID']}"
|
@@ -341,41 +351,44 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
341
351
|
|
342
352
|
command :chgrp, chgrp_desc, [:range, :templateid_list], :groupid do
|
343
353
|
client = Service::Client.new(
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
354
|
+
:username => options[:username],
|
355
|
+
:password => options[:password],
|
356
|
+
:url => options[:server],
|
357
|
+
:user_agent => USER_AGENT
|
358
|
+
)
|
359
|
+
|
360
|
+
Service.perform_actions(args[0]) do |service_id|
|
361
|
+
params = {}
|
351
362
|
params['group_id'] = args[1].to_i
|
352
363
|
|
353
364
|
json_action = Service.build_json_action('chgrp', params)
|
354
365
|
|
355
366
|
client.post("#{RESOURCE_PATH}/#{service_id}/action", json_action)
|
356
|
-
|
367
|
+
end
|
357
368
|
end
|
358
369
|
|
359
370
|
chown_desc = <<-EOT.unindent
|
360
371
|
Changes the service template owner and group
|
361
372
|
EOT
|
362
373
|
|
363
|
-
command :chown, chown_desc, [:range, :templateid_list],
|
374
|
+
command :chown, chown_desc, [:range, :templateid_list],
|
375
|
+
:userid, [:groupid, nil] do
|
364
376
|
client = Service::Client.new(
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
377
|
+
:username => options[:username],
|
378
|
+
:password => options[:password],
|
379
|
+
:url => options[:server],
|
380
|
+
:user_agent => USER_AGENT
|
381
|
+
)
|
382
|
+
|
383
|
+
Service.perform_actions(args[0]) do |service_id|
|
384
|
+
params = {}
|
372
385
|
params['owner_id'] = args[1]
|
373
386
|
params['group_id'] = args[2] if args[2]
|
374
387
|
|
375
388
|
json_action = Service.build_json_action('chown', params)
|
376
389
|
|
377
390
|
client.post("#{RESOURCE_PATH}/#{service_id}/action", json_action)
|
378
|
-
|
391
|
+
end
|
379
392
|
end
|
380
393
|
|
381
394
|
chmod_desc = <<-EOT.unindent
|
@@ -384,19 +397,20 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
384
397
|
|
385
398
|
command :chmod, chmod_desc, [:range, :templateid_list], :octet do
|
386
399
|
client = Service::Client.new(
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
400
|
+
:username => options[:username],
|
401
|
+
:password => options[:password],
|
402
|
+
:url => options[:server],
|
403
|
+
:user_agent => USER_AGENT
|
404
|
+
)
|
405
|
+
|
406
|
+
Service.perform_actions(args[0]) do |service_id|
|
407
|
+
params = {}
|
394
408
|
params['octet'] = args[1]
|
395
409
|
|
396
410
|
json_action = Service.build_json_action('chmod', params)
|
397
411
|
|
398
412
|
client.post("#{RESOURCE_PATH}/#{service_id}/action", json_action)
|
399
|
-
|
413
|
+
end
|
400
414
|
end
|
401
415
|
|
402
416
|
clone_desc = <<-EOT.unindent
|
@@ -405,19 +419,21 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
405
419
|
|
406
420
|
command :clone, clone_desc, :templateid, :name do
|
407
421
|
client = Service::Client.new(
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
422
|
+
:username => options[:username],
|
423
|
+
:password => options[:password],
|
424
|
+
:url => options[:server],
|
425
|
+
:user_agent => USER_AGENT
|
426
|
+
)
|
412
427
|
|
413
|
-
params =
|
428
|
+
params = {}
|
414
429
|
params['name'] = args[1]
|
415
430
|
|
416
431
|
json_action = Service.build_json_action('clone', params)
|
417
432
|
|
418
|
-
response = client.post("#{RESOURCE_PATH}/#{args[0]}/action",
|
433
|
+
response = client.post("#{RESOURCE_PATH}/#{args[0]}/action",
|
434
|
+
json_action)
|
419
435
|
|
420
|
-
if CloudClient
|
436
|
+
if CloudClient.is_error?(response)
|
421
437
|
[response.code.to_i, response.to_s]
|
422
438
|
else
|
423
439
|
if options[:json]
|
@@ -436,19 +452,21 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
436
452
|
|
437
453
|
command :rename, rename_desc, :templateid, :name do
|
438
454
|
client = Service::Client.new(
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
455
|
+
:username => options[:username],
|
456
|
+
:password => options[:password],
|
457
|
+
:url => options[:server],
|
458
|
+
:user_agent => USER_AGENT
|
459
|
+
)
|
443
460
|
|
444
|
-
params =
|
461
|
+
params = {}
|
445
462
|
params['name'] = args[1]
|
446
463
|
|
447
464
|
json_action = Service.build_json_action('rename', params)
|
448
465
|
|
449
|
-
response = client.post("#{RESOURCE_PATH}/#{args[0]}/action",
|
466
|
+
response = client.post("#{RESOURCE_PATH}/#{args[0]}/action",
|
467
|
+
json_action)
|
450
468
|
|
451
|
-
if CloudClient
|
469
|
+
if CloudClient.is_error?(response)
|
452
470
|
[response.code.to_i, response.to_s]
|
453
471
|
else
|
454
472
|
response.code.to_i
|
@@ -463,10 +481,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
463
481
|
command :update, update_desc, :templateid, [:file, nil] do
|
464
482
|
template_id = args[0]
|
465
483
|
client = Service::Client.new(
|
466
|
-
:username
|
467
|
-
:password
|
468
|
-
:url
|
469
|
-
:user_agent => USER_AGENT
|
484
|
+
:username => options[:username],
|
485
|
+
:password => options[:password],
|
486
|
+
:url => options[:server],
|
487
|
+
:user_agent => USER_AGENT
|
488
|
+
)
|
470
489
|
|
471
490
|
if args[1]
|
472
491
|
path = args[1]
|
@@ -478,7 +497,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
478
497
|
|
479
498
|
response = client.get("#{RESOURCE_PATH}/#{template_id}")
|
480
499
|
|
481
|
-
if CloudClient
|
500
|
+
if CloudClient.is_error?(response)
|
482
501
|
exit_with_code response.code.to_i, response.to_s
|
483
502
|
else
|
484
503
|
document_hash = JSON.parse(response.body)
|
@@ -487,12 +506,16 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
487
506
|
tmp << JSON.pretty_generate(template)
|
488
507
|
tmp.flush
|
489
508
|
|
490
|
-
|
509
|
+
if ENV['EDITOR']
|
510
|
+
editor_path = ENV['EDITOR']
|
511
|
+
else
|
512
|
+
editor_path = OpenNebulaHelper::EDITOR_PATH
|
513
|
+
end
|
491
514
|
system("#{editor_path} #{path}")
|
492
515
|
|
493
|
-
unless
|
494
|
-
puts
|
495
|
-
exit
|
516
|
+
unless $CHILD_STATUS.exitstatus.zero?
|
517
|
+
puts 'Editor not defined'
|
518
|
+
exit(-1)
|
496
519
|
end
|
497
520
|
|
498
521
|
tmp.close
|
@@ -503,7 +526,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
|
503
526
|
|
504
527
|
t_str = File.read(path)
|
505
528
|
response = client.put("#{RESOURCE_PATH}/#{template_id}", t_str)
|
506
|
-
if CloudClient
|
529
|
+
if CloudClient.is_error?(response)
|
507
530
|
puts response.to_s
|
508
531
|
exit_code = response.code.to_i
|
509
532
|
end
|