morpheus-cli 5.3.2.1 → 5.3.4
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/lib/morpheus/api/api_client.rb +12 -0
- data/lib/morpheus/api/clouds_interface.rb +4 -11
- data/lib/morpheus/api/instances_interface.rb +18 -5
- data/lib/morpheus/api/load_balancer_pools_interface.rb +4 -4
- data/lib/morpheus/api/load_balancer_profiles_interface.rb +10 -0
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +4 -4
- data/lib/morpheus/api/network_routers_interface.rb +21 -0
- data/lib/morpheus/api/network_servers_interface.rb +42 -0
- data/lib/morpheus/api/rest_interface.rb +2 -1
- data/lib/morpheus/api/virtual_images_interface.rb +23 -2
- data/lib/morpheus/api/virtual_servers_interface.rb +9 -0
- data/lib/morpheus/cli/apps.rb +3 -2
- data/lib/morpheus/cli/cli_command.rb +14 -6
- data/lib/morpheus/cli/cli_registry.rb +55 -2
- data/lib/morpheus/cli/cloud_resource_pools_command.rb +170 -134
- data/lib/morpheus/cli/clouds.rb +22 -40
- data/lib/morpheus/cli/clusters.rb +51 -33
- data/lib/morpheus/cli/hosts.rb +0 -1
- data/lib/morpheus/cli/instances.rb +372 -150
- data/lib/morpheus/cli/invoices_command.rb +117 -133
- data/lib/morpheus/cli/library_cluster_layouts_command.rb +20 -0
- data/lib/morpheus/cli/library_option_lists_command.rb +3 -3
- data/lib/morpheus/cli/load_balancer_pools.rb +111 -0
- data/lib/morpheus/cli/load_balancer_virtual_servers.rb +136 -0
- data/lib/morpheus/cli/load_balancers.rb +0 -155
- data/lib/morpheus/cli/mixins/load_balancers_helper.rb +2 -2
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +155 -112
- data/lib/morpheus/cli/mixins/rest_command.rb +53 -37
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +488 -0
- data/lib/morpheus/cli/monitoring_checks_command.rb +2 -0
- data/lib/morpheus/cli/network_routers_command.rb +291 -7
- data/lib/morpheus/cli/network_scopes_command.rb +442 -0
- data/lib/morpheus/cli/networks_command.rb +3 -3
- data/lib/morpheus/cli/option_parser.rb +25 -17
- data/lib/morpheus/cli/option_types.rb +42 -15
- data/lib/morpheus/cli/subnets_command.rb +7 -2
- data/lib/morpheus/cli/tasks.rb +25 -2
- data/lib/morpheus/cli/vdi_pools_command.rb +4 -1
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/virtual_images.rb +251 -29
- data/lib/morpheus/cli.rb +9 -1
- data/morpheus-cli.gemspec +1 -1
- metadata +11 -4
@@ -564,13 +564,10 @@ class Morpheus::Cli::Clusters
|
|
564
564
|
|
565
565
|
cluster_payload['layout'] = {id: layout['id']}
|
566
566
|
|
567
|
-
#
|
567
|
+
# Provision Type
|
568
568
|
provision_type = (layout && layout['provisionType'] ? layout['provisionType'] : nil) || get_provision_type_for_zone_type(cloud['zoneType']['id'])
|
569
|
-
service_plan = prompt_service_plan(cloud['id'], provision_type, options)
|
570
569
|
|
571
|
-
|
572
|
-
server_payload['plan'] = {'id' => service_plan['id'], 'code' => service_plan['code'], 'options' => prompt_service_plan_options(service_plan, options)}
|
573
|
-
end
|
570
|
+
api_params = {zoneId: cloud['id'], siteId: group['id'], layoutId: layout['id'], groupTypeId: cluster_type['id'], provisionTypeId: provision_type['id']}
|
574
571
|
|
575
572
|
# Controller type
|
576
573
|
server_types = @server_types_interface.list({max:1, computeTypeId: cluster_type['controllerTypes'].first['id'], zoneTypeId: cloud['zoneType']['id'], useZoneProvisionTypes: true})['serverTypes']
|
@@ -581,22 +578,47 @@ class Morpheus::Cli::Clusters
|
|
581
578
|
controller_type = server_types.first
|
582
579
|
controller_provision_type = controller_type['provisionType'] ? (@provision_types_interface.get(controller_type['provisionType']['id'])['provisionType'] rescue nil) : nil
|
583
580
|
|
584
|
-
if controller_provision_type && resource_pool = prompt_resource_pool(group, cloud,
|
585
|
-
|
581
|
+
if controller_provision_type && resource_pool = prompt_resource_pool(group, cloud, nil, controller_provision_type, options)
|
582
|
+
server_payload['config']['resourcePoolId'] = resource_pool['id']
|
583
|
+
api_params['config'] ||= {}
|
584
|
+
api_params['config']['resourcePool'] = resource_pool['id']
|
585
|
+
api_params['resourcePoolId'] = resource_pool['id']
|
586
|
+
api_params['zonePoolId'] = resource_pool['id']
|
586
587
|
end
|
587
588
|
end
|
588
589
|
|
590
|
+
# Service Plan
|
591
|
+
service_plan = prompt_service_plan(api_params, options)
|
592
|
+
|
593
|
+
if service_plan
|
594
|
+
server_payload['plan'] = {'id' => service_plan['id'], 'code' => service_plan['code'], 'options' => prompt_service_plan_options(service_plan, options)}
|
595
|
+
api_params['planId'] = service_plan['id']
|
596
|
+
end
|
597
|
+
|
589
598
|
# Multi-disk / prompt for volumes
|
590
|
-
volumes = options[:volumes] || prompt_volumes(service_plan, options.merge({'defaultAddFirstDataVolume': true}), @api_client,
|
599
|
+
volumes = options[:volumes] || prompt_volumes(service_plan, options.merge({'defaultAddFirstDataVolume': true}), @api_client, api_params)
|
591
600
|
|
592
601
|
if !volumes.empty?
|
593
602
|
server_payload['volumes'] = volumes
|
594
603
|
end
|
595
604
|
|
605
|
+
# Options / Custom Config
|
606
|
+
option_type_list =
|
607
|
+
((controller_type['optionTypes'].reject { |type| !type['enabled'] || type['fieldComponent'] } rescue []) + layout['optionTypes'] +
|
608
|
+
(cluster_type['optionTypes'].reject { |type| !type['enabled'] || !type['creatable'] || type['fieldComponent'] } rescue [])).sort { |type| type['displayOrder'] }
|
609
|
+
|
610
|
+
# KLUDGE: google zone required for network selection
|
611
|
+
if option_type = option_type_list.find {|type| type['code'] == 'computeServerType.googleLinux.googleZoneId'}
|
612
|
+
server_payload.deep_merge!(Morpheus::Cli::OptionTypes.prompt([option_type], options[:options], @api_client, api_params))
|
613
|
+
api_params.deep_merge!(server_payload)
|
614
|
+
api_params.deep_merge!(server_payload['config'])
|
615
|
+
option_type_list = option_type_list.reject {|type| type['code'] == 'computeServerType.googleLinux.googleZoneId'}
|
616
|
+
end
|
617
|
+
|
596
618
|
# Networks
|
597
619
|
# NOTE: You must choose subnets in the same availability zone
|
598
620
|
if controller_provision_type && controller_provision_type['hasNetworks'] && cloud['zoneType']['code'] != 'esxi'
|
599
|
-
server_payload['networkInterfaces'] = options[:networkInterfaces] || prompt_network_interfaces(cloud['id'], provision_type['id'], (resource_pool['id'] rescue nil), options)
|
621
|
+
server_payload['networkInterfaces'] = options[:networkInterfaces] || prompt_network_interfaces(cloud['id'], provision_type['id'], (resource_pool['id'] rescue nil), options.merge({:api_params => api_params}))
|
600
622
|
end
|
601
623
|
|
602
624
|
# Security Groups
|
@@ -605,15 +627,11 @@ class Morpheus::Cli::Clusters
|
|
605
627
|
# Visibility
|
606
628
|
server_payload['visibility'] = options[:visibility] || (Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'visibility', 'fieldLabel' => 'Visibility', 'type' => 'select', 'defaultValue' => 'private', 'required' => true, 'selectOptions' => [{'name' => 'Private', 'value' => 'private'},{'name' => 'Public', 'value' => 'public'}]}], options[:options], @api_client, {})['visibility'])
|
607
629
|
|
608
|
-
|
609
|
-
option_type_list = ((controller_type['optionTypes'].reject { |type| !type['enabled'] || type['fieldComponent'] } rescue []) + layout['optionTypes'] +
|
610
|
-
(cluster_type['optionTypes'].reject { |type| !type['enabled'] || !type['creatable'] || type['fieldComponent'] } rescue [])).sort { |type| type['displayOrder'] }
|
611
|
-
|
612
|
-
server_payload.deep_merge!(Morpheus::Cli::OptionTypes.prompt(option_type_list, options[:options], @api_client, {zoneId: cloud['id'], siteId: group['id'], layoutId: layout['id']}))
|
630
|
+
server_payload.deep_merge!(Morpheus::Cli::OptionTypes.prompt(option_type_list, options[:options], @api_client, api_params, options[:no_prompt], true))
|
613
631
|
|
614
632
|
# Worker count
|
615
633
|
default_node_count = layout['computeServers'] ? (layout['computeServers'].find {|it| it['nodeType'] == 'worker'} || {'nodeCount' => 3})['nodeCount'] : 3
|
616
|
-
server_payload['nodeCount'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => "nodeCount", 'type' => 'number', 'fieldLabel' => "#{cluster_type['code'].include?('docker') ? 'Host' : 'Worker'} Count", 'required' => true, 'defaultValue' => default_node_count}], options[:options], @api_client,
|
634
|
+
server_payload['config']['nodeCount'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => "config.nodeCount", 'type' => 'number', 'fieldLabel' => "#{cluster_type['code'].include?('docker') ? 'Host' : 'Worker'} Count", 'required' => true, 'defaultValue' => default_node_count > 0 ? default_node_count : 3}], options[:options], @api_client, api_params, options[:no_prompt])['config']['nodeCount']
|
617
635
|
|
618
636
|
# Create User
|
619
637
|
if !options[:createUser].nil?
|
@@ -629,7 +647,7 @@ class Morpheus::Cli::Clusters
|
|
629
647
|
if userGroup
|
630
648
|
server_payload['userGroup'] = userGroup
|
631
649
|
elsif !options[:no_prompt]
|
632
|
-
userGroupId = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'userGroupId', 'fieldLabel' => 'User Group', 'type' => 'select', 'required' => false, 'optionSource' => 'userGroups'}], options[:options], @api_client,
|
650
|
+
userGroupId = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'userGroupId', 'fieldLabel' => 'User Group', 'type' => 'select', 'required' => false, 'optionSource' => 'userGroups'}], options[:options], @api_client, api_params)['userGroupId']
|
633
651
|
|
634
652
|
if userGroupId
|
635
653
|
server_payload['userGroup'] = {'id' => userGroupId}
|
@@ -637,11 +655,11 @@ class Morpheus::Cli::Clusters
|
|
637
655
|
end
|
638
656
|
|
639
657
|
# Host / Domain
|
640
|
-
server_payload['networkDomain'] = options[:domain] || Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'networkDomain', 'fieldLabel' => 'Network Domain', 'type' => 'select', 'required' => false, 'optionSource' => 'networkDomains'}], options[:options], @api_client,
|
641
|
-
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)['hostname']
|
658
|
+
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']
|
659
|
+
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']
|
642
660
|
|
643
661
|
# Workflow / Automation
|
644
|
-
task_set_id = options[:taskSetId] || Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'taskSet', 'fieldLabel' => 'Workflow', 'type' => 'select', 'required' => false, 'optionSource' => 'taskSets'}], options[:options], @api_client, {'phase' => 'postProvision'})['taskSet']
|
662
|
+
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']
|
645
663
|
|
646
664
|
if !task_set_id.nil?
|
647
665
|
server_payload['taskSet'] = {'id' => task_set_id}
|
@@ -1147,20 +1165,20 @@ class Morpheus::Cli::Clusters
|
|
1147
1165
|
cloud_id = (default_cloud && cloud_id == default_cloud['name']) ? default_cloud['value'] : cloud_id
|
1148
1166
|
end
|
1149
1167
|
|
1168
|
+
# resources (zone pools)
|
1169
|
+
cloud = @clouds_interface.get(cloud_id)['zone']
|
1170
|
+
cloud['zoneType'] = get_cloud_type(cloud['zoneType']['id'])
|
1171
|
+
group = @groups_interface.get(cluster['site']['id'])['group']
|
1172
|
+
|
1150
1173
|
server_payload['cloud'] = {'id' => cloud_id}
|
1151
|
-
service_plan = prompt_service_plan(cloud_id, server_type['provisionType'], options)
|
1174
|
+
service_plan = prompt_service_plan({zoneId: cloud_id, siteId: cluster['site']['id'], provisionTypeId: server_type['provisionType']['id'], groupTypeId: cluster_type['id'], }, options)
|
1152
1175
|
|
1153
1176
|
if service_plan
|
1154
1177
|
server_payload['plan'] = {'code' => service_plan['code'], 'options' => prompt_service_plan_options(service_plan, options)}
|
1155
1178
|
end
|
1156
1179
|
|
1157
|
-
# resources (zone pools)
|
1158
|
-
cloud = @clouds_interface.get(cloud_id)['zone']
|
1159
|
-
cloud['zoneType'] = get_cloud_type(cloud['zoneType']['id'])
|
1160
|
-
group = @groups_interface.get(cluster['site']['id'])['group']
|
1161
|
-
|
1162
1180
|
if resource_pool = prompt_resource_pool(cluster, cloud, service_plan, server_type['provisionType'], options)
|
1163
|
-
server_payload['config']['
|
1181
|
+
server_payload['config']['resourcePoolId'] = resource_pool['id']
|
1164
1182
|
end
|
1165
1183
|
|
1166
1184
|
# Multi-disk / prompt for volumes
|
@@ -1181,7 +1199,7 @@ class Morpheus::Cli::Clusters
|
|
1181
1199
|
server_payload['securityGroups'] = prompt_security_groups_by_cloud(cloud, provision_type, resource_pool, options)
|
1182
1200
|
|
1183
1201
|
# Worker count
|
1184
|
-
default_node_count = layout['computeServers'] ? (layout['computeServers'].find {|it| it['nodeType'] == 'worker'} || {'nodeCount' =>
|
1202
|
+
default_node_count = layout['computeServers'] ? (layout['computeServers'].find {|it| it['nodeType'] == 'worker'} || {'nodeCount' => 1})['nodeCount'] : 1
|
1185
1203
|
server_payload['nodeCount'] = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => "nodeCount", 'type' => 'number', 'fieldLabel' => "#{cluster_type['code'].include?('docker') ? 'Host' : 'Worker'} Count", 'required' => true, 'defaultValue' => default_node_count}], options[:options], @api_client, {}, options[:no_prompt])["nodeCount"]
|
1186
1204
|
|
1187
1205
|
# Options / Custom Config
|
@@ -3635,8 +3653,8 @@ class Morpheus::Cli::Clusters
|
|
3635
3653
|
@server_types_interface.get(val)['serverType']
|
3636
3654
|
end
|
3637
3655
|
|
3638
|
-
def service_plans_for_dropdown(
|
3639
|
-
@servers_interface.service_plans(
|
3656
|
+
def service_plans_for_dropdown(api_params)
|
3657
|
+
@servers_interface.service_plans(api_params)['plans'] rescue []
|
3640
3658
|
end
|
3641
3659
|
|
3642
3660
|
def namespace_service_plans
|
@@ -3679,10 +3697,10 @@ class Morpheus::Cli::Clusters
|
|
3679
3697
|
@groups_interface.get(group_id)['group']
|
3680
3698
|
end
|
3681
3699
|
|
3682
|
-
def prompt_service_plan(
|
3683
|
-
available_service_plans = service_plans_for_dropdown(
|
3700
|
+
def prompt_service_plan(api_params, options)
|
3701
|
+
available_service_plans = service_plans_for_dropdown(api_params)
|
3684
3702
|
if available_service_plans.empty?
|
3685
|
-
print_red_alert "Cloud #{
|
3703
|
+
print_red_alert "Cloud #{api_params['zoneId']} has no available plans"
|
3686
3704
|
exit 1
|
3687
3705
|
end
|
3688
3706
|
if options[:servicePlan]
|
@@ -3853,7 +3871,7 @@ class Morpheus::Cli::Clusters
|
|
3853
3871
|
resource_pool = options[:resourcePool] ? find_cloud_resource_pool_by_name_or_id(cloud['id'], options[:resourcePool]) : nil
|
3854
3872
|
|
3855
3873
|
if !resource_pool
|
3856
|
-
resource_pool_options = @options_interface.options_for_source('zonePools', {groupId: group['id'], zoneId: cloud['id']
|
3874
|
+
resource_pool_options = @options_interface.options_for_source('zonePools', {groupId: group['id'], zoneId: cloud['id']}.merge(service_plan ? {planId: service_plan['id']} : {}))['data'].reject { |it| it['id'].nil? && it['name'].nil? }
|
3857
3875
|
|
3858
3876
|
if resource_pool_options.empty?
|
3859
3877
|
print_red_alert "Cloud #{cloud['name']} has no available resource pools"
|
data/lib/morpheus/cli/hosts.rb
CHANGED
@@ -553,7 +553,6 @@ class Morpheus::Cli::Hosts
|
|
553
553
|
server_columns.delete("Cost") if server['hourlyCost'].to_f == 0
|
554
554
|
server_columns.delete("Price") if server['hourlyPrice'].to_f == 0 || server['hourlyPrice'] == server['hourlyCost']
|
555
555
|
server_columns.delete("Labels") if server['labels'].nil? || server['labels'].empty?
|
556
|
-
server_columns.delete("Tags") if tags.nil? || tags.empty?
|
557
556
|
|
558
557
|
print_description_list(server_columns, server)
|
559
558
|
|