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,923 @@
|
|
|
1
|
+
require 'mtncloud/cli/cli_command'
|
|
2
|
+
|
|
3
|
+
class MtnCloud::Cli::Deployments
|
|
4
|
+
include MtnCloud::Cli::CliCommand
|
|
5
|
+
include MtnCloud::Cli::DeploymentsHelper
|
|
6
|
+
|
|
7
|
+
set_command_description "View and manage deployments, including versions and files."
|
|
8
|
+
|
|
9
|
+
register_subcommands :list, :get, :add, :update, :remove
|
|
10
|
+
register_subcommands :list_versions, :get_version, :add_version, :update_version, :remove_version
|
|
11
|
+
register_subcommands :list_files, :upload, :remove_file
|
|
12
|
+
alias_subcommand :versions, :'list-versions'
|
|
13
|
+
|
|
14
|
+
def initialize()
|
|
15
|
+
# @appliance_name, @appliance_url = MtnCloud::Cli::Remote.active_appliance
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def connect(opts)
|
|
19
|
+
@api_client = establish_remote_appliance_connection(opts)
|
|
20
|
+
@deployments_interface = @api_client.deployments
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def handle(args)
|
|
24
|
+
handle_subcommand(args)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def list(args)
|
|
28
|
+
options = {}
|
|
29
|
+
params = {}
|
|
30
|
+
ref_ids = []
|
|
31
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
32
|
+
opts.banner = subcommand_usage("[search]")
|
|
33
|
+
build_standard_list_options(opts, options)
|
|
34
|
+
opts.footer = "List deployments."
|
|
35
|
+
end
|
|
36
|
+
optparse.parse!(args)
|
|
37
|
+
connect(options)
|
|
38
|
+
# verify_args!(args:args, optparse:optparse, count:0)
|
|
39
|
+
if args.count > 0
|
|
40
|
+
options[:phrase] = args.join(" ")
|
|
41
|
+
end
|
|
42
|
+
params.merge!(parse_list_options(options))
|
|
43
|
+
@deployments_interface.setopts(options)
|
|
44
|
+
if options[:dry_run]
|
|
45
|
+
print_dry_run @deployments_interface.dry.list(params)
|
|
46
|
+
return
|
|
47
|
+
end
|
|
48
|
+
json_response = @deployments_interface.list(params)
|
|
49
|
+
deployments = json_response['deployments']
|
|
50
|
+
render_response(json_response, options, 'deployments') do
|
|
51
|
+
print_h1 "Deployments", parse_list_subtitles(options), options
|
|
52
|
+
if deployments.empty?
|
|
53
|
+
print cyan,"No deployments found.",reset,"\n"
|
|
54
|
+
else
|
|
55
|
+
print as_pretty_table(deployments, deployment_column_definitions.upcase_keys!, options)
|
|
56
|
+
print_results_pagination(json_response)
|
|
57
|
+
end
|
|
58
|
+
print reset,"\n"
|
|
59
|
+
end
|
|
60
|
+
if deployments.empty?
|
|
61
|
+
return 1, "no deployments found"
|
|
62
|
+
else
|
|
63
|
+
return 0, nil
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def get(args)
|
|
68
|
+
params = {}
|
|
69
|
+
options = {}
|
|
70
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
71
|
+
opts.banner = subcommand_usage("[deployment]")
|
|
72
|
+
build_standard_get_options(opts, options)
|
|
73
|
+
opts.footer = <<-EOT
|
|
74
|
+
Get details about a specific deployment.
|
|
75
|
+
[deployment] is required. This is the name or id of a deployment.
|
|
76
|
+
EOT
|
|
77
|
+
end
|
|
78
|
+
optparse.parse!(args)
|
|
79
|
+
verify_args!(args:args, optparse:optparse, min:1)
|
|
80
|
+
connect(options)
|
|
81
|
+
id_list = parse_id_list(args)
|
|
82
|
+
# lookup IDs if names are given
|
|
83
|
+
id_list = id_list.collect do |id|
|
|
84
|
+
if id.to_s =~ /\A\d{1,}\Z/
|
|
85
|
+
id
|
|
86
|
+
else
|
|
87
|
+
deployment = find_deployment_by_name_or_id(id)
|
|
88
|
+
if deployment
|
|
89
|
+
deployment['id']
|
|
90
|
+
else
|
|
91
|
+
raise_command_error "deployment not found for name '#{id}'"
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
return run_command_for_each_arg(id_list) do |arg|
|
|
96
|
+
_get(arg, params, options)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def _get(id, params, options)
|
|
101
|
+
@deployments_interface.setopts(options)
|
|
102
|
+
if options[:dry_run]
|
|
103
|
+
print_dry_run @deployments_interface.dry.get(id, params)
|
|
104
|
+
print_dry_run @deployments_interface.dry.list_versions(id, {})
|
|
105
|
+
return
|
|
106
|
+
end
|
|
107
|
+
json_response = @deployments_interface.get(id, params)
|
|
108
|
+
deployment_versions = @deployments_interface.list_versions(id)['versions']
|
|
109
|
+
deployment = json_response['deployment']
|
|
110
|
+
render_response(json_response, options, 'deployment') do
|
|
111
|
+
print_h1 "Deployment Details", [], options
|
|
112
|
+
print cyan
|
|
113
|
+
print_description_list(deployment_column_definitions, deployment)
|
|
114
|
+
print_h2 "Versions", options
|
|
115
|
+
if deployment_versions.empty?
|
|
116
|
+
print cyan,"No versions found.",reset,"\n"
|
|
117
|
+
else
|
|
118
|
+
print as_pretty_table(deployment_versions, deployment_version_column_definitions.upcase_keys!, options)
|
|
119
|
+
print_results_pagination({'size' => deployment_versions.size(), 'total' => deployment['versionCount']}, {:label => "version", :n_label => "versions"})
|
|
120
|
+
end
|
|
121
|
+
print reset,"\n"
|
|
122
|
+
end
|
|
123
|
+
return 0, nil
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def list_versions(args)
|
|
127
|
+
params = {}
|
|
128
|
+
options = {}
|
|
129
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
130
|
+
opts.banner = subcommand_usage("[deployment] [search]")
|
|
131
|
+
build_standard_list_options(opts, options)
|
|
132
|
+
opts.footer = <<-EOT
|
|
133
|
+
List versions of a specific deployment.
|
|
134
|
+
[deployment] is required. This is the name or id of a deployment.
|
|
135
|
+
EOT
|
|
136
|
+
end
|
|
137
|
+
optparse.parse!(args)
|
|
138
|
+
verify_args!(args:args, optparse:optparse, min:1,max:2)
|
|
139
|
+
deployment_name = args[0]
|
|
140
|
+
if args.count > 1
|
|
141
|
+
options[:phrase] = args[1]
|
|
142
|
+
end
|
|
143
|
+
connect(options)
|
|
144
|
+
params.merge!(parse_list_options(options))
|
|
145
|
+
@deployments_interface.setopts(options)
|
|
146
|
+
if options[:dry_run]
|
|
147
|
+
print_dry_run @deployments_interface.dry.list(params)
|
|
148
|
+
return
|
|
149
|
+
end
|
|
150
|
+
deployment = find_deployment_by_name_or_id(deployment_name)
|
|
151
|
+
exit 1 if deployment.nil?
|
|
152
|
+
json_response = @deployments_interface.list_versions(deployment['id'], params)
|
|
153
|
+
deployment_versions = json_response['versions']
|
|
154
|
+
render_response(json_response, options, 'versions') do
|
|
155
|
+
print_h1 "Deployment Versions", ["#{deployment['name']}"] + parse_list_subtitles(options), options
|
|
156
|
+
if deployment_versions.empty?
|
|
157
|
+
print cyan,"No versions found.",reset,"\n"
|
|
158
|
+
else
|
|
159
|
+
print as_pretty_table(deployment_versions, deployment_version_column_definitions.upcase_keys!, options)
|
|
160
|
+
print_results_pagination(json_response)
|
|
161
|
+
end
|
|
162
|
+
print reset,"\n"
|
|
163
|
+
end
|
|
164
|
+
if deployment_versions.empty?
|
|
165
|
+
return 1, "no versions found"
|
|
166
|
+
else
|
|
167
|
+
return 0, nil
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def add(args)
|
|
172
|
+
options = {}
|
|
173
|
+
params = {}
|
|
174
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
175
|
+
opts.banner = subcommand_usage("[name] [options]")
|
|
176
|
+
build_option_type_options(opts, options, add_deployment_option_types)
|
|
177
|
+
build_option_type_options(opts, options, add_deployment_advanced_option_types)
|
|
178
|
+
build_standard_add_options(opts, options)
|
|
179
|
+
opts.footer = <<-EOT
|
|
180
|
+
Create a new deployment.
|
|
181
|
+
EOT
|
|
182
|
+
end
|
|
183
|
+
optparse.parse!(args)
|
|
184
|
+
verify_args!(args:args, optparse:optparse, min:0, max:1)
|
|
185
|
+
options[:options]['name'] = args[0] if args[0]
|
|
186
|
+
connect(options)
|
|
187
|
+
payload = {}
|
|
188
|
+
if options[:payload]
|
|
189
|
+
payload = options[:payload]
|
|
190
|
+
payload.deep_merge!({'deployment' => parse_passed_options(options)})
|
|
191
|
+
else
|
|
192
|
+
payload.deep_merge!({'deployment' => parse_passed_options(options)})
|
|
193
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt(add_deployment_option_types, options[:options], @api_client, options[:params])
|
|
194
|
+
params.deep_merge!(v_prompt)
|
|
195
|
+
advanced_config = MtnCloud::Cli::OptionTypes.no_prompt(add_deployment_advanced_option_types, options[:options], @api_client, options[:params])
|
|
196
|
+
advanced_config.deep_compact!
|
|
197
|
+
params.deep_merge!(advanced_config)
|
|
198
|
+
payload['deployment'].deep_merge!(params)
|
|
199
|
+
end
|
|
200
|
+
@deployments_interface.setopts(options)
|
|
201
|
+
if options[:dry_run]
|
|
202
|
+
print_dry_run @deployments_interface.dry.create(payload)
|
|
203
|
+
return 0, nil
|
|
204
|
+
end
|
|
205
|
+
json_response = @deployments_interface.create(payload)
|
|
206
|
+
deployment = json_response['deployment']
|
|
207
|
+
render_response(json_response, options, 'deployment') do
|
|
208
|
+
print_green_success "Added deployment #{deployment['name']}"
|
|
209
|
+
return _get(deployment["id"], {}, options)
|
|
210
|
+
end
|
|
211
|
+
return 0, nil
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def update(args)
|
|
215
|
+
options = {}
|
|
216
|
+
params = {}
|
|
217
|
+
payload = {}
|
|
218
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
219
|
+
opts.banner = subcommand_usage("[deployment] [options]")
|
|
220
|
+
build_option_type_options(opts, options, update_deployment_option_types)
|
|
221
|
+
build_option_type_options(opts, options, update_deployment_advanced_option_types)
|
|
222
|
+
build_standard_update_options(opts, options)
|
|
223
|
+
opts.footer = <<-EOT
|
|
224
|
+
Update a deployment.
|
|
225
|
+
[deployment] is required. This is the name or id of a deployment.
|
|
226
|
+
EOT
|
|
227
|
+
end
|
|
228
|
+
optparse.parse!(args)
|
|
229
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
230
|
+
connect(options)
|
|
231
|
+
deployment = find_deployment_by_name_or_id(args[0])
|
|
232
|
+
return 1 if deployment.nil?
|
|
233
|
+
payload = {}
|
|
234
|
+
if options[:payload]
|
|
235
|
+
payload = options[:payload]
|
|
236
|
+
payload.deep_merge!({'deployment' => parse_passed_options(options)})
|
|
237
|
+
else
|
|
238
|
+
payload.deep_merge!({'deployment' => parse_passed_options(options)})
|
|
239
|
+
# do not prompt on update
|
|
240
|
+
v_prompt = MtnCloud::Cli::OptionTypes.no_prompt(update_deployment_option_types, options[:options], @api_client, options[:params])
|
|
241
|
+
v_prompt.deep_compact!
|
|
242
|
+
params.deep_merge!(v_prompt)
|
|
243
|
+
advanced_config = MtnCloud::Cli::OptionTypes.no_prompt(update_deployment_advanced_option_types, options[:options], @api_client, options[:params])
|
|
244
|
+
advanced_config.deep_compact!
|
|
245
|
+
params.deep_merge!(advanced_config)
|
|
246
|
+
payload.deep_merge!({'deployment' => params})
|
|
247
|
+
if payload['deployment'].empty? # || options[:no_prompt]
|
|
248
|
+
raise_command_error "Specify at least one option to update.\n#{optparse}"
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
@deployments_interface.setopts(options)
|
|
252
|
+
if options[:dry_run]
|
|
253
|
+
print_dry_run @deployments_interface.dry.update(deployment['id'], payload)
|
|
254
|
+
return
|
|
255
|
+
end
|
|
256
|
+
json_response = @deployments_interface.update(deployment['id'], payload)
|
|
257
|
+
deployment = json_response['deployment']
|
|
258
|
+
render_response(json_response, options, 'deployment') do
|
|
259
|
+
print_green_success "Updated deployment #{deployment['name']}"
|
|
260
|
+
return _get(deployment["id"], {}, options)
|
|
261
|
+
end
|
|
262
|
+
return 0, nil
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def remove(args)
|
|
266
|
+
options = {}
|
|
267
|
+
params = {}
|
|
268
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
269
|
+
opts.banner = subcommand_usage("[deployment] [options]")
|
|
270
|
+
build_standard_remove_options(opts, options)
|
|
271
|
+
opts.footer = <<-EOT
|
|
272
|
+
Delete a deployment.
|
|
273
|
+
[deployment] is required. This is the name or id of a deployment.
|
|
274
|
+
EOT
|
|
275
|
+
end
|
|
276
|
+
optparse.parse!(args)
|
|
277
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
278
|
+
connect(options)
|
|
279
|
+
deployment = find_deployment_by_name_or_id(args[0])
|
|
280
|
+
return 1 if deployment.nil?
|
|
281
|
+
unless options[:yes] || MtnCloud::Cli::OptionTypes.confirm("Are you sure you want to delete the deployment #{deployment['name']}?")
|
|
282
|
+
return 9, "aborted command"
|
|
283
|
+
end
|
|
284
|
+
@deployments_interface.setopts(options)
|
|
285
|
+
if options[:dry_run]
|
|
286
|
+
print_dry_run @deployments_interface.dry.destroy(deployment['id'], params)
|
|
287
|
+
return
|
|
288
|
+
end
|
|
289
|
+
json_response = @deployments_interface.destroy(deployment['id'], params)
|
|
290
|
+
render_response(json_response, options) do
|
|
291
|
+
print_green_success "Removed deployment #{deployment['name']}"
|
|
292
|
+
end
|
|
293
|
+
return 0, nil
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def get_version(args)
|
|
297
|
+
options = {}
|
|
298
|
+
params = {}
|
|
299
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
300
|
+
opts.banner = subcommand_usage("[deployment] [version] [options]")
|
|
301
|
+
opts.on(nil, '--no-files', "Do not show files") do
|
|
302
|
+
options[:no_files] = true
|
|
303
|
+
end
|
|
304
|
+
build_option_type_options(opts, options, add_deployment_version_option_types)
|
|
305
|
+
build_option_type_options(opts, options, add_deployment_version_advanced_option_types)
|
|
306
|
+
build_standard_add_options(opts, options)
|
|
307
|
+
opts.footer = <<-EOT
|
|
308
|
+
Create a new deployment version.
|
|
309
|
+
[deployment] is required. This is the name or id of a deployment.
|
|
310
|
+
[version] is required. This is the deployment version identifier
|
|
311
|
+
EOT
|
|
312
|
+
end
|
|
313
|
+
optparse.parse!(args)
|
|
314
|
+
verify_args!(args:args, optparse:optparse, count:2)
|
|
315
|
+
connect(options)
|
|
316
|
+
|
|
317
|
+
deployment = find_deployment_by_name_or_id(args[0])
|
|
318
|
+
return 1 if deployment.nil?
|
|
319
|
+
id = args[1]
|
|
320
|
+
if id.to_s =~ /\A\d{1,}\Z/
|
|
321
|
+
id = id.to_i
|
|
322
|
+
else
|
|
323
|
+
deployment_version = find_deployment_version_by_name_or_id(deployment['id'], id)
|
|
324
|
+
if deployment_version
|
|
325
|
+
id = deployment_version['id']
|
|
326
|
+
else
|
|
327
|
+
# raise_command_error "deployment not found for name '#{id}'"
|
|
328
|
+
return 1, "deployment version not found for name '#{id}'"
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
@deployments_interface.setopts(options)
|
|
332
|
+
if options[:dry_run]
|
|
333
|
+
print_dry_run @deployments_interface.dry.get_version(deployment['id'], id, params)
|
|
334
|
+
return
|
|
335
|
+
end
|
|
336
|
+
json_response = @deployments_interface.get_version(deployment['id'], id, params)
|
|
337
|
+
deployment_version = json_response['version']
|
|
338
|
+
deploy_type = deployment_version['deployType'] || deployment_version['type']
|
|
339
|
+
deployment_files_response = nil
|
|
340
|
+
deployment_files = nil
|
|
341
|
+
if options[:no_files] != true
|
|
342
|
+
deployment_files_response = @deployments_interface.list_files(deployment['id'], deployment_version['id'], params)
|
|
343
|
+
deployment_files = deployment_files_response.is_a?(Array) ? deployment_files_response : deployment_files_response['files']
|
|
344
|
+
end
|
|
345
|
+
render_response(json_response, options, 'version') do
|
|
346
|
+
# print_h1 "Deployment Version Details", [deployment['name']], options
|
|
347
|
+
print_h1 "Deployment Version Details", [], options
|
|
348
|
+
print cyan
|
|
349
|
+
#columns = deployment_version_column_definitions
|
|
350
|
+
columns = {
|
|
351
|
+
"ID" => 'id',
|
|
352
|
+
"Deployment" => lambda {|it| deployment['name'] },
|
|
353
|
+
"Version" => lambda {|it| format_deployment_version_number(it) },
|
|
354
|
+
"Deploy Type" => lambda {|it| it['deployType'] },
|
|
355
|
+
"URL" => lambda {|it| it['fetchUrl'] || it['gitUrl'] || it['url'] },
|
|
356
|
+
"Ref" => lambda {|it| it['gitRef'] || it['ref'] },
|
|
357
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
358
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) },
|
|
359
|
+
}
|
|
360
|
+
if deployment_version['deployType'] == 'git'
|
|
361
|
+
options[:no_files] = true
|
|
362
|
+
elsif deployment_version['deployType'] == 'fetch'
|
|
363
|
+
options[:no_files] = true
|
|
364
|
+
columns['Fetch URL'] = columns['URL']
|
|
365
|
+
columns.delete('Ref')
|
|
366
|
+
else
|
|
367
|
+
columns.delete('URL')
|
|
368
|
+
columns.delete('Ref')
|
|
369
|
+
end
|
|
370
|
+
print_description_list(columns, deployment_version)
|
|
371
|
+
print reset,"\n"
|
|
372
|
+
|
|
373
|
+
if options[:no_files] != true
|
|
374
|
+
print_h2 "Deployment Files", options
|
|
375
|
+
if !deployment_files || deployment_files.empty?
|
|
376
|
+
print cyan,"No files found.",reset,"\n"
|
|
377
|
+
else
|
|
378
|
+
print as_pretty_table(deployment_files, deployment_file_column_definitions.upcase_keys!, options)
|
|
379
|
+
print_results_pagination({size:deployment_files.size,total:deployment_files.size.to_i})
|
|
380
|
+
end
|
|
381
|
+
print reset,"\n"
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
end
|
|
385
|
+
return 0, nil
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def add_version(args)
|
|
389
|
+
options = {}
|
|
390
|
+
params = {}
|
|
391
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
392
|
+
opts.banner = subcommand_usage("[deployment] [version] [options]")
|
|
393
|
+
opts.on('-t', '--type CODE', String, "Deploy Type, file, git or fetch, default is file.") do |val|
|
|
394
|
+
options[:options]['deployType'] = val
|
|
395
|
+
end
|
|
396
|
+
build_option_type_options(opts, options, add_deployment_version_option_types)
|
|
397
|
+
opts.add_hidden_option('--deployType')
|
|
398
|
+
build_option_type_options(opts, options, add_deployment_version_advanced_option_types)
|
|
399
|
+
build_standard_add_options(opts, options)
|
|
400
|
+
opts.footer = <<-EOT
|
|
401
|
+
Create a new deployment version.
|
|
402
|
+
[deployment] is required. This is the name or id of a deployment.
|
|
403
|
+
[version] is required. This is the deployment version identifier
|
|
404
|
+
EOT
|
|
405
|
+
end
|
|
406
|
+
optparse.parse!(args)
|
|
407
|
+
verify_args!(args:args, optparse:optparse, min:0, max:2)
|
|
408
|
+
connect(options)
|
|
409
|
+
deployment = nil
|
|
410
|
+
if args[0]
|
|
411
|
+
deployment = find_deployment_by_name_or_id(args[0])
|
|
412
|
+
return 1 if deployment.nil?
|
|
413
|
+
else
|
|
414
|
+
deployment_id = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'deploymentId', 'fieldLabel' => 'Deployment', 'type' => 'select', 'required' => true, 'description' => 'Deployment to add version to', 'optionSource' => lambda { |api_client, api_params|
|
|
415
|
+
@deployments_interface.list(max:10000)['deployments'].collect {|it|
|
|
416
|
+
{'name' => it['name'], 'value' => it['id']}
|
|
417
|
+
}
|
|
418
|
+
}}], options[:options])['deploymentId']
|
|
419
|
+
deployment = {'id' => deployment_id.to_i}
|
|
420
|
+
end
|
|
421
|
+
options[:options]['userVersion'] = args[1] if args[1]
|
|
422
|
+
payload = {}
|
|
423
|
+
if options[:payload]
|
|
424
|
+
payload = options[:payload]
|
|
425
|
+
payload.deep_merge!({'version' => parse_passed_options(options)})
|
|
426
|
+
else
|
|
427
|
+
payload.deep_merge!({'version' => parse_passed_options(options)})
|
|
428
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt(add_deployment_version_option_types, options[:options], @api_client, options[:params])
|
|
429
|
+
params.deep_merge!(v_prompt)
|
|
430
|
+
advanced_config = MtnCloud::Cli::OptionTypes.no_prompt(add_deployment_version_advanced_option_types, options[:options], @api_client, options[:params])
|
|
431
|
+
advanced_config.deep_compact!
|
|
432
|
+
params.deep_merge!(advanced_config)
|
|
433
|
+
payload['version'].deep_merge!(params)
|
|
434
|
+
end
|
|
435
|
+
@deployments_interface.setopts(options)
|
|
436
|
+
if options[:dry_run]
|
|
437
|
+
print_dry_run @deployments_interface.dry.create_version(deployment['id'], payload)
|
|
438
|
+
return 0, nil
|
|
439
|
+
end
|
|
440
|
+
json_response = @deployments_interface.create_version(deployment['id'], payload)
|
|
441
|
+
deployment_version = json_response['version']
|
|
442
|
+
render_response(json_response, options, 'version') do
|
|
443
|
+
print_green_success "Added deployment version #{deployment_version['userVersion']}"
|
|
444
|
+
return get_version([deployment["id"], deployment_version['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
def update_version(args)
|
|
449
|
+
options = {}
|
|
450
|
+
params = {}
|
|
451
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
452
|
+
opts.banner = subcommand_usage("[deployment] [version] [options]")
|
|
453
|
+
build_option_type_options(opts, options, update_deployment_version_option_types)
|
|
454
|
+
build_option_type_options(opts, options, update_deployment_version_advanced_option_types)
|
|
455
|
+
build_standard_update_options(opts, options)
|
|
456
|
+
opts.footer = <<-EOT
|
|
457
|
+
Update a deployment version.
|
|
458
|
+
[deployment] is required. This is the name or id of a deployment.
|
|
459
|
+
[version] is required. This is the deployment version identifier
|
|
460
|
+
EOT
|
|
461
|
+
end
|
|
462
|
+
optparse.parse!(args)
|
|
463
|
+
verify_args!(args:args, optparse:optparse, min:0, max:2)
|
|
464
|
+
connect(options)
|
|
465
|
+
deployment = find_deployment_by_name_or_id(args[0])
|
|
466
|
+
return 1 if deployment.nil?
|
|
467
|
+
deployment_version = find_deployment_version_by_name_or_id(deployment['id'], args[1])
|
|
468
|
+
return 1 if deployment_version.nil?
|
|
469
|
+
payload = {}
|
|
470
|
+
if options[:payload]
|
|
471
|
+
payload = options[:payload]
|
|
472
|
+
payload.deep_merge!({'version' => parse_passed_options(options)})
|
|
473
|
+
else
|
|
474
|
+
payload.deep_merge!({'version' => parse_passed_options(options)})
|
|
475
|
+
v_prompt = MtnCloud::Cli::OptionTypes.no_prompt(update_deployment_version_option_types, options[:options], @api_client, options[:params])
|
|
476
|
+
params.deep_merge!(v_prompt)
|
|
477
|
+
advanced_config = MtnCloud::Cli::OptionTypes.no_prompt(update_deployment_version_advanced_option_types, options[:options], @api_client, options[:params])
|
|
478
|
+
advanced_config.deep_compact!
|
|
479
|
+
params.deep_merge!(advanced_config)
|
|
480
|
+
payload['version'].deep_merge!(params)
|
|
481
|
+
end
|
|
482
|
+
@deployments_interface.setopts(options)
|
|
483
|
+
if options[:dry_run]
|
|
484
|
+
print_dry_run @deployments_interface.dry.update_version(deployment['id'], deployment_version['id'], payload)
|
|
485
|
+
return 0, nil
|
|
486
|
+
end
|
|
487
|
+
json_response = @deployments_interface.update_version(deployment['id'], deployment_version['id'], payload)
|
|
488
|
+
deployment_version = json_response['version']
|
|
489
|
+
render_response(json_response, options, 'version') do
|
|
490
|
+
print_green_success "Updated deployment version #{deployment_version['userVersion']}"
|
|
491
|
+
return get_version([deployment["id"], deployment_version['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
def remove_version(args)
|
|
496
|
+
options = {}
|
|
497
|
+
params = {}
|
|
498
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
499
|
+
opts.banner = subcommand_usage("[deployment] [version] [options]")
|
|
500
|
+
build_standard_remove_options(opts, options)
|
|
501
|
+
opts.footer = <<-EOT
|
|
502
|
+
Delete a deployment version.
|
|
503
|
+
[deployment] is required. This is the name or id of a deployment.
|
|
504
|
+
[version] is required. This is the version identifier of a deployment version.
|
|
505
|
+
EOT
|
|
506
|
+
end
|
|
507
|
+
optparse.parse!(args)
|
|
508
|
+
verify_args!(args:args, optparse:optparse, count:2)
|
|
509
|
+
connect(options)
|
|
510
|
+
deployment = find_deployment_by_name_or_id(args[0])
|
|
511
|
+
return 1, "deployment not found" if deployment.nil?
|
|
512
|
+
id = args[1]
|
|
513
|
+
deployment_version = find_deployment_version_by_name_or_id(deployment['id'], id)
|
|
514
|
+
return 1, "version not found" if deployment_version.nil?
|
|
515
|
+
unless options[:yes] || MtnCloud::Cli::OptionTypes.confirm("Are you sure you want to delete the deployment version #{format_deployment_version_number(deployment_version)}?")
|
|
516
|
+
return 9, "aborted command"
|
|
517
|
+
end
|
|
518
|
+
@deployments_interface.setopts(options)
|
|
519
|
+
if options[:dry_run]
|
|
520
|
+
print_dry_run @deployments_interface.dry.destroy_version(deployment['id'], deployment_version['id'], params)
|
|
521
|
+
return
|
|
522
|
+
end
|
|
523
|
+
json_response = @deployments_interface.destroy_version(deployment['id'], deployment_version['id'], params)
|
|
524
|
+
render_response(json_response, options) do
|
|
525
|
+
print_green_success "Removed deployment #{deployment['name']} version #{format_deployment_version_number(deployment_version)}"
|
|
526
|
+
end
|
|
527
|
+
return 0, nil
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
def list_files(args)
|
|
531
|
+
options = {}
|
|
532
|
+
params = {}
|
|
533
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
534
|
+
opts.banner = subcommand_usage("[deployment] [version] [path] [options]")
|
|
535
|
+
build_standard_list_options(opts, options)
|
|
536
|
+
opts.footer = <<-EOT
|
|
537
|
+
List files in a deployment version.
|
|
538
|
+
[deployment] is required. This is the name or id of a deployment.
|
|
539
|
+
[version] is required. This is the deployment version identifier
|
|
540
|
+
[path] is optional. This is a the directory to search for files under.
|
|
541
|
+
EOT
|
|
542
|
+
end
|
|
543
|
+
optparse.parse!(args)
|
|
544
|
+
verify_args!(args:args, optparse:optparse, min:2, max: 3)
|
|
545
|
+
connect(options)
|
|
546
|
+
params.merge!(parse_list_options(options))
|
|
547
|
+
deployment = find_deployment_by_name_or_id(args[0])
|
|
548
|
+
return 1, "deployment not found for '#{args[0]}'" if deployment.nil?
|
|
549
|
+
deployment_version = find_deployment_version_by_name_or_id(deployment['id'], args[1])
|
|
550
|
+
return 1, "deployment version not found for '#{args[1]}'" if deployment_version.nil?
|
|
551
|
+
if args[2]
|
|
552
|
+
params['filePath'] = args[2]
|
|
553
|
+
end
|
|
554
|
+
@deployments_interface.setopts(options)
|
|
555
|
+
if options[:dry_run]
|
|
556
|
+
print_dry_run @deployments_interface.dry.list_files(deployment['id'], deployment_version['id'], params)
|
|
557
|
+
return
|
|
558
|
+
end
|
|
559
|
+
json_response = @deployments_interface.list_files(deployment['id'], deployment_version['id'], params)
|
|
560
|
+
# odd, api used to just return an array
|
|
561
|
+
deployment_files = json_response.is_a?(Array) ? json_response : json_response['files']
|
|
562
|
+
render_response(json_response, options) do
|
|
563
|
+
print_h1 "Deployment Files", ["#{deployment['name']} #{format_deployment_version_number(deployment_version)}"]
|
|
564
|
+
if !deployment_files || deployment_files.empty?
|
|
565
|
+
print cyan,"No files found.",reset,"\n"
|
|
566
|
+
else
|
|
567
|
+
print as_pretty_table(deployment_files, deployment_file_column_definitions.upcase_keys!, options)
|
|
568
|
+
#print_results_pagination(json_response)
|
|
569
|
+
print_results_pagination({size:deployment_files.size,total:deployment_files.size.to_i})
|
|
570
|
+
end
|
|
571
|
+
print reset,"\n"
|
|
572
|
+
end
|
|
573
|
+
return 0, nil
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
def upload(args)
|
|
577
|
+
options = {}
|
|
578
|
+
params = {}
|
|
579
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
580
|
+
opts.banner = subcommand_usage("[deployment] [version] [files]")
|
|
581
|
+
opts.on('--files LIST', String, "Files to upload") do |val|
|
|
582
|
+
val_list = val.to_s.split(",").collect {|it| it.to_s.strip }.select { |it| it != "" }
|
|
583
|
+
options[:files] ||= []
|
|
584
|
+
options[:files] += val_list
|
|
585
|
+
end
|
|
586
|
+
opts.on('--workdir DIRECTORY', String, "Working directory to switch to before uploading files, determines the paths of the uploaded files. The current working directory of your terminal is used by default.") do |val|
|
|
587
|
+
options[:workdir] = File.expand_path(val)
|
|
588
|
+
if !File.directory?(options[:workdir])
|
|
589
|
+
raise_command_error "invalid directory: #{val}"
|
|
590
|
+
end
|
|
591
|
+
end
|
|
592
|
+
opts.on('--destination FILEPATH', String, "Destination filepath for file being uploaded, should include full filename and extension. Only applies when uploading a single file.") do |val|
|
|
593
|
+
options[:destination] = val
|
|
594
|
+
end
|
|
595
|
+
build_standard_update_options(opts, options, [:auto_confirm])
|
|
596
|
+
opts.footer = <<-EOT
|
|
597
|
+
Upload one or more files or directories to a deployment version.
|
|
598
|
+
[deployment] is required. This is the name or id of a deployment.
|
|
599
|
+
[version] is required. This is the deployment version identifier
|
|
600
|
+
[files] is required. This is a list of files or directories to be uploaded. Glob pattern format supported eg. build/*.html
|
|
601
|
+
EOT
|
|
602
|
+
end
|
|
603
|
+
optparse.parse!(args)
|
|
604
|
+
# verify_args!(args:args, optparse:optparse, min:0, max:2)
|
|
605
|
+
connect(options)
|
|
606
|
+
|
|
607
|
+
# fetch deployment
|
|
608
|
+
deployment = nil
|
|
609
|
+
if args[0]
|
|
610
|
+
deployment = find_deployment_by_name_or_id(args[0])
|
|
611
|
+
return 1 if deployment.nil?
|
|
612
|
+
else
|
|
613
|
+
all_deployments = @deployments_interface.list(max:10000)['deployments']
|
|
614
|
+
deployment_id = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'deployment', 'fieldLabel' => 'Deployment', 'type' => 'select', 'required' => true, 'description' => 'Deployment identifier (name or ID)', 'optionSource' => lambda { |api_client, api_params|
|
|
615
|
+
all_deployments.collect {|it| {'name' => it['name'], 'value' => it['id']} }
|
|
616
|
+
}}], options[:options])['deployment']
|
|
617
|
+
deployment = all_deployments.find {|it| deployment_id == it['id'] || deployment_id == it['name'] }
|
|
618
|
+
raise_command_error "Deployment not found for '#{deployment_id}'" if deployment.nil?
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
# fetch deployment version
|
|
622
|
+
deployment_version = nil
|
|
623
|
+
if args[1]
|
|
624
|
+
deployment_version = find_deployment_version_by_name_or_id(deployment['id'], args[1])
|
|
625
|
+
return 1 if deployment_version.nil?
|
|
626
|
+
else
|
|
627
|
+
all_deployment_versions = @deployments_interface.list_versions(deployment['id'], {max:10000})['versions']
|
|
628
|
+
deployment_version_id = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'version', 'fieldLabel' => 'Version', 'type' => 'select', 'required' => true, 'description' => 'Deployment Version identifier (version or ID) to upload files to', 'optionSource' => lambda { |api_client, api_params|
|
|
629
|
+
all_deployment_versions.collect {|it| {'name' => it['version'] || it['userVersion'], 'value' => it['id']} }
|
|
630
|
+
}}], options[:options])['version']
|
|
631
|
+
deployment_version = all_deployment_versions.find {|it| deployment_version_id == it['id'] || deployment_version_id == it['userVersion'] || deployment_version_id == it['version'] }
|
|
632
|
+
raise_command_error "Deployment Version not found for '#{deployment_version_id}'" if deployment_version.nil?
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
# Determine which files to find
|
|
637
|
+
file_patterns = []
|
|
638
|
+
# [files] is args 3 - N
|
|
639
|
+
if args.size > 2
|
|
640
|
+
file_patterns += args[2..-1]
|
|
641
|
+
end
|
|
642
|
+
if options[:files]
|
|
643
|
+
file_patterns += options[:files]
|
|
644
|
+
end
|
|
645
|
+
if file_patterns.empty?
|
|
646
|
+
#raise_command_error "Files not specified. Please specify files array, each item may specify a path or pattern of file(s) to upload", args, optparse
|
|
647
|
+
file_patterns = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'files', 'fieldLabel' => 'Files', 'type' => 'text', 'required' => true, 'description' => 'Files or directories to upload'}], options[:options])['files'].to_s.split(",").collect {|it| it.to_s.strip }.select { |it| it != "" }
|
|
648
|
+
end
|
|
649
|
+
|
|
650
|
+
# Find Files to Upload
|
|
651
|
+
deploy_files = []
|
|
652
|
+
|
|
653
|
+
#print "\n",cyan, "Finding Files...", reset, "\n" unless options[:quiet]
|
|
654
|
+
original_working_dir = Dir.pwd
|
|
655
|
+
base_working_dir = options[:workdir] || original_working_dir
|
|
656
|
+
begin
|
|
657
|
+
file_patterns.each do |file_pattern|
|
|
658
|
+
# start in the working directory
|
|
659
|
+
# to preserve relative paths in upload file destinations
|
|
660
|
+
# allow passing just build instead build/**/*
|
|
661
|
+
Dir.chdir(base_working_dir)
|
|
662
|
+
fmap = nil
|
|
663
|
+
full_file_pattern = File.expand_path(file_pattern)
|
|
664
|
+
if File.exist?(full_file_pattern)
|
|
665
|
+
if File.directory?(full_file_pattern)
|
|
666
|
+
fmap = {'path' => full_file_pattern, 'pattern' => '**/*'}
|
|
667
|
+
else
|
|
668
|
+
fmap = {'path' => File.dirname(full_file_pattern), 'pattern' => File.basename(full_file_pattern)}
|
|
669
|
+
end
|
|
670
|
+
else
|
|
671
|
+
fmap = {'path' => nil, 'pattern' => file_pattern}
|
|
672
|
+
end
|
|
673
|
+
if fmap['path']
|
|
674
|
+
Dir.chdir(File.expand_path(fmap['path']))
|
|
675
|
+
end
|
|
676
|
+
files = Dir.glob(fmap['pattern'] || '**/*')
|
|
677
|
+
if files.empty?
|
|
678
|
+
raise_command_error "Found 0 files for file pattern '#{file_pattern}'"
|
|
679
|
+
end
|
|
680
|
+
files.each do |file|
|
|
681
|
+
if File.file?(file)
|
|
682
|
+
destination = file.split("/")[0..-2].join("/")
|
|
683
|
+
# deploy_files << {filepath: File.expand_path(file), destination: destination}
|
|
684
|
+
# absolute path was given, so no path is given to the destination file
|
|
685
|
+
# maybe apply options[:destination] as prefix here
|
|
686
|
+
# actually just do destination.sub!(base_working_dir, '')
|
|
687
|
+
if file[0].chr == "/"
|
|
688
|
+
deploy_files << {filepath: File.expand_path(file), destination: File.basename(file)}
|
|
689
|
+
else
|
|
690
|
+
deploy_files << {filepath: File.expand_path(file), destination: file}
|
|
691
|
+
end
|
|
692
|
+
end
|
|
693
|
+
end
|
|
694
|
+
end
|
|
695
|
+
#print cyan, "Found #{deploy_files.size} Files to Upload!", reset, "\n"
|
|
696
|
+
rescue => ex
|
|
697
|
+
# does not happen, just in case
|
|
698
|
+
#print_error "An error occured while searching for files to upload: #{ex}"
|
|
699
|
+
raise ex
|
|
700
|
+
ensure
|
|
701
|
+
Dir.chdir(original_working_dir)
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
# make sure we have something to upload.
|
|
705
|
+
if deploy_files.empty?
|
|
706
|
+
raise_command_error "0 files found for: #{file_patterns.join(', ')}"
|
|
707
|
+
else
|
|
708
|
+
unless options[:quiet]
|
|
709
|
+
print cyan, "Found #{deploy_files.size} Files to Upload!", reset, "\n"
|
|
710
|
+
end
|
|
711
|
+
end
|
|
712
|
+
|
|
713
|
+
# support uploading a local file to a custom destination
|
|
714
|
+
# this only works for a single file right now, should be better
|
|
715
|
+
# could try to add destination + filename
|
|
716
|
+
# for now expect filename to be included in destination
|
|
717
|
+
if options[:destination]
|
|
718
|
+
if deploy_files.size == 1
|
|
719
|
+
deploy_files[0][:destination] = options[:destination]
|
|
720
|
+
else
|
|
721
|
+
raise_command_error "--destination can only specified for a single file upload, not #{deploy_files} files.", args, optparse
|
|
722
|
+
end
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
confirm_message = "Are you sure you want to upload #{deploy_files.size} files to deployment #{deployment['name']} #{format_deployment_version_number(deployment_version)}?"
|
|
726
|
+
if deploy_files.size == 1
|
|
727
|
+
confirm_message = "Are you sure you want to upload file #{deploy_files[0][:destination]} to deployment #{deployment['name']} #{format_deployment_version_number(deployment_version)}?"
|
|
728
|
+
end
|
|
729
|
+
unless options[:yes] || MtnCloud::Cli::OptionTypes.confirm(confirm_message)
|
|
730
|
+
return 9, "aborted command"
|
|
731
|
+
end
|
|
732
|
+
|
|
733
|
+
@deployments_interface.setopts(options)
|
|
734
|
+
|
|
735
|
+
# Upload Files
|
|
736
|
+
if deploy_files && !deploy_files.empty?
|
|
737
|
+
print "\n",cyan, "Uploading #{deploy_files.size} Files...", reset, "\n" if !options[:quiet]
|
|
738
|
+
deploy_files.each do |f|
|
|
739
|
+
destination = f[:destination]
|
|
740
|
+
if options[:dry_run]
|
|
741
|
+
print_dry_run @deployments_interface.upload_file(deployment['id'], deployment_version['id'], f[:filepath], f[:destination])
|
|
742
|
+
else
|
|
743
|
+
print cyan," - Uploading #{f[:destination]} ...", reset if !options[:quiet]
|
|
744
|
+
upload_result = @deployments_interface.upload_file(deployment['id'], deployment_version['id'], f[:filepath], f[:destination])
|
|
745
|
+
#print green + "SUCCESS" + reset + "\n" if !options[:quiet]
|
|
746
|
+
print reset, "\n" if !options[:quiet]
|
|
747
|
+
end
|
|
748
|
+
end
|
|
749
|
+
if options[:dry_run]
|
|
750
|
+
return 0, nil
|
|
751
|
+
end
|
|
752
|
+
#print cyan, "Upload Complete!", reset, "\n" if !options[:quiet]
|
|
753
|
+
if options[:quiet]
|
|
754
|
+
return 0, nil
|
|
755
|
+
else
|
|
756
|
+
print_green_success "Upload Complete!"
|
|
757
|
+
return get_version([deployment["id"], deployment_version['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
758
|
+
end
|
|
759
|
+
else
|
|
760
|
+
raise_command_error "No files to upload!"
|
|
761
|
+
end
|
|
762
|
+
end
|
|
763
|
+
|
|
764
|
+
def remove_file(args)
|
|
765
|
+
options = {}
|
|
766
|
+
params = {}
|
|
767
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
768
|
+
opts.banner = subcommand_usage("[deployment] [version] [file] [options]")
|
|
769
|
+
opts.on( '-R', '--recursive', "Delete a directory and all of its files. This must be passed if specifying a directory." ) do
|
|
770
|
+
# do_recursive = true
|
|
771
|
+
params['force'] = true
|
|
772
|
+
end
|
|
773
|
+
opts.on( '-f', '--force', "Force delete, this will do a recursive delete of directories." ) do
|
|
774
|
+
params['force'] = true
|
|
775
|
+
end
|
|
776
|
+
build_standard_remove_options(opts, options)
|
|
777
|
+
opts.footer = <<-EOT
|
|
778
|
+
Delete a deployment file.
|
|
779
|
+
[deployment] is required. This is the name or id of a deployment.
|
|
780
|
+
[version] is required. This is the version identifier of a deployment version.
|
|
781
|
+
[file] is required. This is the name of the file to be deleted.
|
|
782
|
+
EOT
|
|
783
|
+
end
|
|
784
|
+
optparse.parse!(args)
|
|
785
|
+
verify_args!(args:args, optparse:optparse, min:2, max:3)
|
|
786
|
+
connect(options)
|
|
787
|
+
deployment = find_deployment_by_name_or_id(args[0])
|
|
788
|
+
return 1, "deployment not found" if deployment.nil?
|
|
789
|
+
id = args[1]
|
|
790
|
+
deployment_version = find_deployment_version_by_name_or_id(deployment['id'], id)
|
|
791
|
+
return 1, "version not found" if deployment_version.nil?
|
|
792
|
+
# could look it up here, or allow a directory instead of a single file
|
|
793
|
+
filename = args[2]
|
|
794
|
+
if filename.nil?
|
|
795
|
+
#raise_command_error "Files not specified. Please specify files array, each item may specify a path or pattern of file(s) to upload", args, optparse
|
|
796
|
+
filename = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'file', 'fieldLabel' => 'Files', 'type' => 'text', 'required' => true, 'description' => 'Files or directories to upload'}], options[:options])['file'].to_s #.split(",").collect {|it| it.to_s.strip }.select { |it| it != "" }
|
|
797
|
+
end
|
|
798
|
+
unless options[:yes] || MtnCloud::Cli::OptionTypes.confirm("Are you sure you want to delete the file #{filename}?")
|
|
799
|
+
return 9, "aborted command"
|
|
800
|
+
end
|
|
801
|
+
@deployments_interface.setopts(options)
|
|
802
|
+
if options[:dry_run]
|
|
803
|
+
print_dry_run @deployments_interface.dry.destroy_file(deployment['id'], deployment_version['id'], filename, params)
|
|
804
|
+
return
|
|
805
|
+
end
|
|
806
|
+
json_response = @deployments_interface.destroy_file(deployment['id'], deployment_version['id'], filename, params)
|
|
807
|
+
render_response(json_response, options) do
|
|
808
|
+
print_green_success "Removed deployment file #{filename}"
|
|
809
|
+
end
|
|
810
|
+
return 0, nil
|
|
811
|
+
end
|
|
812
|
+
|
|
813
|
+
private
|
|
814
|
+
|
|
815
|
+
def deployment_column_definitions
|
|
816
|
+
{
|
|
817
|
+
"ID" => 'id',
|
|
818
|
+
"Name" => 'name',
|
|
819
|
+
"Description" => 'description',
|
|
820
|
+
"Versions" => lambda {|it| it['versionCount'] },
|
|
821
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
822
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) },
|
|
823
|
+
}
|
|
824
|
+
end
|
|
825
|
+
|
|
826
|
+
# this is not so simple, need to first choose select instance, host or provider
|
|
827
|
+
def add_deployment_option_types
|
|
828
|
+
[
|
|
829
|
+
{'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'displayOrder' => 1},
|
|
830
|
+
{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'displayOrder' => 1}
|
|
831
|
+
]
|
|
832
|
+
end
|
|
833
|
+
|
|
834
|
+
def add_deployment_advanced_option_types
|
|
835
|
+
[]
|
|
836
|
+
end
|
|
837
|
+
|
|
838
|
+
def update_deployment_option_types
|
|
839
|
+
add_deployment_option_types.collect {|it|
|
|
840
|
+
it.delete('required')
|
|
841
|
+
it.delete('defaultValue')
|
|
842
|
+
it
|
|
843
|
+
}
|
|
844
|
+
end
|
|
845
|
+
|
|
846
|
+
def update_deployment_advanced_option_types
|
|
847
|
+
add_deployment_advanced_option_types.collect {|it|
|
|
848
|
+
it.delete('required')
|
|
849
|
+
it.delete('defaultValue')
|
|
850
|
+
it
|
|
851
|
+
}
|
|
852
|
+
end
|
|
853
|
+
|
|
854
|
+
## Deployment Versions
|
|
855
|
+
|
|
856
|
+
def deployment_version_column_definitions
|
|
857
|
+
{
|
|
858
|
+
"ID" => 'id',
|
|
859
|
+
"Version" => lambda {|it| format_deployment_version_number(it) },
|
|
860
|
+
"Deploy Type" => lambda {|it| it['deployType'] },
|
|
861
|
+
"URL" => lambda {|it|
|
|
862
|
+
if it['deployType'] == 'fetch'
|
|
863
|
+
"#{it['fetchUrl']}"
|
|
864
|
+
elsif it['deployType'] == 'git'
|
|
865
|
+
"#{it['gitUrl']}"
|
|
866
|
+
end
|
|
867
|
+
},
|
|
868
|
+
"Ref" => lambda {|it|
|
|
869
|
+
if it['deployType'] == 'git'
|
|
870
|
+
"#{it['gitRef']}"
|
|
871
|
+
end
|
|
872
|
+
},
|
|
873
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
874
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) },
|
|
875
|
+
}
|
|
876
|
+
end
|
|
877
|
+
|
|
878
|
+
# this is not so simple, need to first choose select instance, host or provider
|
|
879
|
+
def add_deployment_version_option_types
|
|
880
|
+
[
|
|
881
|
+
{'fieldName' => 'userVersion', 'fieldLabel' => 'Version', 'type' => 'text', 'required' => true, 'displayOrder' => 1, 'description' => 'This is the deployment version identifier (userVersion)'},
|
|
882
|
+
{'fieldName' => 'deployType', 'fieldLabel' => 'Deploy Type', 'type' => 'select', 'optionSource' => 'deployTypes', 'required' => true, 'displayOrder' => 2, 'description' => 'This is the deployment version identifier (userVersion)', 'defaultValue' => 'file', 'code' => 'deployment.deployType'},
|
|
883
|
+
{'fieldName' => 'fetchUrl', 'fieldLabel' => 'Fetch URL', 'type' => 'string', 'required' => true, 'displayOrder' => 3, 'description' => 'The URL to fetch the deployment file(s) from.', 'dependsOnCode' => 'deployment.deployType:fetch'},
|
|
884
|
+
{'fieldName' => 'gitUrl', 'fieldLabel' => 'Git URL', 'type' => 'string', 'required' => true, 'displayOrder' => 4, 'description' => 'The URL to fetch the deployment file(s) from.', 'dependsOnCode' => 'deployment.deployType:git'},
|
|
885
|
+
{'fieldName' => 'gitRef', 'fieldLabel' => 'Git Ref', 'type' => 'string', 'displayOrder' => 5, 'description' => 'The Git Reference to use, this the branch or tag name, defaults to master.', 'dependsOnCode' => 'deployment.deployType:git'}
|
|
886
|
+
]
|
|
887
|
+
end
|
|
888
|
+
|
|
889
|
+
def add_deployment_version_advanced_option_types
|
|
890
|
+
[]
|
|
891
|
+
end
|
|
892
|
+
|
|
893
|
+
def update_deployment_version_option_types
|
|
894
|
+
add_deployment_version_option_types.collect {|it|
|
|
895
|
+
it.delete('required')
|
|
896
|
+
it.delete('defaultValue')
|
|
897
|
+
it
|
|
898
|
+
}
|
|
899
|
+
end
|
|
900
|
+
|
|
901
|
+
def update_deployment_version_advanced_option_types
|
|
902
|
+
add_deployment_version_advanced_option_types.collect {|it|
|
|
903
|
+
it.delete('required')
|
|
904
|
+
it.delete('defaultValue')
|
|
905
|
+
it
|
|
906
|
+
}
|
|
907
|
+
end
|
|
908
|
+
|
|
909
|
+
# Deployment Files
|
|
910
|
+
|
|
911
|
+
def deployment_file_column_definitions
|
|
912
|
+
{
|
|
913
|
+
#"ID" => 'id',
|
|
914
|
+
"Name" => 'name',
|
|
915
|
+
"Type" => lambda {|it| (it['directory'] || it['isDirectory']) ? "directory" : (it["contentType"] || "file") },
|
|
916
|
+
"Size" => lambda {|it| (it['directory'] || it['isDirectory']) ? "" : format_bytes_short(it['contentLength']) },
|
|
917
|
+
#"Content Type" => lambda {|it| it['contentType'] },
|
|
918
|
+
# "Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
919
|
+
# "Updated" => lambda {|it| format_local_dt(it['lastUpdated']) },
|
|
920
|
+
}
|
|
921
|
+
end
|
|
922
|
+
|
|
923
|
+
end
|