morpheus-cli 5.3.3 → 5.4.2
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/account_users_interface.rb +68 -0
- data/lib/morpheus/api/api_client.rb +75 -8
- data/lib/morpheus/api/audit_interface.rb +9 -0
- data/lib/morpheus/api/clouds_interface.rb +4 -11
- data/lib/morpheus/api/health_interface.rb +37 -3
- 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_profiles_interface.rb +9 -0
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +9 -0
- data/lib/morpheus/api/load_balancers_interface.rb +5 -0
- data/lib/morpheus/api/network_dhcp_relays_interface.rb +36 -0
- data/lib/morpheus/api/network_dhcp_servers_interface.rb +36 -0
- data/lib/morpheus/api/network_edge_clusters_interface.rb +26 -0
- data/lib/morpheus/api/network_routers_interface.rb +30 -0
- data/lib/morpheus/api/network_servers_interface.rb +98 -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 +5 -4
- data/lib/morpheus/api/roles_interface.rb +7 -0
- 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/api/virtual_servers_interface.rb +9 -0
- data/lib/morpheus/cli/cli_command.rb +262 -14
- data/lib/morpheus/cli/cli_registry.rb +2 -1
- data/lib/morpheus/cli/{access_token_command.rb → commands/access_token_command.rb} +1 -1
- data/lib/morpheus/cli/{account_groups_command.rb → commands/account_groups_command.rb} +0 -8
- data/lib/morpheus/cli/{activity_command.rb → commands/activity_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/alias_command.rb → alias_command.rb} +1 -4
- data/lib/morpheus/cli/{appliance_settings_command.rb → commands/appliance_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{approvals_command.rb → commands/approvals_command.rb} +0 -0
- data/lib/morpheus/cli/{apps.rb → commands/apps.rb} +14 -87
- data/lib/morpheus/cli/{archives_command.rb → commands/archives_command.rb} +0 -6
- data/lib/morpheus/cli/commands/audit.rb +188 -0
- data/lib/morpheus/cli/{backup_jobs_command.rb → commands/backup_jobs_command.rb} +0 -0
- data/lib/morpheus/cli/{backup_settings_command.rb → commands/backup_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{backups_command.rb → commands/backups_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/benchmark_command.rb → benchmark_command.rb} +0 -3
- data/lib/morpheus/cli/{blueprints_command.rb → commands/blueprints_command.rb} +1 -1
- data/lib/morpheus/cli/{boot_scripts_command.rb → commands/boot_scripts_command.rb} +0 -3
- data/lib/morpheus/cli/{budgets_command.rb → commands/budgets_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/cat_command.rb → cat_command.rb} +0 -0
- data/lib/morpheus/cli/{catalog_item_types_command.rb → commands/catalog_item_types_command.rb} +0 -0
- data/lib/morpheus/cli/{certificates_command.rb → commands/certificates_command.rb} +0 -0
- data/lib/morpheus/cli/commands/change_password_command.rb +132 -0
- data/lib/morpheus/cli/{cloud_datastores_command.rb → commands/cloud_datastores_command.rb} +0 -4
- data/lib/morpheus/cli/{cloud_folders_command.rb → commands/cloud_folders_command.rb} +0 -4
- data/lib/morpheus/cli/{cloud_resource_pools_command.rb → commands/cloud_resource_pools_command.rb} +1 -5
- data/lib/morpheus/cli/{clouds.rb → commands/clouds.rb} +22 -47
- data/lib/morpheus/cli/{clusters.rb → commands/clusters.rb} +38 -19
- data/lib/morpheus/cli/commands/{standard/coloring_command.rb → coloring_command.rb} +0 -2
- data/lib/morpheus/cli/{containers_command.rb → commands/containers_command.rb} +0 -7
- data/lib/morpheus/cli/commands/{standard/curl_command.rb → curl_command.rb} +0 -3
- data/lib/morpheus/cli/{cypher_command.rb → commands/cypher_command.rb} +0 -1
- data/lib/morpheus/cli/{dashboard_command.rb → commands/dashboard_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/debug_command.rb → debug_command.rb} +0 -1
- data/lib/morpheus/cli/{deploy.rb → commands/deploy.rb} +0 -1
- data/lib/morpheus/cli/{deployments.rb → commands/deployments.rb} +0 -0
- data/lib/morpheus/cli/{deploys.rb → commands/deploys.rb} +0 -1
- data/lib/morpheus/cli/{doc.rb → commands/doc.rb} +1 -1
- data/lib/morpheus/cli/commands/{standard/echo_command.rb → echo_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/edit_profile_command.rb → edit_profile_command.rb} +15 -4
- data/lib/morpheus/cli/commands/{standard/edit_rc_command.rb → edit_rc_command.rb} +19 -3
- data/lib/morpheus/cli/{environments_command.rb → commands/environments_command.rb} +0 -5
- data/lib/morpheus/cli/{execute_schedules_command.rb → commands/execute_schedules_command.rb} +0 -0
- data/lib/morpheus/cli/{execution_request_command.rb → commands/execution_request_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/exit_command.rb → exit_command.rb} +0 -2
- data/lib/morpheus/cli/{file_copy_request_command.rb → commands/file_copy_request_command.rb} +0 -4
- data/lib/morpheus/cli/{forgot_password.rb → commands/forgot_password.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/get_prompt_command.rb → get_prompt_command.rb} +0 -3
- data/lib/morpheus/cli/{groups.rb → commands/groups.rb} +0 -7
- data/lib/morpheus/cli/{guidance_command.rb → commands/guidance_command.rb} +1 -1
- data/lib/morpheus/cli/{health_command.rb → commands/health_command.rb} +104 -19
- data/lib/morpheus/cli/commands/{standard/history_command.rb → history_command.rb} +0 -3
- data/lib/morpheus/cli/{hosts.rb → commands/hosts.rb} +15 -25
- data/lib/morpheus/cli/{image_builder_command.rb → commands/image_builder_command.rb} +6 -16
- data/lib/morpheus/cli/{instance_types.rb → commands/instance_types.rb} +0 -3
- data/lib/morpheus/cli/{instances.rb → commands/instances.rb} +220 -13
- data/lib/morpheus/cli/{integrations_command.rb → commands/integrations_command.rb} +1 -12
- data/lib/morpheus/cli/{invoices_command.rb → commands/invoices_command.rb} +43 -39
- data/lib/morpheus/cli/{jobs_command.rb → commands/jobs_command.rb} +0 -0
- data/lib/morpheus/cli/{key_pairs.rb → commands/key_pairs.rb} +0 -6
- data/lib/morpheus/cli/{library_cluster_layouts_command.rb → commands/library_cluster_layouts_command.rb} +0 -4
- data/lib/morpheus/cli/{library_container_scripts_command.rb → commands/library_container_scripts_command.rb} +0 -0
- data/lib/morpheus/cli/{library_container_templates_command.rb → commands/library_container_templates_command.rb} +0 -1
- data/lib/morpheus/cli/{library_container_types_command.rb → commands/library_container_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_instance_types_command.rb → commands/library_instance_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_layouts_command.rb → commands/library_layouts_command.rb} +0 -4
- data/lib/morpheus/cli/{library_option_lists_command.rb → commands/library_option_lists_command.rb} +3 -7
- data/lib/morpheus/cli/{library_option_types_command.rb → commands/library_option_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_spec_templates_command.rb → commands/library_spec_templates_command.rb} +0 -1
- data/lib/morpheus/cli/{library_upgrades_command.rb → commands/library_upgrades_command.rb} +0 -4
- data/lib/morpheus/cli/{license.rb → commands/license.rb} +0 -3
- data/lib/morpheus/cli/commands/load_balancer_monitors.rb +70 -0
- data/lib/morpheus/cli/commands/load_balancer_pools.rb +90 -0
- data/lib/morpheus/cli/commands/load_balancer_profiles.rb +64 -0
- data/lib/morpheus/cli/{load_balancer_types.rb → commands/load_balancer_types.rb} +9 -8
- data/lib/morpheus/cli/commands/load_balancer_virtual_servers.rb +147 -0
- data/lib/morpheus/cli/commands/load_balancers.rb +192 -0
- data/lib/morpheus/cli/commands/{standard/log_level_command.rb → log_level_command.rb} +0 -3
- data/lib/morpheus/cli/{log_settings_command.rb → commands/log_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{login.rb → commands/login.rb} +0 -5
- data/lib/morpheus/cli/commands/logout.rb +63 -0
- data/lib/morpheus/cli/{logs_command.rb → commands/logs_command.rb} +0 -3
- data/lib/morpheus/cli/commands/{standard/man_command.rb → man_command.rb} +0 -2
- data/lib/morpheus/cli/{monitoring_alerts_command.rb → commands/monitoring_alerts_command.rb} +0 -7
- data/lib/morpheus/cli/{monitoring_apps_command.rb → commands/monitoring_apps_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_checks_command.rb → commands/monitoring_checks_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_contacts_command.rb → commands/monitoring_contacts_command.rb} +0 -7
- data/lib/morpheus/cli/{monitoring_groups_command.rb → commands/monitoring_groups_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_incidents_command.rb → commands/monitoring_incidents_command.rb} +0 -1
- data/lib/morpheus/cli/commands/network_dhcp_relays_command.rb +416 -0
- data/lib/morpheus/cli/commands/network_dhcp_servers_command.rb +407 -0
- data/lib/morpheus/cli/{network_domains_command.rb → commands/network_domains_command.rb} +0 -4
- data/lib/morpheus/cli/commands/network_edge_clusters_command.rb +329 -0
- data/lib/morpheus/cli/commands/network_firewalls_command.rb +823 -0
- data/lib/morpheus/cli/{network_groups_command.rb → commands/network_groups_command.rb} +0 -4
- data/lib/morpheus/cli/{network_pool_servers_command.rb → commands/network_pool_servers_command.rb} +0 -4
- data/lib/morpheus/cli/{network_pools_command.rb → commands/network_pools_command.rb} +0 -4
- data/lib/morpheus/cli/{network_proxies_command.rb → commands/network_proxies_command.rb} +0 -4
- data/lib/morpheus/cli/{network_routers_command.rb → commands/network_routers_command.rb} +387 -57
- data/lib/morpheus/cli/{network_services_command.rb → commands/network_services_command.rb} +0 -4
- data/lib/morpheus/cli/commands/network_static_routes_command.rb +446 -0
- data/lib/morpheus/cli/commands/network_transport_zones_command.rb +452 -0
- data/lib/morpheus/cli/{networks_command.rb → commands/networks_command.rb} +20 -20
- data/lib/morpheus/cli/commands/open_command.rb +30 -0
- data/lib/morpheus/cli/commands/options.rb +98 -0
- data/lib/morpheus/cli/{packages_command.rb → commands/packages_command.rb} +0 -2
- data/lib/morpheus/cli/{ping.rb → commands/ping.rb} +0 -7
- data/lib/morpheus/cli/{policies_command.rb → commands/policies_command.rb} +1 -8
- data/lib/morpheus/cli/{power_schedules_command.rb → commands/power_schedules_command.rb} +0 -0
- data/lib/morpheus/cli/{preseed_scripts_command.rb → commands/preseed_scripts_command.rb} +0 -3
- data/lib/morpheus/cli/{price_sets_command.rb → commands/price_sets_command.rb} +0 -0
- data/lib/morpheus/cli/{prices_command.rb → commands/prices_command.rb} +7 -7
- data/lib/morpheus/cli/{processes_command.rb → commands/processes_command.rb} +0 -1
- data/lib/morpheus/cli/{projects_command.rb → commands/projects_command.rb} +0 -0
- data/lib/morpheus/cli/{provisioning_licenses_command.rb → commands/provisioning_licenses_command.rb} +0 -0
- data/lib/morpheus/cli/{provisioning_settings_command.rb → commands/provisioning_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{recent_activity_command.rb → commands/recent_activity_command.rb} +0 -0
- data/lib/morpheus/cli/{remote.rb → commands/remote.rb} +5 -9
- data/lib/morpheus/cli/{reports_command.rb → commands/reports_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/rm_command.rb → rm_command.rb} +0 -0
- data/lib/morpheus/cli/{roles.rb → commands/roles.rb} +245 -40
- data/lib/morpheus/cli/{search_command.rb → commands/search_command.rb} +0 -0
- data/lib/morpheus/cli/{security_group_rules.rb → commands/security_group_rules.rb} +0 -5
- data/lib/morpheus/cli/{security_groups.rb → commands/security_groups.rb} +0 -6
- data/lib/morpheus/cli/{service_catalog_command.rb → commands/service_catalog_command.rb} +0 -0
- data/lib/morpheus/cli/{service_plans_command.rb → commands/service_plans_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/set_prompt_command.rb → set_prompt_command.rb} +0 -3
- data/lib/morpheus/cli/{setup.rb → commands/setup.rb} +0 -0
- data/lib/morpheus/cli/{shell.rb → commands/shell.rb} +4 -105
- data/lib/morpheus/cli/commands/{standard/sleep_command.rb → sleep_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/source_command.rb → source_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/ssl_verification_command.rb → ssl_verification_command.rb} +0 -3
- data/lib/morpheus/cli/{storage_providers_command.rb → commands/storage_providers_command.rb} +0 -4
- 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/{subnets_command.rb → commands/subnets_command.rb} +7 -6
- data/lib/morpheus/cli/{tasks.rb → commands/tasks.rb} +25 -6
- data/lib/morpheus/cli/commands/{standard/tee_command.rb → tee_command.rb} +0 -0
- data/lib/morpheus/cli/{tenants_command.rb → commands/tenants_command.rb} +1 -8
- data/lib/morpheus/cli/commands/{standard/update_command.rb → update_command.rb} +0 -1
- data/lib/morpheus/cli/{usage_command.rb → commands/usage_command.rb} +0 -0
- data/lib/morpheus/cli/{user_groups_command.rb → commands/user_groups_command.rb} +1 -2
- data/lib/morpheus/cli/{user_settings_command.rb → commands/user_settings_command.rb} +2 -1
- data/lib/morpheus/cli/{user_sources_command.rb → commands/user_sources_command.rb} +1 -2
- data/lib/morpheus/cli/{users.rb → commands/users.rb} +28 -35
- data/lib/morpheus/cli/{vdi_allocations_command.rb → commands/vdi_allocations_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_apps_command.rb → commands/vdi_apps_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_command.rb → commands/vdi_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_gateways_command.rb → commands/vdi_gateways_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_pools_command.rb → commands/vdi_pools_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/version_command.rb → version_command.rb} +0 -0
- data/lib/morpheus/cli/commands/view.rb +102 -0
- data/lib/morpheus/cli/{virtual_images.rb → commands/virtual_images.rb} +2 -4
- data/lib/morpheus/cli/{whitelabel_settings_command.rb → commands/whitelabel_settings_command.rb} +0 -1
- data/lib/morpheus/cli/{whoami.rb → commands/whoami.rb} +0 -4
- data/lib/morpheus/cli/{wiki_command.rb → commands/wiki_command.rb} +0 -5
- data/lib/morpheus/cli/{workflows.rb → commands/workflows.rb} +0 -3
- data/lib/morpheus/cli/mixins/accounts_helper.rb +5 -5
- data/lib/morpheus/cli/mixins/load_balancers_helper.rb +26 -6
- data/lib/morpheus/cli/mixins/logs_helper.rb +1 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +51 -18
- data/lib/morpheus/cli/mixins/processes_helper.rb +1 -2
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +48 -17
- data/lib/morpheus/cli/mixins/rest_command.rb +270 -94
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +667 -0
- 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 +149 -40
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +6 -128
- data/lib/morpheus/ext/string.rb +29 -6
- data/lib/morpheus/routes.rb +238 -0
- data/lib/morpheus/terminal.rb +5 -6
- data/lib/morpheus/util.rb +6 -1
- metadata +176 -141
- data/lib/morpheus/cli/change_password_command.rb +0 -147
- data/lib/morpheus/cli/library.rb +0 -1
- data/lib/morpheus/cli/load_balancers.rb +0 -245
- data/lib/morpheus/cli/logout.rb +0 -81
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
require 'rest_client'
|
|
2
|
-
require 'optparse'
|
|
3
|
-
require 'filesize'
|
|
4
1
|
require 'morpheus/cli/cli_command'
|
|
5
|
-
require 'morpheus/cli/mixins/infrastructure_helper'
|
|
6
2
|
|
|
7
3
|
class Morpheus::Cli::NetworkRoutersCommand
|
|
8
4
|
include Morpheus::Cli::CliCommand
|
|
@@ -17,6 +13,7 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
17
13
|
register_subcommands :add_route, :remove_route, :routes
|
|
18
14
|
register_subcommands :update_permissions
|
|
19
15
|
register_subcommands :add_nat, :update_nat, :remove_nat, :nats, :nat
|
|
16
|
+
register_subcommands :add_bgp_neighbor, :update_bgp_neighbor, :remove_bgp_neighbor, :bgp_neighbors, :bgp_neighbor
|
|
20
17
|
|
|
21
18
|
def initialize()
|
|
22
19
|
end
|
|
@@ -313,7 +310,7 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
313
310
|
server_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'networkServer', 'type' => 'select', 'fieldLabel' => 'Network Server', 'required' => true, 'optionSource' => 'networkServer'}], options[:options], @api_client, params, nil, true)['networkServer']
|
|
314
311
|
server = {'id' => server_id}
|
|
315
312
|
end
|
|
316
|
-
router['networkServer'] = {'id' => server['id']}
|
|
313
|
+
params['router']['networkServer'] = router['networkServer'] = {'id' => server['id']}
|
|
317
314
|
params['networkServerId'] = server['id']
|
|
318
315
|
else
|
|
319
316
|
# prompt cloud
|
|
@@ -637,59 +634,51 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
637
634
|
end
|
|
638
635
|
|
|
639
636
|
def _firewall_rule_group(router_id, group_id, options)
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
if
|
|
643
|
-
|
|
644
|
-
|
|
637
|
+
@network_routers_interface.setopts(options)
|
|
638
|
+
if options[:dry_run]
|
|
639
|
+
if router_id.to_s =~ /\A\d{1,}\Z/
|
|
640
|
+
print_dry_run @network_routers_interface.dry.list({name:router_id})
|
|
641
|
+
else
|
|
642
|
+
if group_id.to_s =~ /\A\d{1,}\Z/
|
|
643
|
+
print_dry_run @network_routers_interface.dry.get_firewall_rule_group(router_id.to_i, group_id)
|
|
645
644
|
else
|
|
646
|
-
print_dry_run @network_routers_interface.dry.
|
|
645
|
+
print_dry_run @network_routers_interface.dry.list_firewall_rule_groups(router_id.to_i, {phrase:router_id})
|
|
647
646
|
end
|
|
648
|
-
return
|
|
649
647
|
end
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
group = (router['firewall']['ruleGroups'] || []).find {|it| it['id'].to_s == group_id.to_s || it['name'] == group_id.to_s}
|
|
648
|
+
return
|
|
649
|
+
end
|
|
650
|
+
router = find_router(router_id)
|
|
651
|
+
if router.nil?
|
|
652
|
+
return 1
|
|
653
|
+
end
|
|
657
654
|
|
|
658
|
-
|
|
659
|
-
|
|
655
|
+
if router['type']['hasFirewallGroups']
|
|
656
|
+
group = find_firewall_rule_group(router['id'], group_id)
|
|
657
|
+
return 1 if group.nil?
|
|
660
658
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
659
|
+
render_response({ruleGroup: group}, options, 'ruleGroup') do
|
|
660
|
+
print_h1 "Firewall Rule Group Details"
|
|
661
|
+
print cyan
|
|
662
|
+
description_cols = {
|
|
663
|
+
"ID" => lambda {|it| it['id'] },
|
|
664
|
+
"Name" => lambda {|it| it['name'] },
|
|
665
|
+
"Description" => lambda {|it| it['description']},
|
|
666
|
+
"Priority" => lambda {|it| it['priority']},
|
|
667
|
+
"Category" => lambda {|it| it['groupLayer']}
|
|
668
|
+
}
|
|
669
|
+
print_description_list(description_cols, group)
|
|
671
670
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
description_cols = {
|
|
675
|
-
"ID" => lambda {|it| it['id'] },
|
|
676
|
-
"Name" => lambda {|it| it['name'] },
|
|
677
|
-
"Description" => lambda {|it| it['description']},
|
|
678
|
-
"Priority" => lambda {|it| it['priority']},
|
|
679
|
-
"Category" => lambda {|it| it['groupLayer']}
|
|
680
|
-
}
|
|
681
|
-
print_description_list(description_cols, group)
|
|
682
|
-
else
|
|
683
|
-
print_red_alert "Firewall rule group #{group_id} not found for router #{router['name']}"
|
|
671
|
+
if is_master_account
|
|
672
|
+
description_cols["Visibility"] = lambda {|it| it['visibility']}
|
|
673
|
+
description_cols["Tenants"] = lambda {|it| it['tenants'].collect {|tenant| tenant['name']}.join(', ')}
|
|
684
674
|
end
|
|
685
|
-
|
|
686
|
-
print_h1 "No Firewall Rule Groups"
|
|
675
|
+
print_description_list(description_cols, group)
|
|
687
676
|
end
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
print_rest_exception(e, options)
|
|
677
|
+
else
|
|
678
|
+
print_red_alert "Firewall rule groups not supported for #{router['type']['name']}"
|
|
691
679
|
return 1
|
|
692
680
|
end
|
|
681
|
+
println reset
|
|
693
682
|
end
|
|
694
683
|
|
|
695
684
|
def add_firewall_rule_group(args)
|
|
@@ -706,6 +695,7 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
706
695
|
opts.on('--priority VALUE', Integer, "Priority for this firewall rule group (not applicable to all firewall types)") do |val|
|
|
707
696
|
params['priority'] = val
|
|
708
697
|
end
|
|
698
|
+
add_perms_options(opts, options, ['plans', 'groups'])
|
|
709
699
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
|
710
700
|
opts.footer = "Create a network router firewall rule group."
|
|
711
701
|
end
|
|
@@ -745,7 +735,14 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
745
735
|
|
|
746
736
|
# prompt options
|
|
747
737
|
option_result = Morpheus::Cli::OptionTypes.prompt(option_types, options[:options].deep_merge({:context_map => {'group' => ''}}), @api_client, {}, nil, true)
|
|
748
|
-
|
|
738
|
+
|
|
739
|
+
rule_group = params.deep_merge(option_result)
|
|
740
|
+
|
|
741
|
+
# prompt perms
|
|
742
|
+
if is_master_account
|
|
743
|
+
rule_group.merge!(prompt_permissions_v2(options, ['plans', 'groups']))
|
|
744
|
+
end
|
|
745
|
+
payload = {'ruleGroup' => rule_group}
|
|
749
746
|
end
|
|
750
747
|
|
|
751
748
|
@network_routers_interface.setopts(options)
|
|
@@ -782,6 +779,7 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
782
779
|
opts.on('--priority VALUE', Integer, "Priority for this firewall rule group (not applicable to all firewall types)") do |val|
|
|
783
780
|
params['priority'] = val
|
|
784
781
|
end
|
|
782
|
+
add_perms_options(opts, options, ['plans', 'groups'])
|
|
785
783
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
|
786
784
|
opts.footer = "Update a network router firewall rule group.\n" +
|
|
787
785
|
"[router] is required. This is the name or id of an existing network router.\n" +
|
|
@@ -813,6 +811,11 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
813
811
|
exit 1
|
|
814
812
|
end
|
|
815
813
|
|
|
814
|
+
if is_master_account
|
|
815
|
+
params['visibility'] = options[:visibility] if !options[:visibility].nil?
|
|
816
|
+
params['tenants'] = options[:tenants].collect {|it| {'id' => it}} if !options[:tenants].nil?
|
|
817
|
+
end
|
|
818
|
+
|
|
816
819
|
payload = parse_payload(options) || {'ruleGroup' => params}
|
|
817
820
|
payload['ruleGroup'].deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
|
818
821
|
|
|
@@ -1148,7 +1151,6 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
1148
1151
|
api_params = {}
|
|
1149
1152
|
api_params['networkServerId'] = router['networkServer']['id'] if router['networkServer']
|
|
1150
1153
|
api_params['zoneId'] = router['zone']['id'] if router['networkServer'].nil?
|
|
1151
|
-
api_params['groupId'] = options[:group] if !options[:group].nil?
|
|
1152
1154
|
option_result = Morpheus::Cli::OptionTypes.prompt(option_types, options[:options].deep_merge({:context_map => {'rule' => ''}}), @api_client, api_params, nil, true)
|
|
1153
1155
|
payload = {'rule' => params.deep_merge(option_result)}
|
|
1154
1156
|
end
|
|
@@ -1517,11 +1519,11 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
1517
1519
|
options = {}
|
|
1518
1520
|
query_params = {}
|
|
1519
1521
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1520
|
-
opts.banner = subcommand_usage("[router] [
|
|
1522
|
+
opts.banner = subcommand_usage("[router] [route]")
|
|
1521
1523
|
build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :quiet, :remote])
|
|
1522
1524
|
opts.footer = "Delete a network router route.\n" +
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
+
"[router] is required. This is the name or id of an existing network router."
|
|
1526
|
+
"[route] is required. This is the name or id of an existing network router route."
|
|
1525
1527
|
end
|
|
1526
1528
|
optparse.parse!(args)
|
|
1527
1529
|
if args.count != 2
|
|
@@ -1628,11 +1630,11 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
1628
1630
|
def nat(args)
|
|
1629
1631
|
options = {}
|
|
1630
1632
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1631
|
-
opts.banner = subcommand_usage("[router] [
|
|
1633
|
+
opts.banner = subcommand_usage("[router] [nat]")
|
|
1632
1634
|
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
1633
1635
|
opts.footer = "Display network router firewall rule details." + "\n" +
|
|
1634
1636
|
"[router] is required. This is the name or id of a network router.\n" +
|
|
1635
|
-
"[
|
|
1637
|
+
"[nat] is required. This is the name or id of a NAT.\n"
|
|
1636
1638
|
end
|
|
1637
1639
|
|
|
1638
1640
|
optparse.parse!(args)
|
|
@@ -1887,6 +1889,268 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
1887
1889
|
end
|
|
1888
1890
|
end
|
|
1889
1891
|
|
|
1892
|
+
def bgp_neighbors(args)
|
|
1893
|
+
options = {}
|
|
1894
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1895
|
+
opts.banner = subcommand_usage("[router]")
|
|
1896
|
+
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
1897
|
+
opts.footer = "List network router BGP neighbors." + "\n" +
|
|
1898
|
+
"[router] is required. This is the name or id of a network router."
|
|
1899
|
+
end
|
|
1900
|
+
|
|
1901
|
+
optparse.parse!(args)
|
|
1902
|
+
connect(options)
|
|
1903
|
+
|
|
1904
|
+
if args.count < 1
|
|
1905
|
+
puts optparse
|
|
1906
|
+
return 1
|
|
1907
|
+
end
|
|
1908
|
+
_bgp_neighbors(args[0], options)
|
|
1909
|
+
end
|
|
1910
|
+
|
|
1911
|
+
def _bgp_neighbors(router_id, options)
|
|
1912
|
+
@network_routers_interface.setopts(options)
|
|
1913
|
+
if options[:dry_run]
|
|
1914
|
+
if args[0].to_s =~ /\A\d{1,}\Z/
|
|
1915
|
+
print_dry_run @network_routers_interface.dry.get(router_id.to_i)
|
|
1916
|
+
else
|
|
1917
|
+
print_dry_run @network_routers_interface.dry.list({name:router_id})
|
|
1918
|
+
end
|
|
1919
|
+
return
|
|
1920
|
+
end
|
|
1921
|
+
router = find_router(router_id)
|
|
1922
|
+
if router.nil?
|
|
1923
|
+
return 1
|
|
1924
|
+
end
|
|
1925
|
+
|
|
1926
|
+
if router['type']['hasBgp']
|
|
1927
|
+
json_response = {'networkRouterBgpNeighbors' => router['bgpNeighbors']}
|
|
1928
|
+
render_response(json_response, options, 'networkRouterBgpNeighbor') do
|
|
1929
|
+
print_h1 "Network Router BGP Neighbors For: #{router['name']}"
|
|
1930
|
+
print cyan
|
|
1931
|
+
print_bgp_neighbors(router)
|
|
1932
|
+
end
|
|
1933
|
+
else
|
|
1934
|
+
print_red_alert "BGP not supported for #{router['type']['name']}"
|
|
1935
|
+
end
|
|
1936
|
+
print reset
|
|
1937
|
+
end
|
|
1938
|
+
|
|
1939
|
+
def bgp_neighbor(args)
|
|
1940
|
+
options = {}
|
|
1941
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1942
|
+
opts.banner = subcommand_usage("[router] [BGP neighbor]")
|
|
1943
|
+
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
1944
|
+
opts.footer = "Display details on network router BGP neighbor." + "\n" +
|
|
1945
|
+
"[router] is required. This is the name or id of a network router.\n" +
|
|
1946
|
+
"[BGP neighbor] is required. This is the id of a BGP neighbor.\n"
|
|
1947
|
+
end
|
|
1948
|
+
|
|
1949
|
+
optparse.parse!(args)
|
|
1950
|
+
connect(options)
|
|
1951
|
+
|
|
1952
|
+
if args.count < 2
|
|
1953
|
+
puts optparse
|
|
1954
|
+
return 1
|
|
1955
|
+
end
|
|
1956
|
+
|
|
1957
|
+
@network_routers_interface.setopts(options)
|
|
1958
|
+
if options[:dry_run]
|
|
1959
|
+
if args[0].to_s =~ /\A\d{1,}\Z/
|
|
1960
|
+
print_dry_run @network_routers_interface.dry.get(args[0].to_i)
|
|
1961
|
+
else
|
|
1962
|
+
print_dry_run @network_routers_interface.dry.list({name:args[0]})
|
|
1963
|
+
end
|
|
1964
|
+
return
|
|
1965
|
+
end
|
|
1966
|
+
router = find_router(args[0])
|
|
1967
|
+
if router.nil?
|
|
1968
|
+
return 1
|
|
1969
|
+
end
|
|
1970
|
+
|
|
1971
|
+
if router['type']['hasBgp']
|
|
1972
|
+
bgp_neighbor = (router['bgpNeighbors'] || []).find {|it| it['id'] == args[1].to_i}
|
|
1973
|
+
|
|
1974
|
+
if bgp_neighbor
|
|
1975
|
+
json_response = {'networkRouterBgpNeighbor' => bgp_neighbor}
|
|
1976
|
+
render_response(json_response, options, 'networkRouterBgpNeighbor') do
|
|
1977
|
+
print_h1 "Network Router BGP Neighbor Details"
|
|
1978
|
+
print cyan
|
|
1979
|
+
|
|
1980
|
+
description_cols = {
|
|
1981
|
+
"ID" => lambda {|it| it['id']}
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
router['type']['bgpNeighborOptionTypes'].sort_by {|it| it['displayOrder']}.each do |option_type|
|
|
1985
|
+
description_cols[option_type['fieldLabel']] = lambda {|it| Morpheus::Cli::OptionTypes.get_option_value(it, option_type, true)}
|
|
1986
|
+
end
|
|
1987
|
+
print_description_list(description_cols, bgp_neighbor)
|
|
1988
|
+
end
|
|
1989
|
+
else
|
|
1990
|
+
print_red_alert "BGP Neighbors #{args[1]} not found for router #{router['name']}"
|
|
1991
|
+
end
|
|
1992
|
+
else
|
|
1993
|
+
print_red_alert "BGP Neighbors not supported for #{router['type']['name']}"
|
|
1994
|
+
end
|
|
1995
|
+
println reset
|
|
1996
|
+
end
|
|
1997
|
+
|
|
1998
|
+
def add_bgp_neighbor(args)
|
|
1999
|
+
options = {:options=>{}}
|
|
2000
|
+
params = {}
|
|
2001
|
+
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
2002
|
+
opts.banner = subcommand_usage("[router]")
|
|
2003
|
+
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
|
2004
|
+
opts.footer = "Create a network router BGP neighbor."
|
|
2005
|
+
end
|
|
2006
|
+
optparse.parse!(args)
|
|
2007
|
+
connect(options)
|
|
2008
|
+
if args.count < 1
|
|
2009
|
+
print_error Morpheus::Terminal.angry_prompt
|
|
2010
|
+
puts_error "wrong number of arguments, expected 1 and got (#{args.count}) #{args.inspect}\n#{optparse}"
|
|
2011
|
+
return 1
|
|
2012
|
+
end
|
|
2013
|
+
|
|
2014
|
+
router = find_router(args[0])
|
|
2015
|
+
|
|
2016
|
+
if router.nil?
|
|
2017
|
+
return 1
|
|
2018
|
+
end
|
|
2019
|
+
|
|
2020
|
+
if !router['type']['hasNat']
|
|
2021
|
+
print_red_alert "BGP not supported for #{router['type']['name']}"
|
|
2022
|
+
return 1
|
|
2023
|
+
end
|
|
2024
|
+
|
|
2025
|
+
if options[:payload]
|
|
2026
|
+
payload = options[:payload]
|
|
2027
|
+
else
|
|
2028
|
+
option_types = router['type']['bgpNeighborOptionTypes'].sort_by {|it| it['displayOrder']}
|
|
2029
|
+
|
|
2030
|
+
# prompt options
|
|
2031
|
+
option_result = Morpheus::Cli::OptionTypes.prompt(option_types, options[:options].deep_merge({:context_map => {'bgpNeighbor' => ''}}), @api_client, {'networkRouterId' => router['id']}, nil, true)
|
|
2032
|
+
payload = {'networkRouterBgpNeighbor' => params.deep_merge(option_result)}
|
|
2033
|
+
end
|
|
2034
|
+
|
|
2035
|
+
@network_routers_interface.setopts(options)
|
|
2036
|
+
if options[:dry_run]
|
|
2037
|
+
print_dry_run @network_routers_interface.dry.create_bgp_neighbor(router['id'], payload)
|
|
2038
|
+
return
|
|
2039
|
+
end
|
|
2040
|
+
|
|
2041
|
+
json_response = @network_routers_interface.create_bgp_neighbor(router['id'], payload)
|
|
2042
|
+
render_response(json_response, options, 'networkRouterBgpNeighbor') do
|
|
2043
|
+
print_green_success "\nAdded Network Router BGP neighbor #{json_response['id']}\n"
|
|
2044
|
+
_bgp_neighbors(router['id'], options)
|
|
2045
|
+
end
|
|
2046
|
+
end
|
|
2047
|
+
|
|
2048
|
+
def update_bgp_neighbor(args)
|
|
2049
|
+
options = {:options=>{}}
|
|
2050
|
+
params = {}
|
|
2051
|
+
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
2052
|
+
opts.banner = subcommand_usage("[router] [BGP neighbor]")
|
|
2053
|
+
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
|
2054
|
+
opts.footer = "Update a network router BGP neighbor.\n" +
|
|
2055
|
+
"[router] is required. This is the name or id of an existing network router.\n" +
|
|
2056
|
+
"[BGP neighbor] is required. This is the id of an existing network router BGP neighbor."
|
|
2057
|
+
end
|
|
2058
|
+
optparse.parse!(args)
|
|
2059
|
+
if args.count != 2
|
|
2060
|
+
raise_command_error "wrong number of arguments, expected 2 and got (#{args.count}) #{args}\n#{optparse}"
|
|
2061
|
+
end
|
|
2062
|
+
connect(options)
|
|
2063
|
+
|
|
2064
|
+
router = find_router(args[0])
|
|
2065
|
+
|
|
2066
|
+
if router.nil?
|
|
2067
|
+
return 1
|
|
2068
|
+
end
|
|
2069
|
+
|
|
2070
|
+
if !router['type']['hasBgp']
|
|
2071
|
+
print_red_alert "BGP not supported for #{router['type']['name']}"
|
|
2072
|
+
return 1
|
|
2073
|
+
end
|
|
2074
|
+
|
|
2075
|
+
bgp_neighbor = router['bgpNeighbors'] ? router['bgpNeighbors'].find {|it| it['id'] == args[1].to_i} : nil
|
|
2076
|
+
|
|
2077
|
+
if !bgp_neighbor
|
|
2078
|
+
print_red_alert "BGP neighbor #{args[1]} not found for router #{router['name']}"
|
|
2079
|
+
exit 1
|
|
2080
|
+
end
|
|
2081
|
+
|
|
2082
|
+
payload = parse_payload(options) || {'networkRouterBgpNeighbor' => params}
|
|
2083
|
+
payload['networkRouterBgpNeighbor'].deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options] && !payload['networkRouterBgpNeighbor'].nil?
|
|
2084
|
+
|
|
2085
|
+
if payload['networkRouterBgpNeighbor'].empty?
|
|
2086
|
+
option_types = router['type']['bgpNeighborOptionTypes'].sort_by {|it| it['displayOrder']}
|
|
2087
|
+
print_green_success "Nothing to update"
|
|
2088
|
+
println cyan
|
|
2089
|
+
print Morpheus::Cli::OptionTypes.display_option_types_help(
|
|
2090
|
+
option_types,
|
|
2091
|
+
{:include_context => true, :context_map => {'bgpNeighbor' => ''}, :color => cyan, :title => "Available BGP Neighbor Options"}
|
|
2092
|
+
)
|
|
2093
|
+
exit 1
|
|
2094
|
+
end
|
|
2095
|
+
|
|
2096
|
+
@network_routers_interface.setopts(options)
|
|
2097
|
+
if options[:dry_run]
|
|
2098
|
+
print_dry_run @network_routers_interface.dry.update_bgp_neighbor(router['id'], bgp_neighbor['id'], payload)
|
|
2099
|
+
return
|
|
2100
|
+
end
|
|
2101
|
+
|
|
2102
|
+
json_response = @network_routers_interface.update_bgp_neighbor(router['id'], bgp_neighbor['id'], payload)
|
|
2103
|
+
render_response(json_response, options, 'networkRouterBgpNeighbor') do
|
|
2104
|
+
print_green_success "\nUpdated Network Router BGP Neighbor #{bgp_neighbor['id']}\n"
|
|
2105
|
+
_bgp_neighbors(router['id'], options)
|
|
2106
|
+
end
|
|
2107
|
+
end
|
|
2108
|
+
|
|
2109
|
+
def remove_bgp_neighbor(args)
|
|
2110
|
+
options = {}
|
|
2111
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
2112
|
+
opts.banner = subcommand_usage("[router] [BGP neighbor]")
|
|
2113
|
+
build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :quiet, :remote])
|
|
2114
|
+
opts.footer = "Delete a network router BGP neighbor.\n" +
|
|
2115
|
+
"[router] is required. This is the name or id of an existing network router."
|
|
2116
|
+
"[BGP neighbor] is required. This is the id of an existing network router BGP neighbor."
|
|
2117
|
+
end
|
|
2118
|
+
optparse.parse!(args)
|
|
2119
|
+
if args.count != 2
|
|
2120
|
+
raise_command_error "wrong number of arguments, expected 2 and got (#{args.count}) #{args}\n#{optparse}"
|
|
2121
|
+
end
|
|
2122
|
+
connect(options)
|
|
2123
|
+
|
|
2124
|
+
router = find_router(args[0])
|
|
2125
|
+
return if !router
|
|
2126
|
+
|
|
2127
|
+
if !router['type']['hasBgp']
|
|
2128
|
+
print_red_alert "BGP not supported for #{router['type']['name']}"
|
|
2129
|
+
return 1
|
|
2130
|
+
end
|
|
2131
|
+
|
|
2132
|
+
bgp_neighbor = router['bgpNeighbors'] ? router['bgpNeighbors'].find {|it| it['id'] == args[1].to_i} : nil
|
|
2133
|
+
|
|
2134
|
+
if !bgp_neighbor
|
|
2135
|
+
print_red_alert "BGP neighbor #{args[1]} not found for router #{router['name']}"
|
|
2136
|
+
exit 1
|
|
2137
|
+
end
|
|
2138
|
+
|
|
2139
|
+
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to remove the BGP neighbor '#{bgp_neighbor['id']}' from router '#{router['name']}'?", options)
|
|
2140
|
+
return 9, "aborted command"
|
|
2141
|
+
end
|
|
2142
|
+
@network_routers_interface.setopts(options)
|
|
2143
|
+
if options[:dry_run]
|
|
2144
|
+
print_dry_run @network_routers_interface.dry.destroy_bgp_neighbor(router['id'], bgp_neighbor['id'])
|
|
2145
|
+
return
|
|
2146
|
+
end
|
|
2147
|
+
json_response = @network_routers_interface.destroy_bgp_neighbor(router['id'], bgp_neighbor['id'])
|
|
2148
|
+
render_response(json_response, options, 'networkRouterBgpNeighbor') do
|
|
2149
|
+
print_green_success "\nDeleted Network Router BGP Neighbor #{bgp_neighbor['id']}\n"
|
|
2150
|
+
_bgp_neighbors(router['id'], options)
|
|
2151
|
+
end
|
|
2152
|
+
end
|
|
2153
|
+
|
|
1890
2154
|
def types(args)
|
|
1891
2155
|
options = {}
|
|
1892
2156
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
@@ -1989,7 +2253,7 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
1989
2253
|
}
|
|
1990
2254
|
print_description_list(description_cols, router_type)
|
|
1991
2255
|
|
|
1992
|
-
{'optionTypes' => 'Router', 'ruleOptionTypes' => 'Firewall Rule', 'ruleGroupOptionTypes' => 'Firewall Rule Group', 'natOptionTypes' => 'NAT'}.each_pair do |field, title|
|
|
2256
|
+
{'optionTypes' => 'Router', 'ruleOptionTypes' => 'Firewall Rule', 'ruleGroupOptionTypes' => 'Firewall Rule Group', 'natOptionTypes' => 'NAT', 'bgpNeighborOptionTypes' => 'BGP Neighbor'}.each_pair do |field, title|
|
|
1993
2257
|
if !router_type[field].nil? && router_type[field].count > 0
|
|
1994
2258
|
println cyan
|
|
1995
2259
|
print Morpheus::Cli::OptionTypes.display_option_types_help(
|
|
@@ -2187,6 +2451,27 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
2187
2451
|
end
|
|
2188
2452
|
end
|
|
2189
2453
|
|
|
2454
|
+
def print_bgp_neighbors(router)
|
|
2455
|
+
if router['type']['hasBgp']
|
|
2456
|
+
if router['bgpNeighbors'].count > 0
|
|
2457
|
+
rows = router['bgpNeighbors'].sort_by {|it| it['id']}.collect do |it|
|
|
2458
|
+
{
|
|
2459
|
+
id: it['id'],
|
|
2460
|
+
ip_address: it['ipAddress'],
|
|
2461
|
+
bfd_enabled: it['bfdEnabled'],
|
|
2462
|
+
remote_as: it['remoteAs'],
|
|
2463
|
+
route_filtering_out: it['routeFilteringOut'],
|
|
2464
|
+
route_filtering_in: it['routeFilteringIn'],
|
|
2465
|
+
allow_as_in: it['allowAsIn']
|
|
2466
|
+
}
|
|
2467
|
+
end
|
|
2468
|
+
puts as_pretty_table(rows, [:id, :ip_address, :bfd_enabled, :remote_as, :route_filtering_out, :route_filtering_in, :allow_as_in])
|
|
2469
|
+
else
|
|
2470
|
+
println "No BGP Neighbors\n"
|
|
2471
|
+
end
|
|
2472
|
+
end
|
|
2473
|
+
end
|
|
2474
|
+
|
|
2190
2475
|
def format_router_status(router, return_color = cyan)
|
|
2191
2476
|
status = router['status']
|
|
2192
2477
|
color = white
|
|
@@ -2285,8 +2570,53 @@ class Morpheus::Cli::NetworkRoutersCommand
|
|
|
2285
2570
|
end
|
|
2286
2571
|
end
|
|
2287
2572
|
else
|
|
2288
|
-
rule = router['firewall'] && router['firewall']['rules'] ? router['firewall']['rules'].find {|it| it['name'] ==
|
|
2573
|
+
rule = router['firewall'] && router['firewall']['rules'] ? router['firewall']['rules'].find {|it| it['name'] == rule_id || it['id'] == rule_id.to_i} : nil
|
|
2289
2574
|
end
|
|
2290
2575
|
rule
|
|
2291
2576
|
end
|
|
2577
|
+
|
|
2578
|
+
def find_firewall_rule_group(router_id, val)
|
|
2579
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
|
2580
|
+
return find_firewall_rule_group_by_id(router_id, val)
|
|
2581
|
+
else
|
|
2582
|
+
if group = find_firewall_rule_group_by_name(router_id, val)
|
|
2583
|
+
return find_firewall_rule_group_by_id(router_id, group['id'])
|
|
2584
|
+
end
|
|
2585
|
+
end
|
|
2586
|
+
end
|
|
2587
|
+
|
|
2588
|
+
def find_firewall_rule_group_by_id(router_id, group_id)
|
|
2589
|
+
begin
|
|
2590
|
+
json_response = @network_routers_interface.get_firewall_rule_group(router_id, group_id.to_i)
|
|
2591
|
+
return json_response['ruleGroup']
|
|
2592
|
+
rescue RestClient::Exception => e
|
|
2593
|
+
if e.response && e.response.code == 404
|
|
2594
|
+
print_red_alert "Network firewall rule group not found by id #{group_id}"
|
|
2595
|
+
return nil
|
|
2596
|
+
else
|
|
2597
|
+
raise e
|
|
2598
|
+
end
|
|
2599
|
+
end
|
|
2600
|
+
end
|
|
2601
|
+
|
|
2602
|
+
def find_firewall_rule_group_by_name(router_id, name)
|
|
2603
|
+
groups = search_firewall_rule_groups(router_id, name)
|
|
2604
|
+
if groups.empty?
|
|
2605
|
+
print_red_alert "Network firewall rule group not found by name #{name}"
|
|
2606
|
+
return nil
|
|
2607
|
+
elsif groups.size > 1
|
|
2608
|
+
print_red_alert "#{scopes.size} network firewall rule groups found by name #{name}"
|
|
2609
|
+
rows = groups.collect do |it|
|
|
2610
|
+
{id: it['id'], name: it['name']}
|
|
2611
|
+
end
|
|
2612
|
+
puts as_pretty_table(rows, [:id, :name], {color:red})
|
|
2613
|
+
return nil
|
|
2614
|
+
else
|
|
2615
|
+
return groups[0]
|
|
2616
|
+
end
|
|
2617
|
+
end
|
|
2618
|
+
|
|
2619
|
+
def search_firewall_rule_groups(router_id, phrase = nil)
|
|
2620
|
+
@network_routers_interface.list_firewall_rule_groups(router_id, phrase ? {phrase: phrase.to_s} : {})['ruleGroups']
|
|
2621
|
+
end
|
|
2292
2622
|
end
|