Class: Morpheus::Cli::LoadBalancers

Inherits:
Object
  • Object
show all
Includes:
CliCommand, LoadBalancersHelper, ProvisioningHelper, RestCommand
Defined in:
lib/morpheus/cli/commands/load_balancers.rb

Instance Attribute Summary

Attributes included from CliCommand

#no_prompt

Instance Method Summary collapse

Methods included from ProvisioningHelper

#accounts_interface, #add_perms_options, #api_client, #apps_interface, #cloud_datastores_interface, #clouds_interface, #datastores_interface, #find_app_by_id, #find_app_by_name, #find_app_by_name_or_id, #find_cloud_by_id_for_provisioning, #find_cloud_by_name_for_provisioning, #find_cloud_by_name_or_id_for_provisioning, #find_cloud_resource_pool_by_name_or_id, #find_group_by_id_for_provisioning, #find_group_by_name_for_provisioning, #find_group_by_name_or_id_for_provisioning, #find_host_by_id, #find_host_by_name, #find_host_by_name_or_id, #find_instance_by_id, #find_instance_by_name, #find_instance_by_name_or_id, #find_instance_type_by_code, #find_instance_type_by_id, #find_instance_type_by_name, #find_instance_type_by_name_or_id, #find_instance_type_layout_by_id, #find_server_by_id, #find_server_by_name, #find_server_by_name_or_id, #find_workflow_by_id, #find_workflow_by_name, #find_workflow_by_name_or_id, #format_app_status, #format_blueprint_type, #format_container_connection_string, #format_container_status, #format_instance_connection_string, #format_instance_container_display_name, #format_instance_status, #format_metadata, #format_snapshot_status, #get_available_accounts, #get_available_clouds, #get_available_environments, #get_available_groups, #get_available_plans, #get_provision_type_for_zone_type, #get_static_environments, included, #instance_type_layouts_interface, #instance_types_interface, #instances_interface, #load_balance_protocols_dropdown, #options_interface, #parse_blueprint_type, #parse_host_id_list, #parse_instance_id_list, #parse_metadata, #parse_resource_id_list, #parse_server_id_list, #print_permissions, #prompt_evars, #prompt_exposed_ports, #prompt_instance_load_balancer, #prompt_metadata, #prompt_network_interfaces, #prompt_new_instance, #prompt_permissions, #prompt_permissions_v2, #prompt_resize_volumes, #prompt_security_groups, #prompt_service_plan_options, #prompt_volumes, #provision_types_interface, #reject_service_plan_option_types, #servers_interface

Methods included from LoadBalancersHelper

#find_load_balancer_by_id, #find_load_balancer_by_name, #find_load_balancer_by_name_or_id, #find_load_balancer_type_by_id, #find_load_balancer_type_by_name, #find_load_balancer_type_by_name_or_id, #get_available_load_balancer_types, included, #load_balancer_label, #load_balancer_label_plural, #load_balancer_list_key, #load_balancer_object_key, #load_balancer_type_for_id, #load_balancer_type_for_name, #load_balancer_type_for_name_or_id, #load_balancer_type_label, #load_balancer_type_label_plural, #load_balancer_type_list_key, #load_balancer_type_object_key, #load_balancer_types_interface, #load_balancers_interface

Methods included from RestCommand

#_get, #_get_type, #add, #connect, #get, #get_type, #handle, included, #list, #list_types, #registered_interfaces, #remove, #render_response_for_get_type, #rest_arg, #rest_column_definitions, #rest_find_by_name_or_id, #rest_has_name, #rest_has_type, #rest_interface, #rest_interface_name, #rest_key, #rest_label, #rest_label_plural, #rest_list_column_definitions, #rest_list_key, #rest_name, #rest_object_key, #rest_option_context_map, #rest_perms_config, #rest_type_arg, #rest_type_column_definitions, #rest_type_find_by_name_or_id, #rest_type_interface, #rest_type_interface_name, #rest_type_key, #rest_type_label, #rest_type_label_plural, #rest_type_list_column_definitions, #rest_type_list_key, #rest_type_name, #rest_type_object_key, #update

Methods included from CliCommand

