mtncloud-cli 1.0.0
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 +7 -0
- data/.dockerignore +20 -0
- data/.github/pull_request_template.md +14 -0
- data/.github/workflows/ci.yml +56 -0
- data/.github/workflows/release.yml +46 -0
- data/.gitignore +25 -0
- data/CLAUDE.md +24 -0
- data/CONTRIBUTING.md +91 -0
- data/Dockerfile +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +23 -0
- data/README.md +187 -0
- data/Rakefile +26 -0
- data/bin/mcs +3 -0
- data/bin/mtncloud +27 -0
- data/lib/mtncloud/api/account_groups_interface.rb +48 -0
- data/lib/mtncloud/api/account_users_interface.rb +68 -0
- data/lib/mtncloud/api/accounts_interface.rb +9 -0
- data/lib/mtncloud/api/activity_interface.rb +9 -0
- data/lib/mtncloud/api/affinity_groups_interface.rb +46 -0
- data/lib/mtncloud/api/api_client.rb +1091 -0
- data/lib/mtncloud/api/appliance_settings_interface.rb +49 -0
- data/lib/mtncloud/api/approvals_interface.rb +32 -0
- data/lib/mtncloud/api/apps_interface.rb +180 -0
- data/lib/mtncloud/api/archive_buckets_interface.rb +116 -0
- data/lib/mtncloud/api/archive_files_interface.rb +173 -0
- data/lib/mtncloud/api/audit_interface.rb +9 -0
- data/lib/mtncloud/api/auth_interface.rb +58 -0
- data/lib/mtncloud/api/backup_jobs_interface.rb +13 -0
- data/lib/mtncloud/api/backup_restores_interface.rb +27 -0
- data/lib/mtncloud/api/backup_results_interface.rb +32 -0
- data/lib/mtncloud/api/backup_service_types_interface.rb +9 -0
- data/lib/mtncloud/api/backup_services_interface.rb +9 -0
- data/lib/mtncloud/api/backup_settings_interface.rb +20 -0
- data/lib/mtncloud/api/backup_types_interface.rb +9 -0
- data/lib/mtncloud/api/backups_interface.rb +21 -0
- data/lib/mtncloud/api/billing_interface.rb +34 -0
- data/lib/mtncloud/api/blueprints_interface.rb +70 -0
- data/lib/mtncloud/api/body_io.rb +22 -0
- data/lib/mtncloud/api/budgets_interface.rb +48 -0
- data/lib/mtncloud/api/catalog_item_types_interface.rb +29 -0
- data/lib/mtncloud/api/certificate_types_interface.rb +14 -0
- data/lib/mtncloud/api/certificates_interface.rb +9 -0
- data/lib/mtncloud/api/clients_interface.rb +41 -0
- data/lib/mtncloud/api/cloud_datastores_interface.rb +48 -0
- data/lib/mtncloud/api/cloud_folders_interface.rb +41 -0
- data/lib/mtncloud/api/cloud_policies_interface.rb +41 -0
- data/lib/mtncloud/api/cloud_resource_pools_interface.rb +66 -0
- data/lib/mtncloud/api/clouds_interface.rb +217 -0
- data/lib/mtncloud/api/clusters_interface.rb +471 -0
- data/lib/mtncloud/api/containers_interface.rb +145 -0
- data/lib/mtncloud/api/credential_types_interface.rb +9 -0
- data/lib/mtncloud/api/credentials_interface.rb +9 -0
- data/lib/mtncloud/api/custom_instance_types_interface.rb +99 -0
- data/lib/mtncloud/api/cypher_interface.rb +51 -0
- data/lib/mtncloud/api/dashboard_interface.rb +14 -0
- data/lib/mtncloud/api/datastores_interface.rb +21 -0
- data/lib/mtncloud/api/deploy_interface.rb +44 -0
- data/lib/mtncloud/api/deployments_interface.rb +79 -0
- data/lib/mtncloud/api/distributed_workers_interface.rb +41 -0
- data/lib/mtncloud/api/email_templates_interface.rb +53 -0
- data/lib/mtncloud/api/environments_interface.rb +48 -0
- data/lib/mtncloud/api/execute_schedules_interface.rb +71 -0
- data/lib/mtncloud/api/execution_request_interface.rb +27 -0
- data/lib/mtncloud/api/file_copy_request_interface.rb +68 -0
- data/lib/mtncloud/api/forgot_password_interface.rb +17 -0
- data/lib/mtncloud/api/group_policies_interface.rb +41 -0
- data/lib/mtncloud/api/groups_interface.rb +73 -0
- data/lib/mtncloud/api/guidance_interface.rb +44 -0
- data/lib/mtncloud/api/guidance_settings_interface.rb +17 -0
- data/lib/mtncloud/api/health_interface.rb +100 -0
- data/lib/mtncloud/api/host_vm_groups_interface.rb +37 -0
- data/lib/mtncloud/api/hub_interface.rb +25 -0
- data/lib/mtncloud/api/image_builder_boot_scripts_interface.rb +41 -0
- data/lib/mtncloud/api/image_builder_image_builds_interface.rb +73 -0
- data/lib/mtncloud/api/image_builder_interface.rb +20 -0
- data/lib/mtncloud/api/image_builder_preseed_scripts_interface.rb +41 -0
- data/lib/mtncloud/api/instance_types_interface.rb +20 -0
- data/lib/mtncloud/api/instances_interface.rb +453 -0
- data/lib/mtncloud/api/integration_types_interface.rb +14 -0
- data/lib/mtncloud/api/integrations_interface.rb +74 -0
- data/lib/mtncloud/api/invoice_line_items_interface.rb +9 -0
- data/lib/mtncloud/api/invoices_interface.rb +28 -0
- data/lib/mtncloud/api/jobs_interface.rb +83 -0
- data/lib/mtncloud/api/key_pairs_interface.rb +57 -0
- data/lib/mtncloud/api/library_cluster_layouts_interface.rb +47 -0
- data/lib/mtncloud/api/library_cluster_packages_interface.rb +60 -0
- data/lib/mtncloud/api/library_container_scripts_interface.rb +43 -0
- data/lib/mtncloud/api/library_container_templates_interface.rb +43 -0
- data/lib/mtncloud/api/library_container_types_interface.rb +59 -0
- data/lib/mtncloud/api/library_container_upgrades_interface.rb +60 -0
- data/lib/mtncloud/api/library_instance_types_interface.rb +74 -0
- data/lib/mtncloud/api/library_layouts_interface.rb +69 -0
- data/lib/mtncloud/api/library_operating_systems_interface.rb +63 -0
- data/lib/mtncloud/api/library_spec_template_types_interface.rb +43 -0
- data/lib/mtncloud/api/library_spec_templates_interface.rb +43 -0
- data/lib/mtncloud/api/license_interface.rb +30 -0
- data/lib/mtncloud/api/load_balancer_monitors_interface.rb +9 -0
- data/lib/mtncloud/api/load_balancer_pool_nodes_interface.rb +8 -0
- data/lib/mtncloud/api/load_balancer_pools_interface.rb +9 -0
- data/lib/mtncloud/api/load_balancer_pools_secondary_interface.rb +9 -0
- data/lib/mtncloud/api/load_balancer_profiles_interface.rb +9 -0
- data/lib/mtncloud/api/load_balancer_types_interface.rb +9 -0
- data/lib/mtncloud/api/load_balancer_virtual_servers_interface.rb +18 -0
- data/lib/mtncloud/api/load_balancers_interface.rb +14 -0
- data/lib/mtncloud/api/log_settings_interface.rb +44 -0
- data/lib/mtncloud/api/logs_interface.rb +37 -0
- data/lib/mtncloud/api/migrations_interface.rb +49 -0
- data/lib/mtncloud/api/monitoring_alerts_interface.rb +39 -0
- data/lib/mtncloud/api/monitoring_apps_interface.rb +69 -0
- data/lib/mtncloud/api/monitoring_checks_interface.rb +103 -0
- data/lib/mtncloud/api/monitoring_contacts_interface.rb +41 -0
- data/lib/mtncloud/api/monitoring_groups_interface.rb +77 -0
- data/lib/mtncloud/api/monitoring_incidents_interface.rb +107 -0
- data/lib/mtncloud/api/monitoring_interface.rb +35 -0
- data/lib/mtncloud/api/monitoring_settings_interface.rb +21 -0
- data/lib/mtncloud/api/network_dhcp_relays_interface.rb +36 -0
- data/lib/mtncloud/api/network_dhcp_servers_interface.rb +36 -0
- data/lib/mtncloud/api/network_domain_records_interface.rb +41 -0
- data/lib/mtncloud/api/network_domains_interface.rb +41 -0
- data/lib/mtncloud/api/network_edge_clusters_interface.rb +26 -0
- data/lib/mtncloud/api/network_floating_ips_interface.rb +40 -0
- data/lib/mtncloud/api/network_groups_interface.rb +41 -0
- data/lib/mtncloud/api/network_pool_ips_interface.rb +41 -0
- data/lib/mtncloud/api/network_pool_server_types_interface.rb +9 -0
- data/lib/mtncloud/api/network_pool_servers_interface.rb +48 -0
- data/lib/mtncloud/api/network_pools_interface.rb +41 -0
- data/lib/mtncloud/api/network_proxies_interface.rb +41 -0
- data/lib/mtncloud/api/network_routers_interface.rb +181 -0
- data/lib/mtncloud/api/network_security_server_types_interface.rb +9 -0
- data/lib/mtncloud/api/network_security_servers_interface.rb +27 -0
- data/lib/mtncloud/api/network_server_groups_interface.rb +7 -0
- data/lib/mtncloud/api/network_server_types_interface.rb +9 -0
- data/lib/mtncloud/api/network_servers_interface.rb +102 -0
- data/lib/mtncloud/api/network_services_interface.rb +63 -0
- data/lib/mtncloud/api/network_static_routes_interface.rb +36 -0
- data/lib/mtncloud/api/network_subnets_interface.rb +42 -0
- data/lib/mtncloud/api/network_types_interface.rb +20 -0
- data/lib/mtncloud/api/networks_interface.rb +48 -0
- data/lib/mtncloud/api/option_type_forms_interface.rb +9 -0
- data/lib/mtncloud/api/option_type_lists_interface.rb +53 -0
- data/lib/mtncloud/api/option_types_interface.rb +41 -0
- data/lib/mtncloud/api/options_interface.rb +17 -0
- data/lib/mtncloud/api/packages_interface.rb +112 -0
- data/lib/mtncloud/api/ping_interface.rb +22 -0
- data/lib/mtncloud/api/plugins_interface.rb +22 -0
- data/lib/mtncloud/api/policies_interface.rb +56 -0
- data/lib/mtncloud/api/power_schedules_interface.rb +71 -0
- data/lib/mtncloud/api/price_sets_interface.rb +39 -0
- data/lib/mtncloud/api/prices_interface.rb +71 -0
- data/lib/mtncloud/api/processes_interface.rb +40 -0
- data/lib/mtncloud/api/projects_interface.rb +33 -0
- data/lib/mtncloud/api/provision_types_interface.rb +24 -0
- data/lib/mtncloud/api/provisioning_license_types_interface.rb +31 -0
- data/lib/mtncloud/api/provisioning_licenses_interface.rb +60 -0
- data/lib/mtncloud/api/provisioning_settings_interface.rb +26 -0
- data/lib/mtncloud/api/read_interface.rb +24 -0
- data/lib/mtncloud/api/reports_interface.rb +70 -0
- data/lib/mtncloud/api/resource_pool_groups_interface.rb +51 -0
- data/lib/mtncloud/api/rest_interface.rb +37 -0
- data/lib/mtncloud/api/roles_interface.rb +151 -0
- data/lib/mtncloud/api/scale_thresholds_interface.rb +9 -0
- data/lib/mtncloud/api/search_interface.rb +13 -0
- data/lib/mtncloud/api/secondary_read_interface.rb +25 -0
- data/lib/mtncloud/api/secondary_rest_interface.rb +42 -0
- data/lib/mtncloud/api/security_group_rules_interface.rb +35 -0
- data/lib/mtncloud/api/security_groups_interface.rb +56 -0
- data/lib/mtncloud/api/security_package_types_interface.rb +9 -0
- data/lib/mtncloud/api/security_packages_interface.rb +9 -0
- data/lib/mtncloud/api/security_scans_interface.rb +9 -0
- data/lib/mtncloud/api/server_devices_interface.rb +30 -0
- data/lib/mtncloud/api/server_types_interface.rb +20 -0
- data/lib/mtncloud/api/servers_interface.rb +230 -0
- data/lib/mtncloud/api/service_catalog_interface.rb +89 -0
- data/lib/mtncloud/api/service_plans_interface.rb +62 -0
- data/lib/mtncloud/api/setup_interface.rb +46 -0
- data/lib/mtncloud/api/snapshots_interface.rb +19 -0
- data/lib/mtncloud/api/storage_datastores_interface.rb +44 -0
- data/lib/mtncloud/api/storage_providers_interface.rb +151 -0
- data/lib/mtncloud/api/storage_server_types_interface.rb +14 -0
- data/lib/mtncloud/api/storage_servers_interface.rb +9 -0
- data/lib/mtncloud/api/storage_volume_types_interface.rb +9 -0
- data/lib/mtncloud/api/storage_volumes_interface.rb +24 -0
- data/lib/mtncloud/api/subnet_types_interface.rb +20 -0
- data/lib/mtncloud/api/subnets_interface.rb +41 -0
- data/lib/mtncloud/api/support_bundles_interface.rb +46 -0
- data/lib/mtncloud/api/system_types_interface.rb +13 -0
- data/lib/mtncloud/api/systems_interface.rb +55 -0
- data/lib/mtncloud/api/task_sets_interface.rb +52 -0
- data/lib/mtncloud/api/tasks_interface.rb +66 -0
- data/lib/mtncloud/api/tokens_interface.rb +39 -0
- data/lib/mtncloud/api/usage_interface.rb +18 -0
- data/lib/mtncloud/api/user_groups_interface.rb +59 -0
- data/lib/mtncloud/api/user_settings_interface.rb +90 -0
- data/lib/mtncloud/api/user_sources_interface.rb +99 -0
- data/lib/mtncloud/api/users_interface.rb +33 -0
- data/lib/mtncloud/api/vdi_allocations_interface.rb +9 -0
- data/lib/mtncloud/api/vdi_apps_interface.rb +9 -0
- data/lib/mtncloud/api/vdi_gateways_interface.rb +9 -0
- data/lib/mtncloud/api/vdi_interface.rb +28 -0
- data/lib/mtncloud/api/vdi_pools_interface.rb +19 -0
- data/lib/mtncloud/api/virtual_images_interface.rb +210 -0
- data/lib/mtncloud/api/virtual_servers_interface.rb +9 -0
- data/lib/mtncloud/api/virtual_switches_interface.rb +9 -0
- data/lib/mtncloud/api/whitelabel_settings_interface.rb +57 -0
- data/lib/mtncloud/api/whoami_interface.rb +13 -0
- data/lib/mtncloud/api/wiki_interface.rb +48 -0
- data/lib/mtncloud/api.rb +12 -0
- data/lib/mtncloud/benchmarking.rb +259 -0
- data/lib/mtncloud/cli/cli_command.rb +2281 -0
- data/lib/mtncloud/cli/cli_registry.rb +337 -0
- data/lib/mtncloud/cli/commands/access_token_command.rb +201 -0
- data/lib/mtncloud/cli/commands/account_groups_command.rb +530 -0
- data/lib/mtncloud/cli/commands/activity_command.rb +149 -0
- data/lib/mtncloud/cli/commands/affinity_groups_command.rb +554 -0
- data/lib/mtncloud/cli/commands/alias_command.rb +278 -0
- data/lib/mtncloud/cli/commands/appliance_settings_command.rb +382 -0
- data/lib/mtncloud/cli/commands/approvals_command.rb +236 -0
- data/lib/mtncloud/cli/commands/apps.rb +2549 -0
- data/lib/mtncloud/cli/commands/archives_command.rb +2161 -0
- data/lib/mtncloud/cli/commands/audit.rb +188 -0
- data/lib/mtncloud/cli/commands/backup_jobs_command.rb +366 -0
- data/lib/mtncloud/cli/commands/backup_restores_command.rb +144 -0
- data/lib/mtncloud/cli/commands/backup_results_command.rb +149 -0
- data/lib/mtncloud/cli/commands/backup_services_command.rb +44 -0
- data/lib/mtncloud/cli/commands/backup_settings_command.rb +184 -0
- data/lib/mtncloud/cli/commands/backup_types_command.rb +53 -0
- data/lib/mtncloud/cli/commands/backups_command.rb +674 -0
- data/lib/mtncloud/cli/commands/benchmark_command.rb +458 -0
- data/lib/mtncloud/cli/commands/blueprints_command.rb +2297 -0
- data/lib/mtncloud/cli/commands/boot_scripts_command.rb +379 -0
- data/lib/mtncloud/cli/commands/budgets_command.rb +754 -0
- data/lib/mtncloud/cli/commands/cat_command.rb +45 -0
- data/lib/mtncloud/cli/commands/catalog_item_types_command.rb +858 -0
- data/lib/mtncloud/cli/commands/certificates_command.rb +575 -0
- data/lib/mtncloud/cli/commands/change_password_command.rb +132 -0
- data/lib/mtncloud/cli/commands/clients_command.rb +331 -0
- data/lib/mtncloud/cli/commands/cloud_datastores_command.rb +543 -0
- data/lib/mtncloud/cli/commands/cloud_folders_command.rb +512 -0
- data/lib/mtncloud/cli/commands/cloud_resource_pools_command.rb +870 -0
- data/lib/mtncloud/cli/commands/clouds.rb +2037 -0
- data/lib/mtncloud/cli/commands/clouds_types.rb +140 -0
- data/lib/mtncloud/cli/commands/cluster_types.rb +179 -0
- data/lib/mtncloud/cli/commands/clusters.rb +5855 -0
- data/lib/mtncloud/cli/commands/coloring_command.rb +82 -0
- data/lib/mtncloud/cli/commands/containers_command.rb +967 -0
- data/lib/mtncloud/cli/commands/credential_types_command.rb +36 -0
- data/lib/mtncloud/cli/commands/credentials_command.rb +124 -0
- data/lib/mtncloud/cli/commands/curl_command.rb +168 -0
- data/lib/mtncloud/cli/commands/cypher_command.rb +587 -0
- data/lib/mtncloud/cli/commands/dashboard_command.rb +300 -0
- data/lib/mtncloud/cli/commands/debug_command.rb +75 -0
- data/lib/mtncloud/cli/commands/deploy.rb +485 -0
- data/lib/mtncloud/cli/commands/deployments.rb +923 -0
- data/lib/mtncloud/cli/commands/deploys.rb +485 -0
- data/lib/mtncloud/cli/commands/distributed_workers_command.rb +282 -0
- data/lib/mtncloud/cli/commands/echo_command.rb +61 -0
- data/lib/mtncloud/cli/commands/edit_profile_command.rb +57 -0
- data/lib/mtncloud/cli/commands/edit_rc_command.rb +77 -0
- data/lib/mtncloud/cli/commands/email_templates_command.rb +373 -0
- data/lib/mtncloud/cli/commands/environments_command.rb +401 -0
- data/lib/mtncloud/cli/commands/execute_schedules_command.rb +735 -0
- data/lib/mtncloud/cli/commands/execution_request_command.rb +333 -0
- data/lib/mtncloud/cli/commands/exit_command.rb +34 -0
- data/lib/mtncloud/cli/commands/file_copy_request_command.rb +352 -0
- data/lib/mtncloud/cli/commands/forgot_password.rb +133 -0
- data/lib/mtncloud/cli/commands/get_prompt_command.rb +36 -0
- data/lib/mtncloud/cli/commands/groups.rb +818 -0
- data/lib/mtncloud/cli/commands/guidance_command.rb +529 -0
- data/lib/mtncloud/cli/commands/guidance_settings.rb +148 -0
- data/lib/mtncloud/cli/commands/health_command.rb +1046 -0
- data/lib/mtncloud/cli/commands/history_command.rb +60 -0
- data/lib/mtncloud/cli/commands/host_vm_groups_command.rb +423 -0
- data/lib/mtncloud/cli/commands/hosts.rb +2986 -0
- data/lib/mtncloud/cli/commands/hub.rb +215 -0
- data/lib/mtncloud/cli/commands/image_builder_command.rb +1197 -0
- data/lib/mtncloud/cli/commands/instance_types.rb +163 -0
- data/lib/mtncloud/cli/commands/instances.rb +5813 -0
- data/lib/mtncloud/cli/commands/integrations_command.rb +1412 -0
- data/lib/mtncloud/cli/commands/invoices_command.rb +1151 -0
- data/lib/mtncloud/cli/commands/jobs_command.rb +998 -0
- data/lib/mtncloud/cli/commands/key_pairs.rb +470 -0
- data/lib/mtncloud/cli/commands/library_cluster_layouts_command.rb +901 -0
- data/lib/mtncloud/cli/commands/library_cluster_packages_command.rb +552 -0
- data/lib/mtncloud/cli/commands/library_container_scripts_command.rb +446 -0
- data/lib/mtncloud/cli/commands/library_container_templates_command.rb +526 -0
- data/lib/mtncloud/cli/commands/library_container_types_command.rb +698 -0
- data/lib/mtncloud/cli/commands/library_forms_command.rb +625 -0
- data/lib/mtncloud/cli/commands/library_instance_types_command.rb +668 -0
- data/lib/mtncloud/cli/commands/library_layouts_command.rb +849 -0
- data/lib/mtncloud/cli/commands/library_operating_systems_command.rb +671 -0
- data/lib/mtncloud/cli/commands/library_option_lists_command.rb +503 -0
- data/lib/mtncloud/cli/commands/library_option_types_command.rb +329 -0
- data/lib/mtncloud/cli/commands/library_spec_templates_command.rb +547 -0
- data/lib/mtncloud/cli/commands/library_upgrades_command.rb +596 -0
- data/lib/mtncloud/cli/commands/license.rb +475 -0
- data/lib/mtncloud/cli/commands/load_balancer_monitors.rb +70 -0
- data/lib/mtncloud/cli/commands/load_balancer_pool_nodes.rb +87 -0
- data/lib/mtncloud/cli/commands/load_balancer_pools.rb +129 -0
- data/lib/mtncloud/cli/commands/load_balancer_profiles.rb +64 -0
- data/lib/mtncloud/cli/commands/load_balancer_types.rb +38 -0
- data/lib/mtncloud/cli/commands/load_balancer_virtual_servers.rb +147 -0
- data/lib/mtncloud/cli/commands/load_balancers.rb +189 -0
- data/lib/mtncloud/cli/commands/log_level_command.rb +54 -0
- data/lib/mtncloud/cli/commands/log_settings_command.rb +443 -0
- data/lib/mtncloud/cli/commands/login.rb +148 -0
- data/lib/mtncloud/cli/commands/logout.rb +63 -0
- data/lib/mtncloud/cli/commands/logs_command.rb +140 -0
- data/lib/mtncloud/cli/commands/man_command.rb +409 -0
- data/lib/mtncloud/cli/commands/migrations.rb +453 -0
- data/lib/mtncloud/cli/commands/monitoring_alerts_command.rb +791 -0
- data/lib/mtncloud/cli/commands/monitoring_apps_command.rb +716 -0
- data/lib/mtncloud/cli/commands/monitoring_checks_command.rb +766 -0
- data/lib/mtncloud/cli/commands/monitoring_contacts_command.rb +339 -0
- data/lib/mtncloud/cli/commands/monitoring_groups_command.rb +674 -0
- data/lib/mtncloud/cli/commands/monitoring_incidents_command.rb +835 -0
- data/lib/mtncloud/cli/commands/monitoring_settings.rb +212 -0
- data/lib/mtncloud/cli/commands/network_dhcp_relays_command.rb +375 -0
- data/lib/mtncloud/cli/commands/network_dhcp_servers_command.rb +366 -0
- data/lib/mtncloud/cli/commands/network_domains_command.rb +896 -0
- data/lib/mtncloud/cli/commands/network_edge_clusters_command.rb +288 -0
- data/lib/mtncloud/cli/commands/network_firewalls_command.rb +783 -0
- data/lib/mtncloud/cli/commands/network_floating_ips.rb +147 -0
- data/lib/mtncloud/cli/commands/network_groups_command.rb +654 -0
- data/lib/mtncloud/cli/commands/network_pool_server_types.rb +20 -0
- data/lib/mtncloud/cli/commands/network_pool_servers_command.rb +318 -0
- data/lib/mtncloud/cli/commands/network_pools_command.rb +903 -0
- data/lib/mtncloud/cli/commands/network_proxies_command.rb +578 -0
- data/lib/mtncloud/cli/commands/network_routers_command.rb +2628 -0
- data/lib/mtncloud/cli/commands/network_security_server_types.rb +20 -0
- data/lib/mtncloud/cli/commands/network_server_groups_command.rb +222 -0
- data/lib/mtncloud/cli/commands/network_server_types_command.rb +20 -0
- data/lib/mtncloud/cli/commands/network_servers_command.rb +398 -0
- data/lib/mtncloud/cli/commands/network_services_command.rb +198 -0
- data/lib/mtncloud/cli/commands/network_static_routes_command.rb +451 -0
- data/lib/mtncloud/cli/commands/network_transport_zones_command.rb +412 -0
- data/lib/mtncloud/cli/commands/networks_command.rb +1692 -0
- data/lib/mtncloud/cli/commands/open_command.rb +30 -0
- data/lib/mtncloud/cli/commands/options.rb +231 -0
- data/lib/mtncloud/cli/commands/packages_command.rb +822 -0
- data/lib/mtncloud/cli/commands/ping.rb +242 -0
- data/lib/mtncloud/cli/commands/plugins.rb +214 -0
- data/lib/mtncloud/cli/commands/policies_command.rb +990 -0
- data/lib/mtncloud/cli/commands/power_schedules_command.rb +731 -0
- data/lib/mtncloud/cli/commands/preseed_scripts_command.rb +378 -0
- data/lib/mtncloud/cli/commands/price_sets_command.rb +557 -0
- data/lib/mtncloud/cli/commands/prices_command.rb +692 -0
- data/lib/mtncloud/cli/commands/processes_command.rb +469 -0
- data/lib/mtncloud/cli/commands/projects_command.rb +537 -0
- data/lib/mtncloud/cli/commands/provisioning_licenses_command.rb +509 -0
- data/lib/mtncloud/cli/commands/provisioning_settings_command.rb +238 -0
- data/lib/mtncloud/cli/commands/recent_activity_command.rb +171 -0
- data/lib/mtncloud/cli/commands/remote.rb +1818 -0
- data/lib/mtncloud/cli/commands/reports_command.rb +724 -0
- data/lib/mtncloud/cli/commands/resource_pool_groups_command.rb +586 -0
- data/lib/mtncloud/cli/commands/rm_command.rb +14 -0
- data/lib/mtncloud/cli/commands/roles.rb +3120 -0
- data/lib/mtncloud/cli/commands/scale_thresholds.rb +103 -0
- data/lib/mtncloud/cli/commands/search_command.rb +184 -0
- data/lib/mtncloud/cli/commands/security_group_rules.rb +230 -0
- data/lib/mtncloud/cli/commands/security_groups.rb +1294 -0
- data/lib/mtncloud/cli/commands/security_package_types.rb +32 -0
- data/lib/mtncloud/cli/commands/security_packages.rb +84 -0
- data/lib/mtncloud/cli/commands/security_scans.rb +107 -0
- data/lib/mtncloud/cli/commands/self_service_command.rb +17 -0
- data/lib/mtncloud/cli/commands/server_devices_command.rb +207 -0
- data/lib/mtncloud/cli/commands/service_catalog_command.rb +1528 -0
- data/lib/mtncloud/cli/commands/service_plans_command.rb +895 -0
- data/lib/mtncloud/cli/commands/set_prompt_command.rb +51 -0
- data/lib/mtncloud/cli/commands/setup.rb +423 -0
- data/lib/mtncloud/cli/commands/shell.rb +717 -0
- data/lib/mtncloud/cli/commands/sleep_command.rb +43 -0
- data/lib/mtncloud/cli/commands/snapshots.rb +156 -0
- data/lib/mtncloud/cli/commands/source_command.rb +30 -0
- data/lib/mtncloud/cli/commands/ssl_verification_command.rb +47 -0
- data/lib/mtncloud/cli/commands/storage_datastores.rb +457 -0
- data/lib/mtncloud/cli/commands/storage_providers_command.rb +1401 -0
- data/lib/mtncloud/cli/commands/storage_server_types.rb +45 -0
- data/lib/mtncloud/cli/commands/storage_servers.rb +116 -0
- data/lib/mtncloud/cli/commands/storage_volume_types.rb +45 -0
- data/lib/mtncloud/cli/commands/storage_volumes.rb +236 -0
- data/lib/mtncloud/cli/commands/subnets_command.rb +819 -0
- data/lib/mtncloud/cli/commands/support_bundles_command.rb +606 -0
- data/lib/mtncloud/cli/commands/systems.rb +1203 -0
- data/lib/mtncloud/cli/commands/tasks.rb +1391 -0
- data/lib/mtncloud/cli/commands/tee_command.rb +14 -0
- data/lib/mtncloud/cli/commands/tenants_command.rb +315 -0
- data/lib/mtncloud/cli/commands/tokens_command.rb +391 -0
- data/lib/mtncloud/cli/commands/update_command.rb +46 -0
- data/lib/mtncloud/cli/commands/usage_command.rb +203 -0
- data/lib/mtncloud/cli/commands/user_groups_command.rb +512 -0
- data/lib/mtncloud/cli/commands/user_settings_command.rb +849 -0
- data/lib/mtncloud/cli/commands/user_sources_command.rb +1065 -0
- data/lib/mtncloud/cli/commands/users.rb +897 -0
- data/lib/mtncloud/cli/commands/vdi_allocations_command.rb +159 -0
- data/lib/mtncloud/cli/commands/vdi_apps_command.rb +317 -0
- data/lib/mtncloud/cli/commands/vdi_command.rb +359 -0
- data/lib/mtncloud/cli/commands/vdi_gateways_command.rb +290 -0
- data/lib/mtncloud/cli/commands/vdi_pools_command.rb +574 -0
- data/lib/mtncloud/cli/commands/version_command.rb +38 -0
- data/lib/mtncloud/cli/commands/view.rb +107 -0
- data/lib/mtncloud/cli/commands/virtual_images.rb +1362 -0
- data/lib/mtncloud/cli/commands/virtual_switches_command.rb +336 -0
- data/lib/mtncloud/cli/commands/whitelabel_settings_command.rb +653 -0
- data/lib/mtncloud/cli/commands/whoami.rb +323 -0
- data/lib/mtncloud/cli/commands/wiki_command.rb +448 -0
- data/lib/mtncloud/cli/commands/workflows.rb +1022 -0
- data/lib/mtncloud/cli/credentials.rb +482 -0
- data/lib/mtncloud/cli/dot_file.rb +180 -0
- data/lib/mtncloud/cli/error_handler.rb +307 -0
- data/lib/mtncloud/cli/errors.rb +53 -0
- data/lib/mtncloud/cli/expression_parser.rb +153 -0
- data/lib/mtncloud/cli/mixins/accounts_helper.rb +484 -0
- data/lib/mtncloud/cli/mixins/affinity_helper.rb +118 -0
- data/lib/mtncloud/cli/mixins/backups_helper.rb +200 -0
- data/lib/mtncloud/cli/mixins/deployments_helper.rb +163 -0
- data/lib/mtncloud/cli/mixins/execution_request_helper.rb +50 -0
- data/lib/mtncloud/cli/mixins/infrastructure_helper.rb +966 -0
- data/lib/mtncloud/cli/mixins/jobs_helper.rb +202 -0
- data/lib/mtncloud/cli/mixins/library_helper.rb +539 -0
- data/lib/mtncloud/cli/mixins/load_balancers_helper.rb +176 -0
- data/lib/mtncloud/cli/mixins/logs_helper.rb +131 -0
- data/lib/mtncloud/cli/mixins/monitoring_helper.rb +876 -0
- data/lib/mtncloud/cli/mixins/networks_helper.rb +62 -0
- data/lib/mtncloud/cli/mixins/operations_helper.rb +41 -0
- data/lib/mtncloud/cli/mixins/option_source_helper.rb +254 -0
- data/lib/mtncloud/cli/mixins/print_helper.rb +1631 -0
- data/lib/mtncloud/cli/mixins/processes_helper.rb +286 -0
- data/lib/mtncloud/cli/mixins/prompt_helper.rb +136 -0
- data/lib/mtncloud/cli/mixins/provisioning_helper.rb +2963 -0
- data/lib/mtncloud/cli/mixins/remote_helper.rb +139 -0
- data/lib/mtncloud/cli/mixins/rest_command.rb +994 -0
- data/lib/mtncloud/cli/mixins/secondary_rest_command.rb +700 -0
- data/lib/mtncloud/cli/mixins/storage_servers_helper.rb +93 -0
- data/lib/mtncloud/cli/mixins/storage_volumes_helper.rb +76 -0
- data/lib/mtncloud/cli/mixins/vdi_helper.rb +246 -0
- data/lib/mtncloud/cli/mixins/whoami_helper.rb +73 -0
- data/lib/mtncloud/cli/option_parser.rb +127 -0
- data/lib/mtncloud/cli/option_types.rb +1622 -0
- data/lib/mtncloud/cli/version.rb +6 -0
- data/lib/mtncloud/cli.rb +105 -0
- data/lib/mtncloud/currency.rb +184 -0
- data/lib/mtncloud/ext/hash.rb +109 -0
- data/lib/mtncloud/ext/nil_class.rb +5 -0
- data/lib/mtncloud/ext/rest_client.rb +37 -0
- data/lib/mtncloud/ext/string.rb +66 -0
- data/lib/mtncloud/formatters.rb +511 -0
- data/lib/mtncloud/logging.rb +185 -0
- data/lib/mtncloud/morpkg.rb +119 -0
- data/lib/mtncloud/rest_client.rb +104 -0
- data/lib/mtncloud/routes.rb +304 -0
- data/lib/mtncloud/terminal.rb +528 -0
- data/lib/mtncloud/util.rb +29 -0
- data/lib/mtncloud.rb +5 -0
- data/mtncloud-cli.gemspec +38 -0
- data/test/api/affinity_groups_interface_test.rb +43 -0
- data/test/api/clients_interface_test.rb +23 -0
- data/test/api/clouds_interface_test.rb +67 -0
- data/test/api/containers_interface_test.rb +68 -0
- data/test/api/host_vm_groups_interface_test.rb +35 -0
- data/test/api/instances_interface_test.rb +22 -0
- data/test/api/network_routers_interface_test.rb +22 -0
- data/test/api/systems_interface_test.rb +26 -0
- data/test/api/whoami_interface_test.rb +14 -0
- data/test/branding_test.rb +160 -0
- data/test/cli/access_token_test.rb +36 -0
- data/test/cli/affinity_groups_cloud_cluster_scope_test.rb +270 -0
- data/test/cli/affinity_groups_cluster_scope_test.rb +171 -0
- data/test/cli/affinity_groups_test.rb +57 -0
- data/test/cli/affinity_groups_violations_scope_test.rb +141 -0
- data/test/cli/affinity_helper_test.rb +367 -0
- data/test/cli/auth_test.rb +88 -0
- data/test/cli/backups_test.rb +212 -0
- data/test/cli/cli_test.rb +48 -0
- data/test/cli/clients_test.rb +45 -0
- data/test/cli/clusters_uuid_test.rb +146 -0
- data/test/cli/containers_test.rb +92 -0
- data/test/cli/distributed_workers_test.rb +68 -0
- data/test/cli/help_test.rb +25 -0
- data/test/cli/host_vm_groups_cluster_scope_test.rb +187 -0
- data/test/cli/host_vm_groups_test.rb +63 -0
- data/test/cli/infrastructure_helper_cluster_resolver_test.rb +250 -0
- data/test/cli/instances_test.rb +37 -0
- data/test/cli/man_test.rb +14 -0
- data/test/cli/migrations_test.rb +39 -0
- data/test/cli/network_routers_test.rb +65 -0
- data/test/cli/remote_test.rb +89 -0
- data/test/cli/roles_test.rb +47 -0
- data/test/cli/shell_test.rb +81 -0
- data/test/cli/storage_volumes_test.rb +79 -0
- data/test/cli/systems_test.rb +206 -0
- data/test/cli/version_test.rb +23 -0
- data/test/cli/view_test.rb +55 -0
- data/test/cli/whoami_test.rb +17 -0
- data/test/mtncloud_test.rb +16 -0
- data/test/test_case.rb +342 -0
- data/test/test_config.rb +137 -0
- data/test/test_data_helper.rb +97 -0
- metadata +807 -0
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
require 'mtncloud/cli/cli_command'
|
|
2
|
+
require 'date' #needed?
|
|
3
|
+
|
|
4
|
+
class MtnCloud::Cli::GuidanceCommand
|
|
5
|
+
include MtnCloud::Cli::CliCommand
|
|
6
|
+
|
|
7
|
+
set_command_name :'guidance'
|
|
8
|
+
|
|
9
|
+
register_subcommands :list, :get, :stats, :execute, :ignore, :types
|
|
10
|
+
|
|
11
|
+
def connect(opts)
|
|
12
|
+
@api_client = establish_remote_appliance_connection(opts)
|
|
13
|
+
@guidance_interface = @api_client.guidance
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def handle(args)
|
|
17
|
+
handle_subcommand(args)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def stats(args)
|
|
21
|
+
options = {}
|
|
22
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
23
|
+
opts.banner = subcommand_usage()
|
|
24
|
+
build_standard_get_options(opts, options)
|
|
25
|
+
opts.footer = "Get guidance stats."
|
|
26
|
+
end
|
|
27
|
+
optparse.parse!(args)
|
|
28
|
+
connect(options)
|
|
29
|
+
if args.count != 0
|
|
30
|
+
raise_command_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args}\n#{optparse}"
|
|
31
|
+
return 1
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
begin
|
|
35
|
+
@guidance_interface.setopts(options)
|
|
36
|
+
|
|
37
|
+
if options[:dry_run]
|
|
38
|
+
print_dry_run @guidance_interface.dry.stats()
|
|
39
|
+
return
|
|
40
|
+
end
|
|
41
|
+
json_response = @guidance_interface.stats()
|
|
42
|
+
if options[:json]
|
|
43
|
+
puts as_json(json_response, options, "stats")
|
|
44
|
+
return 0
|
|
45
|
+
elsif options[:yaml]
|
|
46
|
+
puts as_yaml(json_response, options, "stats")
|
|
47
|
+
return 0
|
|
48
|
+
elsif options[:csv]
|
|
49
|
+
puts records_as_csv([json_response['stats']], options)
|
|
50
|
+
return 0
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
stats = json_response['stats']
|
|
54
|
+
|
|
55
|
+
print_h1 "Guidance Stats"
|
|
56
|
+
print cyan
|
|
57
|
+
description_cols = {
|
|
58
|
+
"Total Actions" => lambda {|it| it['total'] },
|
|
59
|
+
"Savings Available" => lambda {|it| format_money(it['savings']['amount'], it['savings']['currency'], {:minus_color => red}) }
|
|
60
|
+
}
|
|
61
|
+
print_description_list(description_cols, stats)
|
|
62
|
+
|
|
63
|
+
print_h2 "Severity Totals"
|
|
64
|
+
{'info'=>white, 'low'=>yellow, 'warning'=>bright_yellow, 'critical'=>red}.each do |level, color|
|
|
65
|
+
print "#{cyan}#{level.capitalize}".rjust(14, ' ') + ": " + stats['severity'][level].to_s.ljust(10, ' ')
|
|
66
|
+
# print "#{cyan} #{guidance['stats']['severity'][level]} of #{guidance['stats']['severity'].collect{|k, v| v}.reduce(:+)}".ljust(20, ' ')
|
|
67
|
+
println generate_usage_bar(stats['severity'][level], stats['severity'].collect{|k, v| v}.reduce(:+), {:max_bars => 20, :bar_color => color})
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# "size": 13, "shutdown": 15, "move": 0, "schedule"
|
|
71
|
+
print_h2 "Action Totals"
|
|
72
|
+
{'size'=>green, 'move'=>magenta, 'shutdown'=>red, 'schedule'=>bright_yellow}.each do |level, color|
|
|
73
|
+
print "#{cyan}#{level.capitalize}".rjust(14, ' ') + ": " + stats['type'][level].to_s.ljust(10, ' ')
|
|
74
|
+
println generate_usage_bar(stats['type'][level], stats['type'].collect{|k, v| v}.reduce(:+), {:max_bars => 20, :bar_color => color})
|
|
75
|
+
end
|
|
76
|
+
print reset, "\n"
|
|
77
|
+
return 0
|
|
78
|
+
rescue RestClient::Exception => e
|
|
79
|
+
print_rest_exception(e, options)
|
|
80
|
+
return 1
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def types(args)
|
|
85
|
+
options = {}
|
|
86
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
87
|
+
opts.banner = subcommand_usage()
|
|
88
|
+
build_standard_get_options(opts, options)
|
|
89
|
+
opts.footer = "List discovery types."
|
|
90
|
+
end
|
|
91
|
+
optparse.parse!(args)
|
|
92
|
+
connect(options)
|
|
93
|
+
if args.count != 0
|
|
94
|
+
raise_command_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args}\n#{optparse}"
|
|
95
|
+
return 1
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
begin
|
|
99
|
+
@guidance_interface.setopts(options)
|
|
100
|
+
|
|
101
|
+
if options[:dry_run]
|
|
102
|
+
print_dry_run @guidance_interface.dry.types()
|
|
103
|
+
return
|
|
104
|
+
end
|
|
105
|
+
json_response = @guidance_interface.types()
|
|
106
|
+
if options[:json]
|
|
107
|
+
puts as_json(json_response, options, "types")
|
|
108
|
+
return 0
|
|
109
|
+
elsif options[:yaml]
|
|
110
|
+
puts as_yaml(json_response, options, "types")
|
|
111
|
+
return 0
|
|
112
|
+
elsif options[:csv]
|
|
113
|
+
puts records_as_csv([json_response['types']], options)
|
|
114
|
+
return 0
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
types = json_response['types']
|
|
118
|
+
|
|
119
|
+
print_h1 "Discovery Types"
|
|
120
|
+
print cyan
|
|
121
|
+
|
|
122
|
+
cols = [
|
|
123
|
+
{"ID" => lambda {|it| it['id']}},
|
|
124
|
+
{"NAME" => lambda {|it| it['name']}},
|
|
125
|
+
{"TITLE" => lambda {|it| it['title']}},
|
|
126
|
+
{"CODE" => lambda {|it| it['code']}}
|
|
127
|
+
];
|
|
128
|
+
print as_pretty_table(types, cols, options)
|
|
129
|
+
print reset, "\n"
|
|
130
|
+
return 0
|
|
131
|
+
rescue RestClient::Exception => e
|
|
132
|
+
print_rest_exception(e, options)
|
|
133
|
+
return 1
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def list(args)
|
|
138
|
+
options = {}
|
|
139
|
+
params = {}
|
|
140
|
+
ref_ids = []
|
|
141
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
142
|
+
opts.banner = subcommand_usage()
|
|
143
|
+
opts.on('-l', '--severity LEVEL', String, "Filter by Severity Level: info, low, warning, critical" ) do |val|
|
|
144
|
+
params['severity'] = val
|
|
145
|
+
end
|
|
146
|
+
opts.on('-t', '--type TYPE', String, "Filter by Type") do |val|
|
|
147
|
+
options[:type] = val
|
|
148
|
+
end
|
|
149
|
+
opts.on('-i', '--ignored', String, "Include Ignored Discoveries") do |val|
|
|
150
|
+
params['state'] = 'ignored'
|
|
151
|
+
end
|
|
152
|
+
opts.on('-p', '--processed', String, "Include Processed Discoveries") do |val|
|
|
153
|
+
params['state'] = 'processed'
|
|
154
|
+
end
|
|
155
|
+
opts.on('-a', '--any', String, "Include Processed and Ignored Discoveries") do |val|
|
|
156
|
+
params['state'] = 'any'
|
|
157
|
+
end
|
|
158
|
+
build_standard_list_options(opts, options)
|
|
159
|
+
opts.footer = "List discoveries"
|
|
160
|
+
end
|
|
161
|
+
optparse.parse!(args)
|
|
162
|
+
connect(options)
|
|
163
|
+
if args.count > 0
|
|
164
|
+
print_error MtnCloud::Terminal.angry_prompt
|
|
165
|
+
puts_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args.join(', ')}\n#{optparse}"
|
|
166
|
+
return 1
|
|
167
|
+
end
|
|
168
|
+
begin
|
|
169
|
+
if options[:type]
|
|
170
|
+
type = find_discovery_type(options[:type])
|
|
171
|
+
|
|
172
|
+
if !type
|
|
173
|
+
print_red_alert "Type #{options[:type]} not found"
|
|
174
|
+
exit 1
|
|
175
|
+
end
|
|
176
|
+
params['code'] = type['code']
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
params.merge!(parse_list_options(options))
|
|
180
|
+
@guidance_interface.setopts(options)
|
|
181
|
+
if options[:dry_run]
|
|
182
|
+
print_dry_run @guidance_interface.dry.list(params)
|
|
183
|
+
return
|
|
184
|
+
end
|
|
185
|
+
json_response = @guidance_interface.list(params)
|
|
186
|
+
render_result = render_with_format(json_response, options, 'discoveries')
|
|
187
|
+
return 0 if render_result
|
|
188
|
+
|
|
189
|
+
discoveries = json_response['discoveries']
|
|
190
|
+
|
|
191
|
+
subtitles = params['state'] ? ["state: #{params['state']}"] : []
|
|
192
|
+
subtitles += parse_list_subtitles(options)
|
|
193
|
+
print_h1 "Discoveries", subtitles
|
|
194
|
+
|
|
195
|
+
if discoveries.empty?
|
|
196
|
+
print cyan,"No discoveries found.",reset,"\n"
|
|
197
|
+
else
|
|
198
|
+
cols = [
|
|
199
|
+
{"ID" => lambda {|it| it['id']}},
|
|
200
|
+
{"SEVERITY" => lambda {|it| (it['severity'] || '').capitalize}},
|
|
201
|
+
{"TYPE/METRIC" => lambda {|it| it['type'] ? "#{it['type']['name']}: #{it['actionCategory'].capitalize || ''}" : ''}},
|
|
202
|
+
{"ACTION" => lambda {|it| it['actionType'].capitalize}},
|
|
203
|
+
{"CLOUD" => lambda {|it| it['zone'] ? it['zone']['name'] : ''}},
|
|
204
|
+
{"RESOURCE" => lambda {|it| it['refName']}},
|
|
205
|
+
{"SAVINGS" => lambda {|it| format_money(it['savings']['amount'], it['savings']['currency'], {:minus_color => red})}},
|
|
206
|
+
{"DATE" => lambda {|it| format_local_date(it['dateCreated'], {:format => DEFAULT_TIME_FORMAT})}}
|
|
207
|
+
];
|
|
208
|
+
if params['state'] == 'any'
|
|
209
|
+
cols << {"STATE" => lambda {|it| (it['state'] == 'processed' ? green : (it['state'] == 'ignored' ? white : '')) + it['state'].capitalize + cyan}}
|
|
210
|
+
end
|
|
211
|
+
print as_pretty_table(discoveries, cols, options)
|
|
212
|
+
print_results_pagination(json_response, {:label => "discovery", :n_label => "discoveries"})
|
|
213
|
+
end
|
|
214
|
+
print reset,"\n"
|
|
215
|
+
rescue RestClient::Exception => e
|
|
216
|
+
print_rest_exception(e, options)
|
|
217
|
+
return 1
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def get(args)
|
|
222
|
+
options = {}
|
|
223
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
224
|
+
opts.banner = subcommand_usage("[id]")
|
|
225
|
+
build_standard_get_options(opts, options)
|
|
226
|
+
opts.footer = "Get details about a specific discovery."
|
|
227
|
+
end
|
|
228
|
+
optparse.parse!(args)
|
|
229
|
+
if args.count < 1
|
|
230
|
+
puts optparse
|
|
231
|
+
return 1
|
|
232
|
+
end
|
|
233
|
+
connect(options)
|
|
234
|
+
id_list = parse_id_list(args)
|
|
235
|
+
return run_command_for_each_arg(id_list) do |arg|
|
|
236
|
+
_get(arg, options)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def _get(id, options)
|
|
241
|
+
params = {}
|
|
242
|
+
begin
|
|
243
|
+
@guidance_interface.setopts(options)
|
|
244
|
+
if options[:dry_run]
|
|
245
|
+
print_dry_run @guidance_interface.dry.get(id, params)
|
|
246
|
+
return
|
|
247
|
+
end
|
|
248
|
+
json_response = @guidance_interface.get(id, params)
|
|
249
|
+
discovery = json_response['discovery']
|
|
250
|
+
render_result = render_with_format(json_response, options, 'discovery')
|
|
251
|
+
return 0 if render_result
|
|
252
|
+
|
|
253
|
+
print_h1 "Discovery Info"
|
|
254
|
+
print cyan
|
|
255
|
+
|
|
256
|
+
description_cols = {
|
|
257
|
+
"ID" => lambda {|it| it['id']},
|
|
258
|
+
#"Ref ID" => lambda {|it| it['refId'] },
|
|
259
|
+
"Resource" => lambda {|it| it['refName'] },
|
|
260
|
+
"Action" => lambda {|it| action_title(it['type'])},
|
|
261
|
+
"Date" => lambda {|it| format_local_date(it['dateCreated'], {:format => DEFAULT_TIME_FORMAT})},
|
|
262
|
+
"State" => lambda {|it| (it['state'] == 'processed' ? green : (it['state'] == 'ignored' ? white : cyan)) + it['state'].capitalize + cyan}
|
|
263
|
+
}
|
|
264
|
+
description_cols['Cloud'] = lambda {|it| it['zone']['name']} if discovery['refType'] == 'computeServer'
|
|
265
|
+
description_cols.merge!({
|
|
266
|
+
"Action Category" => lambda {|it| it['actionCategory'].capitalize},
|
|
267
|
+
"Action Type" => lambda {|it| it['actionType'].capitalize},
|
|
268
|
+
"Savings" => lambda {|it| format_money(it['savings']['amount'], it['savings']['currency']) + '/month'}
|
|
269
|
+
})
|
|
270
|
+
print_description_list(description_cols, discovery)
|
|
271
|
+
|
|
272
|
+
if discovery['resource']
|
|
273
|
+
print_h2 "Resource Info"
|
|
274
|
+
|
|
275
|
+
if discovery['refType'] == 'computeServer'
|
|
276
|
+
cols = [
|
|
277
|
+
{"Power State" => lambda {|it| format_status(it['resource']['powerState'])}},
|
|
278
|
+
{"Status" => lambda {|it| (format_status(it['resource']['status']))}},
|
|
279
|
+
{"Type" => lambda {|it| it['resource']['computeServerType']['name']}},
|
|
280
|
+
{"Platform" => lambda {|it| ((it['resource']['serverOs'] ? it['resource']['serverOs']['platform'] : it['resource']['osType']) || 'unknown').capitalize}},
|
|
281
|
+
{"Cloud Type" => lambda {|it| it['zone']['zoneType']['name']}}
|
|
282
|
+
]
|
|
283
|
+
elsif discovery['refType'] == 'computeZone'
|
|
284
|
+
cols = [
|
|
285
|
+
{"Status" => lambda {|it| format_status(it['resource']['status'])}},
|
|
286
|
+
{"Cloud Type" => lambda {|it| it['zone']['zoneType']['name']}}
|
|
287
|
+
]
|
|
288
|
+
end
|
|
289
|
+
print as_pretty_table(discovery, cols, options)
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
max_bars = 20
|
|
293
|
+
|
|
294
|
+
if discovery['type']['code'] == 'size'
|
|
295
|
+
print_h2 "Usage"
|
|
296
|
+
cols = [
|
|
297
|
+
{"Plan" => lambda {|it| it['planBeforeAction'] ? it['planBeforeAction']['name'] : '--'}},
|
|
298
|
+
{"Compute Usage" => lambda {|it|
|
|
299
|
+
usage = (it['config'] ? it['config']['cpuUsageAvg'] || 0 : 0)
|
|
300
|
+
"#{format_percent(usage)} of 100%".ljust(25, ' ') + generate_usage_bar(usage.round(2), 100, {:max_bars => max_bars}) + cyan
|
|
301
|
+
}},
|
|
302
|
+
{"Memory Usage" => lambda {|it|
|
|
303
|
+
max = (it['resource'] || {})['maxMemory'] || (it['planBeforeAction'] || {})['maxMemory']
|
|
304
|
+
usage = max > 0 ? (it['config']['usedMemoryAvg'] || 0).to_f / max * 100.0 : 0
|
|
305
|
+
usage = 200.0 if usage > 200
|
|
306
|
+
"#{format_bytes((it['config'] || {})['usedMemoryAvg'] || 0, 'auto', 1)} of #{format_bytes(max, 'auto', 1)}".ljust(25, ' ') + generate_usage_bar(usage, 100, {:max_bars => max_bars}) + cyan
|
|
307
|
+
}}
|
|
308
|
+
]
|
|
309
|
+
print_description_list(cols, discovery, options.merge({:wrap => false}))
|
|
310
|
+
print_h2 "After Resize"
|
|
311
|
+
|
|
312
|
+
if discovery['planAfterAction'] && discovery['planAfterAction']['id'] != (discovery['planBeforeAction'] || {})['id']
|
|
313
|
+
cols = [
|
|
314
|
+
{"Plan" => lambda {|it| it['planAfterAction'] ? it['planAfterAction']['name'] : '--'}},
|
|
315
|
+
{"Compute Usage" => lambda {|it|
|
|
316
|
+
usage = ((it['planAfterAction'] || {})['maxCores'] || 0) > 0 ? (((it['resource'] || {})['maxCores'] || (it['planBeforeAction'] || {})['maxCores']) || 0).to_f / it['planAfterAction']['maxCores'] * (it['config']['cpuUsageAvg'] || 0) : 0
|
|
317
|
+
"#{format_percent(usage)} of 100%".ljust(25, ' ') + generate_usage_bar(usage.round(2), 100, {:max_bars => max_bars}) + cyan
|
|
318
|
+
}},
|
|
319
|
+
{"Memory Usage" => lambda {|it|
|
|
320
|
+
max = (it['planAfterAction'] || {})['maxMemory'] || 0
|
|
321
|
+
usage = max > 0 ? ((it['config'] || {})['usedMemoryAvg'] || 0).to_f / it['planAfterAction']['maxMemory'] * 100.0 : 0
|
|
322
|
+
usage = 200.0 if usage > 200
|
|
323
|
+
"#{format_bytes((it['config'] || {})['usedMemoryAvg'] || 0, 'auto', 1)} of #{format_bytes(max, 'auto', 1)}".ljust(25, ' ') + generate_usage_bar(usage, 100, {:max_bars => max_bars}) + cyan
|
|
324
|
+
}}
|
|
325
|
+
]
|
|
326
|
+
else
|
|
327
|
+
if discovery['actionValueType'] == 'memory'
|
|
328
|
+
cols = [
|
|
329
|
+
{"Memory" => lambda {|it| format_bytes(it['actionValue'].to_i, 'auto')}},
|
|
330
|
+
{"Compute Usage" => lambda {|it|
|
|
331
|
+
usage = (it['config'] ? it['config']['cpuUsageAvg'] || 0 : 0).round(2)
|
|
332
|
+
"#{format_percent(usage)} of 100%".ljust(25, ' ') + generate_usage_bar(usage, 100, {:max_bars => max_bars}) + cyan
|
|
333
|
+
}},
|
|
334
|
+
{"Memory Usage" => lambda {|it|
|
|
335
|
+
max = (it['actionValue'] || 0).to_f
|
|
336
|
+
usage = max > 0 ? ((it['config'] || {})['usedMemoryAvg'] || 0) / max * 100.0 : 0
|
|
337
|
+
usage = 200.0 if usage > 200
|
|
338
|
+
"#{format_bytes((it['config'] || {})['usedMemoryAvg'] || 0, 'auto', 1)} of #{format_bytes(max, 'auto', 1)}".ljust(25, ' ') + generate_usage_bar(usage, 100, {:max_bars => max_bars}) + cyan
|
|
339
|
+
}}
|
|
340
|
+
]
|
|
341
|
+
elsif discovery['actionValueType'] == 'cpu'
|
|
342
|
+
cols = [
|
|
343
|
+
{"Cores" => lambda {|it| it['actionValue']}},
|
|
344
|
+
{"Compute Usage" => lambda {|it|
|
|
345
|
+
cores_before = it['beforeValue'] || (it['resource'] || {})['maxCores'] || (it['planBeforeAction'] || {})['maxCores'] || 0
|
|
346
|
+
usage = (it['actionValue'] || 0).to_f > 0 ? cores_before / it['actionValue'].to_f * ((it['config'] || {})['cpuUsageAvg'] || 0) : 0
|
|
347
|
+
"#{format_percent(usage)} of 100%".ljust(25, ' ') + generate_usage_bar(usage.round(2), 100, {:max_bars => max_bars}) + cyan
|
|
348
|
+
}},
|
|
349
|
+
{"Memory Usage" => lambda {|it|
|
|
350
|
+
max = (it['resource'] || {})['maxMemory'] || (it['planAfterAction'] || {})['maxMemory']
|
|
351
|
+
usage = max > 0 ? ((it['config'] || {})['usedMemoryAvg'] || 0) / max.to_f * 100.0 : 0
|
|
352
|
+
usage = 200.0 if usage > 200
|
|
353
|
+
"#{format_bytes((it['config'] || {})['usedMemoryAvg'] || 0, 'auto', 1)} of #{format_bytes(max, 'auto', 1)}".ljust(25, ' ') + generate_usage_bar(usage, 100, {:max_bars => max_bars}) + cyan
|
|
354
|
+
}}
|
|
355
|
+
]
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
print_description_list(cols, discovery, options.merge({:wrap => false}))
|
|
359
|
+
elsif discovery['type']['code'] == 'shutdown'
|
|
360
|
+
print_h2 "Usage"
|
|
361
|
+
cols = [
|
|
362
|
+
{"Plan" => lambda {|it| it['planBeforeAction'] ? it['planBeforeAction']['name'] : '--'}},
|
|
363
|
+
{"Compute Usage" => lambda {|it|
|
|
364
|
+
usage = (it['config'] ? it['config']['cpuUsageAvg'] || 0 : 0).round(2).to_s
|
|
365
|
+
"#{format_percent(usage)} of 100%".ljust(25, ' ') + generate_usage_bar(usage, 100, {:max_bars => max_bars}) + cyan
|
|
366
|
+
}},
|
|
367
|
+
{"Network Usage" => lambda {|it|
|
|
368
|
+
max = 1024 * 1024 * 1024
|
|
369
|
+
usage = (it['config']['networkBandwidthAvg'] || 0) > 0 ? ((it['config']['networkBandwidthAvg'] || 0) / max.to_f) * 100 : 0
|
|
370
|
+
"#{format_bytes((it['config']['networkBandwidthAvg'] || 0), 'auto', 1)} of #{format_bytes(max, 'auto', 1)}".ljust(25, ' ') + generate_usage_bar( usage, 100, {:max_bars => max_bars}) + cyan
|
|
371
|
+
}}
|
|
372
|
+
]
|
|
373
|
+
|
|
374
|
+
print_description_list(cols, discovery, options.merge({:wrap => false}))
|
|
375
|
+
|
|
376
|
+
print_h2 "After Shutdown"
|
|
377
|
+
cols = [
|
|
378
|
+
{"Plan" => lambda {|it| it['planAfterAction'] ? it['planAfterAction']['name'] : '--'}},
|
|
379
|
+
{"Monthly Savings" => lambda {|it| format_money(it['savings']['amount'], it['savings']['currency'], {:minus_color => red})}}
|
|
380
|
+
]
|
|
381
|
+
print_description_list(cols, discovery, options)
|
|
382
|
+
elsif discovery['type']['code'] == 'reservations'
|
|
383
|
+
print_h2 "Current Cost"
|
|
384
|
+
cols = [
|
|
385
|
+
{"Current Cost" => lambda {|it| format_money((it['onDemandCost'] || 0) + (it['reservedCost'] || 0), discovery['savings']['currency'], {:minus_color => red})}},
|
|
386
|
+
{"On-Demand Cost" => lambda {|it| format_money((it['onDemandCost'] || 0), discovery['savings']['currency'], {:minus_color => red})}},
|
|
387
|
+
#{"Proposed Cost" => lambda {|it| format_money((it['recommendedCost'] || 0), discovery['savings']['currency'], {:minus_color => red})}}
|
|
388
|
+
]
|
|
389
|
+
|
|
390
|
+
print_description_list(cols, discovery['config']['summary'], options)
|
|
391
|
+
|
|
392
|
+
print_h2 "After Reservations"
|
|
393
|
+
cols = [
|
|
394
|
+
{"Proposed Cost" => lambda {|it| format_money((it['recommendedCost'] || 0), discovery['savings']['currency'], {:minus_color => red})}},
|
|
395
|
+
{"Monthly Savings" => lambda {|it| format_money(discovery['savings']['amount'], discovery['savings']['currency'], {:minus_color => red})}},
|
|
396
|
+
{"Savings Percent" => lambda {|it| format_percent(it['totalSavingsPercent'] * 100.0)}}
|
|
397
|
+
]
|
|
398
|
+
print_description_list(cols, discovery['config']['summary'], options)
|
|
399
|
+
|
|
400
|
+
cols = [
|
|
401
|
+
{"Name" => lambda {|it| it['name']}},
|
|
402
|
+
{"Region" => lambda {|it| it['region']}},
|
|
403
|
+
{"Term" => lambda {|it| it['term']}},
|
|
404
|
+
{"Current Cost" => lambda {|it| format_money(it['onDemandCost'], discovery['savings']['currency'], {:minus_color => red})}},
|
|
405
|
+
{"Quantity" => lambda {|it| it['recommendedCount']}},
|
|
406
|
+
{"Proposed Cost" => lambda {|it| format_money(it['recommendedCost'], discovery['savings']['currency'], {:minus_color => red})}},
|
|
407
|
+
{"Savings" => lambda {|it| format_money(it['totalSavings'], discovery['savings']['currency'], {:minus_color => red})}}
|
|
408
|
+
]
|
|
409
|
+
print_h2 "Details"
|
|
410
|
+
print as_pretty_table(discovery['config']['detailList'], cols, options)
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
print reset,"\n"
|
|
414
|
+
return 0
|
|
415
|
+
rescue RestClient::Exception => e
|
|
416
|
+
print_rest_exception(e, options)
|
|
417
|
+
return 1
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
def execute(args)
|
|
422
|
+
options = {}
|
|
423
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
424
|
+
opts.banner = subcommand_usage("[id]")
|
|
425
|
+
build_standard_remove_options(opts, options)
|
|
426
|
+
opts.footer = "Get details about a specific discovery."
|
|
427
|
+
end
|
|
428
|
+
optparse.parse!(args)
|
|
429
|
+
if args.count < 1
|
|
430
|
+
puts optparse
|
|
431
|
+
return 1
|
|
432
|
+
end
|
|
433
|
+
connect(options)
|
|
434
|
+
_resolve_action(args[0], options)
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
def ignore(args)
|
|
438
|
+
options = {}
|
|
439
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
440
|
+
opts.banner = subcommand_usage("[id]")
|
|
441
|
+
build_standard_remove_options(opts, options)
|
|
442
|
+
opts.footer = "Ignore discovery."
|
|
443
|
+
end
|
|
444
|
+
optparse.parse!(args)
|
|
445
|
+
if args.count < 1
|
|
446
|
+
puts optparse
|
|
447
|
+
return 1
|
|
448
|
+
end
|
|
449
|
+
connect(options)
|
|
450
|
+
_resolve_action(args[0], options, false)
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
private
|
|
454
|
+
|
|
455
|
+
def _resolve_action(id, options, is_exec=true)
|
|
456
|
+
begin
|
|
457
|
+
discovery = find_discovery(id)
|
|
458
|
+
|
|
459
|
+
if !discovery
|
|
460
|
+
print_red_alert "Discovery #{id} not found"
|
|
461
|
+
exit 1
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
if discovery['state'] != 'open'
|
|
465
|
+
print_green_success "#{discovery['actionTitle'].capitalize} action for #{discovery['refName']} already #{discovery['state']}."
|
|
466
|
+
return 0
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
unless options[:yes] || ::MtnCloud::Cli::OptionTypes::confirm("Are you sure you would like to #{is_exec ? 'execute' : 'ignore'} the #{discovery['actionTitle'].capitalize} action for #{discovery['refName']}?", options)
|
|
470
|
+
return 9, "aborted command"
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
@guidance_interface.setopts(options)
|
|
474
|
+
if options[:dry_run]
|
|
475
|
+
print_dry_run (is_exec ? @guidance_interface.dry.exec(discovery['id']) : @guidance_interface.dry.ignore(discovery['id']))
|
|
476
|
+
return
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
json_response = (is_exec ? @guidance_interface.exec(discovery['id']) : @guidance_interface.ignore(discovery['id']))
|
|
480
|
+
|
|
481
|
+
if options[:json]
|
|
482
|
+
puts as_json(json_response, options)
|
|
483
|
+
elsif !options[:quiet]
|
|
484
|
+
if json_response['success']
|
|
485
|
+
print_green_success "Discovery successfully #{is_exec ? 'queued' : 'ignored'}"
|
|
486
|
+
else
|
|
487
|
+
print_red_alert "Error #{is_exec ? 'executing' : 'ignoring'} the #{discovery['actionTitle'].capitalize} action: #{json_response['msg'] || json_response['errors']}"
|
|
488
|
+
end
|
|
489
|
+
end
|
|
490
|
+
return 0
|
|
491
|
+
rescue RestClient::Exception => e
|
|
492
|
+
print_rest_exception(e, options)
|
|
493
|
+
return 1
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
def find_discovery(id)
|
|
498
|
+
@guidance_interface.get(id)['discovery']
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
def find_discovery_type(id)
|
|
502
|
+
@guidance_interface.types()['types'].find {|it| it['id'].to_s == id.to_s || it['code'] == id || it['name'] == id}
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
def format_status(status)
|
|
506
|
+
color = white
|
|
507
|
+
if ['on', 'ok', 'provisioned', 'success', 'complete'].include? status
|
|
508
|
+
color = green
|
|
509
|
+
elsif ['off', 'failed', 'denied', 'cancelled', 'error'].include? status
|
|
510
|
+
color = red
|
|
511
|
+
elsif ['suspended', 'warning', 'deprovisioning', 'expired'].include? status
|
|
512
|
+
color = yellow
|
|
513
|
+
elsif ['available'].include? status
|
|
514
|
+
color = blue
|
|
515
|
+
end
|
|
516
|
+
"#{color}#{status.capitalize}#{cyan}"
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
def action_title(type)
|
|
520
|
+
{
|
|
521
|
+
'shutdown' => 'Shutdown Resource',
|
|
522
|
+
'size' => 'Resize Resource',
|
|
523
|
+
'hostCapacity' => 'Add Capacity',
|
|
524
|
+
'hostBalancing' => 'Balance Host',
|
|
525
|
+
'datastoreCapacity' => 'Add Capacity',
|
|
526
|
+
'reservations' => 'Reserve Compute'
|
|
527
|
+
}[type['code']] || type['title']
|
|
528
|
+
end
|
|
529
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
require 'mtncloud/cli/cli_command'
|
|
2
|
+
|
|
3
|
+
class MtnCloud::Cli::GuidanceSettings
|
|
4
|
+
include MtnCloud::Cli::CliCommand
|
|
5
|
+
include MtnCloud::Cli::AccountsHelper
|
|
6
|
+
|
|
7
|
+
set_command_name :'guidance-settings'
|
|
8
|
+
set_command_description "View and manage guidance settings"
|
|
9
|
+
register_subcommands :get, :update
|
|
10
|
+
|
|
11
|
+
def connect(opts)
|
|
12
|
+
@api_client = establish_remote_appliance_connection(opts)
|
|
13
|
+
@guidance_settings_interface = @api_client.guidance_settings
|
|
14
|
+
@options_interface = @api_client.options
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def handle(args)
|
|
18
|
+
handle_subcommand(args)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def get(args)
|
|
22
|
+
params = {}
|
|
23
|
+
options = {}
|
|
24
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
25
|
+
opts.banner = subcommand_usage()
|
|
26
|
+
build_standard_get_options(opts, options)
|
|
27
|
+
opts.footer = "Get guidance settings."
|
|
28
|
+
end
|
|
29
|
+
optparse.parse!(args)
|
|
30
|
+
connect(options)
|
|
31
|
+
verify_args!(args:args, optparse:optparse, count:0)
|
|
32
|
+
params.merge!(parse_query_options(options))
|
|
33
|
+
@guidance_settings_interface.setopts(options)
|
|
34
|
+
if options[:dry_run]
|
|
35
|
+
print_dry_run @guidance_settings_interface.dry.get(options)
|
|
36
|
+
return
|
|
37
|
+
end
|
|
38
|
+
json_response = @guidance_settings_interface.get(options)
|
|
39
|
+
render_response(json_response, options, object_key) do
|
|
40
|
+
guidance_settings = json_response[object_key]
|
|
41
|
+
print_h1 "Guidance Settings", options
|
|
42
|
+
print_h2 "Power Settings", options.merge(:border_style => :thin)
|
|
43
|
+
#Power shutdown will be suggested when all of the following baseline thresholds are exceeded for a resource
|
|
44
|
+
print_description_list({
|
|
45
|
+
"Average CPU (%)" => lambda {|it| it['cpuAvgCutoffPower'] }, # #Lower limit for average CPU usage
|
|
46
|
+
"Maximum CPU (%)" => lambda {|it| it['cpuMaxCutoffPower'] }, #Lower limit for peak CPU usage
|
|
47
|
+
"Network threshold (bytes)" => lambda {|it| it['networkCutoffPower'] }, #Lower limit for average network bandwidth
|
|
48
|
+
}, guidance_settings, options)
|
|
49
|
+
#print reset, "\n"
|
|
50
|
+
|
|
51
|
+
print_h2 "CPU Up-size Settings", options.merge(:border_style => :thin)
|
|
52
|
+
#Up-size will be suggested when all of the following baseline thresholds are exceeded for a resource
|
|
53
|
+
print_description_list({
|
|
54
|
+
"Average CPU (%)" => lambda {|it| it['cpuUpAvgStandardCutoffRightSize'] }, #Upper limit for CPU usage
|
|
55
|
+
"Maximum CPU (%)" => lambda {|it| it['cpuUpMaxStandardCutoffRightSize'] }, #Upper limit for peak CPU usage
|
|
56
|
+
}, guidance_settings, options)
|
|
57
|
+
#print reset, "\n"
|
|
58
|
+
|
|
59
|
+
print_h2 "Memory Up-size Settings", options.merge(:border_style => :thin)
|
|
60
|
+
#Up-size is suggested when all of the following baseline thresholds are exceeded for a resource
|
|
61
|
+
print_description_list({
|
|
62
|
+
"Minimum Free Memory (%)" => lambda {|it| it['memoryUpAvgStandardCutoffRightSize'] }, #Lower limit for average free memory usage
|
|
63
|
+
}, guidance_settings, options)
|
|
64
|
+
#print reset, "\n"
|
|
65
|
+
|
|
66
|
+
print_h2 "Memory Down-size Settings", options.merge(:border_style => :thin)
|
|
67
|
+
#Down-size is suggested when all of the following baseline thresholds are exceeded for a resource
|
|
68
|
+
print_description_list({
|
|
69
|
+
#Upper limit for average free memory
|
|
70
|
+
"Average Free Memory (%)" => lambda {|it| it['memoryDownAvgStandardCutoffRightSize'] },
|
|
71
|
+
#Upper limit for peak memory usage
|
|
72
|
+
"Maximum Free Memory (%)" => lambda {|it| it['memoryDownMaxStandardCutoffRightSize'] },
|
|
73
|
+
}, guidance_settings, options)
|
|
74
|
+
print reset, "\n"
|
|
75
|
+
end
|
|
76
|
+
return 0, nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def update(args)
|
|
80
|
+
params = {}
|
|
81
|
+
options = {}
|
|
82
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
83
|
+
opts.banner = opts.banner = subcommand_usage()
|
|
84
|
+
opts.on('--power-cpu-avg PERCENT', String, "Power Shutdown Average CPU (%). Lower limit for average CPU usage") do |val|
|
|
85
|
+
params['cpuAvgCutoffPower'] = val.to_i
|
|
86
|
+
end
|
|
87
|
+
opts.on('--power-cpu-max PERCENT', String, "Power Shutdown Maximum CPU (%). Lower limit for peak CPU usage") do |val|
|
|
88
|
+
params['cpuMaxCutoffPower'] = val.to_i
|
|
89
|
+
end
|
|
90
|
+
opts.on('--power-network BYTES', String, "Power Shutdown Network threshold (bytes). Lower limit for average network bandwidth") do |val|
|
|
91
|
+
params['networkCutoffPower'] = val.to_i
|
|
92
|
+
end
|
|
93
|
+
opts.on('--cpu-up-avg PERCENT', String, "CPU Up-size Average CPU (%). Upper limit for CPU usage") do |val|
|
|
94
|
+
params['cpuUpAvgStandardCutoffRightSize'] = val.to_i
|
|
95
|
+
end
|
|
96
|
+
opts.on('--cpu-up-max PERCENT', String, "CPU Up-size Maximum CPU (%). Upper limit for peak CPU usage") do |val|
|
|
97
|
+
params['cpuUpMaxStandardCutoffRightSize'] = val.to_i
|
|
98
|
+
end
|
|
99
|
+
opts.on('--memory-up-avg PERCENT', String, "Memory Up-size Minimum Free Memory (%). Lower limit for average free memory usage") do |val|
|
|
100
|
+
params['memoryUpAvgStandardCutoffRightSize'] = val.to_i
|
|
101
|
+
end
|
|
102
|
+
opts.on('--memory-down-avg PERCENT', String, "Memory Down-size Maximum Free Memory (%). Upper limit for average free memory") do |val|
|
|
103
|
+
params['memoryDownAvgStandardCutoffRightSize'] = val.to_i
|
|
104
|
+
end
|
|
105
|
+
opts.on('--memory-down-max PERCENT', String, "Memory Down-size Maximum Free Memory (%). Upper limit for peak memory usage") do |val|
|
|
106
|
+
params['memoryDownMaxStandardCutoffRightSize'] = val.to_i
|
|
107
|
+
end
|
|
108
|
+
build_standard_update_options(opts, options)
|
|
109
|
+
opts.footer = "Update guidance settings."
|
|
110
|
+
end
|
|
111
|
+
optparse.parse!(args)
|
|
112
|
+
connect(options)
|
|
113
|
+
verify_args!(args:args, optparse:optparse, count:0)
|
|
114
|
+
payload = parse_payload(options)
|
|
115
|
+
if !payload
|
|
116
|
+
payload = {}
|
|
117
|
+
payload.deep_merge!({object_key => parse_passed_options(options)}) # inject options passed with -O foo=bar
|
|
118
|
+
payload.deep_merge!({object_key => params}) # inject options --foo bar
|
|
119
|
+
end
|
|
120
|
+
if payload[object_key].empty?
|
|
121
|
+
raise_command_error "Specify at least one option to update.\n#{optparse}"
|
|
122
|
+
end
|
|
123
|
+
@guidance_settings_interface.setopts(options)
|
|
124
|
+
if options[:dry_run]
|
|
125
|
+
print_dry_run @guidance_settings_interface.dry.update(payload)
|
|
126
|
+
return
|
|
127
|
+
end
|
|
128
|
+
json_response = @guidance_settings_interface.update(payload)
|
|
129
|
+
exit_code, err = 0, nil
|
|
130
|
+
render_response(json_response, options, object_key) do
|
|
131
|
+
if json_response['success']
|
|
132
|
+
print_green_success "Updated guidance settings"
|
|
133
|
+
get([] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
134
|
+
else
|
|
135
|
+
exit_code, err = 1, "Error updating guidance settings: #{json_response['msg'] || json_response['errors']}"
|
|
136
|
+
print_rest_errors(json_response)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
return exit_code, err
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
private
|
|
143
|
+
|
|
144
|
+
def object_key
|
|
145
|
+
'guidanceSettings'
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
end
|