morpheus-cli 6.0.1 → 6.0.2
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/api/network_services_interface.rb +16 -0
- data/lib/morpheus/cli/commands/curl_command.rb +5 -1
- data/lib/morpheus/cli/commands/invoices_command.rb +1 -1
- data/lib/morpheus/cli/commands/load_balancers.rb +5 -0
- data/lib/morpheus/cli/commands/network_services_command.rb +60 -1
- data/lib/morpheus/cli/commands/service_plans_command.rb +34 -0
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +10 -4
- data/lib/morpheus/cli/option_types.rb +3 -0
- 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: eb39926e3f31b77cdca9175335ca0260b720641e469a240618fc98816b2b98ee
|
4
|
+
data.tar.gz: ef40d39ffa3f4a6d51139524fee83dd990b082c326b528ad66a6a8e6629c43e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32d58f65d940360fdfb48ff00f88d7f2221dbe4ad1d50adbd441ee68ae79cf7fb5e1314b7d1644808a8795fa362b0e0698e0d89ef8f57187442880fc1a0fec40
|
7
|
+
data.tar.gz: 19f7a173551371d306edbbbde91ad910f96c5c77fe8c70ef09200ba85e50885e4533cfb36c1f6c26b3cacacb629d7459aabb569f03e71d07e0a5720e3134fc9c
|
data/Dockerfile
CHANGED
@@ -23,6 +23,22 @@ class Morpheus::NetworkServicesInterface < Morpheus::APIClient
|
|
23
23
|
execute(method: :get, url: url, headers: headers)
|
24
24
|
end
|
25
25
|
|
26
|
+
def get_server(server_id)
|
27
|
+
execute(method: :get, url: "#{@base_url}/api/networks/servers/#{server_id}", params: {}, headers: {})
|
28
|
+
end
|
29
|
+
|
30
|
+
def list_servers()
|
31
|
+
execute(method: :get, url: "#{@base_url}/api/networks/servers", params: {}, headers: {})
|
32
|
+
end
|
33
|
+
|
34
|
+
def refresh(server_id)
|
35
|
+
url = "#{@base_url}/api/networks/servers/#{server_id}/refresh"
|
36
|
+
|
37
|
+
headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
38
|
+
opts = {method: :post, url: url, headers: headers}
|
39
|
+
execute(opts)
|
40
|
+
end
|
41
|
+
|
26
42
|
# def create(payload)
|
27
43
|
# url = "#{@base_url}/api/networks/services"
|
28
44
|
# headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -27,7 +27,11 @@ class Morpheus::Cli::CurlCommand
|
|
27
27
|
curl_method = "DELETE"
|
28
28
|
end
|
29
29
|
opts.on( '--data DATA', String, "HTTP request body for use with POST and PUT, typically JSON." ) do |val|
|
30
|
-
|
30
|
+
begin
|
31
|
+
options[:payload] = JSON.parse(val.to_s)
|
32
|
+
rescue => ex
|
33
|
+
raise ::OptionParser::InvalidOption.new("Failed to parse payload as JSON. Error: #{ex.message}")
|
34
|
+
end
|
31
35
|
end
|
32
36
|
opts.on('--absolute', "Absolute path, value can be used to prevent automatic using the automatic /api/ path prefix to the path by default.") do
|
33
37
|
options[:absolute_path] = true
|
@@ -350,7 +350,7 @@ class Morpheus::Cli::InvoicesCommand
|
|
350
350
|
if cost_rows.sum { |it| it[:extra].to_f } == 0
|
351
351
|
cost_columns.delete("Extra".upcase)
|
352
352
|
end
|
353
|
-
print as_pretty_table(cost_rows, cost_columns, options)
|
353
|
+
print as_pretty_table(cost_rows, cost_columns, options.merge(include_fields: nil))
|
354
354
|
else
|
355
355
|
print "\n"
|
356
356
|
print yellow, "No invoice totals data", reset, "\n"
|
@@ -24,6 +24,9 @@ class Morpheus::Cli::LoadBalancers
|
|
24
24
|
render_response(json_response, options, rest_object_key) do
|
25
25
|
record = json_response[rest_object_key]
|
26
26
|
options[:exclude_username] = record['username'].nil?
|
27
|
+
options[:exclude_owner] = record['owner'].nil?
|
28
|
+
options[:exclude_tenants] = record['tenants'].nil? || record['tenants'].empty?
|
29
|
+
options[:exclude_permissions] = record['resourcePermission'].nil?
|
27
30
|
print_h1 rest_label, [], options
|
28
31
|
print cyan
|
29
32
|
print_description_list(rest_column_definitions(options), record, options)
|
@@ -125,6 +128,8 @@ EOT
|
|
125
128
|
"Provider ID" => 'externalId'
|
126
129
|
}
|
127
130
|
columns.merge!({"Username" => 'username'}) if !options[:exclude_username]
|
131
|
+
columns.merge!({"Owner" => lambda { |it| it['owner']['name'] rescue '' }}) if !options[:exclude_owner]
|
132
|
+
columns.merge!({"Tenants" => lambda { |it| it['tenants'].collect {|tenant| tenant['name']}.join(', ') rescue '' }}) if !options[:exclude_tenants]
|
128
133
|
columns.merge({
|
129
134
|
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
130
135
|
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
@@ -7,7 +7,7 @@ class Morpheus::Cli::NetworkServicesCommand
|
|
7
7
|
set_command_name :'network-services'
|
8
8
|
|
9
9
|
# register_subcommands :list, :get, :add, :update, :remove
|
10
|
-
register_subcommands :list
|
10
|
+
register_subcommands :list, :refresh
|
11
11
|
|
12
12
|
# set_default_subcommand :list
|
13
13
|
|
@@ -90,6 +90,43 @@ class Morpheus::Cli::NetworkServicesCommand
|
|
90
90
|
exit 1
|
91
91
|
end
|
92
92
|
end
|
93
|
+
|
94
|
+
def refresh(args)
|
95
|
+
options = {}
|
96
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
97
|
+
opts.banner = subcommand_usage("[name]")
|
98
|
+
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
99
|
+
opts.footer = "Refresh a network integration/server.\n" +
|
100
|
+
"[name] is required. This is the name or id of a network server/integration."
|
101
|
+
end
|
102
|
+
optparse.parse!(args)
|
103
|
+
if args.count < 1
|
104
|
+
puts optparse
|
105
|
+
exit 1
|
106
|
+
end
|
107
|
+
connect(options)
|
108
|
+
begin
|
109
|
+
server = find_network_server_by_name_or_id(args[0])
|
110
|
+
if !server
|
111
|
+
exit 1
|
112
|
+
end
|
113
|
+
@network_services_interface.setopts(options)
|
114
|
+
if options[:dry_run]
|
115
|
+
print_dry_run @network_services_interface.dry.refresh(server['id'])
|
116
|
+
return
|
117
|
+
end
|
118
|
+
json_response = @network_services_interface.refresh(server['id'])
|
119
|
+
if options[:json]
|
120
|
+
print JSON.pretty_generate(json_response)
|
121
|
+
print "\n"
|
122
|
+
elsif !options[:quiet]
|
123
|
+
print_green_success "Refreshing #{server["name"]}"
|
124
|
+
end
|
125
|
+
rescue RestClient::Exception => e
|
126
|
+
print_rest_exception(e, options)
|
127
|
+
exit 1
|
128
|
+
end
|
129
|
+
end
|
93
130
|
|
94
131
|
|
95
132
|
private
|
@@ -136,4 +173,26 @@ class Morpheus::Cli::NetworkServicesCommand
|
|
136
173
|
end
|
137
174
|
end
|
138
175
|
|
176
|
+
def find_network_server_by_name_or_id(val)
|
177
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
178
|
+
return find_network_server_by_id(val)
|
179
|
+
else
|
180
|
+
return find_network_service_by_name(val)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def find_network_server_by_id(id)
|
185
|
+
begin
|
186
|
+
json_response = @network_services_interface.get_server(id.to_i)
|
187
|
+
return json_response['networkServer']
|
188
|
+
rescue RestClient::Exception => e
|
189
|
+
if e.response && e.response.code == 404
|
190
|
+
print_red_alert "Network Service not found by id #{id}"
|
191
|
+
return nil
|
192
|
+
else
|
193
|
+
raise e
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
139
198
|
end
|
@@ -326,6 +326,18 @@ class Morpheus::Cli::ServicePlanCommand
|
|
326
326
|
opts.on('--max-cores NUMBER', String, "Max cores") do |val|
|
327
327
|
((params['config'] ||= {})['ranges'] ||= {})['maxCores'] = val.to_i
|
328
328
|
end
|
329
|
+
opts.on('--min-sockets NUMBER', String, "Min sockets") do |val|
|
330
|
+
((params['config'] ||= {})['ranges'] ||= {})['minSockets'] = val.to_i
|
331
|
+
end
|
332
|
+
opts.on('--max-sockets NUMBER', String, "Max sockets") do |val|
|
333
|
+
((params['config'] ||= {})['ranges'] ||= {})['maxSockets'] = val.to_i
|
334
|
+
end
|
335
|
+
opts.on('--min-cores-per-socket NUMBER', String, "Min cores per socket") do |val|
|
336
|
+
((params['config'] ||= {})['ranges'] ||= {})['minCoresPerSocket'] = val.to_i
|
337
|
+
end
|
338
|
+
opts.on('--max-cores-per-socket NUMBER', String, "Max cores per socket") do |val|
|
339
|
+
((params['config'] ||= {})['ranges'] ||= {})['maxCoresPerSocket'] = val.to_i
|
340
|
+
end
|
329
341
|
add_perms_options(opts, options, ['plans', 'groupDefaults'])
|
330
342
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote, :quiet])
|
331
343
|
opts.footer = "Create service plan"
|
@@ -429,6 +441,16 @@ class Morpheus::Cli::ServicePlanCommand
|
|
429
441
|
{'fieldContext' => 'config.ranges', 'fieldGroup' => 'Custom Ranges', 'fieldName' => 'maxCores', 'fieldLabel' => 'Max Cores', 'type' => 'number', 'displayOrder' => 8}
|
430
442
|
]
|
431
443
|
|
444
|
+
if provision_type['hasSocketRange']
|
445
|
+
addn_options.push({'fieldContext' => 'config.ranges', 'fieldGroup' => 'Custom Ranges', 'fieldName' => 'minSockets', 'fieldLabel' => 'Min Sockets', 'type' => 'number', 'displayOrder' => 9})
|
446
|
+
addn_options.push({'fieldContext' => 'config.ranges', 'fieldGroup' => 'Custom Ranges', 'fieldName' => 'maxSockets', 'fieldLabel' => 'Max Sockets', 'type' => 'number', 'displayOrder' => 10})
|
447
|
+
end
|
448
|
+
|
449
|
+
if provision_type['hasCoresPerSocketRange']
|
450
|
+
addn_options.push({'fieldContext' => 'config.ranges', 'fieldGroup' => 'Custom Ranges', 'fieldName' => 'minCoresPerSocket', 'fieldLabel' => 'Min Cores Per Socket', 'type' => 'number', 'displayOrder' => 11})
|
451
|
+
addn_options.push({'fieldContext' => 'config.ranges', 'fieldGroup' => 'Custom Ranges', 'fieldName' => 'maxCoresPerSocket', 'fieldLabel' => 'Max Cores Per Socket', 'type' => 'number', 'displayOrder' => 12})
|
452
|
+
end
|
453
|
+
|
432
454
|
v_prompt = Morpheus::Cli::OptionTypes.prompt(addn_options, options[:options], @api_client, params)
|
433
455
|
params.deep_merge!(v_prompt)
|
434
456
|
|
@@ -575,6 +597,18 @@ class Morpheus::Cli::ServicePlanCommand
|
|
575
597
|
end
|
576
598
|
opts.on('--max-cores NUMBER', String, "Max cores") do |val|
|
577
599
|
((params['config'] ||= {})['ranges'] ||= {})['maxCores'] = val.to_i
|
600
|
+
end
|
601
|
+
opts.on('--min-sockets NUMBER', String, "Min sockets") do |val|
|
602
|
+
((params['config'] ||= {})['ranges'] ||= {})['minSockets'] = val.to_i
|
603
|
+
end
|
604
|
+
opts.on('--max-sockets NUMBER', String, "Max sockets") do |val|
|
605
|
+
((params['config'] ||= {})['ranges'] ||= {})['maxSockets'] = val.to_i
|
606
|
+
end
|
607
|
+
opts.on('--min-cores-per-socket NUMBER', String, "Min cores per socket") do |val|
|
608
|
+
((params['config'] ||= {})['ranges'] ||= {})['minCoresPerSocket'] = val.to_i
|
609
|
+
end
|
610
|
+
opts.on('--max-cores-per-socket NUMBER', String, "Max cores per socket") do |val|
|
611
|
+
((params['config'] ||= {})['ranges'] ||= {})['maxCoresPerSocket'] = val.to_i
|
578
612
|
end
|
579
613
|
add_perms_options(opts, options, ['plans', 'groupDefaults'])
|
580
614
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote, :quiet])
|
@@ -777,15 +777,21 @@ module Morpheus::Cli::ProvisioningHelper
|
|
777
777
|
option_type_list = option_type_list.reject {|opt| ['resourcePool','resourcePoolId','azureResourceGroupId'].include?(opt['fieldName']) }
|
778
778
|
|
779
779
|
resource_pool_options = options_interface.options_for_source('zonePools', {groupId: group_id, siteId: group_id, zoneId: cloud_id, cloudId: cloud_id, instanceTypeId: instance_type['id'], layoutId: layout["id"]}.merge(service_plan.nil? ? {} : {planId: service_plan["id"]}))['data']
|
780
|
-
|
780
|
+
if options[:resource_pool]
|
781
|
+
resource_pool = resource_pool_options.find {|opt| opt['value'] == options[:resource_pool].to_s || opt['value'] == "pool-#{options[:resource_pool]}"}
|
782
|
+
end
|
781
783
|
pool_required = provision_type["zonePoolRequired"]
|
782
|
-
|
784
|
+
# Should pool_id have the pool-,poolGroup- prefix or not?
|
785
|
+
use_pool_prefix = resource_pool_options.find {|opt| opt['value'].to_s.include?("pool") }
|
783
786
|
if resource_pool
|
784
|
-
pool_id = resource_pool['id']
|
787
|
+
pool_id = resource_pool['id'] # id or value?
|
785
788
|
else
|
786
789
|
if options[:default_resource_pool]
|
787
790
|
default_resource_pool = resource_pool_options.find {|rp| rp['id'] == options[:default_resource_pool]}
|
788
791
|
end
|
792
|
+
if use_pool_prefix && options[:options]['config'] && options[:options]['config']['resourcePoolId'] && !options[:options]['config']['resourcePoolId'].to_s.include?("pool")
|
793
|
+
options[:options]['config']['resourcePoolId'] = "pool-" + options[:options]['config']['resourcePoolId'].to_s
|
794
|
+
end
|
789
795
|
resource_pool_option_type ||= {'fieldContext' => 'config', 'fieldName' => 'resourcePoolId', 'type' => 'select', 'fieldLabel' => 'Resource Pool', 'selectOptions' => resource_pool_options, 'required' => pool_required, 'skipSingleOption' => true, 'description' => 'Select resource pool.', 'defaultValue' => default_resource_pool ? default_resource_pool['name'] : nil}
|
790
796
|
resource_pool_prompt = Morpheus::Cli::OptionTypes.prompt([resource_pool_option_type],options[:options],api_client,{}, no_prompt, true)
|
791
797
|
resource_pool_prompt.deep_compact!
|
@@ -796,7 +802,7 @@ module Morpheus::Cli::ProvisioningHelper
|
|
796
802
|
elsif resource_pool_prompt[resource_pool_option_type['fieldName']]
|
797
803
|
pool_id = resource_pool_prompt[resource_pool_option_type['fieldName']]
|
798
804
|
end
|
799
|
-
resource_pool ||= resource_pool_options.find {|it| it['
|
805
|
+
resource_pool ||= resource_pool_options.find {|it| it['value'].to_s == pool_id.to_s}
|
800
806
|
end
|
801
807
|
end
|
802
808
|
end
|
@@ -582,6 +582,9 @@ module Morpheus
|
|
582
582
|
|
583
583
|
if no_prompt
|
584
584
|
if !value_found
|
585
|
+
if default_value == ""
|
586
|
+
default_value = nil
|
587
|
+
end
|
585
588
|
if !default_value.nil? && !select_options.nil?
|
586
589
|
matched_option = select_options.find {|it| it[value_field].to_s == default_value.to_s }
|
587
590
|
if matched_option.nil?
|
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: 6.0.
|
4
|
+
version: 6.0.2
|
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: 2023-
|
14
|
+
date: 2023-04-14 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|