morpheus-cli 5.4.0 → 5.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/account_users_interface.rb +68 -0
- data/lib/morpheus/api/api_client.rb +51 -9
- data/lib/morpheus/api/audit_interface.rb +9 -0
- data/lib/morpheus/api/instances_interface.rb +21 -0
- data/lib/morpheus/api/load_balancer_monitors_interface.rb +9 -0
- data/lib/morpheus/api/load_balancer_pools_interface.rb +4 -4
- data/lib/morpheus/api/load_balancer_profiles_interface.rb +4 -5
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +13 -4
- data/lib/morpheus/api/load_balancers_interface.rb +5 -0
- data/lib/morpheus/api/network_routers_interface.rb +9 -0
- data/lib/morpheus/api/network_static_routes_interface.rb +36 -0
- data/lib/morpheus/api/read_interface.rb +4 -3
- data/lib/morpheus/api/rest_interface.rb +3 -3
- data/lib/morpheus/api/secondary_read_interface.rb +1 -1
- data/lib/morpheus/api/secondary_rest_interface.rb +19 -19
- data/lib/morpheus/api/storage_server_types_interface.rb +14 -0
- data/lib/morpheus/api/storage_servers_interface.rb +9 -0
- data/lib/morpheus/api/storage_volume_types_interface.rb +9 -0
- data/lib/morpheus/api/storage_volumes_interface.rb +9 -0
- data/lib/morpheus/api/users_interface.rb +16 -63
- data/lib/morpheus/cli/cli_command.rb +253 -5
- data/lib/morpheus/cli/cli_registry.rb +1 -1
- data/lib/morpheus/cli/commands/alias_command.rb +1 -1
- data/lib/morpheus/cli/commands/apps.rb +14 -78
- data/lib/morpheus/cli/commands/audit.rb +188 -0
- data/lib/morpheus/cli/commands/blueprints_command.rb +1 -1
- data/lib/morpheus/cli/commands/change_password_command.rb +4 -4
- data/lib/morpheus/cli/commands/clusters.rb +37 -12
- data/lib/morpheus/cli/commands/hosts.rb +15 -15
- data/lib/morpheus/cli/commands/instances.rb +109 -2
- data/lib/morpheus/cli/commands/load_balancer_monitors.rb +71 -0
- data/lib/morpheus/cli/commands/load_balancer_pools.rb +30 -50
- data/lib/morpheus/cli/commands/load_balancer_profiles.rb +65 -0
- data/lib/morpheus/cli/commands/load_balancer_types.rb +9 -4
- data/lib/morpheus/cli/commands/load_balancer_virtual_servers.rb +77 -57
- data/lib/morpheus/cli/commands/load_balancers.rb +93 -6
- data/lib/morpheus/cli/commands/network_firewalls_command.rb +22 -5
- data/lib/morpheus/cli/commands/network_routers_command.rb +96 -45
- data/lib/morpheus/cli/commands/network_static_routes_command.rb +446 -0
- data/lib/morpheus/cli/commands/network_transport_zones_command.rb +4 -4
- data/lib/morpheus/cli/commands/open_command.rb +30 -0
- data/lib/morpheus/cli/commands/options.rb +98 -0
- data/lib/morpheus/cli/commands/policies_command.rb +1 -1
- data/lib/morpheus/cli/commands/prices_command.rb +7 -7
- data/lib/morpheus/cli/commands/remote.rb +4 -2
- data/lib/morpheus/cli/commands/roles.rb +1 -1
- data/lib/morpheus/cli/commands/shell.rb +2 -2
- data/lib/morpheus/cli/commands/storage_server_types.rb +50 -0
- data/lib/morpheus/cli/commands/storage_servers.rb +122 -0
- data/lib/morpheus/cli/commands/storage_volume_types.rb +50 -0
- data/lib/morpheus/cli/commands/storage_volumes.rb +103 -0
- data/lib/morpheus/cli/commands/tenants_command.rb +1 -1
- data/lib/morpheus/cli/commands/user_groups_command.rb +1 -1
- data/lib/morpheus/cli/commands/user_settings_command.rb +2 -1
- data/lib/morpheus/cli/commands/user_sources_command.rb +1 -1
- data/lib/morpheus/cli/commands/users.rb +28 -28
- data/lib/morpheus/cli/commands/view.rb +102 -0
- data/lib/morpheus/cli/mixins/accounts_helper.rb +5 -5
- data/lib/morpheus/cli/mixins/load_balancers_helper.rb +24 -4
- data/lib/morpheus/cli/mixins/print_helper.rb +50 -18
- data/lib/morpheus/cli/mixins/processes_helper.rb +1 -2
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +15 -5
- data/lib/morpheus/cli/mixins/rest_command.rb +145 -73
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +174 -81
- data/lib/morpheus/cli/mixins/storage_servers_helper.rb +156 -0
- data/lib/morpheus/cli/mixins/storage_volumes_helper.rb +119 -0
- data/lib/morpheus/cli/option_types.rb +45 -24
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +1 -0
- data/lib/morpheus/ext/string.rb +29 -6
- data/lib/morpheus/routes.rb +238 -0
- data/lib/morpheus/util.rb +6 -1
- metadata +29 -8
@@ -9,7 +9,7 @@ class Morpheus::Cli::ChangePasswordCommand
|
|
9
9
|
def connect(opts)
|
10
10
|
@api_client = establish_remote_appliance_connection(opts)
|
11
11
|
@whoami_interface = @api_client.whoami
|
12
|
-
@
|
12
|
+
@account_users_interface = @api_client.account_users
|
13
13
|
@accounts_interface = @api_client.accounts
|
14
14
|
@roles_interface = @api_client.roles
|
15
15
|
end
|
@@ -105,9 +105,9 @@ class Morpheus::Cli::ChangePasswordCommand
|
|
105
105
|
'password' => new_password
|
106
106
|
}
|
107
107
|
}
|
108
|
-
@
|
108
|
+
@account_users_interface.setopts(options)
|
109
109
|
if options[:dry_run]
|
110
|
-
print_dry_run @
|
110
|
+
print_dry_run @account_users_interface.dry.update(account_id, user['id'], payload)
|
111
111
|
return 0
|
112
112
|
end
|
113
113
|
|
@@ -117,7 +117,7 @@ class Morpheus::Cli::ChangePasswordCommand
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
-
json_response = @
|
120
|
+
json_response = @account_users_interface.update(account_id, user['id'], payload)
|
121
121
|
if options[:json]
|
122
122
|
puts as_json(json_response)
|
123
123
|
elsif !options[:quiet]
|
@@ -458,6 +458,10 @@ class Morpheus::Cli::Clusters
|
|
458
458
|
|
459
459
|
cluster_payload['type'] = cluster_type['code'] # {'id' => cluster_type['id']}
|
460
460
|
|
461
|
+
# Group / Site
|
462
|
+
group = load_group(cluster_type['code'], options)
|
463
|
+
cluster_payload['group'] = {'id' => group['id']}
|
464
|
+
|
461
465
|
# Cluster Name
|
462
466
|
if args.empty? && options[:no_prompt]
|
463
467
|
print_red_alert "No cluster name provided"
|
@@ -514,10 +518,6 @@ class Morpheus::Cli::Clusters
|
|
514
518
|
|
515
519
|
server_payload['tags'] = tags if tags
|
516
520
|
|
517
|
-
# Group / Site
|
518
|
-
group = load_group(options)
|
519
|
-
cluster_payload['group'] = {'id' => group['id']}
|
520
|
-
|
521
521
|
# Cloud / Zone
|
522
522
|
cloud_id = nil
|
523
523
|
cloud = options[:cloud] ? find_cloud_by_name_or_id_for_provisioning(group['id'], options[:cloud]) : nil
|
@@ -526,7 +526,7 @@ class Morpheus::Cli::Clusters
|
|
526
526
|
cloud = @clouds_interface.get(cloud['id'])['zone']
|
527
527
|
cloud_id = cloud['id']
|
528
528
|
else
|
529
|
-
available_clouds = get_available_clouds(group['id'])
|
529
|
+
available_clouds = get_available_clouds(group['id'], {groupType: cluster_payload['type']})
|
530
530
|
|
531
531
|
if available_clouds.empty?
|
532
532
|
print_red_alert "Group #{group['name']} has no available clouds"
|
@@ -556,12 +556,12 @@ class Morpheus::Cli::Clusters
|
|
556
556
|
end
|
557
557
|
end
|
558
558
|
|
559
|
-
cluster_payload['layout'] = {id
|
559
|
+
cluster_payload['layout'] = {'id' => layout['id']}
|
560
560
|
|
561
561
|
# Provision Type
|
562
562
|
provision_type = (layout && layout['provisionType'] ? layout['provisionType'] : nil) || get_provision_type_for_zone_type(cloud['zoneType']['id'])
|
563
563
|
|
564
|
-
api_params = {zoneId: cloud['id'], siteId: group['id'], layoutId: layout['id'], groupTypeId: cluster_type['id'], provisionTypeId: provision_type['id']}
|
564
|
+
api_params = {zoneId: cloud['id'], siteId: group['id'], layoutId: layout['id'], groupTypeId: cluster_type['id'], provisionType: provision_type['code'], provisionTypeId: provision_type['id']}
|
565
565
|
|
566
566
|
# Controller type
|
567
567
|
server_types = @server_types_interface.list({max:1, computeTypeId: cluster_type['controllerTypes'].first['id'], zoneTypeId: cloud['zoneType']['id'], useZoneProvisionTypes: true})['serverTypes']
|
@@ -621,6 +621,10 @@ class Morpheus::Cli::Clusters
|
|
621
621
|
# Visibility
|
622
622
|
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'])
|
623
623
|
|
624
|
+
# Layout template options
|
625
|
+
cluster_payload.deep_merge!(Morpheus::Cli::OptionTypes.prompt(load_layout_options(cluster_payload), options[:options], @api_client, api_params, options[:no_prompt], true))
|
626
|
+
|
627
|
+
# Server options
|
624
628
|
server_payload.deep_merge!(Morpheus::Cli::OptionTypes.prompt(option_type_list, options[:options], @api_client, api_params, options[:no_prompt], true))
|
625
629
|
|
626
630
|
# Worker count
|
@@ -3665,7 +3669,7 @@ class Morpheus::Cli::Clusters
|
|
3665
3669
|
@clouds_interface.cloud_type(zone_type_id)['zoneType']['provisionTypes'].first rescue nil
|
3666
3670
|
end
|
3667
3671
|
|
3668
|
-
def load_group(options)
|
3672
|
+
def load_group(group_type, options)
|
3669
3673
|
# Group / Site
|
3670
3674
|
group_id = nil
|
3671
3675
|
group = options[:group] ? find_group_by_name_or_id_for_provisioning(options[:group]) : nil
|
@@ -3676,15 +3680,13 @@ class Morpheus::Cli::Clusters
|
|
3676
3680
|
if @active_group_id
|
3677
3681
|
group_id = @active_group_id
|
3678
3682
|
else
|
3679
|
-
available_groups = get_available_groups
|
3683
|
+
available_groups = get_available_groups({groupType: group_type})
|
3680
3684
|
|
3681
3685
|
if available_groups.empty?
|
3682
3686
|
print_red_alert "No available groups"
|
3683
3687
|
exit 1
|
3684
|
-
|
3688
|
+
else available_groups.count > 1 && !options[:no_prompt]
|
3685
3689
|
group_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'group', 'type' => 'select', 'fieldLabel' => 'Group', 'selectOptions' => available_groups, 'required' => true, 'description' => 'Select Group.'}],options[:options],@api_client,{})['group']
|
3686
|
-
else
|
3687
|
-
group_id = available_groups.first['id']
|
3688
3690
|
end
|
3689
3691
|
end
|
3690
3692
|
end
|
@@ -3926,4 +3928,27 @@ class Morpheus::Cli::Clusters
|
|
3926
3928
|
]
|
3927
3929
|
end
|
3928
3930
|
|
3931
|
+
def load_layout_options(cluster)
|
3932
|
+
(@api_client.options.options_for_source('computeTypeLayoutParameters', {layoutId: cluster['layout']['id']})['data'] || []).collect do |it|
|
3933
|
+
it['fieldName'] = it['name']
|
3934
|
+
it['fieldLabel'] = it['displayName']
|
3935
|
+
it['fieldContext'] = 'config.templateParameter'
|
3936
|
+
if it['type'] == 'ServicePlan'
|
3937
|
+
it['optionSource'] = 'servicePlans'
|
3938
|
+
it['type'] = 'select'
|
3939
|
+
it['params'] = {:provisionType => '', :zoneId => '', :siteId => '', :resourcePoolId => ''}
|
3940
|
+
it['params'][:provisionType] = 'azure' if it['azureServicePlanType']
|
3941
|
+
elsif it['type'] == 'Subnet'
|
3942
|
+
it['optionSource'] = 'networks'
|
3943
|
+
it['type'] = 'select'
|
3944
|
+
it['params'] = {:siteId => '', :instanceId => '', :serverId => '', :zonePoolId => '', :zoneRegionId => '', :zoneId => '', :provisionType => ''}
|
3945
|
+
if cluster['type'] == 'aks-cluster'
|
3946
|
+
it['params'][:provisionType] = 'azure'
|
3947
|
+
end
|
3948
|
+
else
|
3949
|
+
it['type'] = 'text'
|
3950
|
+
end
|
3951
|
+
it
|
3952
|
+
end
|
3953
|
+
end
|
3929
3954
|
end
|
@@ -22,7 +22,7 @@ class Morpheus::Cli::Hosts
|
|
22
22
|
def connect(opts)
|
23
23
|
@api_client = establish_remote_appliance_connection(opts)
|
24
24
|
@accounts_interface = @api_client.accounts
|
25
|
-
@
|
25
|
+
@account_users_interface = @api_client.account_users
|
26
26
|
@clouds_interface = @api_client.clouds
|
27
27
|
@options_interface = @api_client.options
|
28
28
|
@tasks_interface = @api_client.tasks
|
@@ -81,25 +81,25 @@ class Morpheus::Cli::Hosts
|
|
81
81
|
opts.on( '--plan-code CODE', String, "Filter by Plan code(s)" ) do |val|
|
82
82
|
params['planCode'] = parse_id_list(val)
|
83
83
|
end
|
84
|
-
opts.on(
|
84
|
+
opts.on('--vm', "Show only virtual machines" ) do
|
85
85
|
params[:vm] = true
|
86
86
|
end
|
87
|
-
opts.on(
|
87
|
+
opts.on('--hypervisor', "Show only VM Hypervisors" ) do
|
88
88
|
params[:vmHypervisor] = true
|
89
89
|
end
|
90
|
-
opts.on(
|
90
|
+
opts.on('--container', "Show only Container Hypervisors" ) do
|
91
91
|
params[:containerHypervisor] = true
|
92
92
|
end
|
93
|
-
opts.on(
|
93
|
+
opts.on('--baremetal', "Show only Baremetal Servers" ) do
|
94
94
|
params[:bareMetalHost] = true
|
95
95
|
end
|
96
|
-
opts.on(
|
96
|
+
opts.on('--status STATUS', String, "Filter by Status" ) do |val|
|
97
97
|
params[:status] = val
|
98
98
|
end
|
99
|
-
opts.on(
|
99
|
+
opts.on('--agent', "Show only Servers with the agent installed" ) do
|
100
100
|
params[:agentInstalled] = true
|
101
101
|
end
|
102
|
-
opts.on(
|
102
|
+
opts.on('--noagent', "Show only Servers with No agent" ) do
|
103
103
|
params[:agentInstalled] = false
|
104
104
|
end
|
105
105
|
opts.on( '--created-by USER', "Created By User Username or ID" ) do |val|
|
@@ -374,25 +374,25 @@ class Morpheus::Cli::Hosts
|
|
374
374
|
opts.on( '-i', '--ip IPADDRESS', "Filter by IP Address" ) do |val|
|
375
375
|
params[:ip] = val
|
376
376
|
end
|
377
|
-
opts.on(
|
377
|
+
opts.on('--vm', "Show only virtual machines" ) do
|
378
378
|
params[:vm] = true
|
379
379
|
end
|
380
|
-
opts.on(
|
380
|
+
opts.on('--hypervisor', "Show only VM Hypervisors" ) do
|
381
381
|
params[:vmHypervisor] = true
|
382
382
|
end
|
383
|
-
opts.on(
|
383
|
+
opts.on('--container', "Show only Container Hypervisors" ) do
|
384
384
|
params[:containerHypervisor] = true
|
385
385
|
end
|
386
|
-
opts.on(
|
386
|
+
opts.on('--baremetal', "Show only Baremetal Servers" ) do
|
387
387
|
params[:bareMetalHost] = true
|
388
388
|
end
|
389
|
-
opts.on(
|
389
|
+
opts.on('--status STATUS', "Filter by Status" ) do |val|
|
390
390
|
params[:status] = val
|
391
391
|
end
|
392
|
-
opts.on(
|
392
|
+
opts.on('--agent', "Show only Servers with the agent installed" ) do
|
393
393
|
params[:agentInstalled] = true
|
394
394
|
end
|
395
|
-
opts.on(
|
395
|
+
opts.on('--noagent', "Show only Servers with No agent" ) do
|
396
396
|
params[:agentInstalled] = false
|
397
397
|
end
|
398
398
|
opts.on( '--created-by USER', "Created By User Username or ID" ) do |val|
|
@@ -22,7 +22,8 @@ class Morpheus::Cli::Instances
|
|
22
22
|
:scaling, {:'scaling-update' => :scaling_update},
|
23
23
|
:wiki, :update_wiki,
|
24
24
|
{:exec => :execution_request},
|
25
|
-
:deploys
|
25
|
+
:deploys,
|
26
|
+
:refresh, :apply
|
26
27
|
#register_subcommands :firewall_disable, :firewall_enable
|
27
28
|
# register_subcommands {:'lb-update' => :load_balancer_update}
|
28
29
|
alias_subcommand :details, :get
|
@@ -35,7 +36,7 @@ class Morpheus::Cli::Instances
|
|
35
36
|
def connect(opts)
|
36
37
|
@api_client = establish_remote_appliance_connection(opts)
|
37
38
|
@accounts_interface = @api_client.accounts
|
38
|
-
@
|
39
|
+
@account_users_interface = @api_client.account_users
|
39
40
|
@instances_interface = @api_client.instances
|
40
41
|
@task_sets_interface = @api_client.task_sets
|
41
42
|
@logs_interface = @api_client.logs
|
@@ -77,6 +78,12 @@ class Morpheus::Cli::Instances
|
|
77
78
|
opts.on( '--created-by USER', "Alias for --owner" ) do |val|
|
78
79
|
options[:owner] = val
|
79
80
|
end
|
81
|
+
opts.on('--agent', "Show only Instances with the agent installed" ) do
|
82
|
+
params[:agentInstalled] = true
|
83
|
+
end
|
84
|
+
opts.on('--noagent', "Show only Instances with No agent" ) do
|
85
|
+
params[:agentInstalled] = false
|
86
|
+
end
|
80
87
|
opts.add_hidden_option('--created-by')
|
81
88
|
opts.on('--status STATUS', "Filter by status i.e. provisioning,running,starting,stopping") do |val|
|
82
89
|
params['status'] = (params['status'] || []) + val.to_s.split(',').collect {|s| s.strip }.select {|s| s != "" }
|
@@ -4230,6 +4237,106 @@ EOT
|
|
4230
4237
|
return 0, nil
|
4231
4238
|
end
|
4232
4239
|
|
4240
|
+
def refresh(args)
|
4241
|
+
params, payload, options = {}, {}, {}
|
4242
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
4243
|
+
opts.banner = subcommand_usage("[instance] [options]")
|
4244
|
+
build_standard_update_options(opts, options, [:auto_confirm])
|
4245
|
+
opts.footer = <<-EOT
|
4246
|
+
Refresh an instance.
|
4247
|
+
[instance] is required. This is the name or id of an instance.
|
4248
|
+
This is only supported by certain types of instances such as terraform.
|
4249
|
+
EOT
|
4250
|
+
end
|
4251
|
+
optparse.parse!(args)
|
4252
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
4253
|
+
connect(options)
|
4254
|
+
|
4255
|
+
begin
|
4256
|
+
instance = find_instance_by_name_or_id(args[0])
|
4257
|
+
return 1 if instance.nil?
|
4258
|
+
# construct request
|
4259
|
+
params.merge!(parse_query_options(options))
|
4260
|
+
payload = {}
|
4261
|
+
if options[:payload]
|
4262
|
+
payload = options[:payload]
|
4263
|
+
payload.deep_merge!(parse_passed_options(options))
|
4264
|
+
else
|
4265
|
+
payload.deep_merge!(parse_passed_options(options))
|
4266
|
+
# raise_command_error "Specify at least one option to update.\n#{optparse}" if payload.empty?
|
4267
|
+
end
|
4268
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to refresh this instance: #{instance['name']}?")
|
4269
|
+
return 9, "aborted command"
|
4270
|
+
end
|
4271
|
+
@instances_interface.setopts(options)
|
4272
|
+
if options[:dry_run]
|
4273
|
+
print_dry_run @instances_interface.dry.refresh(instance["id"], params, payload)
|
4274
|
+
return
|
4275
|
+
end
|
4276
|
+
json_response = @instances_interface.refresh(instance["id"], params, payload)
|
4277
|
+
render_response(json_response, options) do
|
4278
|
+
print_green_success "Refreshing instance #{instance['name']}"
|
4279
|
+
# return _get(instance['id'], options)
|
4280
|
+
end
|
4281
|
+
return 0, nil
|
4282
|
+
rescue RestClient::Exception => e
|
4283
|
+
print_rest_exception(e, options)
|
4284
|
+
exit 1
|
4285
|
+
end
|
4286
|
+
end
|
4287
|
+
|
4288
|
+
def apply(args)
|
4289
|
+
params, payload, options = {}, {}, {}
|
4290
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
4291
|
+
opts.banner = subcommand_usage("[instance] [options]")
|
4292
|
+
build_standard_update_options(opts, options, [:auto_confirm])
|
4293
|
+
opts.footer = <<-EOT
|
4294
|
+
Apply an instance.
|
4295
|
+
[instance] is required. This is the name or id of an instance.
|
4296
|
+
This is only supported by certain types of instances such as terraform.
|
4297
|
+
EOT
|
4298
|
+
end
|
4299
|
+
optparse.parse!(args)
|
4300
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
4301
|
+
connect(options)
|
4302
|
+
|
4303
|
+
begin
|
4304
|
+
instance = find_instance_by_name_or_id(args[0])
|
4305
|
+
return 1 if instance.nil?
|
4306
|
+
# construct request
|
4307
|
+
params.merge!(parse_query_options(options))
|
4308
|
+
payload = {}
|
4309
|
+
if options[:payload]
|
4310
|
+
payload = options[:payload]
|
4311
|
+
payload.deep_merge!(parse_passed_options(options))
|
4312
|
+
else
|
4313
|
+
payload.deep_merge!(parse_passed_options(options))
|
4314
|
+
# raise_command_error "Specify at least one option to update.\n#{optparse}" if payload.empty?
|
4315
|
+
end
|
4316
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to apply this instance: #{instance['name']}?")
|
4317
|
+
return 9, "aborted command"
|
4318
|
+
end
|
4319
|
+
@instances_interface.setopts(options)
|
4320
|
+
if options[:dry_run]
|
4321
|
+
print_dry_run @instances_interface.dry.apply(instance["id"], params, payload)
|
4322
|
+
return
|
4323
|
+
end
|
4324
|
+
json_response = @instances_interface.apply(instance["id"], params, payload)
|
4325
|
+
render_response(json_response, options) do
|
4326
|
+
print_green_success "Applying instance #{instance['name']}"
|
4327
|
+
# return _get(instance['id'], options)
|
4328
|
+
end
|
4329
|
+
return 0, nil
|
4330
|
+
rescue RestClient::Exception => e
|
4331
|
+
print_rest_exception(e, options)
|
4332
|
+
exit 1
|
4333
|
+
end
|
4334
|
+
end
|
4335
|
+
|
4336
|
+
# todo: print state summary
|
4337
|
+
def state_summary(args)
|
4338
|
+
end
|
4339
|
+
|
4233
4340
|
private
|
4234
4341
|
|
4235
4342
|
def find_zone_by_name_or_id(group_id, val)
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
2
|
+
|
3
|
+
class Morpheus::Cli::LoadBalancerMonitors
|
4
|
+
include Morpheus::Cli::CliCommand
|
5
|
+
include Morpheus::Cli::RestCommand
|
6
|
+
include Morpheus::Cli::SecondaryRestCommand
|
7
|
+
include Morpheus::Cli::LoadBalancersHelper
|
8
|
+
|
9
|
+
set_command_hidden
|
10
|
+
set_command_description "View and manage load balancer monitors."
|
11
|
+
set_command_name :'load-balancer-monitors'
|
12
|
+
register_subcommands :list, :get, :add, :update, :remove
|
13
|
+
register_interfaces :load_balancer_monitors,
|
14
|
+
:load_balancers, :load_balancer_types
|
15
|
+
|
16
|
+
set_rest_parent_name :load_balancers
|
17
|
+
|
18
|
+
# set_rest_interface_name :load_balancer_monitors
|
19
|
+
# set_parent_rest_interface_name :load_balancers
|
20
|
+
|
21
|
+
# todo: a configurable way to load the optionTypes
|
22
|
+
# option_types = loadBalancer['monitorOptionTypes']
|
23
|
+
# set_rest_has_type true
|
24
|
+
# set_rest_type :load_balancer_virtual_server_types
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def load_balancer_monitor_list_column_definitions(options)
|
29
|
+
{
|
30
|
+
"ID" => 'id',
|
31
|
+
"Name" => 'name',
|
32
|
+
"Monitor Type" => lambda {|it| it['monitorTypeDisplay'] || it['monitorType'] },
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def load_balancer_monitor_column_definitions(options)
|
37
|
+
{
|
38
|
+
"ID" => 'id',
|
39
|
+
"Name" => 'name',
|
40
|
+
"Load Balancer" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
41
|
+
"Description" => 'description',
|
42
|
+
"Monitor Type" => lambda {|it| it['monitorTypeDisplay'] || it['monitorType'] },
|
43
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
44
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def load_balancer_monitor_object_key
|
49
|
+
'loadBalancerMonitor'
|
50
|
+
end
|
51
|
+
|
52
|
+
def load_balancer_monitor_list_key
|
53
|
+
'loadBalancerMonitors'
|
54
|
+
end
|
55
|
+
|
56
|
+
def load_balancer_monitor_label
|
57
|
+
'Load Balancer Monitor'
|
58
|
+
end
|
59
|
+
|
60
|
+
def load_balancer_monitor_label_plural
|
61
|
+
'Load Balancer Monitors'
|
62
|
+
end
|
63
|
+
|
64
|
+
def load_option_types_for_load_balancer_monitor(type_record, parent_record)
|
65
|
+
load_balancer = parent_record
|
66
|
+
load_balancer_type_id = load_balancer['type']['id']
|
67
|
+
load_balancer_type = find_by_id(:load_balancer_type, load_balancer_type_id)
|
68
|
+
load_balancer_type['monitorOptionTypes']
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -3,33 +3,44 @@ require 'morpheus/cli/cli_command'
|
|
3
3
|
class Morpheus::Cli::LoadBalancerPools
|
4
4
|
include Morpheus::Cli::CliCommand
|
5
5
|
include Morpheus::Cli::RestCommand
|
6
|
+
include Morpheus::Cli::SecondaryRestCommand
|
6
7
|
include Morpheus::Cli::LoadBalancersHelper
|
7
8
|
|
8
|
-
set_command_hidden
|
9
|
+
set_command_hidden
|
10
|
+
set_command_description "View and manage load balancer pools."
|
9
11
|
set_command_name :'load-balancer-pools'
|
10
12
|
register_subcommands :list, :get, :add, :update, :remove
|
11
|
-
|
12
13
|
register_interfaces :load_balancer_pools,
|
13
|
-
:load_balancers, :
|
14
|
+
:load_balancers, :load_balancer_types
|
15
|
+
|
16
|
+
set_rest_parent_name :load_balancers
|
17
|
+
|
18
|
+
# set_rest_interface_name :load_balancer_pools
|
19
|
+
# set_parent_rest_interface_name :load_balancers
|
20
|
+
|
21
|
+
# todo: a configurable way to load the optionTypes
|
22
|
+
# option_types = loadBalancer['poolOptionTypes']
|
23
|
+
# set_rest_has_type true
|
24
|
+
# set_rest_type :load_balancer_virtual_server_types
|
14
25
|
|
15
26
|
protected
|
16
27
|
|
17
|
-
def load_balancer_pool_list_column_definitions()
|
28
|
+
def load_balancer_pool_list_column_definitions(options)
|
18
29
|
{
|
19
30
|
"ID" => 'id',
|
20
31
|
"Name" => 'name',
|
32
|
+
#"Load Balancer" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
21
33
|
"Balancer Mode" => lambda {|it| it['vipBalance'] },
|
22
|
-
"LB" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
23
34
|
}
|
24
35
|
end
|
25
36
|
|
26
|
-
def load_balancer_pool_column_definitions()
|
37
|
+
def load_balancer_pool_column_definitions(options)
|
27
38
|
{
|
28
39
|
"ID" => 'id',
|
29
40
|
"Name" => 'name',
|
41
|
+
"Load Balancer" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
30
42
|
"Description" => 'description',
|
31
43
|
"Balancer Mode" => lambda {|it| it['vipBalance'] },
|
32
|
-
"LB" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
33
44
|
# todo: more properties to show here
|
34
45
|
"Status" => lambda {|it| format_load_balancer_pool_status(it) },
|
35
46
|
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
@@ -53,49 +64,9 @@ class Morpheus::Cli::LoadBalancerPools
|
|
53
64
|
'Load Balancer Pools'
|
54
65
|
end
|
55
66
|
|
56
|
-
def
|
57
|
-
if val.to_s =~ /\A\d{1,}\Z/
|
58
|
-
return find_load_balancer_pool_by_id(val)
|
59
|
-
else
|
60
|
-
return find_load_balancer_pool_by_name(val)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def find_load_balancer_pool_by_id(id)
|
65
|
-
begin
|
66
|
-
json_response = load_balancer_pools_interface.get(id.to_i)
|
67
|
-
return json_response[load_balancer_pool_object_key]
|
68
|
-
rescue RestClient::Exception => e
|
69
|
-
if e.response && e.response.code == 404
|
70
|
-
print_red_alert "#{load_balancer_pool_label} not found by id #{id}"
|
71
|
-
return nil
|
72
|
-
else
|
73
|
-
raise e
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def find_load_balancer_pool_by_name(name)
|
79
|
-
json_response = load_balancer_pools_interface.list({name: name.to_s})
|
80
|
-
load_balancer_pools = json_response[load_balancer_pool_list_key]
|
81
|
-
if load_balancer_pools.empty?
|
82
|
-
print_red_alert "#{load_balancer_pool_label_plural} not found by name #{name}"
|
83
|
-
return load_balancer_pools
|
84
|
-
elsif load_balancer_pools.size > 1
|
85
|
-
print_red_alert "#{load_balancer_pools.size} #{load_balancer_pool_label_plural.downcase} found by name #{name}"
|
86
|
-
rows = load_balancer_pools.collect do |it|
|
87
|
-
{id: it['id'], name: it['name']}
|
88
|
-
end
|
89
|
-
puts as_pretty_table(rows, [:id, :name], {color:red})
|
90
|
-
return nil
|
91
|
-
else
|
92
|
-
return load_balancer_pools[0]
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def format_load_balancer_pool_status(pool, return_color=cyan)
|
67
|
+
def format_load_balancer_pool_status(record, return_color=cyan)
|
97
68
|
out = ""
|
98
|
-
status_string =
|
69
|
+
status_string = record['status']
|
99
70
|
if status_string.nil? || status_string.empty? || status_string == "unknown"
|
100
71
|
out << "#{white}UNKNOWN#{return_color}"
|
101
72
|
elsif status_string == 'ok'
|
@@ -103,9 +74,18 @@ class Morpheus::Cli::LoadBalancerPools
|
|
103
74
|
elsif status_string == 'syncing'
|
104
75
|
out << "#{yellow}#{status_string.upcase}#{return_color}"
|
105
76
|
else
|
106
|
-
out << "#{red}#{status_string ? status_string.upcase : 'N/A'}#{
|
77
|
+
out << "#{red}#{status_string ? status_string.upcase : 'N/A'}#{record['statusMessage'] ? "#{return_color} - #{record['statusMessage']}" : ''}#{return_color}"
|
107
78
|
end
|
108
79
|
out
|
109
80
|
end
|
110
81
|
|
82
|
+
def load_option_types_for_load_balancer_pool(type_record, parent_record)
|
83
|
+
load_balancer = parent_record
|
84
|
+
load_balancer_type_id = load_balancer['type']['id']
|
85
|
+
load_balancer_type = find_by_id(:load_balancer_type, load_balancer_type_id)
|
86
|
+
load_balancer_type['poolOptionTypes']
|
87
|
+
end
|
88
|
+
|
89
|
+
## using CliCommand's generic find_by methods
|
90
|
+
|
111
91
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
2
|
+
|
3
|
+
class Morpheus::Cli::LoadBalancerProfiles
|
4
|
+
include Morpheus::Cli::CliCommand
|
5
|
+
include Morpheus::Cli::RestCommand
|
6
|
+
include Morpheus::Cli::SecondaryRestCommand
|
7
|
+
include Morpheus::Cli::LoadBalancersHelper
|
8
|
+
|
9
|
+
set_command_hidden
|
10
|
+
set_command_description "View and manage load balancer profiles."
|
11
|
+
set_command_name :'load-balancer-profiles'
|
12
|
+
register_subcommands :list, :get, :add, :update, :remove
|
13
|
+
register_interfaces :load_balancer_profiles,
|
14
|
+
:load_balancers, :load_balancer_types
|
15
|
+
|
16
|
+
set_rest_parent_name :load_balancers
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def load_balancer_profile_list_column_definitions(options)
|
21
|
+
{
|
22
|
+
"ID" => 'id',
|
23
|
+
"Name" => 'name',
|
24
|
+
# "Profile Type" => lambda {|it| it['config']['profileType'] rescue '' },
|
25
|
+
"Service Type" => lambda {|it| it['serviceTypeDisplay'] || it['serviceType'] },
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def load_balancer_profile_column_definitions(options)
|
30
|
+
{
|
31
|
+
"ID" => 'id',
|
32
|
+
"Name" => 'name',
|
33
|
+
"Load Balancer" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
34
|
+
"Description" => 'description',
|
35
|
+
# "Profile Type" => lambda {|it| it['config']['profileType'] rescue '' },
|
36
|
+
"Service Type" => lambda {|it| it['serviceTypeDisplay'] || it['serviceType'] },
|
37
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
38
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def load_balancer_profile_object_key
|
43
|
+
'loadBalancerProfile'
|
44
|
+
end
|
45
|
+
|
46
|
+
def load_balancer_profile_list_key
|
47
|
+
'loadBalancerProfiles'
|
48
|
+
end
|
49
|
+
|
50
|
+
def load_balancer_profile_label
|
51
|
+
'Load Balancer Profile'
|
52
|
+
end
|
53
|
+
|
54
|
+
def load_balancer_profile_label_plural
|
55
|
+
'Load Balancer Profiles'
|
56
|
+
end
|
57
|
+
|
58
|
+
def load_option_types_for_load_balancer_profile(type_record, parent_record)
|
59
|
+
load_balancer = parent_record
|
60
|
+
load_balancer_type_id = load_balancer['type']['id']
|
61
|
+
load_balancer_type = find_by_id(:load_balancer_type, load_balancer_type_id)
|
62
|
+
load_balancer_type['profileOptionTypes']
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -12,16 +12,21 @@ class Morpheus::Cli::LoadBalancerTypes
|
|
12
12
|
|
13
13
|
protected
|
14
14
|
|
15
|
-
def
|
15
|
+
def load_balancer_type_list_column_definitions(options)
|
16
16
|
{
|
17
17
|
"ID" => 'id',
|
18
18
|
"Name" => 'name',
|
19
|
-
"Code" => 'code'
|
19
|
+
"Code" => 'code',
|
20
20
|
}
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def load_balancer_type_column_definitions(options)
|
24
|
+
{
|
25
|
+
"ID" => 'id',
|
26
|
+
"Name" => 'name',
|
27
|
+
"Code" => 'code',
|
28
|
+
"Creatable" => lambda {|it| format_boolean(it['creatable']) },
|
29
|
+
}
|
25
30
|
end
|
26
31
|
|
27
32
|
# overridden to support name or code
|