morpheus-cli 6.2.2 → 6.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/lib/morpheus/api/api_client.rb +12 -0
  4. data/lib/morpheus/api/clusters_interface.rb +7 -0
  5. data/lib/morpheus/api/network_security_server_types_interface.rb +9 -0
  6. data/lib/morpheus/api/network_server_types_interface.rb +9 -0
  7. data/lib/morpheus/api/network_servers_interface.rb +4 -0
  8. data/lib/morpheus/cli/cli_command.rb +1 -0
  9. data/lib/morpheus/cli/commands/clouds.rb +101 -28
  10. data/lib/morpheus/cli/commands/clouds_types.rb +141 -0
  11. data/lib/morpheus/cli/commands/clusters.rb +44 -0
  12. data/lib/morpheus/cli/commands/instances.rb +1 -0
  13. data/lib/morpheus/cli/commands/network_dhcp_relays_command.rb +1 -42
  14. data/lib/morpheus/cli/commands/network_dhcp_servers_command.rb +3 -44
  15. data/lib/morpheus/cli/commands/network_edge_clusters_command.rb +1 -42
  16. data/lib/morpheus/cli/commands/network_firewalls_command.rb +1 -41
  17. data/lib/morpheus/cli/commands/network_pool_servers_command.rb +3 -1
  18. data/lib/morpheus/cli/commands/network_routers_command.rb +4 -6
  19. data/lib/morpheus/cli/commands/network_security_server_types.rb +20 -0
  20. data/lib/morpheus/cli/commands/network_server_types_command.rb +20 -0
  21. data/lib/morpheus/cli/commands/network_servers_command.rb +368 -0
  22. data/lib/morpheus/cli/commands/network_transport_zones_command.rb +1 -41
  23. data/lib/morpheus/cli/commands/networks_command.rb +1 -1
  24. data/lib/morpheus/cli/commands/options.rb +135 -2
  25. data/lib/morpheus/cli/mixins/infrastructure_helper.rb +103 -2
  26. data/lib/morpheus/cli/mixins/networks_helper.rb +62 -0
  27. data/lib/morpheus/cli/mixins/print_helper.rb +28 -7
  28. data/lib/morpheus/cli/mixins/prompt_helper.rb +15 -0
  29. data/lib/morpheus/cli/mixins/provisioning_helper.rb +25 -9
  30. data/lib/morpheus/cli/mixins/rest_command.rb +1 -1
  31. data/lib/morpheus/cli/option_types.rb +3 -3
  32. data/lib/morpheus/cli/version.rb +1 -1
  33. data/lib/morpheus/logging.rb +6 -3
  34. metadata +10 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a11e083645c99cce105a6ee0a38ba60904debd213c3223f07e84a335a755b6a
4
- data.tar.gz: 318bbfa3ecfa0b2533e29de1a8b773389cac8c7e36c4b75b71316bc1b860aef8
3
+ metadata.gz: a5930c4f23cd2074b678db885c77f067ca32b305371cb93875a372b22a91fd18
4
+ data.tar.gz: 036f912c60e1f86ba302dc240cc1a485722ef0716752d934a352e54d797fd5d4
5
5
  SHA512:
6
- metadata.gz: 79c6bd2a41bbd7c5fc79dfecd769db385626eea40bcf1ca19d6d4021f0cc57404c8eab74bfc831013f55b0668a1cbce86b909d11b71723a9bfc1587b29beb6c4
7
- data.tar.gz: 21973cfd06571448876862f243895dc2334f19f5c20355cff9224d4d1c319911776a7d60c93196b1d79e5e16c65b66b1179476b89816931b181bad7e98bbd3dc
6
+ metadata.gz: c93378cfb509b11873be3d183f69bc5662fd5afb6888ea759271347e84f87443a73c9eb80a12572b1c196f1afe8ebf40068d00290053ebad398df5ee320d8446
7
+ data.tar.gz: 1c277dd0ff9b918b3c2dfd9fc7bc0c4ed662e59ba3fa10a4abf3d037ffc08211e0f0c7a040917ca1322dbc06610391f676560ec195ddd794ff50d2098658235b
data/Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
1
  FROM ruby:2.7.5
2
2
 
3
- RUN gem install morpheus-cli -v 6.2.2
3
+ RUN gem install morpheus-cli -v 6.2.3
4
4
 
5
5
  ENTRYPOINT ["morpheus"]
