morpheus-cli 7.0.3.3 → 7.0.4
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/execution_request_command.rb +9 -8
- data/lib/morpheus/cli/commands/network_servers_command.rb +60 -40
- data/lib/morpheus/cli/version.rb +1 -1
- data/test/cli/instances_test.rb +2 -1
- data/test/cli/network_routers_test.rb +4 -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: 4ee9109e36c34c6c50f1c1053d9d183aa034e5aff2be97eb7494f1135213a209
|
4
|
+
data.tar.gz: 7cf3dfeb5794ae2457818d8bb3ec9a90068ab7a43397f9de31d773e7e8ff5b80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a4afd65531974bb6142919beb435aa756c251821d96660c3a3d8e0baf25c8d3a22e7be7a8b955212777bc7798714db7d0a3c00cd9ec190124a819f5188b84f6
|
7
|
+
data.tar.gz: 5fed3b5ab9017681ee8aba610f23da663fa9ee84000df7d3efa33a696cb4d8f27030cd8c4cda81ecf87dae523cf7a39e26235461130b137715dc098e0a75ae0d
|
data/Dockerfile
CHANGED
@@ -141,6 +141,7 @@ class Morpheus::Cli::ExecutionRequestCommand
|
|
141
141
|
options = {}
|
142
142
|
params = {}
|
143
143
|
script_content = nil
|
144
|
+
send_keys = nil
|
144
145
|
options[:refresh_until_finished] = true
|
145
146
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
146
147
|
opts.banner = subcommand_usage("[options]")
|
@@ -159,14 +160,11 @@ class Morpheus::Cli::ExecutionRequestCommand
|
|
159
160
|
opts.on('--script SCRIPT', "Script to be executed" ) do |val|
|
160
161
|
script_content = val
|
161
162
|
end
|
162
|
-
opts.on('--
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
print_red_alert "File not found: #{full_filename}"
|
168
|
-
exit 1
|
169
|
-
end
|
163
|
+
opts.on('--optionTypes [true|false]', String, "Include optionTypes in the response. Default is false.") do |val|
|
164
|
+
params['optionTypes'] = (val.to_s == '' || val.to_s == 'on' || val.to_s == 'true')
|
165
|
+
end
|
166
|
+
opts.on('--send-keys [true|false]', "Send key mappings to the hypervisor console so commands such as <LEFT>, <RIGHT> and <WAIT> can be used." ) do |val|
|
167
|
+
send_keys = val.to_s == 'on' || val.to_s == 'true' || val.to_s.empty?
|
170
168
|
end
|
171
169
|
opts.on('--refresh [SECONDS]', String, "Refresh until execution is finished. Default interval is #{default_refresh_interval} seconds.") do |val|
|
172
170
|
options[:refresh_until_finished] = true
|
@@ -208,6 +206,9 @@ class Morpheus::Cli::ExecutionRequestCommand
|
|
208
206
|
script_content = v_prompt['script']
|
209
207
|
end
|
210
208
|
payload['script'] = script_content
|
209
|
+
if !send_keys.nil?
|
210
|
+
payload['sendKeys'] = send_keys
|
211
|
+
end
|
211
212
|
end
|
212
213
|
@execution_request_interface.setopts(options)
|
213
214
|
if options[:dry_run]
|
@@ -38,6 +38,8 @@ class Morpheus::Cli::NetworkServersCommand
|
|
38
38
|
# params['enabled'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s.empty?
|
39
39
|
# end
|
40
40
|
# ['name', 'serviceUsername', 'servicePassword', 'servicePort', 'serviceHost', 'serviceUrl', 'serviceMode', 'networkFilter', 'tenantMatch']
|
41
|
+
#build_option_type_options(opts, options, add_network_server_option_types)
|
42
|
+
build_option_type_options(opts, options, add_network_server_advanced_option_types)
|
41
43
|
build_standard_add_options(opts, options)
|
42
44
|
opts.footer = <<-EOT
|
43
45
|
Create a new network server.
|
@@ -108,8 +110,19 @@ EOT
|
|
108
110
|
# prompt options by type
|
109
111
|
network_server_type = @network_server_types_interface.get(network_type_id.to_i)['networkServerType']
|
110
112
|
# params['type'] = network_server_type['code']
|
113
|
+
type_options_types = network_server_type['optionTypes'] || []
|
114
|
+
type_options_types.reject! {|it| it['fieldName'] == 'visibility' } # skip visibility, its under advanced now
|
111
115
|
option_result = prompt(network_server_type['optionTypes'], options.merge({:context_map => {'networkServer' => ''}}))
|
112
116
|
params.deep_merge!(option_result)
|
117
|
+
|
118
|
+
# advanced options
|
119
|
+
advanced_option_types = add_network_server_advanced_option_types
|
120
|
+
if advanced_option_types && !advanced_option_types.empty?
|
121
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt(advanced_option_types, options[:options], @api_client, {})
|
122
|
+
v_prompt.deep_compact!
|
123
|
+
v_prompt.booleanize! # 'on' => true
|
124
|
+
params.deep_merge!(v_prompt)
|
125
|
+
end
|
113
126
|
payload.deep_merge!({rest_object_key => params})
|
114
127
|
end
|
115
128
|
@network_servers_interface.setopts(options)
|
@@ -138,6 +151,8 @@ EOT
|
|
138
151
|
# params['enabled'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s.empty?
|
139
152
|
# end
|
140
153
|
# ['name', 'serviceUsername', 'servicePassword', 'servicePort', 'serviceHost', 'serviceUrl', 'serviceMode', 'networkFilter', 'tenantMatch']
|
154
|
+
#build_option_type_options(opts, options, update_network_server_option_types)
|
155
|
+
build_option_type_options(opts, options, update_network_server_advanced_option_types)
|
141
156
|
build_standard_update_options(opts, options)
|
142
157
|
opts.footer = <<-EOT
|
143
158
|
Update a network server.
|
@@ -155,6 +170,16 @@ EOT
|
|
155
170
|
# merge -O options into normally parsed options
|
156
171
|
params.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
157
172
|
|
173
|
+
# params['tenants'] = options['tenants'].collect {|it| {'id': it}}
|
174
|
+
# advanced options
|
175
|
+
advanced_option_types = update_network_server_advanced_option_types
|
176
|
+
if advanced_option_types && !advanced_option_types.empty?
|
177
|
+
v_prompt = Morpheus::Cli::OptionTypes.no_prompt(advanced_option_types, options[:options], @api_client, {})
|
178
|
+
v_prompt.deep_compact!
|
179
|
+
v_prompt.booleanize! # 'on' => true
|
180
|
+
params.deep_merge!(v_prompt)
|
181
|
+
end
|
182
|
+
|
158
183
|
# construct payload
|
159
184
|
payload = nil
|
160
185
|
if options[:payload]
|
@@ -228,35 +253,13 @@ EOT
|
|
228
253
|
'networkServer'
|
229
254
|
end
|
230
255
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
# record = json_response[rest_object_key]
|
237
|
-
# print_h1 rest_label, [], options
|
238
|
-
# print cyan
|
239
|
-
# columns = rest_column_definitions(options)
|
240
|
-
# if record['credential'] && record['credential']['type'] != 'local'
|
241
|
-
# columns.delete("Username")
|
242
|
-
# columns.delete("Password")
|
243
|
-
# end
|
244
|
-
# columns.delete("Throttle Rate") unless type_option_types.find {|it| it['fieldName'] == 'serviceThrottleRate' }
|
245
|
-
# columns.delete("Disable SSL SNI") unless type_option_types.find {|it| it['fieldName'] == 'ignoreSsl' }
|
246
|
-
# columns.delete("Network Filter") unless type_option_types.find {|it| it['fieldName'] == 'networkFilter' }
|
247
|
-
# columns.delete("Zone Filter") unless type_option_types.find {|it| it['fieldName'] == 'zoneFilter' }
|
248
|
-
# columns.delete("Tenant Match") unless type_option_types.find {|it| it['fieldName'] == 'tenantMatch' }
|
249
|
-
# columns.delete("IP Mode") unless type_option_types.find {|it| it['fieldName'] == 'serviceMode' }
|
250
|
-
# columns.delete("Extra Attributes") unless type_option_types.find {|it| it['fieldName'] == 'extraAttributes' }
|
251
|
-
# columns.delete("App ID") unless type_option_types.find {|it| it['fieldName'] == 'appId' }
|
252
|
-
# columns.delete("Inventory Existing") unless type_option_types.find {|it| it['fieldName'] == 'inventoryExisting' }
|
253
|
-
# columns.delete("Enabled") if record['enabled'].nil? # was not always returned, so don't show false if not present..
|
254
|
-
# print_description_list(columns, record, options)
|
255
|
-
# print reset,"\n"
|
256
|
-
# end
|
257
|
-
# end
|
256
|
+
def render_response_for_get(json_response, options)
|
257
|
+
record = json_response[rest_object_key]
|
258
|
+
options[:exclude_tenants] = record['tenants'].nil?
|
259
|
+
super(json_response, options)
|
260
|
+
end
|
258
261
|
|
259
|
-
|
262
|
+
def find_network_server_by_name_or_id(val)
|
260
263
|
if val.to_s =~ /\A\d{1,}\Z/
|
261
264
|
return find_network_server_by_id(val)
|
262
265
|
else
|
@@ -309,19 +312,31 @@ EOT
|
|
309
312
|
end
|
310
313
|
|
311
314
|
def add_network_server_advanced_option_types()
|
312
|
-
[
|
315
|
+
[
|
316
|
+
{'fieldName' => 'visibility', 'fieldLabel' => 'Visibility', 'type' => 'select', 'selectOptions' => [{'name' => 'Private', 'value' => 'private'},{'name' => 'Public', 'value' => 'public'}], 'required' => false, 'description' => 'Visibility', 'category' => 'permissions', 'defaultValue' => 'private'},
|
317
|
+
{'fieldName' => 'tenants', 'fieldLabel' => 'Tenants', 'fieldGroup' => 'Advanced', 'type' => 'multiSelect', 'resultValueField' => 'id', 'optionSource' => lambda { |api_client, api_params|
|
318
|
+
api_client.options.options_for_source("allTenants", {})['data']
|
319
|
+
}},
|
320
|
+
]
|
313
321
|
end
|
314
322
|
|
315
323
|
def update_network_server_option_types()
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
324
|
+
list = add_network_server_option_types.collect {|it|
|
325
|
+
it.delete('required')
|
326
|
+
it.delete('defaultValue')
|
327
|
+
it
|
328
|
+
}
|
329
|
+
list = list.reject {|it| ["type"].include? it['fieldName'] }
|
330
|
+
list
|
321
331
|
end
|
322
332
|
|
323
333
|
def update_network_server_advanced_option_types()
|
324
|
-
|
334
|
+
list = add_network_server_advanced_option_types.collect {|it|
|
335
|
+
it.delete('required')
|
336
|
+
it.delete('defaultValue')
|
337
|
+
it
|
338
|
+
}
|
339
|
+
list
|
325
340
|
end
|
326
341
|
|
327
342
|
def network_server_list_column_definitions(options)
|
@@ -338,13 +353,12 @@ EOT
|
|
338
353
|
end
|
339
354
|
|
340
355
|
def network_server_column_definitions(options)
|
341
|
-
{
|
356
|
+
columns = {
|
342
357
|
"ID" => 'id',
|
343
358
|
"Name" => lambda {|it| it['name'] },
|
344
359
|
"Type" => lambda {|it| it['type'] ? it['type']['name'] : '' },
|
345
360
|
"URL" => lambda {|it| it['serviceUrl'] },
|
346
|
-
|
347
|
-
#"Credentials" => lambda {|it| it['credential'] ? (it['credential']['type'] == 'local' ? '(Local)' : it['credential']['name']) : nil },
|
361
|
+
"Credentials" => lambda {|it| it['credential'] ? (it['credential']['type'] == 'local' ? '(Local)' : it['credential']['name']) : nil },
|
348
362
|
"Username" => lambda {|it| it['serviceUsername'] },
|
349
363
|
"Password" => lambda {|it| it['servicePassword'] },
|
350
364
|
"Service Mode" => lambda {|it| it['serviceMode'] },
|
@@ -352,10 +366,16 @@ EOT
|
|
352
366
|
"Network Filter" => lambda {|it| it['networkFilter'] },
|
353
367
|
"Tenant Match" => lambda {|it| it['tenantMatch'] },
|
354
368
|
#"Enabled" => lambda {|it| format_boolean(it['enabled']) },
|
369
|
+
"Visibility" => lambda {|it| it['visibility'] ? it['visibility'].capitalize() : '' },
|
370
|
+
"Tenants" => lambda { |it| it['tenants'].collect {|tenant| tenant['name']}.join(', ') rescue '' },
|
355
371
|
"Status" => lambda {|it| format_network_server_status(it) },
|
356
|
-
"
|
357
|
-
"
|
372
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
373
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
358
374
|
}
|
375
|
+
if options[:exclude_tenants]
|
376
|
+
columns.delete("Tenants")
|
377
|
+
end
|
378
|
+
columns
|
359
379
|
end
|
360
380
|
|
361
381
|
def format_network_server_status(network_server, return_color=cyan)
|
data/lib/morpheus/cli/version.rb
CHANGED
data/test/cli/instances_test.rb
CHANGED
@@ -11,7 +11,8 @@ class MorpheusTest::InstancesTest < MorpheusTest::TestCase
|
|
11
11
|
instance = client.instances.list({})['instances'][0]
|
12
12
|
if instance
|
13
13
|
assert_execute %(instances get "#{instance['id']}")
|
14
|
-
|
14
|
+
name_arg = instance['displayName'] || instance['name']
|
15
|
+
assert_execute %(instances get "#{escape_arg name_arg}")
|
15
16
|
else
|
16
17
|
puts "No instance found, unable to execute test `#{__method__}`"
|
17
18
|
end
|
@@ -8,7 +8,10 @@ class MorpheusTest::NetworkRoutersTest < MorpheusTest::TestCase
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_network_routers_get
|
11
|
-
|
11
|
+
# find one that does not have a duplicate name..so we can get it by name
|
12
|
+
#network_router = client.network_routers.list({})['networkRouters'][0]
|
13
|
+
network_routers = client.network_routers.list({})['networkRouters']
|
14
|
+
network_router = network_routers.find {|it| !(network_routers.find {|other| other['name'] == it['name'] }) }
|
12
15
|
if network_router
|
13
16
|
assert_execute %(network-routers get "#{network_router['id']}")
|
14
17
|
assert_execute %(network-routers get "#{escape_arg network_router['name']}")
|
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: 7.0.
|
4
|
+
version: 7.0.4
|
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: 2024-
|
14
|
+
date: 2024-07-19 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: ffi
|