Class: Morpheus::Cli::NetworkFloatingIps
- Inherits:
-
Object
- Object
- Morpheus::Cli::NetworkFloatingIps
- Includes:
- CliCommand, RestCommand
- Defined in:
- lib/morpheus/cli/commands/network_floating_ips.rb
Instance Attribute Summary
Attributes included from CliCommand
Instance Method Summary collapse
Methods included from RestCommand
#_get, #_get_type, #add, #connect, #get, #get_type, #handle, included, #list, #list_types, #registered_interfaces, #remove, #render_response_for_get, #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_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_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
#allocate(args) ⇒ Object
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 |
# File 'lib/morpheus/cli/commands/network_floating_ips.rb', line 52 def allocate(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage() (opts, ) opts. = <<-EOT Allocate a new #{rest_label.downcase}. Only the following cloud types support this command: OpenStack, Huawei and OpenTelekom EOT end optparse.parse!(args) verify_args!(args:args, optparse:optparse, count:0) connect() payload = {} if [:payload] payload = [:payload] payload.deep_merge!(()) else payload.deep_merge!(()) v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'networkServerId', 'fieldLabel' => 'Network Service', 'type' => 'select', 'optionSource' => 'floatingIpNetworkServers', 'required' => true, 'description' => 'Choose a network service.'}], [:options], @api_client, {}) payload[:networkServerId] = v_prompt['networkServerId'] v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'floatingIpPoolId', 'fieldLabel' => 'Network Floating Ip Pool', 'type' => 'select', 'optionSource' => 'floatingIpPools', 'required' => true, 'description' => 'Choose a network service.'}], [:options], @api_client, {networkServerId: v_prompt['networkServerId']}) payload[:floatingIpPoolId] = v_prompt['floatingIpPoolId'] end rest_interface.setopts() if [:dry_run] print_dry_run rest_interface.dry.allocate(payload) return 0, nil end json_response = rest_interface.allocate(payload) render_response(json_response, ) do print_green_success "Allocating #{rest_label.downcase} with ipAddress: #{json_response['networkFloatingIp']['ipAddress'] }" id = json_response['networkFloatingIp']['id'] _get(id.to_s, {}, ) end end |
#release(args) ⇒ Object
16 17 18 19 20 21 22 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 50 |
# File 'lib/morpheus/cli/commands/network_floating_ips.rb', line 16 def release(args) params = {} = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[#{rest_arg}]") (opts, ) opts. = <<-EOT Release 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}. Only the following cloud types support this command: OpenStack, Huawei and OpenTelekom EOT end optparse.parse!(args) verify_args!(args:args, optparse:optparse, count:1) connect() params.merge!(()) id = args[0] record = rest_find_by_name_or_id(id) if record.nil? return 1, "#{rest_name} not found for '#{id}'" end unless [:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to release the #{rest_label.downcase} #{record['name'] || record['id']}?") return 9, "aborted" end rest_interface.setopts() if [:dry_run] print_dry_run rest_interface.dry.release(record['id'], params) return 0, nil end json_response = rest_interface.release(record['id'], params) render_response(json_response, ) do print_green_success "Releasing #{rest_label.downcase} #{record['ipAddress'] || record['id']}" end return 0, nil end |