@@ -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
@@ -0,0 +1,9 @@
1
+ require 'morpheus/api/read_interface'
2
+
3
+ class Morpheus::NetworkSecurityServerTypesInterface < Morpheus::ReadInterface
4
+
5
+ def base_path
6
+ "/api/networks/security-server-types"
7
+ end
8
+
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'morpheus/api/read_interface'
2
+
3
+ class Morpheus::NetworkServerTypesInterface < Morpheus::ReadInterface
4
+
5
+ def base_path
6
+ "/api/networks/server-types"
7
+ end
8
+
9
+ 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, :types => :list_cloud_types
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
- "Status" => lambda {|it| format_cloud_status(it) }
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 list_cloud_types(args)
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
- build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
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
- #cloud_types = get_available_cloud_types()
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 title, subtitles
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
- rescue RestClient::Exception => e
772
- print_rest_exception(e, options)
773
- exit 1
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,15 @@ 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' && (layout['clusterVersion'] == '1.28.x' || layout['clusterVersion'] == '1.27.x')
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
+
740
+
731
741
  # Workflow / Automation
732
742
  if provision_type['code'] != 'manual' && controller_type && controller_type['hasAutomation']
733
743
  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 +4417,38 @@ class Morpheus::Cli::Clusters
4407
4417
  end
4408
4418
  out
4409
4419
  end
4420
+
4421
+ def refresh(args)
4422
+ options = {}
4423
+ optparse = Morpheus::Cli::OptionParser.new do |opts|
4424
+ opts.banner = subcommand_usage("[id]")
4425
+ build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
4426
+ opts.footer = "Refresh cluster."
4427
+ end
4428
+ optparse.parse!(args)
4429
+ if args.count != 1
4430
+ raise_command_error "wrong number of arguments, expected 1 and got (#{args.count}) #{args}\n#{optparse}"
4431
+ end
4432
+ connect(options)
4433
+ begin
4434
+ cluster = find_cluster_by_name_or_id(args[0])
4435
+ return 1 if cluster.nil?
4436
+ json_response = nil
4437
+
4438
+ if options[:dry_run]
4439
+ print_dry_run @clusters_interface.dry.refresh(args[0].to_i)
4440
+ return
4441
+ end
4442
+ json_response = @clusters_interface.refresh(cluster['id'])
4443
+ if options[:json]
4444
+ puts as_json(json_response, options)
4445
+ else
4446
+ print_green_success "Refreshing cluster #{cluster['name']}..."
4447
+ end
4448
+ return 0
4449
+ rescue RestClient::Exception => e
4450
+ print_rest_exception(e, options)
4451
+ exit 1
4452
+ end
4453
+ end
4410
4454
  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::ProvisioningHelper
6
- include Morpheus::Cli::WhoamiHelper
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)
@@ -2,6 +2,7 @@ require 'morpheus/cli/cli_command'
2
2
 
3
3
  class Morpheus::Cli::NetworkEdgeClustersCommand
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
 
@@ -242,48 +243,6 @@ class Morpheus::Cli::NetworkEdgeClustersCommand
242
243
  end
243
244
  end
244
245
 
245
- def find_network_server(val)
246
- if val.to_s =~ /\A\d{1,}\Z/
247
- return find_network_server_by_id(val)
248
- else
249
- if server = find_network_server_by_name(val)
250
- return find_network_server_by_id(server['id'])
251
- end
252
- end
253
- end
254
-
255
- def find_network_server_by_id(id)
256
- begin
257
- json_response = @network_servers_interface.get(id.to_i)
258
- return json_response['networkServer']
259
- rescue RestClient::Exception => e
260
- if e.response && e.response.code == 404
261
- print_red_alert "Network Server not found by id #{id}"
262
- return nil
263
- else
264
- raise e
265
- end
266
- end
267
- end
268
-
269
- def find_network_server_by_name(name)
270
- json_response = @network_servers_interface.list({phrase: name.to_s})
271
- servers = json_response['networkServers']
272
- if servers.empty?
273
- print_red_alert "Network Server not found by name #{name}"
274
- return nil
275
- elsif servers.size > 1
276
- print_red_alert "#{servers.size} network servers found by name #{name}"
277
- rows = servers.collect do |it|
278
- {id: it['id'], name: it['name']}
279
- end
280
- puts as_pretty_table(rows, [:id, :name], {color:red})
281
- return nil
282
- else
283
- return servers[0]
284
- end
285
- end
286
-
287
246
  def find_edge_cluster(server_id, val)
288
247
  if val.to_s =~ /\A\d{1,}\Z/
289
248
  return find_edge_cluster_by_id(server_id, val)