morpheus-cli 4.2.21 → 4.2.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/cli/commands/standard/curl_command.rb +23 -7
- data/lib/morpheus/cli/jobs_command.rb +28 -6
- data/lib/morpheus/cli/network_pools_command.rb +14 -6
- data/lib/morpheus/cli/service_plans_command.rb +2 -2
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/workflows.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: f1e56f81e53557586c3a19751c97163f5c63ce1bda3ea04e5eadd54d7e1c08e0
|
4
|
+
data.tar.gz: 24c543afa2832100919d5451b8d8954952132db4b421cffe889882b5f7ef34e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 682d8dafc50d15c216470971f5c78ca09cba8feafa2d7f1cf0462a6368f88377a627411ba3d4287ff1669d321153be02f4db2e955606620d6a5bf8425b055e23
|
7
|
+
data.tar.gz: 60b6787aacf5b2275197c496a3ff9bc9018fe70e897def95bacb54268dbdf97d5dc362e3d8f7bbfb7b0db0b18cc8028ae99b2e1f2540bb821485c21ee27b945d
|
data/Dockerfile
CHANGED
@@ -9,15 +9,20 @@ class Morpheus::Cli::CurlCommand
|
|
9
9
|
set_command_hidden
|
10
10
|
|
11
11
|
def handle(args)
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
# support syntax for arbitrary curl args after " -- "
|
13
|
+
# eg. curl /api/instances -- -ksv
|
14
|
+
split_index = args.index("--")
|
15
|
+
curl_args = []
|
16
|
+
if split_index
|
17
|
+
if args.length > (split_index + 1)
|
18
|
+
curl_args = args[(split_index + 1)..-1]
|
19
|
+
end
|
20
|
+
args = args[0..(split_index - 1)]
|
21
|
+
end
|
15
22
|
curl_method = nil
|
16
23
|
curl_data = nil
|
17
24
|
curl_verbsose = false
|
18
25
|
show_progress = false
|
19
|
-
# puts "args is : #{args}"
|
20
|
-
# puts "curl_args is : #{curl_args}"
|
21
26
|
options = {}
|
22
27
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
23
28
|
opts.banner = "Usage: morpheus curl [path] -- [*args]"
|
@@ -98,16 +103,27 @@ EOT
|
|
98
103
|
end
|
99
104
|
curl_cmd << " \"#{url}\""
|
100
105
|
if @access_token
|
101
|
-
|
106
|
+
if !(options[:headers] && options[:headers]['Authorization'])
|
107
|
+
curl_cmd << " -H \"Authorization: Bearer #{@access_token}\""
|
108
|
+
end
|
102
109
|
end
|
103
110
|
if curl_data
|
104
111
|
#todo: curl_data.gsub("'","\\'")
|
105
112
|
curl_cmd << " --data '#{curl_data}'"
|
113
|
+
if api_path !~ /^\/?oauth/
|
114
|
+
if !(options[:headers] && options[:headers]['Content-Type'])
|
115
|
+
curl_cmd << " -H \"Content-Type: application/json\""
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
if options[:headers]
|
120
|
+
options[:headers].each do |k,v|
|
121
|
+
curl_cmd << " -H \"#{k}: #{v}\""
|
122
|
+
end
|
106
123
|
end
|
107
124
|
if !curl_args.empty?
|
108
125
|
curl_cmd << " " + curl_args.join(' ')
|
109
126
|
end
|
110
|
-
|
111
127
|
# Morpheus::Logging::DarkPrinter.puts "#{curl_cmd}" if Morpheus::Logging.debug?
|
112
128
|
curl_cmd_str = options[:scrub] ? Morpheus::Logging.scrub_message(curl_cmd) : curl_cmd
|
113
129
|
|
@@ -102,15 +102,15 @@ class Morpheus::Cli::JobsCommand
|
|
102
102
|
if stats = json_response['stats']
|
103
103
|
label_width = 17
|
104
104
|
|
105
|
-
print_h2 "
|
105
|
+
print_h2 "Execution Stats - Last 7 Days"
|
106
106
|
print cyan
|
107
107
|
|
108
108
|
print "Jobs".rjust(label_width, ' ') + ": #{stats['jobCount']}\n"
|
109
109
|
print "Executions Today".rjust(label_width, ' ') + ": #{stats['todayCount']}\n"
|
110
110
|
print "Daily Executions".rjust(label_width, ' ') + ": " + stats['executionsPerDay'].join(' | ') + "\n"
|
111
111
|
print "Total Executions".rjust(label_width, ' ') + ": #{stats['execCount']}\n"
|
112
|
-
print "Completed".rjust(label_width, ' ') + ": " + generate_usage_bar(stats['execSuccessRate'].to_f, 100) + "#{stats['execSuccess']}".rjust(15, ' ') + " of " + "#{stats['execCount']}".ljust(15, ' ') + "\n#{cyan}"
|
113
|
-
print "Failed".rjust(label_width, ' ') + ": " + generate_usage_bar(stats['execFailedRate'].to_f, 100) + "#{stats['execFailed']}".rjust(15, ' ') + " of " + "#{stats['execCount']}".ljust(15, ' ') + "\n#{cyan}"
|
112
|
+
print "Completed".rjust(label_width, ' ') + ": " + generate_usage_bar(stats['execSuccessRate'].to_f, 100, {bar_color:green}) + "#{stats['execSuccess']}".rjust(15, ' ') + " of " + "#{stats['execCount']}".ljust(15, ' ') + "\n#{cyan}"
|
113
|
+
print "Failed".rjust(label_width, ' ') + ": " + generate_usage_bar(stats['execFailedRate'].to_f, 100, {bar_color:red}) + "#{stats['execFailed']}".rjust(15, ' ') + " of " + "#{stats['execCount']}".ljust(15, ' ') + "\n#{cyan}"
|
114
114
|
end
|
115
115
|
print reset,"\n"
|
116
116
|
end
|
@@ -304,7 +304,7 @@ class Morpheus::Cli::JobsCommand
|
|
304
304
|
job_options = @jobs_interface.options(job_type_id)
|
305
305
|
|
306
306
|
# prompt task / workflow
|
307
|
-
if
|
307
|
+
if ['morpheus.task.jobType', 'morpheus.task'].include?(job_type['code'])
|
308
308
|
params['task'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'task.id', 'fieldLabel' => 'Task', 'type' => 'select', 'required' => true, 'optionSource' => 'tasks'}], options[:options], @api_client, {})['task']
|
309
309
|
else
|
310
310
|
params['workflow'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'workflow.id', 'fieldLabel' => 'Workflow', 'type' => 'select', 'required' => true, 'optionSource' => 'operationTaskSets'}], options[:options], @api_client, {})['workflow']
|
@@ -320,10 +320,11 @@ class Morpheus::Cli::JobsCommand
|
|
320
320
|
exit 1
|
321
321
|
end
|
322
322
|
params['task'] = {'id' => task['id']}
|
323
|
-
job_type_id = load_job_type_id_by_code('morpheus.task')
|
323
|
+
job_type_id = load_job_type_id_by_code('morpheus.task.jobType') || load_job_type_id_by_code('morpheus.task')
|
324
324
|
end
|
325
325
|
|
326
326
|
# workflow
|
327
|
+
task_set = nil
|
327
328
|
if !options[:workflow].nil?
|
328
329
|
task_set = find_by_name_or_id('task_set', options[:workflow])
|
329
330
|
|
@@ -332,8 +333,29 @@ class Morpheus::Cli::JobsCommand
|
|
332
333
|
exit 1
|
333
334
|
end
|
334
335
|
params['workflow'] = {'id' => task_set['id']}
|
335
|
-
job_type_id = load_job_type_id_by_code('morpheus.workflow')
|
336
|
+
job_type_id = load_job_type_id_by_code('morpheus.workflow.jobType') || load_job_type_id_by_code('morpheus.workflow')
|
336
337
|
end
|
338
|
+
# load workflow if we havent yet
|
339
|
+
if (params['workflow'] && params['workflow']['id']) && task_set.nil?
|
340
|
+
task_set = find_by_name_or_id('task_set', params['workflow']['id'])
|
341
|
+
if task_set.nil?
|
342
|
+
print_red_alert "Workflow #{params['workflow']['id']} not found"
|
343
|
+
exit 1
|
344
|
+
end
|
345
|
+
end
|
346
|
+
# prompt for custom options for workflow
|
347
|
+
custom_option_types = task_set ? task_set['optionTypes'] : nil
|
348
|
+
if custom_option_types && custom_option_types.size() > 0
|
349
|
+
# they are all returned in a single array right now, so skip prompting for the jobType optionTypes
|
350
|
+
custom_option_types.reject! { |it| it['code'] && it['code'].include?('job.type') }
|
351
|
+
custom_option_types = custom_option_types.collect {|it|
|
352
|
+
it['fieldContext'] = 'customOptions'
|
353
|
+
it
|
354
|
+
}
|
355
|
+
custom_options = Morpheus::Cli::OptionTypes.prompt(custom_option_types, options[:options], @api_client, {})
|
356
|
+
params['customOptions'] = custom_options['customOptions']
|
357
|
+
end
|
358
|
+
|
337
359
|
|
338
360
|
# load options based upon job type + task / taskset
|
339
361
|
job_options = @jobs_interface.options(job_type_id, {'taskId' => params['task'] ? params['task']['id'] : nil, 'workflowId' => params['workflow'] ? params['workflow']['id'] : nil})
|
@@ -596,22 +596,28 @@ class Morpheus::Cli::NetworkPoolsCommand
|
|
596
596
|
def add_ip(args)
|
597
597
|
options = {}
|
598
598
|
params = {}
|
599
|
+
next_free_ip = false
|
599
600
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
600
|
-
opts.banner = subcommand_usage("[network-pool] [ip]")
|
601
|
+
opts.banner = subcommand_usage("[network-pool] [ip] [--next]")
|
601
602
|
opts.on('--ip-address VALUE', String, "IP Address for this network pool IP") do |val|
|
602
603
|
options[:options]['ipAddress'] = val
|
603
604
|
end
|
605
|
+
opts.on('--next-free-ip', '--next-free-ip', "Use the next available ip address. This can be used instead of specifying an ip address") do
|
606
|
+
next_free_ip = true
|
607
|
+
end
|
604
608
|
opts.on('--hostname VALUE', String, "Hostname for this network pool IP") do |val|
|
605
609
|
options[:options]['hostname'] = val
|
606
610
|
end
|
607
611
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :quiet, :remote])
|
608
612
|
opts.footer = "Create a new network pool IP." + "\n" +
|
609
613
|
"[network-pool] is required. This is the name or id of a network pool.\n" +
|
610
|
-
"[ip] is required
|
614
|
+
"[ip] is required or --next-free-ip to use the next available address instead."
|
611
615
|
end
|
612
616
|
optparse.parse!(args)
|
613
|
-
if
|
614
|
-
|
617
|
+
if next_free_ip
|
618
|
+
verify_args!(args:args, count:1, optparse:optparse)
|
619
|
+
else
|
620
|
+
verify_args!(args:args, min:1, max:2, optparse:optparse)
|
615
621
|
end
|
616
622
|
connect(options)
|
617
623
|
begin
|
@@ -639,8 +645,10 @@ class Morpheus::Cli::NetworkPoolsCommand
|
|
639
645
|
payload['networkPoolIp'].deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
640
646
|
|
641
647
|
# IP Address
|
642
|
-
|
643
|
-
|
648
|
+
unless next_free_ip
|
649
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'ipAddress', 'fieldLabel' => 'IP Address', 'type' => 'text', 'required' => true, 'description' => 'IP Address for this network pool IP.'}], options[:options])
|
650
|
+
payload['networkPoolIp']['ipAddress'] = v_prompt['ipAddress'] unless v_prompt['ipAddress'].to_s.empty?
|
651
|
+
end
|
644
652
|
|
645
653
|
# Hostname
|
646
654
|
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'hostname', 'fieldLabel' => 'Hostname', 'type' => 'text', 'required' => true, 'description' => 'Hostname for this network pool IP.'}], options[:options])
|
@@ -409,9 +409,9 @@ class Morpheus::Cli::ServicePlanCommand
|
|
409
409
|
while Morpheus::Cli::OptionTypes.confirm("Add #{price_sets.empty? ? '' : 'another '}price set?", {:default => false}) do
|
410
410
|
price_unit = prompt_price_unit(options)
|
411
411
|
|
412
|
-
avail_price_sets ||= @price_sets_interface.list['priceSets'].collect {|it| {'name' => it['name'], 'value' => it['id'], 'priceUnit' => it['priceUnit']}}
|
412
|
+
avail_price_sets ||= @price_sets_interface.list({'priceUnit' => price_unit, 'max' => 10000})['priceSets'].collect {|it| {'name' => it['name'], 'value' => it['id'], 'priceUnit' => it['priceUnit']}}
|
413
413
|
|
414
|
-
if price_set_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'priceSet', 'type' => 'select', 'fieldLabel' => 'Price Set', 'selectOptions' => avail_price_sets
|
414
|
+
if price_set_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'priceSet', 'type' => 'select', 'fieldLabel' => 'Price Set', 'selectOptions' => avail_price_sets, 'required' => false, 'description' => 'Select Price.'}],options[:options],@api_client,{}, options[:no_prompt], true)['priceSet']
|
415
415
|
price_set = avail_price_sets.find {|it| it['value'] == price_set_id}
|
416
416
|
price_sets << {'id' => price_set['value'], 'priceUnit' => price_set['priceUnit']}
|
417
417
|
avail_price_sets.reject! {|it| it['value'] == price_set_id}
|
data/lib/morpheus/cli/version.rb
CHANGED
@@ -623,7 +623,7 @@ class Morpheus::Cli::Workflows
|
|
623
623
|
#raise_command_error "missing required option: --instance, --host or --appliance\n#{optparse}"
|
624
624
|
end
|
625
625
|
|
626
|
-
#
|
626
|
+
# prompt to workflow optionTypes for customOptions
|
627
627
|
custom_options = nil
|
628
628
|
if workflow['optionTypes'] && workflow['optionTypes'].size() > 0
|
629
629
|
custom_option_types = workflow['optionTypes'].collect {|it|
|
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: 4.2.
|
4
|
+
version: 4.2.22
|
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: 2020-09-
|
14
|
+
date: 2020-09-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|