morpheus-cli 3.6.2 → 3.6.3
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/lib/morpheus/api/blueprints_interface.rb +6 -7
- data/lib/morpheus/cli/apps.rb +37 -8
- data/lib/morpheus/cli/blueprints_command.rb +220 -89
- data/lib/morpheus/cli/instances.rb +2 -2
- data/lib/morpheus/cli/packages_command.rb +1 -1
- data/lib/morpheus/cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c4ff5dbc24449eb5603e8f786653d613a1e204e03c5f5071647074127c7144e
|
4
|
+
data.tar.gz: '08e8a66410060ac421d790ab7b0ace8c3e0e2d923b99080bc686efae00047ebc'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4da0dd9d22fe6907b5c8adf120a22650802a310eacfa3b499963e6df240eebec5d13fd8462d7497ddbaed48af27fe9069a64a806e819bd09f0a0e2402518882b
|
7
|
+
data.tar.gz: 2329a3d24c1a24e7b12c71bd8b5ae6dec2997577d89a3eb2926fef3d7e1dffa6be0f03c46be7518ece5c0e9e81cee4c9d8bc0753b434654802459df631f47241
|
@@ -73,12 +73,11 @@ class Morpheus::BlueprintsInterface < Morpheus::APIClient
|
|
73
73
|
execute(method: :get, url: url, headers: headers)
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
# end
|
76
|
+
def list_types(options={})
|
77
|
+
url = "#{@base_url}/api/blueprints/types"
|
78
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
79
|
+
headers[:params].merge!(options)
|
80
|
+
execute(method: :get, url: url, headers: headers)
|
81
|
+
end
|
83
82
|
|
84
83
|
end
|
data/lib/morpheus/cli/apps.rb
CHANGED
@@ -110,13 +110,16 @@ class Morpheus::Cli::Apps
|
|
110
110
|
# options[:cloud] = val
|
111
111
|
# end
|
112
112
|
opts.on('--config JSON', String, "App Config JSON") do |val|
|
113
|
-
options[
|
113
|
+
options[:config] = JSON.parse(val.to_s)
|
114
114
|
end
|
115
115
|
opts.on('--config-yaml YAML', String, "App Config YAML") do |val|
|
116
|
-
options[
|
116
|
+
options[:config] = YAML.load(val.to_s)
|
117
117
|
end
|
118
118
|
opts.on('--config-file FILE', String, "App Config from a local JSON or YAML file") do |val|
|
119
|
-
options[
|
119
|
+
options[:config_file] = val.to_s
|
120
|
+
end
|
121
|
+
opts.on('--config-dir DIRECTORY', String, "Blueprint Config from a local directory, merging all JSON or YAML files") do |val|
|
122
|
+
options[:config_dir] = val.to_s
|
120
123
|
end
|
121
124
|
build_common_options(opts, options, [:options, :json, :dry_run, :quiet])
|
122
125
|
opts.footer = "Create a new app.\n" +
|
@@ -140,12 +143,12 @@ class Morpheus::Cli::Apps
|
|
140
143
|
end
|
141
144
|
|
142
145
|
payload = {}
|
143
|
-
|
144
|
-
|
145
|
-
config_payload = options['config']
|
146
|
+
if options[:config]
|
147
|
+
config_payload = options[:config]
|
146
148
|
payload = config_payload
|
147
|
-
|
148
|
-
|
149
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
150
|
+
elsif options[:config_file]
|
151
|
+
config_file = File.expand_path(options[:config_file])
|
149
152
|
if !File.exists?(config_file) || !File.file?(config_file)
|
150
153
|
print_red_alert "File not found: #{config_file}"
|
151
154
|
return false
|
@@ -156,9 +159,35 @@ class Morpheus::Cli::Apps
|
|
156
159
|
config_payload = JSON.parse(File.read(config_file))
|
157
160
|
end
|
158
161
|
payload = config_payload
|
162
|
+
elsif options[:config_dir]
|
163
|
+
config_dir = File.expand_path(options[:config_dir])
|
164
|
+
if !Dir.exists?(config_dir) || !File.directory?(config_dir)
|
165
|
+
print_red_alert "Directory not found: #{config_dir}"
|
166
|
+
return false
|
167
|
+
end
|
168
|
+
merged_payload = {}
|
169
|
+
config_files = []
|
170
|
+
config_files += Dir["#{config_dir}/*.json"]
|
171
|
+
config_files += Dir["#{config_dir}/*.yml"]
|
172
|
+
config_files += Dir["#{config_dir}/*.yaml"]
|
173
|
+
if config_files.empty?
|
174
|
+
print_red_alert "No .json/yaml files found in config directory: #{config_dir}"
|
175
|
+
return false
|
176
|
+
end
|
177
|
+
config_files.each do |config_file|
|
178
|
+
if config_file =~ /\.ya?ml\Z/
|
179
|
+
config_payload = YAML.load_file(config_file)
|
180
|
+
else
|
181
|
+
config_payload = JSON.parse(File.read(config_file))
|
182
|
+
end
|
183
|
+
merged_payload.deep_merge!(config_payload)
|
184
|
+
end
|
185
|
+
payload = merged_payload
|
186
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
159
187
|
else
|
160
188
|
# prompt for Name, Description, Group, Environment
|
161
189
|
payload = {}
|
190
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
162
191
|
params = Morpheus::Cli::OptionTypes.prompt(add_app_option_types, options[:options], @api_client, options[:params])
|
163
192
|
params = params.deep_compact! # remove nulls and blank strings
|
164
193
|
template_id = params.delete('blueprint')
|
@@ -6,6 +6,7 @@ class Morpheus::Cli::BlueprintsCommand
|
|
6
6
|
include Morpheus::Cli::ProvisioningHelper
|
7
7
|
set_command_name :'blueprints'
|
8
8
|
register_subcommands :list, :get, :add, :update, :remove
|
9
|
+
register_subcommands :'types' => :list_types
|
9
10
|
register_subcommands :duplicate
|
10
11
|
register_subcommands :'upload-image' => :upload_image
|
11
12
|
register_subcommands :'update-permissions' => :update_permissions
|
@@ -192,16 +193,19 @@ class Morpheus::Cli::BlueprintsCommand
|
|
192
193
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
193
194
|
opts.banner = subcommand_usage("[name] [options]")
|
194
195
|
opts.on('--config JSON', String, "Blueprint Config JSON") do |val|
|
195
|
-
options[
|
196
|
+
options[:config] = JSON.parse(val.to_s)
|
196
197
|
end
|
197
198
|
opts.on('--config-yaml YAML', String, "Blueprint Config YAML") do |val|
|
198
|
-
options[
|
199
|
+
options[:config] = YAML.load(val.to_s)
|
199
200
|
end
|
200
201
|
opts.on('--config-file FILE', String, "Blueprint Config from a local JSON or YAML file") do |val|
|
201
|
-
options[
|
202
|
+
options[:config_file] = val.to_s
|
203
|
+
end
|
204
|
+
opts.on('--config-dir DIRECTORY', String, "Blueprint Config from a local directory, merging all JSON or YAML files") do |val|
|
205
|
+
options[:config_dir] = val.to_s
|
202
206
|
end
|
203
207
|
build_option_type_options(opts, options, add_blueprint_option_types(false))
|
204
|
-
build_common_options(opts, options, [:options, :json, :dry_run, :remote])
|
208
|
+
build_common_options(opts, options, [:options, :json, :dry_run, :quiet, :remote])
|
205
209
|
opts.footer = "Create a new blueprint.\n" +
|
206
210
|
"[name] is optional and can be passed as --name or inside the config instead."
|
207
211
|
"[--config] or [--config-file] can be used to define the blueprint."
|
@@ -218,13 +222,13 @@ class Morpheus::Cli::BlueprintsCommand
|
|
218
222
|
end
|
219
223
|
connect(options)
|
220
224
|
begin
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
elsif options[
|
227
|
-
config_file = File.expand_path(options[
|
225
|
+
payload = nil
|
226
|
+
if options[:config]
|
227
|
+
config_payload = options[:config]
|
228
|
+
payload = config_payload
|
229
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
230
|
+
elsif options[:config_file]
|
231
|
+
config_file = File.expand_path(options[:config_file])
|
228
232
|
if !File.exists?(config_file) || !File.file?(config_file)
|
229
233
|
print_red_alert "File not found: #{config_file}"
|
230
234
|
return false
|
@@ -234,29 +238,59 @@ class Morpheus::Cli::BlueprintsCommand
|
|
234
238
|
else
|
235
239
|
config_payload = JSON.parse(File.read(config_file))
|
236
240
|
end
|
237
|
-
|
241
|
+
payload = config_payload
|
242
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
243
|
+
elsif options[:config_dir]
|
244
|
+
config_dir = File.expand_path(options[:config_dir])
|
245
|
+
if !Dir.exists?(config_dir) || !File.directory?(config_dir)
|
246
|
+
print_red_alert "Directory not found: #{config_dir}"
|
247
|
+
return false
|
248
|
+
end
|
249
|
+
merged_payload = {}
|
250
|
+
config_files = []
|
251
|
+
config_files += Dir["#{config_dir}/*.json"]
|
252
|
+
config_files += Dir["#{config_dir}/*.yml"]
|
253
|
+
config_files += Dir["#{config_dir}/*.yaml"]
|
254
|
+
if config_files.empty?
|
255
|
+
print_red_alert "No .json/yaml files found in config directory: #{config_dir}"
|
256
|
+
return false
|
257
|
+
end
|
258
|
+
config_files.each do |config_file|
|
259
|
+
if config_file =~ /\.ya?ml\Z/
|
260
|
+
config_payload = YAML.load_file(config_file)
|
261
|
+
else
|
262
|
+
config_payload = JSON.parse(File.read(config_file))
|
263
|
+
end
|
264
|
+
merged_payload.deep_merge!(config_payload)
|
265
|
+
end
|
266
|
+
payload = merged_payload
|
267
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
238
268
|
else
|
269
|
+
payload = {}
|
270
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
239
271
|
params = Morpheus::Cli::OptionTypes.prompt(add_blueprint_option_types, options[:options], @api_client, options[:params])
|
240
|
-
blueprint_payload = params.select {|k,v| ['name', 'description', 'category'].include?(k) }
|
272
|
+
#blueprint_payload = params.select {|k,v| ['name', 'description', 'category'].include?(k) }
|
241
273
|
# expects no namespace, just the config
|
242
|
-
|
274
|
+
#payload = blueprint_payload
|
275
|
+
payload.deep_merge!(params)
|
243
276
|
end
|
244
277
|
|
245
278
|
if options[:dry_run]
|
246
|
-
print_dry_run @blueprints_interface.dry.create(
|
279
|
+
print_dry_run @blueprints_interface.dry.create(payload)
|
247
280
|
return
|
248
281
|
end
|
249
282
|
|
250
|
-
json_response = @blueprints_interface.create(
|
283
|
+
json_response = @blueprints_interface.create(payload)
|
251
284
|
|
252
285
|
if options[:json]
|
253
286
|
print JSON.pretty_generate(json_response)
|
254
287
|
print "\n"
|
255
|
-
|
288
|
+
elsif !options[:quiet]
|
256
289
|
blueprint = json_response["blueprint"]
|
257
290
|
print_green_success "Added blueprint #{blueprint['name']}"
|
258
291
|
if !options[:no_prompt]
|
259
|
-
|
292
|
+
prompt_for_tier = options[:config].nil? && options[:config_file].nil? && options[:config_dir].nil?
|
293
|
+
if prompt_for_tier && ::Morpheus::Cli::OptionTypes::confirm("Would you like to add a tier now?", options.merge({default: false}))
|
260
294
|
add_tier([blueprint['id']])
|
261
295
|
while ::Morpheus::Cli::OptionTypes::confirm("Add another tier?", options.merge({default: false})) do
|
262
296
|
add_tier([blueprint['id']])
|
@@ -267,7 +301,7 @@ class Morpheus::Cli::BlueprintsCommand
|
|
267
301
|
end
|
268
302
|
end
|
269
303
|
end
|
270
|
-
|
304
|
+
return 0
|
271
305
|
rescue RestClient::Exception => e
|
272
306
|
print_rest_exception(e, options)
|
273
307
|
exit 1
|
@@ -279,13 +313,16 @@ class Morpheus::Cli::BlueprintsCommand
|
|
279
313
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
280
314
|
opts.banner = subcommand_usage("[id] [options]")
|
281
315
|
opts.on('--config JSON', String, "Blueprint Config JSON") do |val|
|
282
|
-
options[
|
316
|
+
options[:config] = JSON.parse(val.to_s)
|
283
317
|
end
|
284
318
|
opts.on('--config-yaml YAML', String, "Blueprint Config YAML") do |val|
|
285
|
-
options[
|
319
|
+
options[:config] = YAML.load(val.to_s)
|
286
320
|
end
|
287
321
|
opts.on('--config-file FILE', String, "Blueprint Config from a local JSON or YAML file") do |val|
|
288
|
-
options[
|
322
|
+
options[:config_file] = val.to_s
|
323
|
+
end
|
324
|
+
opts.on('--config-dir DIRECTORY', String, "Blueprint Config from a local directory, merging all JSON or YAML files") do |val|
|
325
|
+
options[:config_dir] = val.to_s
|
289
326
|
end
|
290
327
|
build_option_type_options(opts, options, update_blueprint_option_types(false))
|
291
328
|
build_common_options(opts, options, [:options, :json, :dry_run, :quiet, :remote])
|
@@ -308,13 +345,13 @@ class Morpheus::Cli::BlueprintsCommand
|
|
308
345
|
blueprint = find_blueprint_by_name_or_id(args[0])
|
309
346
|
exit 1 if blueprint.nil?
|
310
347
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
elsif options[
|
317
|
-
config_file = options[
|
348
|
+
payload = nil
|
349
|
+
if options[:config]
|
350
|
+
config_payload = options[:config]
|
351
|
+
payload = config_payload
|
352
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
353
|
+
elsif options[:config_file]
|
354
|
+
config_file = options[:config_file]
|
318
355
|
if !File.exists?(config_file)
|
319
356
|
print_red_alert "File not found: #{config_file}"
|
320
357
|
return false
|
@@ -324,36 +361,44 @@ class Morpheus::Cli::BlueprintsCommand
|
|
324
361
|
else
|
325
362
|
config_payload = JSON.parse(File.read(config_file))
|
326
363
|
end
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
if params.empty?
|
336
|
-
# print_red_alert "Specify atleast one option to update"
|
337
|
-
print_red_alert "Specify atleast one option to update.\nOr use --config or --config-file to replace the entire config."
|
338
|
-
puts optparse
|
339
|
-
exit 1
|
364
|
+
payload = config_payload
|
365
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
366
|
+
elsif options[:config_dir]
|
367
|
+
config_dir = File.expand_path(options[:config_dir])
|
368
|
+
if !Dir.exists?(config_dir) || !File.directory?(config_dir)
|
369
|
+
print_red_alert "Directory not found: #{config_dir}"
|
370
|
+
return false
|
340
371
|
end
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
372
|
+
merged_payload = {}
|
373
|
+
config_files = []
|
374
|
+
config_files += Dir["#{config_dir}/*.json"]
|
375
|
+
config_files += Dir["#{config_dir}/*.yml"]
|
376
|
+
config_files += Dir["#{config_dir}/*.yaml"]
|
377
|
+
if config_files.empty?
|
378
|
+
print_red_alert "No .json/yaml files found in config directory: #{config_dir}"
|
379
|
+
return false
|
380
|
+
end
|
381
|
+
config_files.each do |config_file|
|
382
|
+
if config_file =~ /\.ya?ml\Z/
|
383
|
+
config_payload = YAML.load_file(config_file)
|
384
|
+
else
|
385
|
+
config_payload = JSON.parse(File.read(config_file))
|
386
|
+
end
|
387
|
+
merged_payload.deep_merge!(config_payload)
|
388
|
+
end
|
389
|
+
payload = merged_payload
|
390
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
391
|
+
else
|
392
|
+
payload = blueprint["config"]
|
393
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
349
394
|
end
|
350
395
|
|
351
396
|
if options[:dry_run]
|
352
|
-
print_dry_run @blueprints_interface.dry.update(blueprint['id'],
|
397
|
+
print_dry_run @blueprints_interface.dry.update(blueprint['id'], payload)
|
353
398
|
return
|
354
399
|
end
|
355
400
|
|
356
|
-
json_response = @blueprints_interface.update(blueprint['id'],
|
401
|
+
json_response = @blueprints_interface.update(blueprint['id'], payload)
|
357
402
|
|
358
403
|
if options[:json]
|
359
404
|
print JSON.pretty_generate(json_response)
|
@@ -548,9 +593,9 @@ class Morpheus::Cli::BlueprintsCommand
|
|
548
593
|
exit 1
|
549
594
|
end
|
550
595
|
|
551
|
-
|
596
|
+
payload = {"blueprint" => {}}
|
552
597
|
if args[1]
|
553
|
-
|
598
|
+
payload["blueprint"]["name"] = args[1]
|
554
599
|
end
|
555
600
|
|
556
601
|
connect(options)
|
@@ -561,10 +606,10 @@ class Morpheus::Cli::BlueprintsCommand
|
|
561
606
|
# exit
|
562
607
|
# end
|
563
608
|
if options[:dry_run]
|
564
|
-
print_dry_run @blueprints_interface.dry.duplicate(blueprint['id'],
|
609
|
+
print_dry_run @blueprints_interface.dry.duplicate(blueprint['id'], payload)
|
565
610
|
return
|
566
611
|
end
|
567
|
-
json_response = @blueprints_interface.duplicate(blueprint['id'],
|
612
|
+
json_response = @blueprints_interface.duplicate(blueprint['id'], payload)
|
568
613
|
|
569
614
|
if options[:json]
|
570
615
|
print JSON.pretty_generate(json_response)
|
@@ -713,14 +758,14 @@ class Morpheus::Cli::BlueprintsCommand
|
|
713
758
|
|
714
759
|
# ok, make api request
|
715
760
|
blueprint["config"]["tiers"] = tiers
|
716
|
-
|
761
|
+
payload = {blueprint: blueprint}
|
717
762
|
|
718
763
|
if options[:dry_run]
|
719
|
-
print_dry_run @blueprints_interface.dry.update(blueprint['id'],
|
764
|
+
print_dry_run @blueprints_interface.dry.update(blueprint['id'], payload)
|
720
765
|
return 0
|
721
766
|
end
|
722
767
|
|
723
|
-
json_response = @blueprints_interface.update(blueprint['id'],
|
768
|
+
json_response = @blueprints_interface.update(blueprint['id'], payload)
|
724
769
|
|
725
770
|
if options[:json]
|
726
771
|
puts JSON.pretty_generate(json_response)
|
@@ -871,14 +916,14 @@ class Morpheus::Cli::BlueprintsCommand
|
|
871
916
|
|
872
917
|
# ok, make api request
|
873
918
|
blueprint["config"]["tiers"] = tiers
|
874
|
-
|
919
|
+
payload = {blueprint: blueprint}
|
875
920
|
|
876
921
|
if options[:dry_run]
|
877
|
-
print_dry_run @blueprints_interface.dry.update(blueprint['id'],
|
922
|
+
print_dry_run @blueprints_interface.dry.update(blueprint['id'], payload)
|
878
923
|
return 0
|
879
924
|
end
|
880
925
|
|
881
|
-
json_response = @blueprints_interface.update(blueprint['id'],
|
926
|
+
json_response = @blueprints_interface.update(blueprint['id'], payload)
|
882
927
|
|
883
928
|
if options[:json]
|
884
929
|
puts JSON.pretty_generate(json_response)
|
@@ -1055,13 +1100,13 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1055
1100
|
|
1056
1101
|
# ok, make api request
|
1057
1102
|
blueprint["config"]["tiers"] = tiers
|
1058
|
-
|
1103
|
+
payload = {blueprint: blueprint}
|
1059
1104
|
|
1060
1105
|
if options[:dry_run]
|
1061
|
-
print_dry_run @blueprints_interface.dry.update(blueprint['id'],
|
1106
|
+
print_dry_run @blueprints_interface.dry.update(blueprint['id'], payload)
|
1062
1107
|
return
|
1063
1108
|
end
|
1064
|
-
json_response = @blueprints_interface.update(blueprint['id'],
|
1109
|
+
json_response = @blueprints_interface.update(blueprint['id'], payload)
|
1065
1110
|
|
1066
1111
|
if options[:json]
|
1067
1112
|
puts JSON.pretty_generate(json_response)
|
@@ -1177,13 +1222,13 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1177
1222
|
|
1178
1223
|
# ok, make api request
|
1179
1224
|
blueprint["config"]["tiers"] = tiers
|
1180
|
-
|
1225
|
+
payload = {blueprint: blueprint}
|
1181
1226
|
|
1182
1227
|
if options[:dry_run]
|
1183
|
-
print_dry_run @blueprints_interface.dry.update(blueprint['id'],
|
1228
|
+
print_dry_run @blueprints_interface.dry.update(blueprint['id'], payload)
|
1184
1229
|
return
|
1185
1230
|
end
|
1186
|
-
json_response = @blueprints_interface.update(blueprint['id'],
|
1231
|
+
json_response = @blueprints_interface.update(blueprint['id'], payload)
|
1187
1232
|
|
1188
1233
|
if options[:json]
|
1189
1234
|
puts JSON.pretty_generate(json_response)
|
@@ -1286,14 +1331,14 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1286
1331
|
|
1287
1332
|
# ok, make api request
|
1288
1333
|
blueprint["config"]["tiers"] = tiers
|
1289
|
-
|
1290
|
-
#
|
1334
|
+
payload = blueprint["config"]
|
1335
|
+
# payload = {blueprint: blueprint}
|
1291
1336
|
|
1292
1337
|
if options[:dry_run]
|
1293
|
-
print_dry_run @blueprints_interface.dry.update(blueprint['id'],
|
1338
|
+
print_dry_run @blueprints_interface.dry.update(blueprint['id'], payload)
|
1294
1339
|
return
|
1295
1340
|
end
|
1296
|
-
json_response = @blueprints_interface.update(blueprint['id'],
|
1341
|
+
json_response = @blueprints_interface.update(blueprint['id'], payload)
|
1297
1342
|
|
1298
1343
|
if options[:json]
|
1299
1344
|
puts JSON.pretty_generate(json_response)
|
@@ -1431,14 +1476,14 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1431
1476
|
|
1432
1477
|
# ok, make api request
|
1433
1478
|
blueprint["config"]["tiers"] = tiers
|
1434
|
-
|
1435
|
-
#
|
1479
|
+
payload = blueprint["config"]
|
1480
|
+
# payload = {blueprint: blueprint}
|
1436
1481
|
|
1437
1482
|
if options[:dry_run]
|
1438
|
-
print_dry_run @blueprints_interface.dry.update(blueprint['id'],
|
1483
|
+
print_dry_run @blueprints_interface.dry.update(blueprint['id'], payload)
|
1439
1484
|
return
|
1440
1485
|
end
|
1441
|
-
json_response = @blueprints_interface.update(blueprint['id'],
|
1486
|
+
json_response = @blueprints_interface.update(blueprint['id'], payload)
|
1442
1487
|
|
1443
1488
|
if options[:json]
|
1444
1489
|
puts JSON.pretty_generate(json_response)
|
@@ -1495,15 +1540,15 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1495
1540
|
|
1496
1541
|
# ok, make api request
|
1497
1542
|
blueprint["config"]["tiers"] = tiers
|
1498
|
-
|
1499
|
-
#
|
1543
|
+
payload = blueprint["config"]
|
1544
|
+
# payload = {blueprint: blueprint}
|
1500
1545
|
|
1501
1546
|
if options[:dry_run]
|
1502
|
-
print_dry_run @blueprints_interface.dry.update(blueprint['id'],
|
1547
|
+
print_dry_run @blueprints_interface.dry.update(blueprint['id'], payload)
|
1503
1548
|
return
|
1504
1549
|
end
|
1505
1550
|
|
1506
|
-
json_response = @blueprints_interface.update(blueprint['id'],
|
1551
|
+
json_response = @blueprints_interface.update(blueprint['id'], payload)
|
1507
1552
|
|
1508
1553
|
|
1509
1554
|
if options[:json]
|
@@ -1594,14 +1639,14 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1594
1639
|
|
1595
1640
|
# ok, make api request
|
1596
1641
|
blueprint["config"]["tiers"] = tiers
|
1597
|
-
|
1598
|
-
#
|
1642
|
+
payload = blueprint["config"]
|
1643
|
+
# payload = {blueprint: blueprint}
|
1599
1644
|
|
1600
1645
|
if options[:dry_run]
|
1601
|
-
print_dry_run @blueprints_interface.dry.update(blueprint['id'],
|
1646
|
+
print_dry_run @blueprints_interface.dry.update(blueprint['id'], payload)
|
1602
1647
|
return
|
1603
1648
|
end
|
1604
|
-
json_response = @blueprints_interface.update(blueprint['id'],
|
1649
|
+
json_response = @blueprints_interface.update(blueprint['id'], payload)
|
1605
1650
|
|
1606
1651
|
|
1607
1652
|
if options[:json]
|
@@ -1684,14 +1729,14 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1684
1729
|
|
1685
1730
|
# ok, make api request
|
1686
1731
|
blueprint["config"]["tiers"] = tiers
|
1687
|
-
|
1688
|
-
#
|
1732
|
+
payload = blueprint["config"]
|
1733
|
+
# payload = {blueprint: blueprint}
|
1689
1734
|
|
1690
1735
|
if options[:dry_run]
|
1691
|
-
print_dry_run @blueprints_interface.dry.update(blueprint['id'],
|
1736
|
+
print_dry_run @blueprints_interface.dry.update(blueprint['id'], payload)
|
1692
1737
|
return
|
1693
1738
|
end
|
1694
|
-
json_response = @blueprints_interface.update(blueprint['id'],
|
1739
|
+
json_response = @blueprints_interface.update(blueprint['id'], payload)
|
1695
1740
|
|
1696
1741
|
|
1697
1742
|
if options[:json]
|
@@ -1755,6 +1800,70 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1755
1800
|
|
1756
1801
|
end
|
1757
1802
|
|
1803
|
+
def list_types(args)
|
1804
|
+
options = {}
|
1805
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
1806
|
+
opts.banner = subcommand_usage()
|
1807
|
+
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
1808
|
+
opts.footer = "List blueprint types."
|
1809
|
+
end
|
1810
|
+
optparse.parse!(args)
|
1811
|
+
connect(options)
|
1812
|
+
begin
|
1813
|
+
params = {}
|
1814
|
+
[:phrase, :offset, :max, :sort, :direction].each do |k|
|
1815
|
+
params[k] = options[k] unless options[k].nil?
|
1816
|
+
end
|
1817
|
+
if options[:dry_run]
|
1818
|
+
print_dry_run @blueprints_interface.dry.list_types(params)
|
1819
|
+
return
|
1820
|
+
end
|
1821
|
+
|
1822
|
+
json_response = @blueprints_interface.list_types(params)
|
1823
|
+
blueprint_types = json_response['types']
|
1824
|
+
|
1825
|
+
if options[:json]
|
1826
|
+
puts as_json(json_response, options, "types")
|
1827
|
+
return 0
|
1828
|
+
elsif options[:csv]
|
1829
|
+
puts records_as_csv(json_response['types'], options)
|
1830
|
+
return 0
|
1831
|
+
elsif options[:yaml]
|
1832
|
+
puts as_yaml(json_response, options, "types")
|
1833
|
+
return 0
|
1834
|
+
end
|
1835
|
+
|
1836
|
+
|
1837
|
+
title = "Morpheus Blueprint Types"
|
1838
|
+
subtitles = []
|
1839
|
+
if params[:phrase]
|
1840
|
+
subtitles << "Search: #{params[:phrase]}".strip
|
1841
|
+
end
|
1842
|
+
print_h1 title, subtitles
|
1843
|
+
if blueprint_types.empty?
|
1844
|
+
print cyan,"No blueprint types found.",reset,"\n"
|
1845
|
+
else
|
1846
|
+
rows = blueprint_types.collect do |blueprint_type|
|
1847
|
+
{
|
1848
|
+
code: blueprint_type['code'],
|
1849
|
+
name: blueprint_type['name']
|
1850
|
+
}
|
1851
|
+
end
|
1852
|
+
columns = [:code, :name]
|
1853
|
+
print cyan
|
1854
|
+
print as_pretty_table(rows, columns, options)
|
1855
|
+
print reset
|
1856
|
+
# print_results_pagination(json_response)
|
1857
|
+
end
|
1858
|
+
print reset,"\n"
|
1859
|
+
return 0
|
1860
|
+
|
1861
|
+
rescue RestClient::Exception => e
|
1862
|
+
print_rest_exception(e, options)
|
1863
|
+
exit 1
|
1864
|
+
end
|
1865
|
+
end
|
1866
|
+
|
1758
1867
|
private
|
1759
1868
|
|
1760
1869
|
|
@@ -1762,11 +1871,30 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1762
1871
|
[
|
1763
1872
|
{'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'displayOrder' => 1},
|
1764
1873
|
{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false, 'displayOrder' => 2},
|
1765
|
-
|
1874
|
+
# skip Type for now because other types need to use --config anyhow
|
1875
|
+
#{'fieldName' => 'type', 'fieldLabel' => 'Type', 'type' => 'select', 'selectOptions' => (connected ? get_available_blueprint_types() : []), 'required' => true, 'defaultValue' => 'morpheus', 'displayOrder' => 3},
|
1876
|
+
{'fieldName' => 'category', 'fieldLabel' => 'Category', 'type' => 'text', 'required' => false, 'displayOrder' => 4},
|
1766
1877
|
#{'fieldName' => 'group', 'fieldLabel' => 'Group', 'type' => 'select', 'selectOptions' => (connected ? get_available_groups() : []), 'required' => true}
|
1767
1878
|
]
|
1768
1879
|
end
|
1769
1880
|
|
1881
|
+
def get_available_blueprint_types(refresh=false)
|
1882
|
+
if !@available_blueprint_types || refresh
|
1883
|
+
begin
|
1884
|
+
# results = @options_interface.options_for_source('blueprintTypes',{})
|
1885
|
+
results = @blueprints_interface.list_types({})
|
1886
|
+
@available_blueprint_types = results['types'].collect {|it|
|
1887
|
+
{"name" => (it["name"] || it["code"]), "value" => (it["code"] || it["value"])}
|
1888
|
+
}
|
1889
|
+
rescue RestClient::Exception => e
|
1890
|
+
# older version
|
1891
|
+
@available_blueprint_types = [{"name" => "Morpheus", "value" => "morpheus"}, {"name" => "Terraform", "value" => "terraform"}, {"name" => "CloudFormation", "value" => "cloudFormation"}, {"name" => "ARM template", "value" => "arm"}]
|
1892
|
+
end
|
1893
|
+
end
|
1894
|
+
#puts "get_available_blueprints() rtn: #{@available_blueprints.inspect}"
|
1895
|
+
return @available_blueprint_types
|
1896
|
+
end
|
1897
|
+
|
1770
1898
|
def update_blueprint_option_types(connected=true)
|
1771
1899
|
list = add_blueprint_option_types(connected)
|
1772
1900
|
list = list.reject {|it| ["group"].include? it['fieldName'] }
|
@@ -1842,6 +1970,7 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1842
1970
|
id: blueprint['id'],
|
1843
1971
|
name: blueprint['name'],
|
1844
1972
|
description: blueprint['description'],
|
1973
|
+
type: blueprint['type'].kind_of?(Hash) ? blueprint['type']['name'] : blueprint['type'],
|
1845
1974
|
category: blueprint['category'],
|
1846
1975
|
tiers_summary: format_blueprint_tiers_summary(blueprint)
|
1847
1976
|
}
|
@@ -1856,6 +1985,7 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1856
1985
|
:id,
|
1857
1986
|
:name,
|
1858
1987
|
:description,
|
1988
|
+
:type,
|
1859
1989
|
:category,
|
1860
1990
|
{:tiers_summary => {:display_name => "TIERS", :max_width => tiers_col_width} }
|
1861
1991
|
]
|
@@ -1931,6 +2061,7 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1931
2061
|
"ID" => 'id',
|
1932
2062
|
"Name" => 'name',
|
1933
2063
|
"Description" => 'description',
|
2064
|
+
"Type" => lambda {|it| it['type'].kind_of?(Hash) ? it['type']['name'] : it['type'] },
|
1934
2065
|
"Category" => 'category',
|
1935
2066
|
"Image" => lambda {|it| it['config'] ? (it['config']['image'] == '/assets/apps/template.png' ? '(default)' : it['config']['image']) : '' },
|
1936
2067
|
"Visibility" => 'visibility'
|
@@ -903,7 +903,7 @@ class Morpheus::Cli::Instances
|
|
903
903
|
if containers.empty?
|
904
904
|
print yellow,"No containers found for instance.",reset,"\n"
|
905
905
|
else
|
906
|
-
|
906
|
+
containers = containers.sort { |x,y| x['id'] <=> y['id'] }
|
907
907
|
rows = containers.collect {|container|
|
908
908
|
stats = container['stats']
|
909
909
|
cpu_usage_str = !stats ? "" : generate_usage_bar((stats['usedCpu'] || stats['cpuUsage']).to_f, 100, {max_bars: 10})
|
@@ -1015,7 +1015,7 @@ class Morpheus::Cli::Instances
|
|
1015
1015
|
|
1016
1016
|
|
1017
1017
|
containers = json_response['containers']
|
1018
|
-
|
1018
|
+
containers = containers.sort { |x,y| x['id'] <=> y['id'] }
|
1019
1019
|
title = "Instance Containers: #{instance['name']} (#{instance['instanceType']['name']})"
|
1020
1020
|
print_h1 title
|
1021
1021
|
if containers.empty?
|
@@ -8,7 +8,7 @@ class Morpheus::Cli::LibraryPackagesCommand
|
|
8
8
|
include Morpheus::Cli::LibraryHelper
|
9
9
|
|
10
10
|
set_command_name :'packages'
|
11
|
-
register_subcommands :list, :search, :get, :install, :update, :remove, :export
|
11
|
+
register_subcommands :list, :search, :get, :install, :update, :remove, :export, :build
|
12
12
|
register_subcommands :'install-file' => :install_file
|
13
13
|
|
14
14
|
# hide until this is released
|
data/lib/morpheus/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morpheus-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Estes
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-01-
|
14
|
+
date: 2019-01-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|