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,484 @@
|
|
|
1
|
+
require 'mtncloud/cli/mixins/print_helper'
|
|
2
|
+
|
|
3
|
+
# Mixin for MtnCloud::Cli command classes
|
|
4
|
+
# Provides common methods for fetching and printing accounts, roles, and users.
|
|
5
|
+
# The including class must establish @accounts_interface, @roles_interface, @users_interface
|
|
6
|
+
module MtnCloud::Cli::AccountsHelper
|
|
7
|
+
|
|
8
|
+
def self.included(klass)
|
|
9
|
+
klass.send :include, MtnCloud::Cli::PrintHelper
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def accounts_interface
|
|
13
|
+
# @api_client.accounts
|
|
14
|
+
raise "#{self.class} has not defined @accounts_interface" if @accounts_interface.nil?
|
|
15
|
+
@accounts_interface
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def account_users_interface
|
|
19
|
+
# @api_client.users
|
|
20
|
+
raise "#{self.class} has not defined @account_users_interface" if @account_users_interface.nil?
|
|
21
|
+
@account_users_interface
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def user_groups_interface
|
|
25
|
+
# @api_client.users
|
|
26
|
+
raise "#{self.class} has not defined @user_groups_interface" if @user_groups_interface.nil?
|
|
27
|
+
@user_groups_interface
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def roles_interface
|
|
31
|
+
# @api_client.roles
|
|
32
|
+
raise "#{self.class} has not defined @roles_interface" if @roles_interface.nil?
|
|
33
|
+
@roles_interface
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
## Tenants (Accounts)
|
|
37
|
+
|
|
38
|
+
def account_column_definitions()
|
|
39
|
+
{
|
|
40
|
+
"ID" => 'id',
|
|
41
|
+
"Name" => 'name',
|
|
42
|
+
# "Name" => lambda {|it| it['name'].to_s + (it['master'] ? " (Master Tenant)" : '') },
|
|
43
|
+
"Description" => 'description',
|
|
44
|
+
"Subdomain" => 'subdomain',
|
|
45
|
+
"# Instances" => 'stats.instanceCount',
|
|
46
|
+
"# Users" => 'stats.userCount',
|
|
47
|
+
"Role" => lambda {|it| it['role']['authority'] rescue nil },
|
|
48
|
+
"Parent Tenant" => lambda {|it| it['parent']['name'] rescue nil },
|
|
49
|
+
"Master" => lambda {|it| format_boolean(it['master']) },
|
|
50
|
+
"Currency" => 'currency',
|
|
51
|
+
"Status" => lambda {|it|
|
|
52
|
+
status_state = nil
|
|
53
|
+
if it['active']
|
|
54
|
+
status_state = "#{green}ACTIVE#{cyan}"
|
|
55
|
+
else
|
|
56
|
+
status_state = "#{red}INACTIVE#{cyan}"
|
|
57
|
+
end
|
|
58
|
+
status_state
|
|
59
|
+
},
|
|
60
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
61
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) },
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def list_account_column_definitions()
|
|
66
|
+
columns = account_column_definitions
|
|
67
|
+
columns.delete("Subdomain")
|
|
68
|
+
columns.delete("Master")
|
|
69
|
+
columns.delete("Currency")
|
|
70
|
+
return columns.upcase_keys!
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def find_account_by_name_or_id(val)
|
|
75
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
|
76
|
+
return find_account_by_id(val)
|
|
77
|
+
else
|
|
78
|
+
return find_account_by_name(val)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def find_account_by_id(id)
|
|
83
|
+
begin
|
|
84
|
+
json_response = accounts_interface.get(id.to_i)
|
|
85
|
+
return json_response['account']
|
|
86
|
+
rescue RestClient::Exception => e
|
|
87
|
+
if e.response && e.response.code == 404
|
|
88
|
+
print_red_alert "Tenant not found by id #{id}"
|
|
89
|
+
else
|
|
90
|
+
raise e
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def find_account_by_name(name)
|
|
96
|
+
accounts = accounts_interface.list({name: name.to_s})['accounts']
|
|
97
|
+
if accounts.empty?
|
|
98
|
+
print_red_alert "Tenant not found by name #{name}"
|
|
99
|
+
return nil
|
|
100
|
+
elsif accounts.size > 1
|
|
101
|
+
print_red_alert "Found #{accounts.size} tenants by name '#{name}'. Try using ID instead: #{format_list(accounts.collect {|it| it['id']}, 'or', 3)}"
|
|
102
|
+
print "\n"
|
|
103
|
+
print as_pretty_table(accounts, [:id, :name, :description], {color: red, thin: true})
|
|
104
|
+
print reset,"\n"
|
|
105
|
+
return nil
|
|
106
|
+
else
|
|
107
|
+
return accounts[0]
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def find_account_from_options(options)
|
|
112
|
+
account = nil
|
|
113
|
+
if options[:account]
|
|
114
|
+
account = find_account_by_name_or_id(options[:account])
|
|
115
|
+
exit 1 if account.nil?
|
|
116
|
+
elsif options[:account_name]
|
|
117
|
+
account = find_account_by_name(options[:account_name])
|
|
118
|
+
exit 1 if account.nil?
|
|
119
|
+
elsif options[:account_id]
|
|
120
|
+
account = find_account_by_id(options[:account_id])
|
|
121
|
+
exit 1 if account.nil?
|
|
122
|
+
else
|
|
123
|
+
account = nil # use current account
|
|
124
|
+
end
|
|
125
|
+
return account
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
## Roles
|
|
129
|
+
|
|
130
|
+
def role_column_definitions(options={})
|
|
131
|
+
{
|
|
132
|
+
"ID" => 'id',
|
|
133
|
+
"Name" => 'authority',
|
|
134
|
+
"Description" => 'description',
|
|
135
|
+
"Landing URL" => 'landingUrl',
|
|
136
|
+
#"Scope" => lambda {|it| it['scope'] },
|
|
137
|
+
"Type" => lambda {|it| format_role_type(it) },
|
|
138
|
+
"Multitenant" => lambda {|it|
|
|
139
|
+
format_boolean(it['multitenant']).to_s + (it['multitenantLocked'] ? " (LOCKED)" : "")
|
|
140
|
+
},
|
|
141
|
+
"Default Persona" => lambda {|it| it['defaultPersona'] ? it['defaultPersona']['name'] : '' },
|
|
142
|
+
"Owner" => lambda {|it| it['owner'] ? it['owner']['name'] : '' },
|
|
143
|
+
#"Tenant" => lambda {|it| it['account'] ? it['account']['name'] : '' },
|
|
144
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
145
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
|
146
|
+
}
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def subtenant_role_column_definitions(options={})
|
|
150
|
+
{
|
|
151
|
+
"ID" => 'id',
|
|
152
|
+
"Name" => 'authority',
|
|
153
|
+
"Description" => 'description',
|
|
154
|
+
"Landing URL" => 'landingUrl',
|
|
155
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
156
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
|
157
|
+
}
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def find_role_by_name_or_id(account_id, val)
|
|
161
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
|
162
|
+
return find_role_by_id(account_id, val)
|
|
163
|
+
else
|
|
164
|
+
return find_role_by_name(account_id, val)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def find_role_by_id(account_id, id)
|
|
169
|
+
begin
|
|
170
|
+
json_response = roles_interface.get(account_id, id.to_i)
|
|
171
|
+
return json_response['role']
|
|
172
|
+
rescue RestClient::Exception => e
|
|
173
|
+
if e.response && e.response.code == 404
|
|
174
|
+
print_red_alert "Role not found by id #{id}"
|
|
175
|
+
else
|
|
176
|
+
raise e
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def find_role_by_name(account_id, name)
|
|
182
|
+
roles = roles_interface.list(account_id, {authority: name.to_s})['roles']
|
|
183
|
+
if roles.empty?
|
|
184
|
+
print_red_alert "Role not found by name #{name}"
|
|
185
|
+
return nil
|
|
186
|
+
elsif roles.size > 1
|
|
187
|
+
print_red_alert "Found #{roles.size} roles by name '#{name}'. Try using ID instead: #{format_list(roles.collect {|it| it['id']}, 'or', 3)}"
|
|
188
|
+
print "\n"
|
|
189
|
+
# print as_pretty_table(accounts, [:id, :name, :description], {color: red, thin: true})
|
|
190
|
+
print as_pretty_table(roles, {"ID" => 'id', "Name" => 'authority',"Description" => 'description'}.upcase_keys!, {color: red, thin: true})
|
|
191
|
+
print reset,"\n"
|
|
192
|
+
return nil
|
|
193
|
+
else
|
|
194
|
+
return roles[0]
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
alias_method :find_role_by_authority, :find_role_by_name
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
## Users
|
|
202
|
+
|
|
203
|
+
def user_column_definitions(opts={})
|
|
204
|
+
{
|
|
205
|
+
"ID" => 'id',
|
|
206
|
+
"Tenant" => lambda {|it| it['account'] ? it['account']['name'] : '' },
|
|
207
|
+
"First Name" => 'firstName',
|
|
208
|
+
"Last Name" => 'lastName',
|
|
209
|
+
"Username" => 'username',
|
|
210
|
+
"Email" => 'email',
|
|
211
|
+
"Role" => lambda {|it| format_user_role_names(it) },
|
|
212
|
+
"Notifications" => lambda {|it| it['receiveNotifications'].nil? ? '' : format_boolean(it['receiveNotifications']) },
|
|
213
|
+
"Status" => lambda {|it| format_user_status(it, opts[:color] || cyan) },
|
|
214
|
+
"Last Login" => lambda {|it| format_duration_ago(it['lastLoginDate']) },
|
|
215
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
216
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) },
|
|
217
|
+
}
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def list_user_column_definitions(opts={})
|
|
221
|
+
columns = user_column_definitions(opts)
|
|
222
|
+
columns.delete("Notifications")
|
|
223
|
+
return columns.upcase_keys!
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def format_user_status(user, return_color=cyan)
|
|
227
|
+
if user["enabled"] != true
|
|
228
|
+
red + "DISABLED" + return_color
|
|
229
|
+
elsif user["accountLocked"]
|
|
230
|
+
red + "ACCOUNT LOCKED" + return_color
|
|
231
|
+
elsif user["accountExpired"]
|
|
232
|
+
yellow + "ACCOUNT EXPIRED" + return_color
|
|
233
|
+
elsif user["passwordExpired"]
|
|
234
|
+
yellow + "PASSWORD EXPIRED" + return_color
|
|
235
|
+
else
|
|
236
|
+
green + "ACTIVE" + return_color
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def find_user_by_username_or_id(account_id, val, params={})
|
|
241
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
|
242
|
+
return find_user_by_id(account_id, val, params)
|
|
243
|
+
else
|
|
244
|
+
return find_user_by_username(account_id, val, params)
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def find_user_by_id(account_id, id, params={})
|
|
249
|
+
begin
|
|
250
|
+
json_response = account_users_interface.get(account_id, id.to_i, params)
|
|
251
|
+
return json_response['user']
|
|
252
|
+
rescue RestClient::Exception => e
|
|
253
|
+
if e.response && e.response.code == 404
|
|
254
|
+
print_red_alert "User not found by id #{id}"
|
|
255
|
+
else
|
|
256
|
+
raise e
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
def find_user_by_username(account_id, username, params={})
|
|
262
|
+
users = account_users_interface.list(account_id, params.merge({username: username.to_s}))['users']
|
|
263
|
+
if users.empty?
|
|
264
|
+
print_red_alert "User not found by username #{username}"
|
|
265
|
+
return nil
|
|
266
|
+
elsif users.size > 1
|
|
267
|
+
print_red_alert "Found #{users.size} users by username '#{username}'. Try using ID instead: #{format_list(users.collect {|it| it['id']}, 'or', 3)}"
|
|
268
|
+
print_error "\n"
|
|
269
|
+
print_error as_pretty_table(users, list_user_column_definitions({color: red}), {color: red, thin: true})
|
|
270
|
+
print reset,"\n"
|
|
271
|
+
return nil
|
|
272
|
+
else
|
|
273
|
+
return users[0]
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def find_all_user_ids(account_id, usernames, params={})
|
|
278
|
+
user_ids = []
|
|
279
|
+
if usernames.is_a?(String)
|
|
280
|
+
usernames = usernames.split(",").collect {|it| it.to_s.strip }.select {|it| it }.uniq
|
|
281
|
+
else
|
|
282
|
+
usernames = usernames.collect {|it| it.to_s.strip }.select {|it| it }.uniq
|
|
283
|
+
end
|
|
284
|
+
usernames.each do |username|
|
|
285
|
+
# save a query
|
|
286
|
+
#user = find_user_by_username_or_id(nil, username, params)
|
|
287
|
+
if username.to_s =~ /\A\d{1,}\Z/
|
|
288
|
+
user_ids << username.to_i
|
|
289
|
+
else
|
|
290
|
+
user = find_user_by_username(account_id, username, params)
|
|
291
|
+
if user.nil?
|
|
292
|
+
return nil
|
|
293
|
+
else
|
|
294
|
+
user_ids << user['id']
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
user_ids
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
## User Groups
|
|
303
|
+
|
|
304
|
+
def user_group_column_definitions()
|
|
305
|
+
{
|
|
306
|
+
"ID" => lambda {|it| it['id'] },
|
|
307
|
+
#"Account" => lambda {|it| it['account'] ? it['account']['name'] : '' },
|
|
308
|
+
"Name" => lambda {|it| it['name'] },
|
|
309
|
+
"Description" => lambda {|it| it['description'] },
|
|
310
|
+
"Server Group" => lambda {|it| it['serverGroup'] },
|
|
311
|
+
"Sudo Access" => lambda {|it| format_boolean it['sudoAccess'] },
|
|
312
|
+
# "Shared User" => lambda {|it| format_boolean it['sharedUser'] },
|
|
313
|
+
"# Users" => lambda {|it| it['users'].size rescue nil },
|
|
314
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
315
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
|
316
|
+
}
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
def list_user_group_column_definitions()
|
|
320
|
+
columns = user_group_column_definitions
|
|
321
|
+
columns.delete("Sudo Access")
|
|
322
|
+
columns.delete("Server Group")
|
|
323
|
+
columns.delete("Updated")
|
|
324
|
+
return columns.upcase_keys!
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def find_user_group_by_name_or_id(account_id, val)
|
|
328
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
|
329
|
+
return find_user_group_by_id(account_id, val)
|
|
330
|
+
else
|
|
331
|
+
return find_user_group_by_name(account_id, val)
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def find_user_group_by_id(account_id, id)
|
|
336
|
+
begin
|
|
337
|
+
json_response = @user_groups_interface.get(account_id, id.to_i)
|
|
338
|
+
return json_response['userGroup']
|
|
339
|
+
rescue RestClient::Exception => e
|
|
340
|
+
if e.response && e.response.code == 404
|
|
341
|
+
print_red_alert "User Group not found by id #{id}"
|
|
342
|
+
else
|
|
343
|
+
raise e
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
def find_user_group_by_name(account_id, name)
|
|
349
|
+
user_groups = @user_groups_interface.list(account_id, {name: name.to_s})['userGroups']
|
|
350
|
+
if user_groups.empty?
|
|
351
|
+
print_red_alert "User Group not found by name #{name}"
|
|
352
|
+
return nil
|
|
353
|
+
elsif user_groups.size > 1
|
|
354
|
+
print_red_alert "Found #{user_groups.size} user groups by name '#{name}'. Try using ID instead: #{format_list(user_groups.collect {|it| it['id']}, 'or', 3)}"
|
|
355
|
+
print as_pretty_table(user_groups, [:id, :name, :description], {color: red, thin: true})
|
|
356
|
+
print reset,"\n"
|
|
357
|
+
return nil
|
|
358
|
+
else
|
|
359
|
+
return user_groups[0]
|
|
360
|
+
end
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
def format_role_type(role)
|
|
364
|
+
str = ""
|
|
365
|
+
if role['roleType'] == "account"
|
|
366
|
+
str = "Account"
|
|
367
|
+
elsif role['roleType'] == "user"
|
|
368
|
+
str = "User"
|
|
369
|
+
else
|
|
370
|
+
if role['scope'] == 'Account'
|
|
371
|
+
str = "Legacy"
|
|
372
|
+
else
|
|
373
|
+
str = "Admin" # System Admin
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
# if role['scope'] && role['filterType'] != 'Account'
|
|
377
|
+
# str = "(System) #{str}"
|
|
378
|
+
# end
|
|
379
|
+
return str
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
## These user access formatted methods should probably move up to PrintHelper to be more ubiquitous.
|
|
383
|
+
|
|
384
|
+
def format_user_role_names(user)
|
|
385
|
+
role_names = ""
|
|
386
|
+
if user && user['roles']
|
|
387
|
+
roles = user['roles']
|
|
388
|
+
roles = roles.sort {|a,b| a['authority'].to_s.downcase <=> b['authority'].to_s.downcase }
|
|
389
|
+
role_names = roles.collect {|r| r['authority'] }.join(', ')
|
|
390
|
+
end
|
|
391
|
+
role_names
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
def get_access_color(access)
|
|
395
|
+
access ||= 'default'
|
|
396
|
+
if access == 'none'
|
|
397
|
+
# maybe reset instead of white?
|
|
398
|
+
white
|
|
399
|
+
elsif access.include? 'full'
|
|
400
|
+
green
|
|
401
|
+
else
|
|
402
|
+
cyan
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
def get_access_string(access, return_color=cyan)
|
|
407
|
+
access ||= 'default'
|
|
408
|
+
get_access_color(access) + access.to_s + return_color.to_s
|
|
409
|
+
# access ||= 'none'
|
|
410
|
+
# if access == 'none'
|
|
411
|
+
# "#{white}#{access.to_s}#{return_color}"
|
|
412
|
+
# elsif access == 'read'
|
|
413
|
+
# "#{cyan}#{access.to_s.capitalize}#{return_color}"
|
|
414
|
+
# else
|
|
415
|
+
# "#{green}#{access.to_s}#{return_color}"
|
|
416
|
+
# end
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
# this outputs a string that matches the length of all available access levels
|
|
420
|
+
# for outputting in a grid that looks like this:
|
|
421
|
+
#
|
|
422
|
+
# none
|
|
423
|
+
# full
|
|
424
|
+
# full
|
|
425
|
+
# user
|
|
426
|
+
# read
|
|
427
|
+
# full
|
|
428
|
+
# none
|
|
429
|
+
#
|
|
430
|
+
# Examples: format_permission_access("read")
|
|
431
|
+
# format_permission_access("custom", "full,custom,none")
|
|
432
|
+
def format_access_string(access, access_levels=nil, return_color=cyan)
|
|
433
|
+
# nevermind all this, just colorized access level
|
|
434
|
+
return get_access_string(access, return_color)
|
|
435
|
+
|
|
436
|
+
access = access.to_s.downcase.strip
|
|
437
|
+
if access.empty?
|
|
438
|
+
access = "none"
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
if access_levels.nil?
|
|
442
|
+
access_levels = ["none","read","user","full"]
|
|
443
|
+
elsif access_levels.is_a?(Array)
|
|
444
|
+
# access_levels = access_levels
|
|
445
|
+
else
|
|
446
|
+
# parse values like "full,custom,none"
|
|
447
|
+
access_levels = [access_levels].flatten.collect {|it| it.strip.split(",") }.flatten.collect {|it| it.strip }.compact
|
|
448
|
+
end
|
|
449
|
+
# build padded string that contains access eg. 'full' or ' read'
|
|
450
|
+
access_levels_string = access_levels.join(",")
|
|
451
|
+
padded_value = ""
|
|
452
|
+
access_levels.each do |a|
|
|
453
|
+
# handle some unusual access values
|
|
454
|
+
# print custom, and provision where 'user' normally is at index 1
|
|
455
|
+
if (access == "custom" || access == "provision") && a == "user"
|
|
456
|
+
padded_value << access
|
|
457
|
+
else
|
|
458
|
+
if access == a
|
|
459
|
+
padded_value << access
|
|
460
|
+
else
|
|
461
|
+
padded_value << " " * a.size
|
|
462
|
+
end
|
|
463
|
+
end
|
|
464
|
+
end
|
|
465
|
+
# no matching access was found, so just print it in one slot
|
|
466
|
+
if padded_value == ""
|
|
467
|
+
padded_value = " " * access_levels[0].to_s.size
|
|
468
|
+
padded_value << access
|
|
469
|
+
end
|
|
470
|
+
# strip any extra whitespace off the end
|
|
471
|
+
if padded_value.size > access_levels_string.size
|
|
472
|
+
padded_value = padded_value.rstrip
|
|
473
|
+
end
|
|
474
|
+
# ok build out string
|
|
475
|
+
out = ""
|
|
476
|
+
access_color = get_access_color(access || 'default')
|
|
477
|
+
out << access_color if access_color
|
|
478
|
+
out << padded_value
|
|
479
|
+
out << reset if access_color
|
|
480
|
+
out << return_color if return_color
|
|
481
|
+
return out
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
require 'mtncloud/cli/mixins/print_helper'
|
|
2
|
+
|
|
3
|
+
# Mixin for MtnCloud::Cli command classes
|
|
4
|
+
# Single source of truth for affinity group / host-vm group enums and formatting.
|
|
5
|
+
#
|
|
6
|
+
# Keep this in sync with morpheus-ui and the OpenAPI shared affinity-type schema.
|
|
7
|
+
# Defining these values here (rather than inline in each command) prevents the
|
|
8
|
+
# definitions from drifting apart between cluster-scoped, cloud-scoped and
|
|
9
|
+
# top-level flat-by-ID commands.
|
|
10
|
+
module MtnCloud::Cli::AffinityHelper
|
|
11
|
+
|
|
12
|
+
def self.included(klass)
|
|
13
|
+
klass.send :include, MtnCloud::Cli::PrintHelper
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# All affinity types supported by the API.
|
|
17
|
+
# The _MUST variants are mandatory placement constraints and are what the
|
|
18
|
+
# violations endpoint reports on.
|
|
19
|
+
AFFINITY_TYPES = [
|
|
20
|
+
{'name' => 'Keep Together (Should)', 'value' => 'KEEP_TOGETHER'},
|
|
21
|
+
{'name' => 'Keep Separate (Should)', 'value' => 'KEEP_SEPARATE'},
|
|
22
|
+
{'name' => 'Keep Together (Must)', 'value' => 'KEEP_TOGETHER_MUST'},
|
|
23
|
+
{'name' => 'Keep Separate (Must)', 'value' => 'KEEP_SEPARATE_MUST'},
|
|
24
|
+
].freeze
|
|
25
|
+
|
|
26
|
+
# Group types, per HostVmGroup.HostVmGroupType (morpheus-ui rc-9.1.0,
|
|
27
|
+
# morpheus-domains/grails-app/domain/com/morpheus/HostVmGroup.groovy).
|
|
28
|
+
# SITE_GROUP exists in the enum but is not valid on either side of a combined
|
|
29
|
+
# VM-to-Host rule -- AffinityGroupService.applyRuleShapeFields rejects it.
|
|
30
|
+
HOST_VM_GROUP_TYPES = [
|
|
31
|
+
{'name' => 'Site Group', 'value' => 'SITE_GROUP'},
|
|
32
|
+
{'name' => 'Host Group', 'value' => 'HOST_GROUP'},
|
|
33
|
+
{'name' => 'VM Group', 'value' => 'VM_GROUP'},
|
|
34
|
+
].freeze
|
|
35
|
+
|
|
36
|
+
def affinity_type_select_options
|
|
37
|
+
AFFINITY_TYPES.map {|it| it.dup }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def host_vm_group_type_select_options
|
|
41
|
+
HOST_VM_GROUP_TYPES.map {|it| it.dup }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# affinityType is editable on update as well as create.
|
|
45
|
+
# AffinityGroupService.updateAffinityGroup applies params.affinityGroup.affinityType,
|
|
46
|
+
# so callers may switch between MUST and non-MUST behaviour during an edit.
|
|
47
|
+
def affinity_type_option_type(required: false, default: nil)
|
|
48
|
+
opt = {
|
|
49
|
+
'fieldName' => 'affinityType',
|
|
50
|
+
'fieldLabel' => 'Type',
|
|
51
|
+
'type' => 'select',
|
|
52
|
+
'selectOptions' => affinity_type_select_options,
|
|
53
|
+
'description' => 'Affinity type. The _MUST variants are mandatory placement constraints.',
|
|
54
|
+
}
|
|
55
|
+
opt['required'] = true if required
|
|
56
|
+
opt['defaultValue'] = default if default
|
|
57
|
+
opt
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def host_vm_group_type_option_type(required: false, default: nil)
|
|
61
|
+
opt = {
|
|
62
|
+
'fieldName' => 'type',
|
|
63
|
+
'fieldLabel' => 'Group Type',
|
|
64
|
+
'type' => 'select',
|
|
65
|
+
'selectOptions' => host_vm_group_type_select_options,
|
|
66
|
+
'description' => 'Choose group type.',
|
|
67
|
+
}
|
|
68
|
+
opt['required'] = true if required
|
|
69
|
+
opt['defaultValue'] = default if default
|
|
70
|
+
opt
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def format_affinity_type(affinity_type)
|
|
74
|
+
found = AFFINITY_TYPES.find {|it| it['value'] == affinity_type.to_s }
|
|
75
|
+
found ? found['name'].sub(' (Should)', '') : affinity_type.to_s
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def format_host_vm_group_type(type)
|
|
79
|
+
found = HOST_VM_GROUP_TYPES.find {|it| it['value'] == type.to_s }
|
|
80
|
+
found ? found['name'] : type.to_s
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Groups carry poolId; keep only those in the chosen cluster.
|
|
84
|
+
def filter_by_pool(rows, pool_id)
|
|
85
|
+
return rows if pool_id.nil?
|
|
86
|
+
rows.select {|r| r['poolId'].nil? || r['poolId'].to_s == pool_id.to_s }
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Surface the server's own error text for affinity failures.
|
|
90
|
+
#
|
|
91
|
+
# The API returns {success:false, msg:"<human text>", errors:{<field>:"<i18n key>"}}
|
|
92
|
+
# -- there is no top-level errorCode. AffinityGroupService and
|
|
93
|
+
# VmwareComputeService.combinedRuleGroupSyncGuard already compose actionable
|
|
94
|
+
# messages (cross-cluster group refs, groups not yet synced to vSphere, rule
|
|
95
|
+
# shape violations), so print them verbatim rather than restating them here.
|
|
96
|
+
def handle_affinity_rest_exception(e, options)
|
|
97
|
+
if e.respond_to?(:response) && e.response
|
|
98
|
+
begin
|
|
99
|
+
body = JSON.parse(e.response.to_s)
|
|
100
|
+
if body.is_a?(Hash) && (body['msg'] || body['errors'])
|
|
101
|
+
print_red_alert body['msg'] if body['msg']
|
|
102
|
+
errors = body['errors']
|
|
103
|
+
if errors.is_a?(Hash) && !errors.empty?
|
|
104
|
+
# Same stream as print_red_alert, so msg and field detail stay together.
|
|
105
|
+
errors.each do |field, message|
|
|
106
|
+
$stderr.print "#{red} #{field}: #{message}#{reset}\n"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
return
|
|
110
|
+
end
|
|
111
|
+
rescue TypeError, JSON::ParserError
|
|
112
|
+
# fall through to the generic handler
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
print_rest_exception(e, options)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
end
|