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,1046 @@
|
|
|
1
|
+
require 'mtncloud/cli/cli_command'
|
|
2
|
+
|
|
3
|
+
class MtnCloud::Cli::HealthCommand
|
|
4
|
+
include MtnCloud::Cli::CliCommand
|
|
5
|
+
include MtnCloud::Cli::LogsHelper
|
|
6
|
+
set_command_name :health
|
|
7
|
+
register_subcommands :get, :alarms, :'get-alarm', :'acknowledge-alarms', :'unacknowledge-alarms', :logs, :'export-logs'
|
|
8
|
+
|
|
9
|
+
def connect(opts)
|
|
10
|
+
@api_client = establish_remote_appliance_connection(opts)
|
|
11
|
+
@health_interface = @api_client.health
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def handle(args)
|
|
15
|
+
handle_subcommand(args)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get(args)
|
|
19
|
+
options = {}
|
|
20
|
+
params = {}
|
|
21
|
+
live_health = false
|
|
22
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
23
|
+
opts.banner = subcommand_usage("[-a] [options]")
|
|
24
|
+
opts.on('-a', '--all', "Display all details: CPU, Memory, Database, etc." ) do
|
|
25
|
+
options[:details] = true
|
|
26
|
+
options[:show_cpu] = true
|
|
27
|
+
options[:show_threads] = true
|
|
28
|
+
options[:show_memory] = true
|
|
29
|
+
options[:show_database] = true
|
|
30
|
+
options[:show_elastic] = true
|
|
31
|
+
options[:show_queue] = true
|
|
32
|
+
end
|
|
33
|
+
opts.on('--details', '--details', "Display all details: CPU, Memory, Database, etc." ) do
|
|
34
|
+
options[:details] = true
|
|
35
|
+
options[:show_cpu] = true
|
|
36
|
+
options[:show_memory] = true
|
|
37
|
+
options[:show_database] = true
|
|
38
|
+
options[:show_elastic] = true
|
|
39
|
+
options[:show_queue] = true
|
|
40
|
+
end
|
|
41
|
+
opts.add_hidden_option('--details') # prefer -a, --all
|
|
42
|
+
opts.on('--cpu', "Display CPU details" ) do
|
|
43
|
+
options[:show_cpu] = true
|
|
44
|
+
end
|
|
45
|
+
opts.on('--threads', "Display Thread details" ) do
|
|
46
|
+
options[:show_threads] = true
|
|
47
|
+
end
|
|
48
|
+
opts.on('--memory', "Display Memory details" ) do
|
|
49
|
+
options[:show_memory] = true
|
|
50
|
+
end
|
|
51
|
+
opts.on('--database', "Display Database details" ) do
|
|
52
|
+
options[:show_database] = true
|
|
53
|
+
end
|
|
54
|
+
opts.on('--elastic', "Display Elasticsearch details" ) do
|
|
55
|
+
options[:show_elastic] = true
|
|
56
|
+
end
|
|
57
|
+
opts.on('--queue', "Display Queue (Rabbit) details" ) do
|
|
58
|
+
options[:show_queue] = true
|
|
59
|
+
end
|
|
60
|
+
opts.on('--queues', "Display Queue (Rabbit) details" ) do
|
|
61
|
+
options[:show_queue] = true
|
|
62
|
+
end
|
|
63
|
+
opts.on('--rabbit', "Display Queue (Rabbit) details" ) do
|
|
64
|
+
options[:show_queue] = true
|
|
65
|
+
end
|
|
66
|
+
opts.add_hidden_option('--queues')
|
|
67
|
+
opts.add_hidden_option('--rabbit')
|
|
68
|
+
opts.on('--live', "Fetch Live Health Data. By default the last cached health data is returned. This also retrieves all elastic indices." ) do
|
|
69
|
+
live_health = true
|
|
70
|
+
end
|
|
71
|
+
build_common_options(opts, options, [:query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
72
|
+
opts.footer = "Get appliance health information." + "\n" +
|
|
73
|
+
"By default, only the health status and levels are displayed." + "\n" +
|
|
74
|
+
"Display more details with the options --cpu, --database, --memory, etc." + "\n" +
|
|
75
|
+
"Display all details with the -a option."
|
|
76
|
+
end
|
|
77
|
+
optparse.parse!(args)
|
|
78
|
+
|
|
79
|
+
if args.count != 0
|
|
80
|
+
raise_command_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args}\n#{optparse}"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
connect(options)
|
|
84
|
+
begin
|
|
85
|
+
@health_interface.setopts(options)
|
|
86
|
+
if options[:dry_run]
|
|
87
|
+
print_dry_run(live_health ? @health_interface.dry.live(params) : @health_interface.dry.get(params))
|
|
88
|
+
return 0
|
|
89
|
+
end
|
|
90
|
+
json_response = live_health ? @health_interface.live(params) : @health_interface.get(params)
|
|
91
|
+
render_result = render_with_format(json_response, options, 'health')
|
|
92
|
+
exit_code = json_response['success'] == true ? 0 : 1
|
|
93
|
+
return exit_code if render_result
|
|
94
|
+
|
|
95
|
+
health = json_response['health']
|
|
96
|
+
subtitles = []
|
|
97
|
+
if options[:details]
|
|
98
|
+
subtitles << "Details"
|
|
99
|
+
end
|
|
100
|
+
if live_health
|
|
101
|
+
subtitles << "(Live)"
|
|
102
|
+
end
|
|
103
|
+
print_h1 "Health", subtitles, options
|
|
104
|
+
# thin print below here
|
|
105
|
+
options.merge!({thin:true})
|
|
106
|
+
|
|
107
|
+
if health.nil?
|
|
108
|
+
print yellow,"No health data returned.",reset,"\n"
|
|
109
|
+
return 1
|
|
110
|
+
end
|
|
111
|
+
if health['elastic'] && health['elastic']['noticeMessage'].to_s != ""
|
|
112
|
+
print cyan,health['elastic']['noticeMessage'],reset,"\n"
|
|
113
|
+
print "\n"
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
#print_h2 "Health Summary", options
|
|
117
|
+
print cyan
|
|
118
|
+
health_summary_columns = {
|
|
119
|
+
"Overall" => lambda {|it| format_health_status(it['cpu']['status']) rescue '' },
|
|
120
|
+
"CPU" => lambda {|it| format_health_status(it['cpu']['status']) rescue '' },
|
|
121
|
+
"Memory" => lambda {|it| format_health_status(it['memory']['status']) rescue '' },
|
|
122
|
+
"Database" => lambda {|it| format_health_status(it['database']['status']) rescue '' },
|
|
123
|
+
"Elastic" => lambda {|it| format_health_status(it['elastic']['status']) rescue '' },
|
|
124
|
+
"Queue" => lambda {|it| format_health_status(it['rabbit']['status']) rescue '' },
|
|
125
|
+
}
|
|
126
|
+
print as_pretty_table(health, health_summary_columns, options)
|
|
127
|
+
print "\n"
|
|
128
|
+
|
|
129
|
+
# flash warnings
|
|
130
|
+
if health['cpu'] && health['cpu']['status'] != 'ok' && health['cpu']['statusMessage']
|
|
131
|
+
status_color = health['cpu']['status'] == 'error' ? red : yellow
|
|
132
|
+
print status_color,health['cpu']['statusMessage'],reset,"\n"
|
|
133
|
+
end
|
|
134
|
+
if health['memory'] && health['memory']['status'] != 'ok' && health['memory']['statusMessage']
|
|
135
|
+
status_color = health['memory']['status'] == 'error' ? red : yellow
|
|
136
|
+
print status_color,health['memory']['statusMessage'],reset,"\n"
|
|
137
|
+
end
|
|
138
|
+
if health['database'] && health['database']['status'] != 'ok' && health['database']['statusMessage']
|
|
139
|
+
status_color = health['database']['status'] == 'error' ? red : yellow
|
|
140
|
+
print status_color,health['database']['statusMessage'],reset,"\n"
|
|
141
|
+
end
|
|
142
|
+
# if health['elastic'] && health['elastic']['noticeMessage'].to_s != ""
|
|
143
|
+
# print cyan,health['elastic']['noticeMessage'],reset,"\n"
|
|
144
|
+
# end
|
|
145
|
+
if health['elastic'] && health['elastic']['status'] != 'ok' && health['elastic']['statusMessage']
|
|
146
|
+
status_color = health['elastic']['status'] == 'error' ? red : yellow
|
|
147
|
+
print status_color,health['elastic']['statusMessage'],reset,"\n"
|
|
148
|
+
end
|
|
149
|
+
if health['rabbit'] && health['rabbit']['status'] != 'ok' && health['rabbit']['statusMessage']
|
|
150
|
+
status_color = health['rabbit']['status'] == 'error' ? red : yellow
|
|
151
|
+
print status_color,health['rabbit']['statusMessage'],reset,"\n"
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
print_h2 "Health Levels", options
|
|
155
|
+
print cyan
|
|
156
|
+
health_levels_columns = {
|
|
157
|
+
"Appliance CPU" => lambda {|it| format_percent(it['cpu']['cpuLoad'].to_f, 0) rescue '' },
|
|
158
|
+
"System CPU" => lambda {|it| format_percent(it['cpu']['cpuTotalLoad'].to_f, 0) rescue '' },
|
|
159
|
+
"Appliance Memory" => lambda {|it| format_percent(it['memory']['memoryPercent'].to_f * 100, 0) rescue '' },
|
|
160
|
+
"System Memory" => lambda {|it| format_percent(it['memory']['systemMemoryPercent'].to_f * 100, 0) rescue '' },
|
|
161
|
+
"Used Swap" => lambda {|it| format_percent(it['memory']['swapPercent'].to_f * 100, 0) rescue '' },
|
|
162
|
+
}
|
|
163
|
+
print as_pretty_table(health, health_levels_columns, options)
|
|
164
|
+
# print "\n"
|
|
165
|
+
|
|
166
|
+
if options[:show_cpu]
|
|
167
|
+
# CPU
|
|
168
|
+
if health['cpu'].nil?
|
|
169
|
+
print yellow,"No cpu health information returned.",reset,"\n"
|
|
170
|
+
else
|
|
171
|
+
print_h2 "CPU", options
|
|
172
|
+
print cyan
|
|
173
|
+
cpu_columns = {
|
|
174
|
+
"Processor Count" => lambda {|it| it['processorCount'] rescue '' },
|
|
175
|
+
"Process Time" => lambda {|it| format_human_duration(it['processTime'].to_f / 1000) rescue '' },
|
|
176
|
+
"Appliance CPU" => lambda {|it| (it['cpuLoad'].to_f.round(2).to_s + '%') rescue '' },
|
|
177
|
+
"System CPU" => lambda {|it| (it['cpuTotalLoad'].to_f.round(2).to_s + '%') rescue '' },
|
|
178
|
+
"System Load" => lambda {|it| (it['systemLoad'].to_f.round(3)) rescue '' },
|
|
179
|
+
}
|
|
180
|
+
#print as_pretty_table(health['cpu'], cpu_columns, options)
|
|
181
|
+
print_description_list(cpu_columns, health['cpu'], options)
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Threads ()
|
|
186
|
+
if options[:show_threads]
|
|
187
|
+
print_h2 "Threads", options
|
|
188
|
+
if health['threads'].nil?
|
|
189
|
+
print yellow,"No thread information returned.",reset,"\n\n"
|
|
190
|
+
else
|
|
191
|
+
print cyan
|
|
192
|
+
|
|
193
|
+
thread_summary_columns = {
|
|
194
|
+
"Thread Count" => lambda {|it| it['totalThreads'].size rescue '' },
|
|
195
|
+
"Busy Threads" => lambda {|it| it['busyThreads'].size rescue '' },
|
|
196
|
+
"Running Threads" => lambda {|it| it['runningThreads'].size rescue '' },
|
|
197
|
+
"Blocked Threads" => lambda {|it| it['blockedThreads'].size rescue '' },
|
|
198
|
+
}
|
|
199
|
+
print_description_list(thread_summary_columns, health['threads'], options)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
thread_columns = [
|
|
203
|
+
{"Name".upcase => lambda {|it| it['name']} },
|
|
204
|
+
{"Status".upcase => lambda {|it|
|
|
205
|
+
# hrmm
|
|
206
|
+
status_string = (it['status'] || it['state']).to_s.downcase
|
|
207
|
+
status_color = cyan
|
|
208
|
+
# if status_string.include?('waiting')
|
|
209
|
+
# status_color = yellow
|
|
210
|
+
# end
|
|
211
|
+
"#{status_color}#{status_string.upcase}#{cyan}"
|
|
212
|
+
} },
|
|
213
|
+
# {"CPU Time" => lambda {|it| it['cpuTime'].to_s } },
|
|
214
|
+
# {"CPU Time" => lambda {|it| format_human_duration(it['cpuTime'].to_f / 1000) rescue '' } },
|
|
215
|
+
{"CPU Percent" => lambda {|it| it['cpuPercent'].to_i.to_s + '%' } }
|
|
216
|
+
]
|
|
217
|
+
|
|
218
|
+
if health['threads']['busyThreads'] && health['threads']['busyThreads'].size > 0
|
|
219
|
+
print_h2 "Busy Threads"
|
|
220
|
+
print cyan
|
|
221
|
+
print as_pretty_table(health['threads']['busyThreads'], thread_columns, options)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
if health['threads']['runningThreads'] && health['threads']['runningThreads'].size > 0
|
|
225
|
+
print_h2 "Running Threads"
|
|
226
|
+
print cyan
|
|
227
|
+
print as_pretty_table(health['threads']['runningThreads'], thread_columns, options)
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
if health['threads']['blockedThreads'] && health['threads']['blockedThreads'].size > 0
|
|
231
|
+
print_h2 "Blocked Threads"
|
|
232
|
+
print cyan
|
|
233
|
+
print as_pretty_table(health['threads']['blockedThreads'], thread_columns, options)
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# Memory
|
|
239
|
+
if options[:show_memory]
|
|
240
|
+
if health['memory'].nil?
|
|
241
|
+
print yellow,"No memory health information returned.",reset,"\n"
|
|
242
|
+
else
|
|
243
|
+
print_h2 "Memory", options
|
|
244
|
+
print cyan
|
|
245
|
+
memory_columns = {
|
|
246
|
+
"Appliance Memory" => lambda {|it| format_bytes_short(it['totalMemory']) rescue '' },
|
|
247
|
+
"Appliance Used Memory" => lambda {|it| format_bytes_short(it['usedMemory']) rescue '' },
|
|
248
|
+
"Appliance Free Memory" => lambda {|it| format_bytes_short(it['freeMemory']) rescue '' },
|
|
249
|
+
"Appliance Memory Usage" => lambda {|it| format_percent(it['memoryPercent'].to_f * 100) rescue '' },
|
|
250
|
+
"System Memory" => lambda {|it| format_bytes_short(it['systemMemory']) rescue '' },
|
|
251
|
+
"System Used Memory" => lambda {|it| format_bytes_short(it['committedMemory']) rescue '' },
|
|
252
|
+
"System Free Memory" => lambda {|it| format_bytes_short(it['systemFreeMemory']) rescue '' },
|
|
253
|
+
"System Memory Usage" => lambda {|it| format_percent(it['systemMemoryPercent'].to_f * 100) rescue '' },
|
|
254
|
+
"System Swap" => lambda {|it| format_bytes_short(it['systemSwap']) rescue '' },
|
|
255
|
+
"Free Swap" => lambda {|it| format_bytes_short(it['systemFreeSwap']) rescue '' },
|
|
256
|
+
#"Used Swap" => lambda {|it| format_percent(it['swapPercent'].to_f * 100) rescue '' }
|
|
257
|
+
# "System Load" => lambda {|it| (it['systemLoad'].to_f(3)) rescue '' },
|
|
258
|
+
}
|
|
259
|
+
#print as_pretty_table(health['memory'], memory_columns, options)
|
|
260
|
+
print_description_list(memory_columns, health['memory'], options)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
# Database (mysql)
|
|
265
|
+
if options[:show_database]
|
|
266
|
+
if health['database'].nil?
|
|
267
|
+
print yellow,"No database health information returned.",reset,"\n"
|
|
268
|
+
else
|
|
269
|
+
print_h2 "Database", options
|
|
270
|
+
print cyan
|
|
271
|
+
database_columns = {
|
|
272
|
+
"Lifetime Connections" => lambda {|it| it['stats']['Connections'] rescue '' },
|
|
273
|
+
"Aborted Connections" => lambda {|it| it['stats']['Aborted_connects'] rescue '' },
|
|
274
|
+
"Max Used Connections" => lambda {|it| it['stats']['Max_used_connections'] rescue '' },
|
|
275
|
+
"Max Connections" => lambda {|it| it['maxConnections'] rescue '' },
|
|
276
|
+
"Threads Running" => lambda {|it| it['stats']['Threads_running'] rescue '' },
|
|
277
|
+
"Threads Connected" => lambda {|it| it['stats']['Threads_connected'] rescue '' },
|
|
278
|
+
"Slow Queries" => lambda {|it| it['stats']['Slow_queries'] rescue '' },
|
|
279
|
+
"Temp Tables" => lambda {|it| it['stats']['Created_tmp_disk_tables'] rescue '' },
|
|
280
|
+
"Handler Read First" => lambda {|it| it['stats']['Handler_read_first'] rescue '' },
|
|
281
|
+
"Buffer Pool Free" => lambda {|it| it['stats']['Innodb_buffer_pool_wait_free'] rescue '' },
|
|
282
|
+
"Open Tables" => lambda {|it| it['stats']['Open_tables'] rescue '' },
|
|
283
|
+
"Table Scans" => lambda {|it| it['stats']['Select_scan'] rescue '' },
|
|
284
|
+
"Full Joins" => lambda {|it| it['stats']['Select_full_join'] rescue '' },
|
|
285
|
+
"Key Read Requests" => lambda {|it| it['stats']['Key_read_requests'] rescue '' },
|
|
286
|
+
"Key Reads" => lambda {|it| it['stats']['Key_reads'] rescue '' },
|
|
287
|
+
"Engine Waits" => lambda {|it| it['stats']['Innodb_log_waits'] rescue '' },
|
|
288
|
+
"Lock Waits" => lambda {|it| it['stats']['Table_locks_waited'] rescue '' },
|
|
289
|
+
"Handler Read Rnd" => lambda {|it| it['stats']['Handler_read_rnd'] rescue '' },
|
|
290
|
+
"Engine IO Writes" => lambda {|it| it['stats']['Innodb_data_writes'] rescue '' },
|
|
291
|
+
"Engine IO Reads" => lambda {|it| it['stats']['Innodb_data_reads'] rescue '' },
|
|
292
|
+
"Engine IO Double Writes" => lambda {|it| it['stats']['Innodb_dblwr_writes'] rescue '' },
|
|
293
|
+
"Engine Log Writes" => lambda {|it| it['stats']['Innodb_log_writes'] rescue '' },
|
|
294
|
+
"Engine Memory" => lambda {|it| format_bytes_short(it['innodbStats']['largeMemory']) rescue '' },
|
|
295
|
+
"Dictionary Memory" => lambda {|it| format_bytes_short(it['innodbStats']['dictionaryMemory']) rescue '' },
|
|
296
|
+
"Buffer Pool Size" => lambda {|it| it['innodbStats']['bufferPoolSize'] rescue '' },
|
|
297
|
+
"Free Buffers" => lambda {|it| it['innodbStats']['freeBuffers'] rescue '' },
|
|
298
|
+
"Database Pages" => lambda {|it| it['innodbStats']['databasePages'] rescue '' },
|
|
299
|
+
"Old Pages" => lambda {|it| it['innodbStats']['oldPages'] rescue '' },
|
|
300
|
+
"Dirty Page Percent" => lambda {|it| format_percent(it['innodbStats']['dirtyPagePercent'] ? it['innodbStats']['dirtyPagePercent'] : '') rescue '' },
|
|
301
|
+
"Max Dirty Pages" => lambda {|it| format_percent(it['innodbStats']['maxDirtyPagePercent'].to_f) rescue '' },
|
|
302
|
+
"Pending Reads" => lambda {|it| format_number(it['innodbStats']['pendingReads']) rescue '' },
|
|
303
|
+
"Insert Rate" => lambda {|it| format_rate(it['innodbStats']['insertsPerSecond'].to_f) rescue '' },
|
|
304
|
+
"Update Rate" => lambda {|it| format_rate(it['innodbStats']['updatesPerSecond'].to_f) rescue '' },
|
|
305
|
+
"Delete Rate" => lambda {|it| format_rate(it['innodbStats']['deletesPerSecond'].to_f) rescue '' },
|
|
306
|
+
"Read Rate" => lambda {|it| format_rate(it['innodbStats']['readsPerSecond']) rescue '' },
|
|
307
|
+
"Buffer Hit Rate" => lambda {|it| format_percent(it['innodbStats']['bufferHitRate'].to_f * 100) rescue '' },
|
|
308
|
+
"Read Write Ratio" => lambda {|it|
|
|
309
|
+
rw_ratio = ""
|
|
310
|
+
begin
|
|
311
|
+
total_writes = (it['stats']['Com_update'].to_i) + (it['stats']['Com_insert'].to_i) + (it['stats']['Com_delete'].to_f)
|
|
312
|
+
total_reads = (it['stats']['Com_select'].to_i)
|
|
313
|
+
if total_writes > 0
|
|
314
|
+
rw_ratio = (total_reads.to_f / total_writes.to_f).round(2).to_s
|
|
315
|
+
end
|
|
316
|
+
rescue => ex
|
|
317
|
+
puts ex
|
|
318
|
+
end
|
|
319
|
+
rw_ratio
|
|
320
|
+
},
|
|
321
|
+
"Uptime" => lambda {|it| (it['stats']['Uptime'] ? format_human_duration(it['stats']['Uptime'].to_i) : '') rescue '' },
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
print_description_list(database_columns, health['database'], options)
|
|
325
|
+
#print as_pretty_table(health['database'], database_columns, options)
|
|
326
|
+
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
# Elasticsearch
|
|
331
|
+
if options[:show_elastic]
|
|
332
|
+
if health['elastic'].nil?
|
|
333
|
+
print yellow,"No elastic health information returned.",reset,"\n\n"
|
|
334
|
+
else
|
|
335
|
+
print_h2 "Elastic", options
|
|
336
|
+
print cyan
|
|
337
|
+
|
|
338
|
+
elastic_columns = {
|
|
339
|
+
"Status" => 'status',
|
|
340
|
+
# "Status" => lambda {|it| format_health_status(it['status']) rescue '' },
|
|
341
|
+
# "Status" => lambda {|it|
|
|
342
|
+
# begin
|
|
343
|
+
# if it['statusMessage'].to_s != ""
|
|
344
|
+
# format_health_status(it['status']).to_s + " - " + it['statusMessage']
|
|
345
|
+
# else
|
|
346
|
+
# format_health_status(it['status'])
|
|
347
|
+
# end
|
|
348
|
+
# rescue => ex
|
|
349
|
+
# ''
|
|
350
|
+
# end
|
|
351
|
+
# },
|
|
352
|
+
"Cluster" => lambda {|it| it['stats']['clusterName'] rescue '' },
|
|
353
|
+
"Node Count" => lambda {|it| it['stats']['nodeTotal'] rescue '' },
|
|
354
|
+
"Data Nodes" => lambda {|it| it['stats']['nodeData'] rescue '' },
|
|
355
|
+
"Shards" => lambda {|it| it['stats']['shards'] rescue '' },
|
|
356
|
+
"Primary Shards" => lambda {|it| it['stats']['primary'] rescue '' },
|
|
357
|
+
"Relocating Shards" => lambda {|it| it['stats']['relocating'] rescue '' },
|
|
358
|
+
"Initializing" => lambda {|it| it['stats']['initializing'] rescue '' },
|
|
359
|
+
"Unassigned" => lambda {|it| it['stats']['unassigned'] rescue '' },
|
|
360
|
+
"Pending Tasks" => lambda {|it| it['stats']['pendingTasks'] rescue '' },
|
|
361
|
+
"Active Shards" => lambda {|it| it['stats']['activePercent'] rescue '' },
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
print_description_list(elastic_columns, health['elastic'], options)
|
|
365
|
+
#print as_pretty_table(health['elastic'], elastic_columns, options)
|
|
366
|
+
|
|
367
|
+
elastic_nodes_columns = [
|
|
368
|
+
{"NODE" => lambda {|it| it['name'] } },
|
|
369
|
+
{"MASTER" => lambda {|it| it['master'] == '*' } },
|
|
370
|
+
{"LOCATION" => lambda {|it| it['ip'] } },
|
|
371
|
+
{"RAM" => lambda {|it| it['ramPercent'] } },
|
|
372
|
+
{"HEAP" => lambda {|it| it['heapPercent'] } },
|
|
373
|
+
{"CPU USAGE" => lambda {|it| it['cpuCount'] } },
|
|
374
|
+
{"1M LOAD" => lambda {|it| it['loadOne'] } },
|
|
375
|
+
{"5M LOAD" => lambda {|it| it['loadFive'] } },
|
|
376
|
+
{"15M LOAD" => lambda {|it| it['loadFifteen'] } }
|
|
377
|
+
]
|
|
378
|
+
|
|
379
|
+
print_h2 "Elastic Nodes"
|
|
380
|
+
if health['elastic']['nodes'].nil? || health['elastic']['nodes'].empty?
|
|
381
|
+
print yellow,"No nodes found.",reset,"\n\n"
|
|
382
|
+
else
|
|
383
|
+
print as_pretty_table(health['elastic']['nodes'], elastic_nodes_columns, options)
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
elastic_indices_columns = [
|
|
387
|
+
{"Health".upcase => lambda {|it| format_index_health(it['health']) } },
|
|
388
|
+
{"Index".upcase => lambda {|it| it['index']} },
|
|
389
|
+
{"Status".upcase => lambda {|it| it['status'] } },
|
|
390
|
+
{"Primary".upcase => lambda {|it| it['primary'] } },
|
|
391
|
+
{"Replicas".upcase => lambda {|it| it['replicas'] } },
|
|
392
|
+
{"Doc Count".upcase => lambda {|it| format_number(it['count']) } },
|
|
393
|
+
{"Primary Size".upcase => lambda {|it| it['primarySize'] } },
|
|
394
|
+
{"Total Size".upcase => lambda {|it| it['totalSize'] } },
|
|
395
|
+
]
|
|
396
|
+
|
|
397
|
+
# when the api returns indices, it will include badIndices, so don't show both.
|
|
398
|
+
if health['elastic']['indices'] && health['elastic']['indices'].size > 0
|
|
399
|
+
print_h2 "Elastic Indices"
|
|
400
|
+
if health['elastic']['indices'].nil? || health['elastic']['indices'].empty?
|
|
401
|
+
print yellow,"No indices found.",reset,"\n\n"
|
|
402
|
+
else
|
|
403
|
+
print cyan
|
|
404
|
+
print as_pretty_table(health['elastic']['indices'], elastic_indices_columns, options)
|
|
405
|
+
end
|
|
406
|
+
else
|
|
407
|
+
print_h2 "Bad Elastic Indices"
|
|
408
|
+
if health['elastic']['badIndices'].nil? || health['elastic']['badIndices'].empty?
|
|
409
|
+
# print cyan,"No bad indices found.",reset,"\n\n"
|
|
410
|
+
else
|
|
411
|
+
print cyan
|
|
412
|
+
print as_pretty_table(health['elastic']['badIndices'], elastic_indices_columns, options)
|
|
413
|
+
end
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
end
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
# Queues (rabbit)
|
|
421
|
+
if options[:show_queue]
|
|
422
|
+
print_h2 "Queue (Rabbit)", options
|
|
423
|
+
if health['rabbit'].nil?
|
|
424
|
+
print yellow,"No rabbit queue health information returned.",reset,"\n\n"
|
|
425
|
+
else
|
|
426
|
+
print cyan
|
|
427
|
+
|
|
428
|
+
rabbit_summary_columns = {
|
|
429
|
+
"Status" => lambda {|it|
|
|
430
|
+
begin
|
|
431
|
+
if it['statusMessage'].to_s != ""
|
|
432
|
+
format_health_status(it['status']).to_s + " - " + it['statusMessage']
|
|
433
|
+
else
|
|
434
|
+
format_health_status(it['status'])
|
|
435
|
+
end
|
|
436
|
+
rescue => ex
|
|
437
|
+
''
|
|
438
|
+
end
|
|
439
|
+
},
|
|
440
|
+
"Queues" => lambda {|it| it['queues'].size rescue '' },
|
|
441
|
+
"Busy Queues" => lambda {|it| it['busyQueues'].size rescue '' },
|
|
442
|
+
"Error Queues" => lambda {|it| it['errorQueues'].size rescue '' }
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
print_description_list(rabbit_summary_columns, health['rabbit'], options)
|
|
446
|
+
#print as_pretty_table(health['rabbit'], rabbit_summary_columns, options)
|
|
447
|
+
|
|
448
|
+
print_h2 "Queues"
|
|
449
|
+
queue_columns = [
|
|
450
|
+
{"Status".upcase => lambda {|it|
|
|
451
|
+
# hrmm
|
|
452
|
+
status_string = it['status'].to_s.downcase # || 'green'
|
|
453
|
+
if status_string == 'warning'
|
|
454
|
+
"#{yellow}WARNING#{cyan}"
|
|
455
|
+
elsif status_string == 'error'
|
|
456
|
+
"#{red}ERROR#{cyan}"
|
|
457
|
+
elsif status_string == 'ok'
|
|
458
|
+
"#{green}OK#{cyan}"
|
|
459
|
+
else
|
|
460
|
+
# hrmm
|
|
461
|
+
it['status']
|
|
462
|
+
end
|
|
463
|
+
} },
|
|
464
|
+
{"Name".upcase => lambda {|it| it['name']} },
|
|
465
|
+
{"Count".upcase => lambda {|it| format_number(it['count']) } }
|
|
466
|
+
]
|
|
467
|
+
|
|
468
|
+
if health['rabbit'].nil? || health['rabbit']['queues'].nil? || health['rabbit']['queues'].empty?
|
|
469
|
+
print yellow,"No queues found.",reset,"\n\n"
|
|
470
|
+
else
|
|
471
|
+
print cyan
|
|
472
|
+
print as_pretty_table(health['rabbit']['queues'], queue_columns, options)
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
if health['rabbit'].nil? || health['rabbit']['busyQueues'].nil? || health['rabbit']['busyQueues'].empty?
|
|
476
|
+
# print cyan,"No busy queues found.",reset,"\n"
|
|
477
|
+
else
|
|
478
|
+
print_h2 "Busy Queues"
|
|
479
|
+
print cyan
|
|
480
|
+
print as_pretty_table(health['rabbit']['busyQueues'], queue_columns, options)
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
if health['rabbit'].nil? || health['rabbit']['errorQueues'].nil? || health['rabbit']['errorQueues'].empty?
|
|
484
|
+
# print cyan,"No error queues found.",reset,"\n"
|
|
485
|
+
else
|
|
486
|
+
print_h2 "Error Queues"
|
|
487
|
+
print cyan
|
|
488
|
+
print as_pretty_table(health['rabbit']['errorQueues'], queue_columns, options)
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
end
|
|
492
|
+
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
print "\n"
|
|
497
|
+
return 0
|
|
498
|
+
rescue RestClient::Exception => e
|
|
499
|
+
print_rest_exception(e, options)
|
|
500
|
+
exit 1
|
|
501
|
+
end
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
def logs(args)
|
|
505
|
+
options = {}
|
|
506
|
+
params = {}
|
|
507
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
508
|
+
opts.banner = subcommand_usage()
|
|
509
|
+
opts.on('--level VALUE', String, "Log Level. DEBUG,INFO,WARN,ERROR") do |val|
|
|
510
|
+
params['level'] = params['level'] ? [params['level'], val].flatten : [val]
|
|
511
|
+
end
|
|
512
|
+
opts.on('--start TIMESTAMP','--start TIMESTAMP', "Start date timestamp in standard iso8601 format. Default is 24 hours ago.") do |val|
|
|
513
|
+
params['startDate'] = val # parse_time(val).utc.iso8601
|
|
514
|
+
end
|
|
515
|
+
opts.on('--end TIMESTAMP','--end TIMESTAMP', "End date timestamp in standard iso8601 format. Default is now.") do |val|
|
|
516
|
+
params['endDate'] = val # parse_time(val).utc.iso8601
|
|
517
|
+
end
|
|
518
|
+
opts.on('-t', '--table', "Format output as a table.") do
|
|
519
|
+
options[:table] = true
|
|
520
|
+
end
|
|
521
|
+
opts.on('-a', '--all', "Display all details: entire message." ) do
|
|
522
|
+
options[:details] = true
|
|
523
|
+
end
|
|
524
|
+
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
525
|
+
opts.footer = "List health logs. These are the logs of the MTN Cloud appliance itself."
|
|
526
|
+
end
|
|
527
|
+
optparse.parse!(args)
|
|
528
|
+
if args.count > 0
|
|
529
|
+
options[:phrase] = args.join(" ")
|
|
530
|
+
end
|
|
531
|
+
connect(options)
|
|
532
|
+
begin
|
|
533
|
+
# params['startDate'] = start_date.utc.iso8601 if start_date
|
|
534
|
+
# params['endDate'] = end_date.utc.iso8601 if end_date
|
|
535
|
+
# params['startMs'] = (start_date.to_i * 1000) if start_date
|
|
536
|
+
# params['endMs'] = (end_date.to_i * 1000) if end_date
|
|
537
|
+
params['level'] = params['level'].collect {|it| it.to_s.upcase }.join('|') if params['level'] # api works with INFO|WARN
|
|
538
|
+
params.merge!(parse_list_options(options))
|
|
539
|
+
@health_interface.setopts(options)
|
|
540
|
+
if options[:dry_run]
|
|
541
|
+
print_dry_run @health_interface.dry.logs(params)
|
|
542
|
+
return 0
|
|
543
|
+
end
|
|
544
|
+
json_response = @health_interface.logs(params)
|
|
545
|
+
render_result = json_response['logs'] ? render_with_format(json_response, options, 'logs') : render_with_format(json_response, options, 'data')
|
|
546
|
+
return 0 if render_result
|
|
547
|
+
logs = json_response['data'] || json_response['logs']
|
|
548
|
+
title = "Health Logs"
|
|
549
|
+
subtitles = []
|
|
550
|
+
if params['level']
|
|
551
|
+
subtitles << "Level: #{[params['level']].flatten.join(',')}"
|
|
552
|
+
end
|
|
553
|
+
if params['startDate']
|
|
554
|
+
subtitles << "Start: #{params['startDate']}"
|
|
555
|
+
end
|
|
556
|
+
if params['endDate']
|
|
557
|
+
subtitles << "End: #{params['endDate']}"
|
|
558
|
+
end
|
|
559
|
+
subtitles += parse_list_subtitles(options)
|
|
560
|
+
print_h1 title, subtitles
|
|
561
|
+
|
|
562
|
+
if logs.empty?
|
|
563
|
+
print "#{cyan}No logs found.#{reset}\n"
|
|
564
|
+
else
|
|
565
|
+
print format_log_records(logs, options, false)
|
|
566
|
+
print_results_pagination(json_response)
|
|
567
|
+
end
|
|
568
|
+
print reset,"\n"
|
|
569
|
+
return 0
|
|
570
|
+
rescue RestClient::Exception => e
|
|
571
|
+
print_rest_exception(e, options)
|
|
572
|
+
exit 1
|
|
573
|
+
end
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
def export_logs(args)
|
|
577
|
+
params = {}
|
|
578
|
+
options = {}
|
|
579
|
+
outfile = nil
|
|
580
|
+
do_overwrite = false
|
|
581
|
+
do_mkdir = false
|
|
582
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
583
|
+
opts.banner = subcommand_usage("[file]")
|
|
584
|
+
opts.on('--level VALUE', String, "Log Level. DEBUG,INFO,WARN,ERROR") do |val|
|
|
585
|
+
params['level'] = params['level'] ? [params['level'], val].flatten : [val]
|
|
586
|
+
end
|
|
587
|
+
opts.on('--start TIMESTAMP','--start TIMESTAMP', "Start date timestamp in standard iso8601 format. Default is 24 hours ago.") do |val|
|
|
588
|
+
params['startDate'] = val # parse_time(val).utc.iso8601
|
|
589
|
+
end
|
|
590
|
+
opts.on('--end TIMESTAMP','--end TIMESTAMP', "End date timestamp in standard iso8601 format. Default is now.") do |val|
|
|
591
|
+
params['endDate'] = val # parse_time(val).utc.iso8601
|
|
592
|
+
end
|
|
593
|
+
opts.on( '-f', '--force', "Overwrite existing [file] if it exists." ) do
|
|
594
|
+
do_overwrite = true
|
|
595
|
+
# do_mkdir = true
|
|
596
|
+
end
|
|
597
|
+
opts.on( '-p', '--mkdir', "Create missing directories for [file] if they do not exist." ) do
|
|
598
|
+
do_mkdir = true
|
|
599
|
+
end
|
|
600
|
+
build_common_options(opts, options, [:list, :query, :dry_run, :remote])
|
|
601
|
+
opts.footer = "Export MTN Cloud appliance log." + "\n" +
|
|
602
|
+
"[file] is required. This is local destination for the downloaded file. Example: appliance.log"
|
|
603
|
+
end
|
|
604
|
+
optparse.parse!(args)
|
|
605
|
+
verify_args!(args:args, optparse:optparse, count: 1)
|
|
606
|
+
connect(options)
|
|
607
|
+
params['level'] = params['level'].collect {|it| it.to_s.upcase }.join('|') if params['level'] # api works with INFO|WARN
|
|
608
|
+
params.merge!(parse_list_options(options))
|
|
609
|
+
|
|
610
|
+
outfile = args[0]
|
|
611
|
+
outfile = File.expand_path(outfile)
|
|
612
|
+
|
|
613
|
+
if Dir.exist?(outfile)
|
|
614
|
+
raise_command_error("[file] is invalid. It is the name of an existing directory: #{outfile}", args, optparse)
|
|
615
|
+
end
|
|
616
|
+
destination_dir = File.dirname(outfile)
|
|
617
|
+
if !Dir.exist?(destination_dir)
|
|
618
|
+
if do_mkdir
|
|
619
|
+
print cyan,"Creating local directory #{destination_dir}",reset,"\n"
|
|
620
|
+
FileUtils.mkdir_p(destination_dir)
|
|
621
|
+
else
|
|
622
|
+
raise_command_error("[file] is invalid. Directory not found: #{destination_dir}", args, optparse)
|
|
623
|
+
end
|
|
624
|
+
end
|
|
625
|
+
if File.exist?(outfile)
|
|
626
|
+
if do_overwrite
|
|
627
|
+
# uhh need to be careful wih the passed filepath here..
|
|
628
|
+
# don't delete, just overwrite.
|
|
629
|
+
# File.delete(outfile)
|
|
630
|
+
else
|
|
631
|
+
raise_command_error("[file] is invalid. File already exists: #{outfile}\nUse -f to overwrite the existing file.", args, optparse)
|
|
632
|
+
end
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
@health_interface.setopts(options)
|
|
636
|
+
if options[:dry_run]
|
|
637
|
+
print_dry_run @health_interface.dry.export_logs(outfile, params)
|
|
638
|
+
return 0
|
|
639
|
+
end
|
|
640
|
+
if !options[:quiet]
|
|
641
|
+
print cyan + "Downloading file #{outfile} ... "
|
|
642
|
+
end
|
|
643
|
+
http_response, bad_body = @health_interface.export_logs(outfile, params)
|
|
644
|
+
# FileUtils.chmod(0600, outfile)
|
|
645
|
+
success = http_response.code.to_i == 200
|
|
646
|
+
if success
|
|
647
|
+
if !options[:quiet]
|
|
648
|
+
print green + "SUCCESS" + reset + " (" + format_bytes(http_response["Content-Length"].to_i).to_s + ")" + "\n"
|
|
649
|
+
end
|
|
650
|
+
# todo: parse default outfile from http_response["Content-Type"]
|
|
651
|
+
return 0
|
|
652
|
+
else
|
|
653
|
+
if !options[:quiet]
|
|
654
|
+
print red + "ERROR" + reset + " HTTP #{http_response.code}" + "\n"
|
|
655
|
+
end
|
|
656
|
+
# F it, just remove a bad result
|
|
657
|
+
if File.exist?(outfile) && File.file?(outfile)
|
|
658
|
+
MtnCloud::Logging::DarkPrinter.puts "Deleting bad file download: #{outfile}" if MtnCloud::Logging.debug?
|
|
659
|
+
File.delete(outfile)
|
|
660
|
+
end
|
|
661
|
+
if options[:debug]
|
|
662
|
+
puts_error http_response.inspect
|
|
663
|
+
end
|
|
664
|
+
return 1, "download failed"
|
|
665
|
+
end
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
def alarms(args)
|
|
669
|
+
options = {}
|
|
670
|
+
params = {}
|
|
671
|
+
start_date, end_date = nil, nil
|
|
672
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
673
|
+
opts.banner = subcommand_usage()
|
|
674
|
+
opts.on('--category VALUE', String, "Filter by Alarm Category. datastore, computeZone, computeServer, etc.") do |val|
|
|
675
|
+
params['alarmCategory'] = params['alarmCategory'] ? [params['alarmCategory'], val].flatten : val
|
|
676
|
+
end
|
|
677
|
+
opts.on('--status VALUE', String, "Filter by status. warning, error") do |val|
|
|
678
|
+
params['status'] = params['status'] ? [params['status'], val].flatten : val
|
|
679
|
+
end
|
|
680
|
+
opts.on('--acknowledged', '--acknowledged', "Filter by acknowledged. By default only open alarms are returned.") do
|
|
681
|
+
params['alarmStatus'] = 'acknowledged'
|
|
682
|
+
end
|
|
683
|
+
opts.on('--start TIMESTAMP','--start TIMESTAMP', "Start timestamp. Default is 24 hours ago.") do |val|
|
|
684
|
+
start_date = parse_time(val) #.utc.iso8601
|
|
685
|
+
end
|
|
686
|
+
opts.on('--end TIMESTAMP','--end TIMESTAMP', "End timestamp. Default is now.") do |val|
|
|
687
|
+
end_date = parse_time(val) #.utc.iso8601
|
|
688
|
+
end
|
|
689
|
+
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
690
|
+
opts.footer = "List health alarms."
|
|
691
|
+
end
|
|
692
|
+
optparse.parse!(args)
|
|
693
|
+
if args.count != 0
|
|
694
|
+
raise_command_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args}\n#{optparse}"
|
|
695
|
+
end
|
|
696
|
+
connect(options)
|
|
697
|
+
begin
|
|
698
|
+
params['startDate'] = start_date.utc.iso8601 if start_date
|
|
699
|
+
params['endDate'] = end_date.utc.iso8601 if end_date
|
|
700
|
+
params.merge!(parse_list_options(options))
|
|
701
|
+
@health_interface.setopts(options)
|
|
702
|
+
if options[:dry_run]
|
|
703
|
+
print_dry_run @health_interface.dry.list_alarms(params)
|
|
704
|
+
return 0
|
|
705
|
+
end
|
|
706
|
+
json_response = @health_interface.list_alarms(params)
|
|
707
|
+
render_result = render_with_format(json_response, options, 'alarms')
|
|
708
|
+
return 0 if render_result
|
|
709
|
+
alarms = json_response['alarms']
|
|
710
|
+
title = "Health Alarms"
|
|
711
|
+
subtitles = []
|
|
712
|
+
# if params['category']
|
|
713
|
+
# subtitles << "Category: #{params['category']}"
|
|
714
|
+
# end
|
|
715
|
+
if params['status']
|
|
716
|
+
subtitles << "Status: #{params['status']}"
|
|
717
|
+
end
|
|
718
|
+
if params['alarmStatus'] == 'acknowledged'
|
|
719
|
+
subtitles << "(Acknowledged)"
|
|
720
|
+
end
|
|
721
|
+
if params['startDate']
|
|
722
|
+
subtitles << "Start Date: #{params['startDate']}"
|
|
723
|
+
end
|
|
724
|
+
if params['endDate']
|
|
725
|
+
subtitles << "End Date: #{params['endDate']}"
|
|
726
|
+
end
|
|
727
|
+
subtitles += parse_list_subtitles(options)
|
|
728
|
+
print_h1 title, subtitles
|
|
729
|
+
if alarms.empty?
|
|
730
|
+
print cyan,"No alarms found.",reset,"\n"
|
|
731
|
+
else
|
|
732
|
+
alarm_columns = [
|
|
733
|
+
{"ID" => lambda {|alarm| alarm['id'] } },
|
|
734
|
+
{"STATUS" => lambda {|alarm| format_health_status(alarm['status']) } },
|
|
735
|
+
{"RESOURCE" => lambda {|alarm| alarm['resourceName'] || alarm['refName'] } },
|
|
736
|
+
{"INFO" => lambda {|alarm| alarm['name'] } },
|
|
737
|
+
{"START DATE" => lambda {|alarm| format_local_dt(alarm['startDate']) } },
|
|
738
|
+
{"DURATION" => lambda {|alarm| format_duration(alarm['startDate'], alarm['acknoDate'] || Time.now) } },
|
|
739
|
+
]
|
|
740
|
+
if options[:include_fields]
|
|
741
|
+
columns = options[:include_fields]
|
|
742
|
+
end
|
|
743
|
+
print as_pretty_table(alarms, alarm_columns, options)
|
|
744
|
+
print_results_pagination(json_response)
|
|
745
|
+
end
|
|
746
|
+
print reset,"\n"
|
|
747
|
+
return 0
|
|
748
|
+
rescue RestClient::Exception => e
|
|
749
|
+
print_rest_exception(e, options)
|
|
750
|
+
exit 1
|
|
751
|
+
end
|
|
752
|
+
end
|
|
753
|
+
|
|
754
|
+
def get_alarm(args)
|
|
755
|
+
options = {}
|
|
756
|
+
params = {}
|
|
757
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
758
|
+
opts.banner = subcommand_usage("[id]")
|
|
759
|
+
build_common_options(opts, options, [:query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
760
|
+
opts.footer = "Get details about a health alarm.\n[id] is required. Health Alarm ID"
|
|
761
|
+
end
|
|
762
|
+
optparse.parse!(args)
|
|
763
|
+
|
|
764
|
+
if args.count != 1
|
|
765
|
+
raise_command_error "wrong number of arguments, expected 1 and got (#{args.count}) #{args}\n#{optparse}"
|
|
766
|
+
end
|
|
767
|
+
|
|
768
|
+
connect(options)
|
|
769
|
+
|
|
770
|
+
@health_interface.setopts(options)
|
|
771
|
+
if options[:dry_run]
|
|
772
|
+
print_dry_run @health_interface.dry.get_alarm(args[0], params)
|
|
773
|
+
return 0
|
|
774
|
+
end
|
|
775
|
+
json_response = @health_interface.get_alarm(args[0], params)
|
|
776
|
+
render_result = render_with_format(json_response, options, 'alarm')
|
|
777
|
+
return 0 if render_result
|
|
778
|
+
if json_response['alarm'].nil?
|
|
779
|
+
print_red_alert "Alarm not found by id #{args[0]}"
|
|
780
|
+
return 1
|
|
781
|
+
end
|
|
782
|
+
print_h1 "Alarm Details"
|
|
783
|
+
print cyan
|
|
784
|
+
alarm_columns = [
|
|
785
|
+
{"ID" => lambda {|alarm| alarm['id'] } },
|
|
786
|
+
{"Status" => lambda {|alarm| format_health_status(alarm['status']) } },
|
|
787
|
+
{"Resource" => lambda {|alarm| alarm['resourceName'] || alarm['refName'] } },
|
|
788
|
+
{"Info" => lambda {|alarm| alarm['name'] } },
|
|
789
|
+
{"Active" => lambda {|alarm| format_boolean(alarm['active']) } },
|
|
790
|
+
{"Start Date" => lambda {|alarm| format_local_dt(alarm['startDate']) } },
|
|
791
|
+
{"Duration" => lambda {|alarm| format_duration(alarm['startDate'], alarm['acknowledgedDate'] || Time.now) } },
|
|
792
|
+
{"Acknowledged Date" => lambda {|alarm| format_local_dt(alarm['acknowledgedDate']) } },
|
|
793
|
+
{"Acknowledged" => lambda {|alarm| format_boolean(alarm['acknowledged']) } }
|
|
794
|
+
]
|
|
795
|
+
print_description_list(alarm_columns, json_response['alarm'])
|
|
796
|
+
print reset,"\n"
|
|
797
|
+
return 0
|
|
798
|
+
|
|
799
|
+
end
|
|
800
|
+
|
|
801
|
+
def acknowledge_alarms(args)
|
|
802
|
+
options = {}
|
|
803
|
+
params = {}
|
|
804
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
805
|
+
opts.banner = subcommand_usage("[alarm] [options]")
|
|
806
|
+
opts.on('-a', '--all', "Acknowledge all open alarms. This can be used instead of passing specific alarms.") do
|
|
807
|
+
params['all'] = true
|
|
808
|
+
end
|
|
809
|
+
build_common_options(opts, options, [:payload, :options, :json, :dry_run, :remote])
|
|
810
|
+
opts.footer = "Acknowledge health alarm(s).\n[alarm] is required. Alarm ID, supports multiple arguments."
|
|
811
|
+
end
|
|
812
|
+
optparse.parse!(args)
|
|
813
|
+
|
|
814
|
+
if params['all']
|
|
815
|
+
# updating all
|
|
816
|
+
if args.count > 0
|
|
817
|
+
raise_command_error "wrong number of arguments, --all option expects 0 and got (#{args.count}) #{args}\n#{optparse}"
|
|
818
|
+
end
|
|
819
|
+
else
|
|
820
|
+
# updating 1-N ids
|
|
821
|
+
if args.count < 0
|
|
822
|
+
raise_command_error "wrong number of arguments, expected 1-N and got (#{args.count}) #{args}\n#{optparse}"
|
|
823
|
+
end
|
|
824
|
+
params['ids'] = args.collect {|arg| arg }
|
|
825
|
+
end
|
|
826
|
+
connect(options)
|
|
827
|
+
begin
|
|
828
|
+
# validate ids
|
|
829
|
+
if params['ids']
|
|
830
|
+
parsed_id_list = []
|
|
831
|
+
params['ids'].each do |alarm_id|
|
|
832
|
+
alarm = find_health_alarm_by_name_or_id(alarm_id)
|
|
833
|
+
if alarm.nil?
|
|
834
|
+
# print_red_alert "Alarm not found by id #{args[0]}"
|
|
835
|
+
return 1
|
|
836
|
+
end
|
|
837
|
+
parsed_id_list << alarm['id']
|
|
838
|
+
end
|
|
839
|
+
params['ids'] = parsed_id_list.uniq
|
|
840
|
+
end
|
|
841
|
+
|
|
842
|
+
# construct payload
|
|
843
|
+
passed_options = options[:options] ? options[:options].reject {|k,v| k.is_a?(Symbol) } : {}
|
|
844
|
+
payload = nil
|
|
845
|
+
if options[:payload]
|
|
846
|
+
payload = options[:payload]
|
|
847
|
+
payload.deep_merge!(passed_options) unless passed_options.empty?
|
|
848
|
+
else
|
|
849
|
+
payload = {}
|
|
850
|
+
# allow arbitrary -O options
|
|
851
|
+
payload.deep_merge!(passed_options) unless passed_options.empty?
|
|
852
|
+
end
|
|
853
|
+
id_list = params['ids'] || []
|
|
854
|
+
confirm_msg = params['all'] ? "Are you sure you want to acknowledge all open alarms?" : "Are you sure you want to acknowledge the #{id_list.size == 1 ? 'alarm' : 'alarms'} #{anded_list(id_list)}?"
|
|
855
|
+
unless options[:yes] || MtnCloud::Cli::OptionTypes.confirm(confirm_msg)
|
|
856
|
+
return 9, "aborted command"
|
|
857
|
+
end
|
|
858
|
+
@health_interface.setopts(options)
|
|
859
|
+
if options[:dry_run]
|
|
860
|
+
print_dry_run @health_interface.dry.acknowledge_alarms(params, payload)
|
|
861
|
+
return
|
|
862
|
+
end
|
|
863
|
+
json_response = @health_interface.acknowledge_alarms(params, payload)
|
|
864
|
+
render_result = render_with_format(json_response, options)
|
|
865
|
+
exit_code = 0 # json_response['success'] == true ? 0 : 1
|
|
866
|
+
return exit_code if render_result
|
|
867
|
+
|
|
868
|
+
if params['all']
|
|
869
|
+
print_green_success "Acknowledged all alarms"
|
|
870
|
+
else
|
|
871
|
+
print_green_success "Acknowledged #{id_list.size == 1 ? 'alarm' : 'alarms'} #{anded_list(id_list)}"
|
|
872
|
+
end
|
|
873
|
+
return exit_code
|
|
874
|
+
rescue RestClient::Exception => e
|
|
875
|
+
print_rest_exception(e, options)
|
|
876
|
+
exit 1
|
|
877
|
+
end
|
|
878
|
+
end
|
|
879
|
+
|
|
880
|
+
def unacknowledge_alarms(args)
|
|
881
|
+
options = {}
|
|
882
|
+
params = {acknowledged:false}
|
|
883
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
884
|
+
opts.banner = subcommand_usage("[alarm] [options]")
|
|
885
|
+
# opts.on('-a', '--all', "Acknowledge all open alarms. This can be used instead of passing specific alarms.") do
|
|
886
|
+
# params['all'] = true
|
|
887
|
+
# end
|
|
888
|
+
build_common_options(opts, options, [:payload, :options, :json, :dry_run, :remote])
|
|
889
|
+
opts.footer = "Unacknowledge health alarm(s).\n[alarm] is required. Alarm ID, supports multiple arguments."
|
|
890
|
+
end
|
|
891
|
+
optparse.parse!(args)
|
|
892
|
+
|
|
893
|
+
if params['all']
|
|
894
|
+
# updating all
|
|
895
|
+
if args.count > 0
|
|
896
|
+
raise_command_error "wrong number of arguments, --all option expects 0 and got (#{args.count}) #{args}\n#{optparse}"
|
|
897
|
+
end
|
|
898
|
+
else
|
|
899
|
+
# updating 1-N ids
|
|
900
|
+
if args.count < 0
|
|
901
|
+
raise_command_error "wrong number of arguments, expected 1-N and got (#{args.count}) #{args}\n#{optparse}"
|
|
902
|
+
end
|
|
903
|
+
params['ids'] = args.collect {|arg| arg }
|
|
904
|
+
end
|
|
905
|
+
connect(options)
|
|
906
|
+
begin
|
|
907
|
+
# validate ids
|
|
908
|
+
if params['ids']
|
|
909
|
+
parsed_id_list = []
|
|
910
|
+
params['ids'].each do |alarm_id|
|
|
911
|
+
alarm = find_health_alarm_by_name_or_id(alarm_id)
|
|
912
|
+
if alarm.nil?
|
|
913
|
+
# print_red_alert "Alarm not found by id #{args[0]}"
|
|
914
|
+
return 1
|
|
915
|
+
end
|
|
916
|
+
parsed_id_list << alarm['id']
|
|
917
|
+
end
|
|
918
|
+
params['ids'] = parsed_id_list.uniq
|
|
919
|
+
end
|
|
920
|
+
|
|
921
|
+
# construct payload
|
|
922
|
+
passed_options = options[:options] ? options[:options].reject {|k,v| k.is_a?(Symbol) } : {}
|
|
923
|
+
payload = nil
|
|
924
|
+
if options[:payload]
|
|
925
|
+
payload = options[:payload]
|
|
926
|
+
payload.deep_merge!(passed_options) unless passed_options.empty?
|
|
927
|
+
else
|
|
928
|
+
payload = {}
|
|
929
|
+
# allow arbitrary -O options
|
|
930
|
+
payload.deep_merge!(passed_options) unless passed_options.empty?
|
|
931
|
+
end
|
|
932
|
+
id_list = params['ids'] || []
|
|
933
|
+
confirm_msg = params['all'] ? "Are you sure you want to unacknowledge all alarms?" : "Are you sure you want to unacknowledge the #{id_list.size == 1 ? 'alarm' : 'alarms'} #{anded_list(id_list)}?"
|
|
934
|
+
unless options[:yes] || MtnCloud::Cli::OptionTypes.confirm(confirm_msg)
|
|
935
|
+
return 9, "aborted command"
|
|
936
|
+
end
|
|
937
|
+
@health_interface.setopts(options)
|
|
938
|
+
if options[:dry_run]
|
|
939
|
+
print_dry_run @health_interface.dry.acknowledge_alarms(params, payload)
|
|
940
|
+
return
|
|
941
|
+
end
|
|
942
|
+
json_response = @health_interface.acknowledge_alarms(params, payload)
|
|
943
|
+
render_result = render_with_format(json_response, options)
|
|
944
|
+
exit_code = 0 # json_response['success'] == true ? 0 : 1
|
|
945
|
+
return exit_code if render_result
|
|
946
|
+
|
|
947
|
+
if params['all']
|
|
948
|
+
print_green_success "Acknowledged all alarms"
|
|
949
|
+
else
|
|
950
|
+
print_green_success "Acknowledged #{id_list.size == 1 ? 'alarm' : 'alarms'} #{anded_list(id_list)}"
|
|
951
|
+
end
|
|
952
|
+
return exit_code
|
|
953
|
+
rescue RestClient::Exception => e
|
|
954
|
+
print_rest_exception(e, options)
|
|
955
|
+
exit 1
|
|
956
|
+
end
|
|
957
|
+
end
|
|
958
|
+
private
|
|
959
|
+
|
|
960
|
+
def find_health_alarm_by_name_or_id(val)
|
|
961
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
|
962
|
+
return find_health_alarm_by_id(val)
|
|
963
|
+
else
|
|
964
|
+
return find_health_alarm_by_name(val)
|
|
965
|
+
end
|
|
966
|
+
end
|
|
967
|
+
|
|
968
|
+
def find_health_alarm_by_id(id)
|
|
969
|
+
raise "#{self.class} has not defined @health_interface" if @health_interface.nil?
|
|
970
|
+
begin
|
|
971
|
+
json_response = @health_interface.get_alarm(id)
|
|
972
|
+
return json_response['alarm']
|
|
973
|
+
rescue RestClient::Exception => e
|
|
974
|
+
if e.response && e.response.code == 404
|
|
975
|
+
print_red_alert "Alarm not found by id #{id}"
|
|
976
|
+
else
|
|
977
|
+
raise e
|
|
978
|
+
end
|
|
979
|
+
end
|
|
980
|
+
end
|
|
981
|
+
|
|
982
|
+
def find_health_alarm_by_name(name)
|
|
983
|
+
raise "#{self.class} has not defined @health_interface" if @health_interface.nil?
|
|
984
|
+
alarms = @health_interface.list_alarms({name: name.to_s})['alarms']
|
|
985
|
+
if alarm.empty?
|
|
986
|
+
print_red_alert "Alarm not found by name #{name}"
|
|
987
|
+
return nil
|
|
988
|
+
elsif alarms.size > 1
|
|
989
|
+
print_red_alert "#{alarms.size} alarms found by name #{name}"
|
|
990
|
+
print as_pretty_table(alarms, [:id,:name], {color:red})
|
|
991
|
+
print reset,"\n"
|
|
992
|
+
return nil
|
|
993
|
+
else
|
|
994
|
+
return alarms[0]
|
|
995
|
+
end
|
|
996
|
+
end
|
|
997
|
+
|
|
998
|
+
def format_health_status(val, return_color=cyan)
|
|
999
|
+
out = ""
|
|
1000
|
+
status_string = val.to_s.downcase
|
|
1001
|
+
if(status_string)
|
|
1002
|
+
if(status_string == 'ok' || status_string == 'running')
|
|
1003
|
+
out << "#{green}#{status_string.upcase}#{return_color}"
|
|
1004
|
+
elsif(status_string == 'error' || status_string == 'offline')
|
|
1005
|
+
out << "#{red}#{status_string.upcase}#{return_color}"
|
|
1006
|
+
elsif status_string == 'syncing'
|
|
1007
|
+
out << "#{cyan}#{status_string.upcase}#{return_color}"
|
|
1008
|
+
else
|
|
1009
|
+
out << "#{yellow}#{status_string.upcase}#{return_color}"
|
|
1010
|
+
end
|
|
1011
|
+
end
|
|
1012
|
+
out
|
|
1013
|
+
end
|
|
1014
|
+
|
|
1015
|
+
# this is for weird elastic status values that are actually colors
|
|
1016
|
+
def format_index_health(val, return_color=cyan)
|
|
1017
|
+
# hrmm
|
|
1018
|
+
status_string = val.to_s.downcase # || 'green'
|
|
1019
|
+
if status_string == 'warning' || status_string == 'yellow'
|
|
1020
|
+
"#{yellow}WARNING#{cyan}"
|
|
1021
|
+
elsif status_string == 'error' || status_string == 'red'
|
|
1022
|
+
"#{red}ERROR#{cyan}"
|
|
1023
|
+
elsif status_string == 'ok' || status_string == 'green'
|
|
1024
|
+
"#{green}OK#{cyan}"
|
|
1025
|
+
else
|
|
1026
|
+
# hrmm
|
|
1027
|
+
it['status']
|
|
1028
|
+
end
|
|
1029
|
+
end
|
|
1030
|
+
|
|
1031
|
+
def format_queue_status(val, return_color=cyan)
|
|
1032
|
+
# hrmm
|
|
1033
|
+
status_string = val.to_s.downcase # || 'ok'
|
|
1034
|
+
if status_string == 'warning'
|
|
1035
|
+
"#{yellow}WARNING#{cyan}"
|
|
1036
|
+
elsif status_string == 'error'
|
|
1037
|
+
"#{red}ERROR#{cyan}"
|
|
1038
|
+
elsif status_string == 'ok'
|
|
1039
|
+
"#{green}OK#{cyan}"
|
|
1040
|
+
else
|
|
1041
|
+
# hrmm
|
|
1042
|
+
it['status']
|
|
1043
|
+
end
|
|
1044
|
+
end
|
|
1045
|
+
|
|
1046
|
+
end
|