morpheus-cli 6.2.2 → 6.3.0
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/Dockerfile +1 -1
- data/README.md +6 -0
- data/lib/morpheus/api/api_client.rb +12 -0
- data/lib/morpheus/api/clusters_interface.rb +7 -0
- data/lib/morpheus/api/network_security_server_types_interface.rb +9 -0
- data/lib/morpheus/api/network_server_types_interface.rb +9 -0
- data/lib/morpheus/api/network_servers_interface.rb +4 -0
- data/lib/morpheus/cli/cli_command.rb +1 -0
- data/lib/morpheus/cli/commands/clouds.rb +101 -28
- data/lib/morpheus/cli/commands/clouds_types.rb +141 -0
- data/lib/morpheus/cli/commands/clusters.rb +43 -0
- data/lib/morpheus/cli/commands/instances.rb +1 -0
- data/lib/morpheus/cli/commands/network_dhcp_relays_command.rb +1 -42
- data/lib/morpheus/cli/commands/network_dhcp_servers_command.rb +3 -44
- data/lib/morpheus/cli/commands/network_edge_clusters_command.rb +1 -42
- data/lib/morpheus/cli/commands/network_firewalls_command.rb +1 -41
- data/lib/morpheus/cli/commands/network_pool_servers_command.rb +3 -1
- data/lib/morpheus/cli/commands/network_routers_command.rb +4 -6
- data/lib/morpheus/cli/commands/network_security_server_types.rb +20 -0
- data/lib/morpheus/cli/commands/network_server_types_command.rb +20 -0
- data/lib/morpheus/cli/commands/network_servers_command.rb +368 -0
- data/lib/morpheus/cli/commands/network_transport_zones_command.rb +1 -41
- data/lib/morpheus/cli/commands/networks_command.rb +1 -1
- data/lib/morpheus/cli/commands/options.rb +135 -2
- data/lib/morpheus/cli/commands/policies_command.rb +112 -128
- data/lib/morpheus/cli/commands/roles.rb +3 -0
- data/lib/morpheus/cli/mixins/accounts_helper.rb +2 -0
- data/lib/morpheus/cli/mixins/infrastructure_helper.rb +103 -2
- data/lib/morpheus/cli/mixins/networks_helper.rb +62 -0
- data/lib/morpheus/cli/mixins/print_helper.rb +28 -7
- data/lib/morpheus/cli/mixins/prompt_helper.rb +15 -0
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +25 -9
- data/lib/morpheus/cli/mixins/rest_command.rb +1 -1
- data/lib/morpheus/cli/option_types.rb +3 -3
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/logging.rb +6 -3
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02effa7bdd51120b68b2253e21f9be4df3a3388424975e21ec4add33a6ad516e
|
4
|
+
data.tar.gz: 55ce2d5a93cce0ac5aa77ed3d993af5daa41fd3473bddeae773e6d18ac324442
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8a17ab56472e03157c1e9d2fd2cbaf36dd98dbc4c0d06270b84dfd8b0064d93f2259206a0f6623dc2a51995cd0888ba7ea3785cbcf43936fe7998f4f54577b7
|
7
|
+
data.tar.gz: 3086104a09b6739bab99d963937dec66d8f1de208270aae3a7bb23374c3c848e1636e6bd7086f37dee0e259f6dc718e57b7a15213b615d37a985805fcc620f43
|
data/Dockerfile
CHANGED
data/README.md
CHANGED
@@ -58,6 +58,12 @@ While developing, you can quickly reload your code changes in a morpheus shell w
|
|
58
58
|
morpheus shell
|
59
59
|
```
|
60
60
|
|
61
|
+
or
|
62
|
+
|
63
|
+
```shell
|
64
|
+
bundle exec morpheus shell —debug
|
65
|
+
```
|
66
|
+
|
61
67
|
Then to reload changes without restarting the morpheus shell (and the ruby process), use:
|
62
68
|
|
63
69
|
```shell
|
@@ -674,10 +674,18 @@ class Morpheus::APIClient
|
|
674
674
|
Morpheus::NetworkServicesInterface.new(common_interface_options).setopts(@options)
|
675
675
|
end
|
676
676
|
|
677
|
+
# def network_service_types
|
678
|
+
# Morpheus::NetworkServiceTypesInterface.new(common_interface_options).setopts(@options)
|
679
|
+
# end
|
680
|
+
|
677
681
|
def network_security_servers
|
678
682
|
Morpheus::NetworkSecurityServersInterface.new(common_interface_options).setopts(@options)
|
679
683
|
end
|
680
684
|
|
685
|
+
def network_security_server_types
|
686
|
+
Morpheus::NetworkSecurityServerTypesInterface.new(common_interface_options).setopts(@options)
|
687
|
+
end
|
688
|
+
|
681
689
|
def network_pool_servers
|
682
690
|
Morpheus::NetworkPoolServersInterface.new(common_interface_options).setopts(@options)
|
683
691
|
end
|
@@ -918,6 +926,10 @@ class Morpheus::APIClient
|
|
918
926
|
Morpheus::NetworkServersInterface.new(common_interface_options).setopts(@options)
|
919
927
|
end
|
920
928
|
|
929
|
+
def network_server_types
|
930
|
+
Morpheus::NetworkServerTypesInterface.new(common_interface_options).setopts(@options)
|
931
|
+
end
|
932
|
+
|
921
933
|
def network_server_groups
|
922
934
|
Morpheus::NetworkServerGroupsInterface.new(common_interface_options).setopts(@options)
|
923
935
|
end
|
@@ -313,4 +313,11 @@ class Morpheus::ClustersInterface < Morpheus::APIClient
|
|
313
313
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
314
314
|
execute(method: :post, url: url, headers: headers, payload: payload.to_json)
|
315
315
|
end
|
316
|
+
|
317
|
+
def refresh(id)
|
318
|
+
url = "#{@base_url}/api/clusters/#{id}/refresh"
|
319
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
320
|
+
opts = {method: :get, url: url, headers: headers}
|
321
|
+
execute(opts)
|
322
|
+
end
|
316
323
|
end
|
@@ -6,6 +6,10 @@ class Morpheus::NetworkServersInterface < Morpheus::RestInterface
|
|
6
6
|
"/api/networks/servers"
|
7
7
|
end
|
8
8
|
|
9
|
+
def refresh(id, params={}, payload={}, headers={})
|
10
|
+
execute(method: :post, url: "#{base_path}/#{id}/refresh", params: params, payload: payload, headers: headers)
|
11
|
+
end
|
12
|
+
|
9
13
|
def list_scopes(server_id, params={}, headers={})
|
10
14
|
validate_id!(server_id)
|
11
15
|
execute(method: :get, url: "#{base_path}/#{server_id}/scopes", params: params, headers: headers)
|
@@ -19,6 +19,7 @@ module Morpheus
|
|
19
19
|
|
20
20
|
def self.included(base)
|
21
21
|
base.send :include, Morpheus::Cli::PrintHelper
|
22
|
+
base.send :include, Morpheus::Cli::PromptHelper
|
22
23
|
base.send :include, Morpheus::Benchmarking::HasBenchmarking
|
23
24
|
base.extend ClassMethods
|
24
25
|
Morpheus::Cli::CliRegistry.add(base, base.command_name)
|
@@ -5,7 +5,10 @@ class Morpheus::Cli::Clouds
|
|
5
5
|
include Morpheus::Cli::InfrastructureHelper
|
6
6
|
include Morpheus::Cli::ProvisioningHelper
|
7
7
|
|
8
|
-
register_subcommands :list, :count, :get, :add, :update, :remove, :refresh, :security_groups, :apply_security_groups
|
8
|
+
register_subcommands :list, :count, :get, :add, :update, :remove, :refresh, :security_groups, :apply_security_groups
|
9
|
+
register_subcommands :types, :type
|
10
|
+
alias_subcommand :'list-types', :types
|
11
|
+
alias_subcommand :'get-type', :type
|
9
12
|
register_subcommands :wiki, :update_wiki
|
10
13
|
register_subcommands({:'update-logo' => :update_logo,:'update-dark-logo' => :update_dark_logo})
|
11
14
|
#register_subcommands :firewall_disable, :firewall_enable
|
@@ -182,10 +185,12 @@ class Morpheus::Cli::Clouds
|
|
182
185
|
#"Owner" => lambda {|it| it['owner'].instance_of?(Hash) ? it['owner']['name'] : it['ownerId'] },
|
183
186
|
"Tenant" => lambda {|it| it['account'].instance_of?(Hash) ? it['account']['name'] : it['accountId'] },
|
184
187
|
"Enabled" => lambda {|it| format_boolean(it['enabled']) },
|
185
|
-
"
|
188
|
+
"Last Sync" => lambda {|it| format_local_dt(it['lastSync']) },
|
189
|
+
"Sync Duration" => lambda {|it| format_duration_milliseconds(it['lastSyncDuration']).to_s },
|
190
|
+
"Status" => lambda {|it| format_cloud_status(it) },
|
186
191
|
}
|
187
192
|
print_description_list(description_cols, cloud)
|
188
|
-
|
193
|
+
|
189
194
|
print_h2 "Cloud Servers"
|
190
195
|
print cyan
|
191
196
|
if server_counts
|
@@ -722,36 +727,35 @@ class Morpheus::Cli::Clouds
|
|
722
727
|
end
|
723
728
|
end
|
724
729
|
|
725
|
-
def
|
730
|
+
def types(args)
|
726
731
|
options={}
|
727
732
|
params = {}
|
728
733
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
729
|
-
opts.banner = subcommand_usage()
|
730
|
-
|
734
|
+
opts.banner = subcommand_usage("[search]")
|
735
|
+
build_standard_list_options(opts, options)
|
736
|
+
opts.footer = <<-EOT
|
737
|
+
List cloud types.
|
738
|
+
EOT
|
731
739
|
end
|
732
740
|
optparse.parse!(args)
|
733
741
|
connect(options)
|
734
|
-
begin
|
735
|
-
params.merge!(parse_list_options(options))
|
736
|
-
@clouds_interface.setopts(options)
|
737
|
-
if options[:dry_run]
|
738
|
-
print_dry_run @clouds_interface.dry.cloud_types({})
|
739
|
-
return 0
|
740
|
-
end
|
741
|
-
json_response = @clouds_interface.cloud_types(params)
|
742
|
-
|
743
|
-
render_result = render_with_format(json_response, options, 'zoneTypes')
|
744
|
-
return 0 if render_result
|
745
742
|
|
746
|
-
|
743
|
+
if args.count > 0
|
744
|
+
options[:phrase] = args.join(" ")
|
745
|
+
end
|
746
|
+
params.merge!(parse_list_options(options))
|
747
|
+
@clouds_interface.setopts(options)
|
748
|
+
if options[:dry_run]
|
749
|
+
print_dry_run @clouds_interface.dry.cloud_types({})
|
750
|
+
return 0
|
751
|
+
end
|
752
|
+
json_response = @clouds_interface.cloud_types(params)
|
753
|
+
|
754
|
+
render_response(json_response, options, 'zoneTypes') do
|
747
755
|
cloud_types = json_response['zoneTypes']
|
748
|
-
|
749
|
-
title = "Morpheus Cloud Types"
|
750
|
-
subtitles = []
|
751
|
-
|
756
|
+
subtitles = []
|
752
757
|
subtitles += parse_list_subtitles(options)
|
753
|
-
print_h1
|
754
|
-
|
758
|
+
print_h1 "Morpheus Cloud Types", subtitles, options
|
755
759
|
if cloud_types.empty?
|
756
760
|
print cyan,"No cloud types found.",reset,"\n"
|
757
761
|
else
|
@@ -767,10 +771,79 @@ class Morpheus::Cli::Clouds
|
|
767
771
|
print_results_pagination(json_response)
|
768
772
|
print reset,"\n"
|
769
773
|
end
|
774
|
+
end
|
775
|
+
end
|
776
|
+
|
777
|
+
def type(args)
|
778
|
+
options={}
|
779
|
+
params = {}
|
780
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
781
|
+
opts.banner = subcommand_usage("[type]")
|
782
|
+
build_standard_get_options(opts, options)
|
783
|
+
opts.footer = <<-EOT
|
784
|
+
Get details about a cloud type.
|
785
|
+
[type] is required. This is the name or id of cloud type.
|
786
|
+
EOT
|
787
|
+
end
|
788
|
+
optparse.parse!(args)
|
789
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
790
|
+
connect(options)
|
791
|
+
# construct request
|
792
|
+
params.merge!(parse_query_options(options))
|
793
|
+
id = args[0]
|
794
|
+
cloud_type = nil
|
795
|
+
if id.to_s !~ /\A\d{1,}\Z/
|
796
|
+
cloud_type = cloud_type_for_name_or_id(id)
|
797
|
+
if cloud_type.nil?
|
798
|
+
raise_command_error "cloud type not found for name or code '#{id}'"
|
799
|
+
end
|
800
|
+
id = cloud_type['id']
|
801
|
+
end
|
802
|
+
# execute request
|
803
|
+
@clouds_interface.setopts(options)
|
804
|
+
if options[:dry_run]
|
805
|
+
print_dry_run @clouds_interface.dry.cloud_type(id.to_i)
|
770
806
|
return 0
|
771
|
-
|
772
|
-
|
773
|
-
|
807
|
+
end
|
808
|
+
json_response = @clouds_interface.cloud_type(id.to_i)
|
809
|
+
# render response
|
810
|
+
render_response(json_response, options, 'zoneType') do
|
811
|
+
cloud_type = json_response['zoneType']
|
812
|
+
print_h1 "Cloud Type", [], options
|
813
|
+
print cyan
|
814
|
+
#columns = rest_type_column_definitions(options)
|
815
|
+
columns = {
|
816
|
+
"ID" => 'id',
|
817
|
+
"Name" => 'name',
|
818
|
+
"Code" => 'code',
|
819
|
+
"Enabled" => lambda {|it| format_boolean it['enabled'] },
|
820
|
+
"Provision" => lambda {|it| format_boolean it['provision'] },
|
821
|
+
"Auto Capacity" => lambda {|it| format_boolean it['autoCapacity'] },
|
822
|
+
# "Migration Target" => lambda {|it| format_boolean it['migrationTarget'] },
|
823
|
+
"Datastores" => lambda {|it| format_boolean it['hasDatastores'] },
|
824
|
+
"Networks" => lambda {|it| format_boolean it['hasNetworks'] },
|
825
|
+
"Resource Pools" => lambda {|it| format_boolean it['hasResourcePools'] },
|
826
|
+
"Security Groups" => lambda {|it| format_boolean it['hasSecurityGroups'] },
|
827
|
+
"Containers" => lambda {|it| format_boolean it['hasContainers'] },
|
828
|
+
"Bare Metal" => lambda {|it| format_boolean it['hasBareMetal'] },
|
829
|
+
"Services" => lambda {|it| format_boolean it['hasServices'] },
|
830
|
+
"Functions" => lambda {|it| format_boolean it['hasFunctions'] },
|
831
|
+
"Jobs" => lambda {|it| format_boolean it['hasJobs'] },
|
832
|
+
"Discovery" => lambda {|it| format_boolean it['hasDiscovery'] },
|
833
|
+
"Cloud Init" => lambda {|it| format_boolean it['hasCloudInit'] },
|
834
|
+
"Folders" => lambda {|it| format_boolean it['hasFolders'] },
|
835
|
+
"Floating Ips" => lambda {|it| format_boolean it['hasFloatingIps'] },
|
836
|
+
# "Marketplace" => lambda {|it| format_boolean it['hasMarketplace'] },
|
837
|
+
"Public Cloud" => lambda {|it| format_boolean(it['cloud'] == 'public') },
|
838
|
+
}
|
839
|
+
print_description_list(columns, cloud_type, options)
|
840
|
+
# Option Types
|
841
|
+
option_types = cloud_type['optionTypes']
|
842
|
+
if option_types && option_types.size > 0
|
843
|
+
print_h2 "Option Types", options
|
844
|
+
print format_option_types_table(option_types, options, "zone")
|
845
|
+
end
|
846
|
+
print reset,"\n"
|
774
847
|
end
|
775
848
|
end
|
776
849
|
|
@@ -1136,7 +1209,7 @@ EOT
|
|
1136
1209
|
out << "#{white}UNKNOWN#{return_color}"
|
1137
1210
|
elsif status_string == 'ok'
|
1138
1211
|
out << "#{green}#{status_string.upcase}#{return_color}"
|
1139
|
-
elsif status_string == 'syncing'
|
1212
|
+
elsif status_string == 'syncing' || status_string == 'initializing' || status_string == 'removing'
|
1140
1213
|
out << "#{yellow}#{status_string.upcase}#{return_color}"
|
1141
1214
|
else
|
1142
1215
|
out << "#{red}#{status_string ? status_string.upcase : 'N/A'}#{cloud['statusMessage'] ? "#{return_color} - #{cloud['statusMessage']}" : ''}#{return_color}"
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
2
|
+
|
3
|
+
class Morpheus::Cli::CloudTypes
|
4
|
+
include Morpheus::Cli::CliCommand
|
5
|
+
include Morpheus::Cli::InfrastructureHelper
|
6
|
+
|
7
|
+
register_subcommands :list, :get
|
8
|
+
|
9
|
+
# hidden in favor of get-type and list-types
|
10
|
+
set_command_hidden
|
11
|
+
|
12
|
+
def connect(opts)
|
13
|
+
@api_client = establish_remote_appliance_connection(opts)
|
14
|
+
@clouds_interface = @api_client.clouds
|
15
|
+
end
|
16
|
+
|
17
|
+
def handle(args)
|
18
|
+
handle_subcommand(args)
|
19
|
+
end
|
20
|
+
|
21
|
+
def list(args)
|
22
|
+
options={}
|
23
|
+
params = {}
|
24
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
25
|
+
opts.banner = subcommand_usage("[search]")
|
26
|
+
build_standard_list_options(opts, options)
|
27
|
+
opts.footer = <<-EOT
|
28
|
+
List cloud types.
|
29
|
+
EOT
|
30
|
+
end
|
31
|
+
optparse.parse!(args)
|
32
|
+
connect(options)
|
33
|
+
|
34
|
+
if args.count > 0
|
35
|
+
options[:phrase] = args.join(" ")
|
36
|
+
end
|
37
|
+
params.merge!(parse_list_options(options))
|
38
|
+
@clouds_interface.setopts(options)
|
39
|
+
if options[:dry_run]
|
40
|
+
print_dry_run @clouds_interface.dry.cloud_types({})
|
41
|
+
return 0
|
42
|
+
end
|
43
|
+
json_response = @clouds_interface.cloud_types(params)
|
44
|
+
|
45
|
+
render_response(json_response, options, 'zoneTypes') do
|
46
|
+
cloud_types = json_response['zoneTypes']
|
47
|
+
subtitles = []
|
48
|
+
subtitles += parse_list_subtitles(options)
|
49
|
+
print_h1 "Morpheus Cloud Types", subtitles, options
|
50
|
+
if cloud_types.empty?
|
51
|
+
print cyan,"No cloud types found.",reset,"\n"
|
52
|
+
else
|
53
|
+
print cyan
|
54
|
+
cloud_types = cloud_types.select {|it| it['enabled'] }
|
55
|
+
rows = cloud_types.collect do |cloud_type|
|
56
|
+
{id: cloud_type['id'], name: cloud_type['name'], code: cloud_type['code']}
|
57
|
+
end
|
58
|
+
#print "\n"
|
59
|
+
columns = [:id, :name, :code]
|
60
|
+
columns = options[:include_fields] if options[:include_fields]
|
61
|
+
print as_pretty_table(rows, columns, options)
|
62
|
+
print_results_pagination(json_response)
|
63
|
+
print reset,"\n"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def get(args)
|
69
|
+
options={}
|
70
|
+
params = {}
|
71
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
72
|
+
opts.banner = subcommand_usage("[type]")
|
73
|
+
build_standard_get_options(opts, options)
|
74
|
+
opts.footer = <<-EOT
|
75
|
+
Get details about a cloud type.
|
76
|
+
[type] is required. This is the name or id of cloud type.
|
77
|
+
EOT
|
78
|
+
end
|
79
|
+
optparse.parse!(args)
|
80
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
81
|
+
connect(options)
|
82
|
+
# construct request
|
83
|
+
params.merge!(parse_query_options(options))
|
84
|
+
id = args[0]
|
85
|
+
cloud_type = nil
|
86
|
+
if id.to_s !~ /\A\d{1,}\Z/
|
87
|
+
cloud_type = cloud_type_for_name_or_id(id)
|
88
|
+
if cloud_type.nil?
|
89
|
+
raise_command_error "cloud type not found for name or code '#{id}'"
|
90
|
+
end
|
91
|
+
id = cloud_type['id']
|
92
|
+
end
|
93
|
+
# execute request
|
94
|
+
@clouds_interface.setopts(options)
|
95
|
+
if options[:dry_run]
|
96
|
+
print_dry_run @clouds_interface.dry.cloud_type(id.to_i)
|
97
|
+
return 0
|
98
|
+
end
|
99
|
+
json_response = @clouds_interface.cloud_type(id.to_i)
|
100
|
+
# render response
|
101
|
+
render_response(json_response, options, 'zoneType') do
|
102
|
+
cloud_type = json_response['zoneType']
|
103
|
+
print_h1 "Cloud Type", [], options
|
104
|
+
print cyan
|
105
|
+
#columns = rest_type_column_definitions(options)
|
106
|
+
columns = {
|
107
|
+
"ID" => 'id',
|
108
|
+
"Name" => 'name',
|
109
|
+
"Code" => 'code',
|
110
|
+
"Enabled" => lambda {|it| format_boolean it['enabled'] },
|
111
|
+
"Provision" => lambda {|it| format_boolean it['provision'] },
|
112
|
+
"Auto Capacity" => lambda {|it| format_boolean it['autoCapacity'] },
|
113
|
+
# "Migration Target" => lambda {|it| format_boolean it['migrationTarget'] },
|
114
|
+
"Datastores" => lambda {|it| format_boolean it['hasDatastores'] },
|
115
|
+
"Networks" => lambda {|it| format_boolean it['hasNetworks'] },
|
116
|
+
"Resource Pools" => lambda {|it| format_boolean it['hasResourcePools'] },
|
117
|
+
"Security Groups" => lambda {|it| format_boolean it['hasSecurityGroups'] },
|
118
|
+
"Containers" => lambda {|it| format_boolean it['hasContainers'] },
|
119
|
+
"Bare Metal" => lambda {|it| format_boolean it['hasBareMetal'] },
|
120
|
+
"Services" => lambda {|it| format_boolean it['hasServices'] },
|
121
|
+
"Functions" => lambda {|it| format_boolean it['hasFunctions'] },
|
122
|
+
"Jobs" => lambda {|it| format_boolean it['hasJobs'] },
|
123
|
+
"Discovery" => lambda {|it| format_boolean it['hasDiscovery'] },
|
124
|
+
"Cloud Init" => lambda {|it| format_boolean it['hasCloudInit'] },
|
125
|
+
"Folders" => lambda {|it| format_boolean it['hasFolders'] },
|
126
|
+
"Floating Ips" => lambda {|it| format_boolean it['hasFloatingIps'] },
|
127
|
+
# "Marketplace" => lambda {|it| format_boolean it['hasMarketplace'] },
|
128
|
+
"Public Cloud" => lambda {|it| format_boolean(it['cloud'] == 'public') },
|
129
|
+
}
|
130
|
+
print_description_list(columns, cloud_type, options)
|
131
|
+
# Option Types
|
132
|
+
option_types = cloud_type['optionTypes']
|
133
|
+
if option_types && option_types.size > 0
|
134
|
+
print_h2 "Option Types", options
|
135
|
+
print format_option_types_table(option_types, options, "zone")
|
136
|
+
end
|
137
|
+
print reset,"\n"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
@@ -24,6 +24,7 @@ class Morpheus::Cli::Clusters
|
|
24
24
|
register_subcommands :api_config, :view_api_token, :view_kube_config
|
25
25
|
register_subcommands :wiki, :update_wiki
|
26
26
|
register_subcommands :apply_template
|
27
|
+
register_subcommands :refresh
|
27
28
|
|
28
29
|
def connect(opts)
|
29
30
|
@api_client = establish_remote_appliance_connection(opts)
|
@@ -728,6 +729,14 @@ class Morpheus::Cli::Clusters
|
|
728
729
|
server_payload['networkDomain'] = options[:domain] || Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'networkDomain', 'fieldLabel' => 'Network Domain', 'type' => 'select', 'required' => false, 'optionSource' => 'networkDomains'}], options[:options], @api_client, api_params)['networkDomain']
|
729
730
|
server_payload['hostname'] = options[:hostname] || Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'hostname', 'fieldLabel' => 'Hostname', 'type' => 'text', 'required' => true, 'description' => 'Hostname', 'defaultValue' => resourceName}], options[:options], @api_client, api_params)['hostname']
|
730
731
|
|
732
|
+
# Kube Default Repo
|
733
|
+
if cluster_payload['type'] == 'kubernetes-cluster'
|
734
|
+
default_repo = options[:default_repo] || Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'defaultRepoAccount', 'fieldLabel' => 'Cluster Repo Account', 'type' => 'select', 'required' => false, 'optionSource' => 'dockerHubRegistries'}], options[:options], @api_client, api_params)['defaultRepoAccount']
|
735
|
+
if default_repo != ""
|
736
|
+
server_payload['config']['defaultRepoAccount'] = default_repo
|
737
|
+
end
|
738
|
+
end
|
739
|
+
|
731
740
|
# Workflow / Automation
|
732
741
|
if provision_type['code'] != 'manual' && controller_type && controller_type['hasAutomation']
|
733
742
|
task_set_id = options[:taskSetId] || Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'taskSet', 'fieldLabel' => 'Workflow', 'type' => 'select', 'required' => false, 'optionSource' => 'taskSets'}], options[:options], @api_client, api_params.merge({'phase' => 'postProvision'}))['taskSet']
|
@@ -4407,4 +4416,38 @@ class Morpheus::Cli::Clusters
|
|
4407
4416
|
end
|
4408
4417
|
out
|
4409
4418
|
end
|
4419
|
+
|
4420
|
+
def refresh(args)
|
4421
|
+
options = {}
|
4422
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
4423
|
+
opts.banner = subcommand_usage("[id]")
|
4424
|
+
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
4425
|
+
opts.footer = "Refresh cluster."
|
4426
|
+
end
|
4427
|
+
optparse.parse!(args)
|
4428
|
+
if args.count != 1
|
4429
|
+
raise_command_error "wrong number of arguments, expected 1 and got (#{args.count}) #{args}\n#{optparse}"
|
4430
|
+
end
|
4431
|
+
connect(options)
|
4432
|
+
begin
|
4433
|
+
cluster = find_cluster_by_name_or_id(args[0])
|
4434
|
+
return 1 if cluster.nil?
|
4435
|
+
json_response = nil
|
4436
|
+
|
4437
|
+
if options[:dry_run]
|
4438
|
+
print_dry_run @clusters_interface.dry.refresh(args[0].to_i)
|
4439
|
+
return
|
4440
|
+
end
|
4441
|
+
json_response = @clusters_interface.refresh(cluster['id'])
|
4442
|
+
if options[:json]
|
4443
|
+
puts as_json(json_response, options)
|
4444
|
+
else
|
4445
|
+
print_green_success "Refreshing cluster #{cluster['name']}..."
|
4446
|
+
end
|
4447
|
+
return 0
|
4448
|
+
rescue RestClient::Exception => e
|
4449
|
+
print_rest_exception(e, options)
|
4450
|
+
exit 1
|
4451
|
+
end
|
4452
|
+
end
|
4410
4453
|
end
|
@@ -466,6 +466,7 @@ class Morpheus::Cli::Instances
|
|
466
466
|
optparse.parse!(args)
|
467
467
|
connect(options)
|
468
468
|
|
469
|
+
|
469
470
|
if args.count > 1
|
470
471
|
print_error Morpheus::Terminal.angry_prompt
|
471
472
|
puts_error "#{command_name} add has just 1 (optional) argument: [name]. Got #{args.count} arguments: #{args.join(' ')}\n#{optparse}"
|
@@ -2,6 +2,7 @@ require 'morpheus/cli/cli_command'
|
|
2
2
|
|
3
3
|
class Morpheus::Cli::NetworkDhcpRelaysCommand
|
4
4
|
include Morpheus::Cli::CliCommand
|
5
|
+
include Morpheus::Cli::NetworksHelper
|
5
6
|
include Morpheus::Cli::ProvisioningHelper
|
6
7
|
include Morpheus::Cli::WhoamiHelper
|
7
8
|
|
@@ -329,48 +330,6 @@ class Morpheus::Cli::NetworkDhcpRelaysCommand
|
|
329
330
|
println reset
|
330
331
|
end
|
331
332
|
|
332
|
-
def find_network_server(val)
|
333
|
-
if val.to_s =~ /\A\d{1,}\Z/
|
334
|
-
return find_network_server_by_id(val)
|
335
|
-
else
|
336
|
-
if server = find_network_server_by_name(val)
|
337
|
-
return find_network_server_by_id(server['id'])
|
338
|
-
end
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
def find_network_server_by_id(id)
|
343
|
-
begin
|
344
|
-
json_response = @network_servers_interface.get(id.to_i)
|
345
|
-
return json_response['networkServer']
|
346
|
-
rescue RestClient::Exception => e
|
347
|
-
if e.response && e.response.code == 404
|
348
|
-
print_red_alert "Network Server not found by id #{id}"
|
349
|
-
return nil
|
350
|
-
else
|
351
|
-
raise e
|
352
|
-
end
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
|
-
def find_network_server_by_name(name)
|
357
|
-
json_response = @network_servers_interface.list({phrase: name.to_s})
|
358
|
-
servers = json_response['networkServers']
|
359
|
-
if servers.empty?
|
360
|
-
print_red_alert "Network Server not found by name #{name}"
|
361
|
-
return nil
|
362
|
-
elsif servers.size > 1
|
363
|
-
print_red_alert "#{servers.size} network servers found by name #{name}"
|
364
|
-
rows = servers.collect do |it|
|
365
|
-
{id: it['id'], name: it['name']}
|
366
|
-
end
|
367
|
-
puts as_pretty_table(rows, [:id, :name], {color:red})
|
368
|
-
return nil
|
369
|
-
else
|
370
|
-
return servers[0]
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
333
|
def find_dhcp_relay(server_id, val)
|
375
334
|
if val.to_s =~ /\A\d{1,}\Z/
|
376
335
|
return find_dhcp_relay_by_id(server_id, val)
|
@@ -2,8 +2,9 @@ require 'morpheus/cli/cli_command'
|
|
2
2
|
|
3
3
|
class Morpheus::Cli::NetworkDhcpServersCommand
|
4
4
|
include Morpheus::Cli::CliCommand
|
5
|
-
include Morpheus::Cli::
|
6
|
-
include Morpheus::Cli::
|
5
|
+
include Morpheus::Cli::NetworksHelper
|
6
|
+
include Morpheus::Cli::ProvisioningHelper # needed?
|
7
|
+
include Morpheus::Cli::WhoamiHelper # needed?
|
7
8
|
|
8
9
|
set_command_name :'network-dhcp-servers'
|
9
10
|
register_subcommands :list, :get, :add, :remove, :update
|
@@ -320,48 +321,6 @@ class Morpheus::Cli::NetworkDhcpServersCommand
|
|
320
321
|
println reset
|
321
322
|
end
|
322
323
|
|
323
|
-
def find_network_server(val)
|
324
|
-
if val.to_s =~ /\A\d{1,}\Z/
|
325
|
-
return find_network_server_by_id(val)
|
326
|
-
else
|
327
|
-
if server = find_network_server_by_name(val)
|
328
|
-
return find_network_server_by_id(server['id'])
|
329
|
-
end
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
def find_network_server_by_id(id)
|
334
|
-
begin
|
335
|
-
json_response = @network_servers_interface.get(id.to_i)
|
336
|
-
return json_response['networkServer']
|
337
|
-
rescue RestClient::Exception => e
|
338
|
-
if e.response && e.response.code == 404
|
339
|
-
print_red_alert "Network Server not found by id #{id}"
|
340
|
-
return nil
|
341
|
-
else
|
342
|
-
raise e
|
343
|
-
end
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
def find_network_server_by_name(name)
|
348
|
-
json_response = @network_servers_interface.list({phrase: name.to_s})
|
349
|
-
servers = json_response['networkServers']
|
350
|
-
if servers.empty?
|
351
|
-
print_red_alert "Network Server not found by name #{name}"
|
352
|
-
return nil
|
353
|
-
elsif servers.size > 1
|
354
|
-
print_red_alert "#{servers.size} network servers found by name #{name}"
|
355
|
-
rows = servers.collect do |it|
|
356
|
-
{id: it['id'], name: it['name']}
|
357
|
-
end
|
358
|
-
puts as_pretty_table(rows, [:id, :name], {color:red})
|
359
|
-
return nil
|
360
|
-
else
|
361
|
-
return servers[0]
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
324
|
def find_dhcp_server(server_id, val)
|
366
325
|
if val.to_s =~ /\A\d{1,}\Z/
|
367
326
|
return find_dhcp_server_by_id(server_id, val)
|