#add_query_parameter, #apply_options, #build_common_options, #build_get_options, #build_list_options, #build_option_type_options, #build_standard_add_many_options, #build_standard_add_options, #build_standard_api_options, #build_standard_delete_options, #build_standard_get_options, #build_standard_list_options, #build_standard_post_options, #build_standard_put_options, #build_standard_remove_options, #build_standard_update_options, #command_description, #command_name, #confirm, #confirm!, #default_refresh_interval, #default_sigdig, #default_subcommand, #establish_remote_appliance_connection, #execute_api, #execute_api_payload, #execute_api_request, #find_all, #find_all_json, #find_by_id, #find_by_name, #find_by_name_or_id, #find_record, #find_record_json, #full_command_usage, #get_interface, #get_list_key, #get_object_key, #get_subcommand_description, #handle, #handle_each_payload, #handle_subcommand, included, #interactive?, #my_help_command, #my_terminal, #my_terminal=, #parse_array, #parse_bytes_param, #parse_get_options!, #parse_id_list, #parse_labels, #parse_list_options, #parse_list_options!, #parse_list_subtitles, #parse_options, #parse_parameter_as_resource_id!, #parse_passed_options, #parse_payload, #parse_query_options, #print, #print_error, #println, #prog_name, #puts, #puts_error, #raise_args_error, #raise_command_error, #render_response, #run_command_for_each_arg, #subcommand_aliases, #subcommand_description, #subcommand_usage, #subcommands, #usage, #validate_outfile, #verify_args!, #visible_subcommands

Instance Method Details

#refresh(args) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/morpheus/cli/commands/load_balancers.rb', line 51

def refresh(args)
  id = args[0]
  record_type = nil
  record_type_id = nil
  options = {}
  optparse = Morpheus::Cli::OptionParser.new do |opts|
    opts.banner = subcommand_usage("[#{rest_arg}] [options]")
    build_standard_update_options(opts, options)
    opts.footer = <<-EOT
Refresh an existing #{rest_label.downcase}.
[#{rest_arg}] is required. This is the #{rest_has_name ? 'name or id' : 'id'} of #{a_or_an(rest_label)} #{rest_label.downcase}.
EOT
  end
  optparse.parse!(args)
  verify_args!(args:args, optparse:optparse, count:1)
  connect(options)
  record = rest_find_by_name_or_id(id)
  if record.nil?
    return 1, "#{rest_name} not found for '#{id}'"
  end
  passed_options = parse_passed_options(options)
  payload = {}
  if options[:payload]
    payload = options[:payload]
    payload.deep_merge!({rest_object_key => passed_options}) unless passed_options.empty?
  else
    record_payload = passed_options
    payload[rest_object_key] = record_payload
  end
  rest_interface.setopts(options)
  if options[:dry_run]
    print_dry_run rest_interface.dry.refresh(record['id'], payload)
    return
  end
  json_response = rest_interface.refresh(record['id'], payload)
  render_response(json_response, options, rest_object_key) do
    print_green_success "Refreshing #{rest_label.downcase} #{record['name'] || record['id']}"
    _get(record["id"], {}, options)
  end
  return 0, nil
end

#render_response_for_get(json_response, options) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/morpheus/cli/commands/load_balancers.rb', line 23

def render_response_for_get(json_response, options)
  render_response(json_response, options, rest_object_key) do
    record = json_response[rest_object_key]
    options[:exclude_username] = record['username'].nil?
    options[:exclude_owner] = record['owner'].nil?
    options[:exclude_tenants] = record['tenants'].nil? || record['tenants'].empty?
    options[:exclude_permissions] = record['resourcePermission'].nil?
    print_h1 rest_label, [], options
    print cyan
    print_description_list(rest_column_definitions(options), record, options)
    # show LB Ports
    ports = record['ports']
    if ports && ports.size > 0
      print_h2 "LB Ports", options
      columns = [
        {"ID" => 'id'},
        {"Name" => 'name'},
        #{"Description" => 'description'},
        {"Port" => lambda {|it| it['port'] } },
        {"Protocol" => lambda {|it| it['proxyProtocol'] } },
        {"SSL" => lambda {|it| it['sslEnabled'] ? "Yes (#{it['sslCert'] ? it['sslCert']['name'] : 'none'})" : "No" } },
      ]
      print as_pretty_table(ports, columns, options)
    end
    print reset,"\n"
  end
end

#types(args) ⇒ Object

deprecated, to be removed in the future.



94
95
96
97
# File 'lib/morpheus/cli/commands/load_balancers.rb', line 94

def types(args)
  print_error yellow,"[DEPRECATED] The command `load-balancers types` is deprecated and replaced by `load-balancer-types list`.",reset,"\n"
  my_terminal.execute("load-balancer-types list #{args.join(' ')}")
end