morpheus-cli 3.6.20 → 3.6.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/morpheus/api/api_client.rb +4 -0
- data/lib/morpheus/api/apps_interface.rb +4 -0
- data/lib/morpheus/api/server_types_interface.rb +26 -0
- data/lib/morpheus/cli/apps.rb +48 -5
- data/lib/morpheus/cli/blueprints_command.rb +2 -6
- data/lib/morpheus/cli/clouds.rb +29 -18
- data/lib/morpheus/cli/commands/standard/history_command.rb +1 -1
- data/lib/morpheus/cli/hosts.rb +174 -40
- data/lib/morpheus/cli/instances.rb +40 -0
- data/lib/morpheus/cli/mixins/infrastructure_helper.rb +1 -1
- data/lib/morpheus/cli/remote.rb +1 -1
- data/lib/morpheus/cli/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 789787ba7a4ccb2132d5bcc90b9a7d56201b16cfba7ea0033e853eeeb82745cb
|
4
|
+
data.tar.gz: '069c49c5ce79c069e5082fd6cbd18995f603a90e4be7562ddae2057ea9318d9a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b272c53c874322cdd53ab7b1fa75a53db2961149765bfc69682f9ea35eb4f342df69bb7b98d01d9caafb6ad2e4d7d6433ea5e5e22534a097ae2c5747bee3ece
|
7
|
+
data.tar.gz: 47e44158f0be09618e8c8285b691fb7a8d0d4aa50bd7452b020ba87259871ffd578172df8ba3dbb02a8f75eff62bde08ce8c6e40cdd06c654f8e389369d702ab
|
@@ -232,6 +232,10 @@ class Morpheus::APIClient
|
|
232
232
|
Morpheus::InstanceTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
|
233
233
|
end
|
234
234
|
|
235
|
+
def server_types
|
236
|
+
Morpheus::ServerTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
|
237
|
+
end
|
238
|
+
|
235
239
|
def provision_types
|
236
240
|
Morpheus::ProvisionTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
|
237
241
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::ServerTypesInterface < Morpheus::APIClient
|
4
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
5
|
+
@access_token = access_token
|
6
|
+
@refresh_token = refresh_token
|
7
|
+
@base_url = base_url
|
8
|
+
@expires_at = expires_at
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(id, params={})
|
12
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
13
|
+
url = "#{@base_url}/api/server-types/#{id}"
|
14
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
15
|
+
opts = {method: :get, url: url, headers: headers}
|
16
|
+
execute(opts)
|
17
|
+
end
|
18
|
+
|
19
|
+
def list(params={})
|
20
|
+
url = "#{@base_url}/api/server-types"
|
21
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
22
|
+
opts = {method: :get, url: url, headers: headers}
|
23
|
+
execute(opts)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/morpheus/cli/apps.rb
CHANGED
@@ -15,7 +15,7 @@ class Morpheus::Cli::Apps
|
|
15
15
|
include Morpheus::Cli::ProcessesHelper
|
16
16
|
set_command_name :apps
|
17
17
|
set_command_description "View and manage apps."
|
18
|
-
register_subcommands :list, :get, :add, :update, :remove, :add_instance, :remove_instance, :logs, :firewall_disable, :firewall_enable, :security_groups, :apply_security_groups, :history
|
18
|
+
register_subcommands :list, :count, :get, :add, :update, :remove, :add_instance, :remove_instance, :logs, :firewall_disable, :firewall_enable, :security_groups, :apply_security_groups, :history
|
19
19
|
register_subcommands :stop, :start, :restart
|
20
20
|
#register_subcommands :validate # add --validate instead
|
21
21
|
alias_subcommand :details, :get
|
@@ -75,11 +75,11 @@ class Morpheus::Cli::Apps
|
|
75
75
|
end
|
76
76
|
@apps_interface.setopts(options)
|
77
77
|
if options[:dry_run]
|
78
|
-
print_dry_run @apps_interface.dry.
|
78
|
+
print_dry_run @apps_interface.dry.list(params)
|
79
79
|
return
|
80
80
|
end
|
81
81
|
|
82
|
-
json_response = @apps_interface.
|
82
|
+
json_response = @apps_interface.list(params)
|
83
83
|
if options[:json]
|
84
84
|
puts as_json(json_response, options, "apps")
|
85
85
|
return 0
|
@@ -102,7 +102,50 @@ class Morpheus::Cli::Apps
|
|
102
102
|
print_apps_table(apps, options)
|
103
103
|
print_results_pagination(json_response)
|
104
104
|
end
|
105
|
-
|
105
|
+
print reset,"\n"
|
106
|
+
rescue RestClient::Exception => e
|
107
|
+
print_rest_exception(e, options)
|
108
|
+
exit 1
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def count(args)
|
113
|
+
options = {}
|
114
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
115
|
+
opts.banner = subcommand_usage("[options]")
|
116
|
+
opts.on( '--created-by USER', "Created By User Username or ID" ) do |val|
|
117
|
+
options[:created_by] = val
|
118
|
+
end
|
119
|
+
opts.on( '-s', '--search PHRASE', "Search Phrase" ) do |phrase|
|
120
|
+
options[:phrase] = phrase
|
121
|
+
end
|
122
|
+
build_common_options(opts, options, [:query, :remote, :dry_run])
|
123
|
+
opts.footer = "Get the number of apps."
|
124
|
+
end
|
125
|
+
optparse.parse!(args)
|
126
|
+
connect(options)
|
127
|
+
begin
|
128
|
+
params = {}
|
129
|
+
params.merge!(parse_list_options(options))
|
130
|
+
account = nil
|
131
|
+
if options[:created_by]
|
132
|
+
created_by_ids = find_all_user_ids(account ? account['id'] : nil, options[:created_by])
|
133
|
+
return if created_by_ids.nil?
|
134
|
+
params['createdBy'] = created_by_ids
|
135
|
+
end
|
136
|
+
@apps_interface.setopts(options)
|
137
|
+
if options[:dry_run]
|
138
|
+
print_dry_run @apps_interface.dry.list(params)
|
139
|
+
return
|
140
|
+
end
|
141
|
+
json_response = @apps_interface.list(params)
|
142
|
+
# print number only
|
143
|
+
if json_response['meta'] && json_response['meta']['total']
|
144
|
+
print cyan, json_response['meta']['total'], reset, "\n"
|
145
|
+
else
|
146
|
+
print yellow, "unknown", reset, "\n"
|
147
|
+
end
|
148
|
+
return 0
|
106
149
|
rescue RestClient::Exception => e
|
107
150
|
print_rest_exception(e, options)
|
108
151
|
exit 1
|
@@ -1536,7 +1579,7 @@ class Morpheus::Cli::Apps
|
|
1536
1579
|
# end
|
1537
1580
|
# print cyan
|
1538
1581
|
print as_pretty_table(rows, columns, options) #{color: table_color}
|
1539
|
-
print reset
|
1582
|
+
print reset
|
1540
1583
|
end
|
1541
1584
|
|
1542
1585
|
def format_app_status(app, return_color=cyan)
|
@@ -1740,9 +1740,7 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1740
1740
|
connect(options)
|
1741
1741
|
begin
|
1742
1742
|
params = {}
|
1743
|
-
|
1744
|
-
params[k] = options[k] unless options[k].nil?
|
1745
|
-
end
|
1743
|
+
params.merge!(parse_list_options(options))
|
1746
1744
|
@blueprints_interface.setopts(options)
|
1747
1745
|
if options[:dry_run]
|
1748
1746
|
print_dry_run @blueprints_interface.dry.list_types(params)
|
@@ -1766,9 +1764,7 @@ class Morpheus::Cli::BlueprintsCommand
|
|
1766
1764
|
|
1767
1765
|
title = "Morpheus Blueprint Types"
|
1768
1766
|
subtitles = []
|
1769
|
-
|
1770
|
-
subtitles << "Search: #{params[:phrase]}".strip
|
1771
|
-
end
|
1767
|
+
subtitles += parse_list_subtitles(options)
|
1772
1768
|
print_h1 title, subtitles
|
1773
1769
|
if blueprint_types.empty?
|
1774
1770
|
print cyan,"No blueprint types found.",reset,"\n"
|
data/lib/morpheus/cli/clouds.rb
CHANGED
@@ -611,36 +611,47 @@ class Morpheus::Cli::Clouds
|
|
611
611
|
params = {}
|
612
612
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
613
613
|
opts.banner = subcommand_usage()
|
614
|
-
build_common_options(opts, options, [:json, :dry_run, :remote])
|
614
|
+
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
615
615
|
end
|
616
616
|
optparse.parse!(args)
|
617
617
|
connect(options)
|
618
618
|
begin
|
619
|
+
params.merge!(parse_list_options(options))
|
619
620
|
@clouds_interface.setopts(options)
|
620
621
|
if options[:dry_run]
|
621
622
|
print_dry_run @clouds_interface.dry.cloud_types({})
|
622
623
|
return 0
|
623
624
|
end
|
624
|
-
|
625
|
-
|
626
|
-
|
625
|
+
json_response = @clouds_interface.cloud_types(params)
|
626
|
+
|
627
|
+
render_result = render_with_format(json_response, options, 'zoneTypes')
|
628
|
+
return 0 if render_result
|
629
|
+
|
630
|
+
#cloud_types = get_available_cloud_types()
|
631
|
+
cloud_types = json_response['zoneTypes']
|
632
|
+
|
633
|
+
title = "Morpheus Cloud Types"
|
634
|
+
subtitles = []
|
635
|
+
|
636
|
+
subtitles += parse_list_subtitles(options)
|
637
|
+
print_h1 title, subtitles
|
638
|
+
|
639
|
+
if cloud_types.empty?
|
640
|
+
print yellow,"No cloud types found.",reset,"\n"
|
627
641
|
else
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
print cyan
|
633
|
-
cloud_types = cloud_types.select {|it| it['enabled'] }
|
634
|
-
rows = cloud_types.collect do |cloud_type|
|
635
|
-
{id: cloud_type['id'], name: cloud_type['name'], code: cloud_type['code']}
|
636
|
-
end
|
637
|
-
#print "\n"
|
638
|
-
puts as_pretty_table(rows, [:id, :name, :code], options)
|
639
|
-
#print_results_pagination({size:rows.size,total:rows.size})
|
640
|
-
#print "\n"
|
642
|
+
print cyan
|
643
|
+
cloud_types = cloud_types.select {|it| it['enabled'] }
|
644
|
+
rows = cloud_types.collect do |cloud_type|
|
645
|
+
{id: cloud_type['id'], name: cloud_type['name'], code: cloud_type['code']}
|
641
646
|
end
|
642
|
-
#print
|
647
|
+
#print "\n"
|
648
|
+
columns = [:id, :name, :code]
|
649
|
+
columns = options[:include_fields] if options[:include_fields]
|
650
|
+
print as_pretty_table(rows, columns, options)
|
651
|
+
print_results_pagination(json_response)
|
652
|
+
print reset,"\n"
|
643
653
|
end
|
654
|
+
return 0
|
644
655
|
rescue RestClient::Exception => e
|
645
656
|
print_rest_exception(e, options)
|
646
657
|
exit 1
|
@@ -22,7 +22,7 @@ class Morpheus::Cli::HistoryCommand
|
|
22
22
|
opts.on( '-p', '--pagination', "Display pagination and count info eg. Viewing 1-M of N" ) do
|
23
23
|
options[:show_pagination] = true
|
24
24
|
end
|
25
|
-
opts.on( nil, '--flush', "Flush history, purges entire shell history file." ) do
|
25
|
+
opts.on( nil, '--flush', "Flush history, purges entire shell history file." ) do
|
26
26
|
options[:do_flush] = true
|
27
27
|
end
|
28
28
|
build_common_options(opts, options, [:list, :auto_confirm])
|
data/lib/morpheus/cli/hosts.rb
CHANGED
@@ -14,7 +14,8 @@ class Morpheus::Cli::Hosts
|
|
14
14
|
include Morpheus::Cli::ProvisioningHelper
|
15
15
|
set_command_name :hosts
|
16
16
|
set_command_description "View and manage hosts (servers)."
|
17
|
-
register_subcommands :list, :count, :get, :stats, :add, :update, :remove, :logs, :start, :stop, :resize, :run_workflow, {:'make-managed' => :install_agent}, :upgrade_agent
|
17
|
+
register_subcommands :list, :count, :get, :stats, :add, :update, :remove, :logs, :start, :stop, :resize, :run_workflow, {:'make-managed' => :install_agent}, :upgrade_agent
|
18
|
+
register_subcommands :'types' => :list_types
|
18
19
|
register_subcommands :exec => :execution_request
|
19
20
|
alias_subcommand :details, :get
|
20
21
|
set_default_subcommand :list
|
@@ -32,6 +33,7 @@ class Morpheus::Cli::Hosts
|
|
32
33
|
@tasks_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).tasks
|
33
34
|
@task_sets_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).task_sets
|
34
35
|
@servers_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).servers
|
36
|
+
@server_types_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).server_types
|
35
37
|
@logs_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).logs
|
36
38
|
@accounts_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).accounts
|
37
39
|
@active_group_id = Morpheus::Cli::Groups.active_group
|
@@ -86,7 +88,6 @@ class Morpheus::Cli::Hosts
|
|
86
88
|
opts.on( '', '--status STATUS', "Filter by Status" ) do |val|
|
87
89
|
params[:status] = val
|
88
90
|
end
|
89
|
-
|
90
91
|
opts.on( '', '--agent', "Show only Servers with the agent installed" ) do |val|
|
91
92
|
params[:agentInstalled] = true
|
92
93
|
end
|
@@ -243,17 +244,97 @@ class Morpheus::Cli::Hosts
|
|
243
244
|
end
|
244
245
|
|
245
246
|
def count(args)
|
247
|
+
params = {}
|
246
248
|
options = {}
|
247
249
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
248
250
|
opts.banner = subcommand_usage("[options]")
|
251
|
+
opts.on( '-a', '--account ACCOUNT', "Account Name or ID" ) do |val|
|
252
|
+
options[:account] = val
|
253
|
+
end
|
254
|
+
opts.on( '-g', '--group GROUP', "Group Name or ID" ) do |val|
|
255
|
+
options[:group] = val
|
256
|
+
end
|
257
|
+
opts.on( '-c', '--cloud CLOUD', "Cloud Name or ID" ) do |val|
|
258
|
+
options[:cloud] = val
|
259
|
+
end
|
260
|
+
opts.on( '-M', '--managed', "Show only Managed Servers" ) do |val|
|
261
|
+
params[:managed] = true
|
262
|
+
end
|
263
|
+
opts.on( '-U', '--unmanaged', "Show only Unmanaged Servers" ) do |val|
|
264
|
+
params[:managed] = false
|
265
|
+
end
|
266
|
+
opts.on( '-t', '--type TYPE', "Show only Certain Server Types" ) do |val|
|
267
|
+
params[:serverType] = val
|
268
|
+
end
|
269
|
+
opts.on( '-p', '--power STATE', "Filter by Power Status" ) do |val|
|
270
|
+
params[:powerState] = val
|
271
|
+
end
|
272
|
+
opts.on( '-i', '--ip IPADDRESS', "Filter by IP Address" ) do |val|
|
273
|
+
params[:ip] = val
|
274
|
+
end
|
275
|
+
opts.on( '', '--vm', "Show only virtual machines" ) do |val|
|
276
|
+
params[:vm] = true
|
277
|
+
end
|
278
|
+
opts.on( '', '--hypervisor', "Show only VM Hypervisors" ) do |val|
|
279
|
+
params[:vmHypervisor] = true
|
280
|
+
end
|
281
|
+
opts.on( '', '--container', "Show only Container Hypervisors" ) do |val|
|
282
|
+
params[:containerHypervisor] = true
|
283
|
+
end
|
284
|
+
opts.on( '', '--baremetal', "Show only Baremetal Servers" ) do |val|
|
285
|
+
params[:bareMetalHost] = true
|
286
|
+
end
|
287
|
+
opts.on( '', '--status STATUS', "Filter by Status" ) do |val|
|
288
|
+
params[:status] = val
|
289
|
+
end
|
290
|
+
opts.on( '', '--agent', "Show only Servers with the agent installed" ) do |val|
|
291
|
+
params[:agentInstalled] = true
|
292
|
+
end
|
293
|
+
opts.on( '', '--noagent', "Show only Servers with No agent" ) do |val|
|
294
|
+
params[:agentInstalled] = false
|
295
|
+
end
|
296
|
+
opts.on( '--created-by USER', "Created By User Username or ID" ) do |val|
|
297
|
+
options[:created_by] = val
|
298
|
+
end
|
299
|
+
opts.on('--details', "Display more details: memory and storage usage used / max values." ) do
|
300
|
+
options[:details] = true
|
301
|
+
end
|
302
|
+
opts.on( '-s', '--search PHRASE', "Search Phrase" ) do |phrase|
|
303
|
+
options[:phrase] = phrase
|
304
|
+
end
|
249
305
|
build_common_options(opts, options, [:query, :remote, :dry_run])
|
250
306
|
opts.footer = "Get the number of hosts."
|
251
307
|
end
|
252
308
|
optparse.parse!(args)
|
253
309
|
connect(options)
|
254
310
|
begin
|
255
|
-
params = {}
|
256
311
|
params.merge!(parse_list_options(options))
|
312
|
+
account = nil
|
313
|
+
if options[:account]
|
314
|
+
account = find_account_by_name_or_id(options[:account])
|
315
|
+
if account.nil?
|
316
|
+
return 1
|
317
|
+
else
|
318
|
+
params['accountId'] = account['id']
|
319
|
+
end
|
320
|
+
end
|
321
|
+
group = options[:group] ? find_group_by_name_or_id_for_provisioning(options[:group]) : nil
|
322
|
+
if group
|
323
|
+
params['siteId'] = group['id']
|
324
|
+
end
|
325
|
+
|
326
|
+
# argh, this doesn't work because group_id is required for options/clouds
|
327
|
+
# cloud = options[:cloud] ? find_cloud_by_name_or_id_for_provisioning(group_id, options[:cloud]) : nil
|
328
|
+
cloud = options[:cloud] ? find_zone_by_name_or_id(nil, options[:cloud]) : nil
|
329
|
+
if cloud
|
330
|
+
params['zoneId'] = cloud['id']
|
331
|
+
end
|
332
|
+
|
333
|
+
if options[:created_by]
|
334
|
+
created_by_ids = find_all_user_ids(account ? account['id'] : nil, options[:created_by])
|
335
|
+
return if created_by_ids.nil?
|
336
|
+
params['createdBy'] = created_by_ids
|
337
|
+
end
|
257
338
|
@servers_interface.setopts(options)
|
258
339
|
if options[:dry_run]
|
259
340
|
print_dry_run @servers_interface.dry.list(params)
|
@@ -266,6 +347,7 @@ class Morpheus::Cli::Hosts
|
|
266
347
|
else
|
267
348
|
print yellow, "unknown", reset, "\n"
|
268
349
|
end
|
350
|
+
return 0
|
269
351
|
rescue RestClient::Exception => e
|
270
352
|
print_rest_exception(e, options)
|
271
353
|
exit 1
|
@@ -497,41 +579,6 @@ class Morpheus::Cli::Hosts
|
|
497
579
|
end
|
498
580
|
end
|
499
581
|
|
500
|
-
def server_types(args)
|
501
|
-
options = {}
|
502
|
-
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
503
|
-
opts.banner = subcommand_usage("[cloud]")
|
504
|
-
build_common_options(opts, options, [:json, :remote])
|
505
|
-
end
|
506
|
-
optparse.parse!(args)
|
507
|
-
if args.count < 1
|
508
|
-
puts optparse
|
509
|
-
exit 1
|
510
|
-
end
|
511
|
-
options[:zone] = args[0]
|
512
|
-
connect(options)
|
513
|
-
params = {}
|
514
|
-
|
515
|
-
zone = find_zone_by_name_or_id(nil, options[:zone])
|
516
|
-
cloud_type = cloud_type_for_id(zone['zoneTypeId'])
|
517
|
-
cloud_server_types = cloud_type['serverTypes'].select{|b| b['creatable'] == true}
|
518
|
-
cloud_server_types = cloud_server_types.sort { |x,y| x['displayOrder'] <=> y['displayOrder'] }
|
519
|
-
if options[:json]
|
520
|
-
print JSON.pretty_generate(cloud_server_types)
|
521
|
-
print "\n"
|
522
|
-
else
|
523
|
-
print_h1 "Morpheus Server Types - Cloud: #{zone['name']}", [], options
|
524
|
-
if cloud_server_types.nil? || cloud_server_types.empty?
|
525
|
-
print yellow,"No server types found for the selected cloud",reset,"\n"
|
526
|
-
else
|
527
|
-
cloud_server_types.each do |server_type|
|
528
|
-
print cyan, "[#{server_type['code']}]".ljust(20), " - ", "#{server_type['name']}", "\n"
|
529
|
-
end
|
530
|
-
end
|
531
|
-
print reset,"\n"
|
532
|
-
end
|
533
|
-
end
|
534
|
-
|
535
582
|
def add(args)
|
536
583
|
options = {}
|
537
584
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
@@ -608,7 +655,7 @@ class Morpheus::Cli::Hosts
|
|
608
655
|
end
|
609
656
|
server_type = cloud_server_types.find {|it| it['code'] == server_type_code }
|
610
657
|
if server_type.nil?
|
611
|
-
print_red_alert "Server Type #{server_type_code} not found cloud #{cloud['name']}"
|
658
|
+
print_red_alert "Server Type #{server_type_code} not found for cloud #{cloud['name']}"
|
612
659
|
exit 1
|
613
660
|
end
|
614
661
|
|
@@ -1269,6 +1316,93 @@ class Morpheus::Cli::Hosts
|
|
1269
1316
|
end
|
1270
1317
|
end
|
1271
1318
|
|
1319
|
+
def server_types_for_cloud(cloud_id, options)
|
1320
|
+
connect(options)
|
1321
|
+
zone = find_zone_by_name_or_id(nil, cloud_id)
|
1322
|
+
cloud_type = cloud_type_for_id(zone['zoneTypeId'])
|
1323
|
+
cloud_server_types = cloud_type['serverTypes'].select{|b| b['creatable'] == true}
|
1324
|
+
cloud_server_types = cloud_server_types.sort { |x,y| x['displayOrder'] <=> y['displayOrder'] }
|
1325
|
+
if options[:json]
|
1326
|
+
print JSON.pretty_generate(cloud_server_types)
|
1327
|
+
print "\n"
|
1328
|
+
else
|
1329
|
+
print_h1 "Morpheus Server Types - Cloud: #{zone['name']}", [], options
|
1330
|
+
if cloud_server_types.nil? || cloud_server_types.empty?
|
1331
|
+
print yellow,"No server types found for the selected cloud",reset,"\n"
|
1332
|
+
else
|
1333
|
+
cloud_server_types.each do |server_type|
|
1334
|
+
print cyan, "[#{server_type['code']}]".ljust(20), " - ", "#{server_type['name']}", "\n"
|
1335
|
+
end
|
1336
|
+
end
|
1337
|
+
print reset,"\n"
|
1338
|
+
end
|
1339
|
+
end
|
1340
|
+
|
1341
|
+
def list_types(args)
|
1342
|
+
options = {}
|
1343
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
1344
|
+
opts.banner = subcommand_usage()
|
1345
|
+
opts.on( '-c', '--cloud CLOUD', "Cloud Name or ID" ) do |val|
|
1346
|
+
options[:cloud] = val
|
1347
|
+
end
|
1348
|
+
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
1349
|
+
opts.footer = "List host types."
|
1350
|
+
end
|
1351
|
+
optparse.parse!(args)
|
1352
|
+
connect(options)
|
1353
|
+
begin
|
1354
|
+
params = {}
|
1355
|
+
params.merge!(parse_list_options(options))
|
1356
|
+
if options[:cloud]
|
1357
|
+
#return server_types_for_cloud(options[:cloud], options)
|
1358
|
+
zone = find_zone_by_name_or_id(nil, options[:cloud])
|
1359
|
+
params["zoneTypeId"] = zone['zoneTypeId']
|
1360
|
+
params["creatable"] = true
|
1361
|
+
end
|
1362
|
+
@server_types_interface.setopts(options)
|
1363
|
+
if options[:dry_run]
|
1364
|
+
print_dry_run @server_types_interface.dry.list(params)
|
1365
|
+
return
|
1366
|
+
end
|
1367
|
+
json_response = @server_types_interface.list(params)
|
1368
|
+
|
1369
|
+
render_result = render_with_format(json_response, options, 'serverTypes')
|
1370
|
+
return 0 if render_result
|
1371
|
+
|
1372
|
+
server_types = json_response['serverTypes']
|
1373
|
+
|
1374
|
+
title = "Morpheus Server Types"
|
1375
|
+
subtitles = []
|
1376
|
+
subtitles += parse_list_subtitles(options)
|
1377
|
+
if options[:cloud]
|
1378
|
+
subtitles << "Cloud: #{options[:cloud]}"
|
1379
|
+
end
|
1380
|
+
print_h1 title, subtitles
|
1381
|
+
if server_types.empty?
|
1382
|
+
print cyan,"No server types found.",reset,"\n"
|
1383
|
+
else
|
1384
|
+
rows = server_types.collect do |server_type|
|
1385
|
+
{
|
1386
|
+
id: server_type['id'],
|
1387
|
+
code: server_type['code'],
|
1388
|
+
name: server_type['name']
|
1389
|
+
}
|
1390
|
+
end
|
1391
|
+
columns = [:id, :name, :code]
|
1392
|
+
print cyan
|
1393
|
+
print as_pretty_table(rows, columns, options)
|
1394
|
+
print reset
|
1395
|
+
print_results_pagination(json_response)
|
1396
|
+
end
|
1397
|
+
print reset,"\n"
|
1398
|
+
return 0
|
1399
|
+
|
1400
|
+
rescue RestClient::Exception => e
|
1401
|
+
print_rest_exception(e, options)
|
1402
|
+
exit 1
|
1403
|
+
end
|
1404
|
+
end
|
1405
|
+
|
1272
1406
|
private
|
1273
1407
|
|
1274
1408
|
def find_host_by_id(id)
|
@@ -1336,7 +1470,7 @@ class Morpheus::Cli::Hosts
|
|
1336
1470
|
end
|
1337
1471
|
|
1338
1472
|
def cloud_type_for_id(id)
|
1339
|
-
cloud_types = @clouds_interface.cloud_types['zoneTypes']
|
1473
|
+
cloud_types = @clouds_interface.cloud_types({max:1000})['zoneTypes']
|
1340
1474
|
cloud_type = cloud_types.find { |z| z['id'].to_i == id.to_i}
|
1341
1475
|
if cloud_type.nil?
|
1342
1476
|
print_red_alert "Cloud Type not found by id #{id}"
|
@@ -211,6 +211,21 @@ class Morpheus::Cli::Instances
|
|
211
211
|
options = {}
|
212
212
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
213
213
|
opts.banner = subcommand_usage("[options]")
|
214
|
+
opts.on( '-g', '--group GROUP', "Group Name or ID" ) do |val|
|
215
|
+
options[:group] = val
|
216
|
+
end
|
217
|
+
opts.on( '-c', '--cloud CLOUD', "Cloud Name or ID" ) do |val|
|
218
|
+
options[:cloud] = val
|
219
|
+
end
|
220
|
+
opts.on( '-H', '--host HOST', "Host Name or ID" ) do |val|
|
221
|
+
options[:host] = val
|
222
|
+
end
|
223
|
+
opts.on( '--created-by USER', "Created By User Username or ID" ) do |val|
|
224
|
+
options[:created_by] = val
|
225
|
+
end
|
226
|
+
opts.on( '-s', '--search PHRASE', "Search Phrase" ) do |phrase|
|
227
|
+
options[:phrase] = phrase
|
228
|
+
end
|
214
229
|
build_common_options(opts, options, [:query, :remote, :dry_run])
|
215
230
|
opts.footer = "Get the number of instances."
|
216
231
|
end
|
@@ -219,6 +234,30 @@ class Morpheus::Cli::Instances
|
|
219
234
|
begin
|
220
235
|
params = {}
|
221
236
|
params.merge!(parse_list_options(options))
|
237
|
+
group = options[:group] ? find_group_by_name_or_id_for_provisioning(options[:group]) : nil
|
238
|
+
if group
|
239
|
+
params['siteId'] = group['id']
|
240
|
+
end
|
241
|
+
|
242
|
+
# argh, this doesn't work because group_id is required for options/clouds
|
243
|
+
# cloud = options[:cloud] ? find_cloud_by_name_or_id_for_provisioning(group_id, options[:cloud]) : nil
|
244
|
+
cloud = options[:cloud] ? find_zone_by_name_or_id(nil, options[:cloud]) : nil
|
245
|
+
if cloud
|
246
|
+
params['zoneId'] = cloud['id']
|
247
|
+
end
|
248
|
+
|
249
|
+
host = options[:host] ? find_host_by_name_or_id(options[:host]) : options[:host]
|
250
|
+
if host
|
251
|
+
params['serverId'] = host['id']
|
252
|
+
end
|
253
|
+
|
254
|
+
account = nil
|
255
|
+
if options[:created_by]
|
256
|
+
created_by_ids = find_all_user_ids(account ? account['id'] : nil, options[:created_by])
|
257
|
+
return if created_by_ids.nil?
|
258
|
+
params['createdBy'] = created_by_ids
|
259
|
+
end
|
260
|
+
|
222
261
|
@instances_interface.setopts(options)
|
223
262
|
if options[:dry_run]
|
224
263
|
print_dry_run @instances_interface.dry.list(params)
|
@@ -231,6 +270,7 @@ class Morpheus::Cli::Instances
|
|
231
270
|
else
|
232
271
|
print yellow, "unknown", reset, "\n"
|
233
272
|
end
|
273
|
+
return 0
|
234
274
|
rescue RestClient::Exception => e
|
235
275
|
print_rest_exception(e, options)
|
236
276
|
exit 1
|
@@ -83,7 +83,7 @@ module Morpheus::Cli::InfrastructureHelper
|
|
83
83
|
|
84
84
|
def get_available_cloud_types(refresh=false)
|
85
85
|
if !@available_cloud_types || refresh
|
86
|
-
@available_cloud_types = clouds_interface.cloud_types['zoneTypes']
|
86
|
+
@available_cloud_types = clouds_interface.cloud_types({max:1000})['zoneTypes']
|
87
87
|
end
|
88
88
|
return @available_cloud_types
|
89
89
|
end
|
data/lib/morpheus/cli/remote.rb
CHANGED
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.21
|
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-
|
14
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -219,6 +219,7 @@ files:
|
|
219
219
|
- lib/morpheus/api/roles_interface.rb
|
220
220
|
- lib/morpheus/api/security_group_rules_interface.rb
|
221
221
|
- lib/morpheus/api/security_groups_interface.rb
|
222
|
+
- lib/morpheus/api/server_types_interface.rb
|
222
223
|
- lib/morpheus/api/servers_interface.rb
|
223
224
|
- lib/morpheus/api/setup_interface.rb
|
224
225
|
- lib/morpheus/api/storage_providers_interface.rb
|