morpheus-cli 3.3.2.3 → 3.3.2.4
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/cli/instances.rb +38 -13
- data/lib/morpheus/cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23b7256e7bd53616a95b10545533e64cc2968492
|
4
|
+
data.tar.gz: 8e7f50f6e32d7f0d203907b033b1c88ff644ffd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c02866eacbb6104b57f41af564b5a032b659e1029c95a4d59705b6cd91feaba103405a1664fec20c6cda1ab4e668aff08fe0412f464c5d609824360c02c90c7b
|
7
|
+
data.tar.gz: 44ca0888b0bb4857ecc52faeb5d38c16cca055507fbc3c89db5cadfc9174933c49b9efd7039873d33412beb1ed562da6a474d987496bf2d42a8bb5f1073733d6
|
@@ -208,6 +208,7 @@ class Morpheus::Cli::Instances
|
|
208
208
|
|
209
209
|
def add(args)
|
210
210
|
options = {}
|
211
|
+
options[:create_user] = true
|
211
212
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
212
213
|
# opts.banner = subcommand_usage("[type] [name]")
|
213
214
|
opts.banner = subcommand_usage("[name] -c CLOUD -t TYPE")
|
@@ -220,6 +221,9 @@ class Morpheus::Cli::Instances
|
|
220
221
|
opts.on( '-t', '--type CODE', "Instance Type" ) do |val|
|
221
222
|
options[:instance_type_code] = val
|
222
223
|
end
|
224
|
+
opts.on( '--name NAME', "Instance Name" ) do |val|
|
225
|
+
options[:instance_name] = val
|
226
|
+
end
|
223
227
|
opts.on("--copies NUMBER", Integer, "Number of copies to provision") do |val|
|
224
228
|
options[:copies] = val.to_i
|
225
229
|
end
|
@@ -232,6 +236,12 @@ class Morpheus::Cli::Instances
|
|
232
236
|
# opts.on('-L', "--lb", "Enable Load Balancer") do
|
233
237
|
# options[:enable_load_balancer] = true
|
234
238
|
# end
|
239
|
+
opts.on("--create-user on|off", String, "User Config: Create Your User. Default is on") do |val|
|
240
|
+
options[:create_user] = !['false','off','0'].include?(val.to_s)
|
241
|
+
end
|
242
|
+
opts.on("--user-group USERGROUP", String, "User Config: User Group") do |val|
|
243
|
+
options[:user_group_id] = val
|
244
|
+
end
|
235
245
|
opts.on("--shutdown-days NUMBER", Integer, "Automation: Shutdown Days") do |val|
|
236
246
|
options[:expire_days] = val.to_i
|
237
247
|
end
|
@@ -242,6 +252,9 @@ class Morpheus::Cli::Instances
|
|
242
252
|
options[:create_backup] = ['on','true','1'].include?(val.to_s.downcase) ? 'on' : 'off'
|
243
253
|
end
|
244
254
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote, :quiet])
|
255
|
+
opts.footer = "Create a new instance." + "\n" +
|
256
|
+
"[name] is required. This is the new instance name." + "\n" +
|
257
|
+
"The available options vary by --type."
|
245
258
|
end
|
246
259
|
|
247
260
|
optparse.parse!(args)
|
@@ -264,24 +277,13 @@ class Morpheus::Cli::Instances
|
|
264
277
|
payload = nil
|
265
278
|
if options[:payload]
|
266
279
|
payload = options[:payload]
|
280
|
+
# support -O OPTION switch on top of --payload
|
281
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
267
282
|
else
|
268
283
|
# prompt for all the instance configuration options
|
269
284
|
# this provisioning helper method handles all (most) of the parsing and prompting
|
270
285
|
# and it relies on the method to exit non-zero on error, like a bad CLOUD or TYPE value
|
271
286
|
payload = prompt_new_instance(options)
|
272
|
-
# other stuff
|
273
|
-
payload[:copies] = options[:copies] if options[:copies] && options[:copies] > 0
|
274
|
-
payload[:layoutSize] = options[:layout_size] if options[:layout_size] && options[:layout_size] > 0 # aka Scale Factor
|
275
|
-
payload[:createBackup] = options[:create_backup] ? 'on' : 'off' if options[:create_backup] == true
|
276
|
-
payload['instance']['expireDays'] = options[:expire_days] if options[:expire_days]
|
277
|
-
payload['instance']['shutdownDays'] = options[:shutdown_days] if options[:shutdown_days]
|
278
|
-
if options[:workflow_id]
|
279
|
-
payload['taskSetId'] = options[:workflow_id]
|
280
|
-
end
|
281
|
-
if options[:enable_load_balancer]
|
282
|
-
lb_payload = prompt_instance_load_balancer(payload['instance'], nil, options)
|
283
|
-
payload.deep_merge!(lb_payload)
|
284
|
-
end
|
285
287
|
# clean payload of empty objects
|
286
288
|
# note: this is temporary and should be fixed upstream in OptionTypes.prompt()
|
287
289
|
if payload['instance'].is_a?(Hash)
|
@@ -298,6 +300,29 @@ class Morpheus::Cli::Instances
|
|
298
300
|
end
|
299
301
|
end
|
300
302
|
|
303
|
+
if options[:instance_name]
|
304
|
+
payload['instance'] ||= payload['instance']
|
305
|
+
payload['instance']['name'] = options[:instance_name]
|
306
|
+
end
|
307
|
+
payload[:copies] = options[:copies] if options[:copies] && options[:copies] > 0
|
308
|
+
payload[:layoutSize] = options[:layout_size] if options[:layout_size] && options[:layout_size] > 0 # aka Scale Factor
|
309
|
+
payload[:createBackup] = options[:create_backup] ? 'on' : 'off' if options[:create_backup] == true
|
310
|
+
payload['instance']['expireDays'] = options[:expire_days] if options[:expire_days]
|
311
|
+
payload['instance']['shutdownDays'] = options[:shutdown_days] if options[:shutdown_days]
|
312
|
+
if options.key?(:create_user)
|
313
|
+
payload['config']['createUser'] = options[:create_user]
|
314
|
+
end
|
315
|
+
if options[:user_group_id]
|
316
|
+
payload['instance']['userGroup'] = {'id' => options[:user_group_id] }
|
317
|
+
end
|
318
|
+
if options[:workflow_id]
|
319
|
+
payload['taskSetId'] = options[:workflow_id]
|
320
|
+
end
|
321
|
+
if options[:enable_load_balancer]
|
322
|
+
lb_payload = prompt_instance_load_balancer(payload['instance'], nil, options)
|
323
|
+
payload.deep_merge!(lb_payload)
|
324
|
+
end
|
325
|
+
|
301
326
|
if options[:dry_run]
|
302
327
|
print_dry_run @instances_interface.dry.create(payload)
|
303
328
|
return 0
|
data/lib/morpheus/cli/version.rb
CHANGED