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,485 @@
|
|
|
1
|
+
require 'mtncloud/cli/cli_command'
|
|
2
|
+
|
|
3
|
+
class MtnCloud::Cli::Deploy
|
|
4
|
+
include MtnCloud::Cli::CliCommand
|
|
5
|
+
include MtnCloud::Cli::DeploymentsHelper
|
|
6
|
+
|
|
7
|
+
set_command_name :deploy
|
|
8
|
+
set_command_description "Deploy to an instance from a mtncloud.yml file."
|
|
9
|
+
|
|
10
|
+
def connect(opts)
|
|
11
|
+
@api_client = establish_remote_appliance_connection(opts)
|
|
12
|
+
@instances_interface = @api_client.instances
|
|
13
|
+
@deploy_interface = @api_client.deploy
|
|
14
|
+
@deployments_interface = @api_client.deployments
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def handle(args)
|
|
18
|
+
options={}
|
|
19
|
+
optparse = MtnCloud::Cli::OptionParser.new do|opts|
|
|
20
|
+
opts.banner = "Usage: #{prog_name} deploy [environment]"
|
|
21
|
+
build_common_options(opts, options, [:auto_confirm, :quiet, :remote, :dry_run])
|
|
22
|
+
opts.footer = <<-EOT
|
|
23
|
+
Deploy to an instance using the mtncloud.yml file, located in the working directory.
|
|
24
|
+
[environment] is optional. Merge settings under environments.{environment}. Default is no environment.
|
|
25
|
+
|
|
26
|
+
First the mtncloud.yml YAML file is parsed, merging the specified environment's nested settings.
|
|
27
|
+
The specified instance must exist and the specified deployment version must not exist.
|
|
28
|
+
If the settings are valid, the new deployment version will be created.
|
|
29
|
+
If is a file type deployment, all the discovered files are uploaded to the new deployment version.
|
|
30
|
+
Finally, it deploys the new version to the instance using any specified config options.
|
|
31
|
+
|
|
32
|
+
The mtncloud.yml should be located in the working directory.
|
|
33
|
+
A morpheus.yml file is used instead if there is no mtncloud.yml.
|
|
34
|
+
This YAML file contains the settings that specify how to execute the deployment.
|
|
35
|
+
|
|
36
|
+
File Settings
|
|
37
|
+
==================
|
|
38
|
+
|
|
39
|
+
* name - (required) The instance name being deployed to, also the default name of the deployment.
|
|
40
|
+
* version - (required) The version identifier of the deployment being created (userVersion)
|
|
41
|
+
* deployment - The name of the deployment being created, name is used by default
|
|
42
|
+
* type - The type of deployment, file, 'git' or 'fetch', default is 'file'.
|
|
43
|
+
* script - The initial script to run, happens before finding the files to be uploaded.
|
|
44
|
+
* files - (required) List of file patterns to use for uploading files and their target destination.
|
|
45
|
+
Each item should contain path and pattern, path may be relative to the working directory, default pattern is: '**/*'
|
|
46
|
+
only applies to type 'file'
|
|
47
|
+
* url - (required) The url to fetch files from, only applies to types 'git' and 'fetch'.
|
|
48
|
+
* ref - The git reference, default is master (main), only applies to type git.
|
|
49
|
+
* config - Map of deployment config options depending on deployment type
|
|
50
|
+
* options - alias for config
|
|
51
|
+
* post_script - A post operation script to be run on the local machine
|
|
52
|
+
* stage_only - If set to true the deploy will only be staged and not actually run
|
|
53
|
+
* environments - Map of objects that contain nested properties for each environment name
|
|
54
|
+
|
|
55
|
+
It is possible to nest these properties in an "environments" map to override based on a passed environment.
|
|
56
|
+
|
|
57
|
+
Example
|
|
58
|
+
==================
|
|
59
|
+
|
|
60
|
+
name: mysite
|
|
61
|
+
version: 5.0
|
|
62
|
+
script: "rake build"
|
|
63
|
+
files:
|
|
64
|
+
- path: build
|
|
65
|
+
environments:
|
|
66
|
+
production:
|
|
67
|
+
files:
|
|
68
|
+
- path: production-build
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
Git Example
|
|
72
|
+
==================
|
|
73
|
+
|
|
74
|
+
name: my-app
|
|
75
|
+
version: 5.0.0
|
|
76
|
+
type: git
|
|
77
|
+
url: "https://github.com/example/my-app"
|
|
78
|
+
|
|
79
|
+
EOT
|
|
80
|
+
end
|
|
81
|
+
optparse.parse!(args)
|
|
82
|
+
verify_args!(args:args, optparse:optparse, min:0, max:1)
|
|
83
|
+
options[:options]['name'] = args[0] if args[0]
|
|
84
|
+
connect(options)
|
|
85
|
+
payload = {}
|
|
86
|
+
|
|
87
|
+
environment = default_deploy_environment
|
|
88
|
+
if args.count > 0
|
|
89
|
+
environment = args[0]
|
|
90
|
+
end
|
|
91
|
+
if load_deploy_file().nil?
|
|
92
|
+
raise_command_error "Deploy File `mtncloud.yml` not detected. Please create one and try again."
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Parse and validate config, need instance + deployment + version + files
|
|
96
|
+
# name can be specified as a single value for both instance and deployment
|
|
97
|
+
|
|
98
|
+
deploy_args = merged_deploy_args(environment)
|
|
99
|
+
|
|
100
|
+
instance_name = deploy_args['name']
|
|
101
|
+
if deploy_args['instance'].is_a?(String)
|
|
102
|
+
instance_name = deploy_args['instance']
|
|
103
|
+
end
|
|
104
|
+
if instance_name.nil?
|
|
105
|
+
raise_command_error "Instance not specified. Please specify the instance name and try again."
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
deployment_name = deploy_args['name'] || instance_name
|
|
109
|
+
if deploy_args['deployment'].is_a?(String)
|
|
110
|
+
deployment_name = deploy_args['deployment']
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
version_number = deploy_args['version']
|
|
114
|
+
if version_number.nil?
|
|
115
|
+
raise_command_error "Version not specified. Please specify the version and try again."
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
instance_results = @instances_interface.list(name: instance_name)
|
|
119
|
+
if instance_results['instances'].empty?
|
|
120
|
+
raise_command_error "Instance not found by name '#{instance_name}'"
|
|
121
|
+
end
|
|
122
|
+
instance = instance_results['instances'][0]
|
|
123
|
+
instance_id = instance['id']
|
|
124
|
+
|
|
125
|
+
# auto detect type, default to file
|
|
126
|
+
deploy_type = deploy_args['type'] || deploy_args['deployType']
|
|
127
|
+
if deploy_type.nil?
|
|
128
|
+
if deploy_args['gitUrl']
|
|
129
|
+
deploy_type = 'git'
|
|
130
|
+
elsif deploy_args['fetchUrl'] || deploy_args['url']
|
|
131
|
+
deploy_type = 'fetch'
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
if deploy_type.nil?
|
|
135
|
+
deploy_type = "file"
|
|
136
|
+
end
|
|
137
|
+
deploy_url = deploy_args['url'] || deploy_args['fetchUrl'] || deploy_args['gitUrl']
|
|
138
|
+
if deploy_url.nil? && (deploy_type == "git" || deploy_type == "fetch")
|
|
139
|
+
raise_command_error "Deploy type '#{deploy_type}' requires a url to be specified"
|
|
140
|
+
end
|
|
141
|
+
#deploy_type = "file" if deploy_type.to_s.downcase == "files"
|
|
142
|
+
|
|
143
|
+
deploy_config = deploy_args['options'] || deploy_args['config']
|
|
144
|
+
|
|
145
|
+
# ok do it
|
|
146
|
+
# fetch/create deployment, create deployment version, upload files, and deploy it to instance.
|
|
147
|
+
|
|
148
|
+
unless options[:quiet]
|
|
149
|
+
|
|
150
|
+
print_h1 "Deployment", options
|
|
151
|
+
|
|
152
|
+
columns = {
|
|
153
|
+
"Instance" => :name,
|
|
154
|
+
"Deployment" => :deployment,
|
|
155
|
+
"Version" => :version,
|
|
156
|
+
"Deploy Type" => :type,
|
|
157
|
+
"Script" => :script,
|
|
158
|
+
"Post Script" => :post_script,
|
|
159
|
+
"Files" => :files,
|
|
160
|
+
"Git Url" => :git_url,
|
|
161
|
+
"Git Ref" => :git_ref,
|
|
162
|
+
"Fetch Url" => :fetch_url,
|
|
163
|
+
"Environment" => :environment,
|
|
164
|
+
}
|
|
165
|
+
pretty_file_config = deploy_args['files'] ? deploy_args['files'].collect {|it|
|
|
166
|
+
[(it['path'] ? "path: #{it['path']}" : nil), (it['pattern'] ? "pattern: #{it['pattern']}" : nil)].compact.join(", ")
|
|
167
|
+
}.join(", ") : "(none)"
|
|
168
|
+
deploy_settings = {
|
|
169
|
+
:name => instance_name,
|
|
170
|
+
:deployment => deployment_name,
|
|
171
|
+
:version => version_number,
|
|
172
|
+
:script => deploy_args['script'],
|
|
173
|
+
:post_script => deploy_args['post_script'],
|
|
174
|
+
:files => pretty_file_config,
|
|
175
|
+
:type => format_deploy_type(deploy_type),
|
|
176
|
+
:git_url => deploy_args['gitUrl'] || (deploy_type == "git" ? deploy_args['url'] : nil),
|
|
177
|
+
:git_ref => deploy_args['gitRef'] || (deploy_type == "git" ? deploy_args['ref'] : nil),
|
|
178
|
+
:fetch_url => deploy_args['fetchUrl'] || (deploy_type == "fetch" ? deploy_args['url'] : nil),
|
|
179
|
+
# :files => deploy_args['files'],
|
|
180
|
+
# :files => deploy_files.size,
|
|
181
|
+
# :file_config => (deploy_files.size == 1 ? deploy_files[0][:destination] : deploy_args['files'])
|
|
182
|
+
:environment => environment
|
|
183
|
+
}
|
|
184
|
+
columns.delete("Script") if deploy_settings[:script].nil?
|
|
185
|
+
columns.delete("Post Script") if deploy_settings[:post_script].nil?
|
|
186
|
+
columns.delete("Environment") if deploy_settings[:environment].nil?
|
|
187
|
+
columns.delete("Files") if deploy_type != "file" && deploy_type != "files"
|
|
188
|
+
columns.delete("Git Url") if deploy_settings[:git_url].nil?
|
|
189
|
+
columns.delete("Git Ref") if deploy_settings[:git_ref].nil?
|
|
190
|
+
columns.delete("Fetch Url") if deploy_settings[:fetch_url].nil?
|
|
191
|
+
print_description_list(columns, deploy_settings)
|
|
192
|
+
print reset, "\n"
|
|
193
|
+
|
|
194
|
+
if deploy_config
|
|
195
|
+
print_h2 "Config Options", options
|
|
196
|
+
print cyan
|
|
197
|
+
puts as_json(deploy_config)
|
|
198
|
+
print "\n\n", reset
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
end # unless options[:quiet]
|
|
202
|
+
|
|
203
|
+
if !deploy_args['script'].nil?
|
|
204
|
+
# do this for dry run too since this is usually what creates the files to be uploaded
|
|
205
|
+
unless options[:quiet]
|
|
206
|
+
print cyan, "Executing Pre Deploy Script...", reset, "\n"
|
|
207
|
+
puts "running command: #{deploy_args['script']}"
|
|
208
|
+
end
|
|
209
|
+
if !system(deploy_args['script'])
|
|
210
|
+
raise_command_error "Error executing pre script..."
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Find Files to Upload
|
|
215
|
+
deploy_files = []
|
|
216
|
+
if deploy_type == "file" || deploy_type == "files"
|
|
217
|
+
if deploy_args['files'].nil? || deploy_args['files'].empty? || !deploy_args['files'].is_a?(Array)
|
|
218
|
+
raise_command_error "Files not specified. Please specify the files to include, each item may specify a path or pattern of file(s) to upload"
|
|
219
|
+
else
|
|
220
|
+
#print "\n",cyan, "Finding Files...", reset, "\n"
|
|
221
|
+
current_working_dir = Dir.pwd
|
|
222
|
+
deploy_args['files'].each do |fmap|
|
|
223
|
+
Dir.chdir(fmap['path'] || current_working_dir)
|
|
224
|
+
files = Dir.glob(fmap['pattern'] || '**/*')
|
|
225
|
+
files.each do |file|
|
|
226
|
+
if File.file?(file)
|
|
227
|
+
destination = file.split("/")[0..-2].join("/")
|
|
228
|
+
# deploy_files << {filepath: File.expand_path(file), destination: destination}
|
|
229
|
+
deploy_files << {filepath: File.expand_path(file), destination: file}
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
#print cyan, "Found #{deploy_files.size} Files to Upload!", reset, "\n"
|
|
234
|
+
Dir.chdir(current_working_dir)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
if deploy_files.empty?
|
|
238
|
+
raise_command_error "0 files found for: #{deploy_args['files'].inspect}"
|
|
239
|
+
else
|
|
240
|
+
unless options[:quiet]
|
|
241
|
+
print cyan, "Found #{deploy_files.size} Files to Upload!", reset, "\n"
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
elsif deploy_type == "git"
|
|
245
|
+
# make it work with simpler config, url instead of gitUrl
|
|
246
|
+
if deploy_args['gitUrl'].nil? && deploy_args['url']
|
|
247
|
+
deploy_args['gitUrl'] = deploy_args['url'] # .delete('url') maybe?
|
|
248
|
+
end
|
|
249
|
+
if deploy_args['gitRef'].nil? && deploy_args['ref']
|
|
250
|
+
deploy_args['gitRef'] = deploy_args['ref'] # .delete('ref') maybe?
|
|
251
|
+
end
|
|
252
|
+
if deploy_args['gitRef'].nil?
|
|
253
|
+
raise_command_error "fetchUrl not specified. Please specify the git url to fetch the deploy files from."
|
|
254
|
+
end
|
|
255
|
+
if deploy_args['gitRef'].nil?
|
|
256
|
+
#raise_command_error "gitRef not specified. Please specify the git reference to use. eg. main"
|
|
257
|
+
# deploy_args['gitRef'] = "main"
|
|
258
|
+
end
|
|
259
|
+
elsif deploy_type == "git"
|
|
260
|
+
# make it work with simpler config, url instead of fetchUrl
|
|
261
|
+
if deploy_args['fetchUrl'].nil? && deploy_args['url']
|
|
262
|
+
deploy_args['fetchUrl'] = deploy_args['url'] # .delete('url') maybe?
|
|
263
|
+
end
|
|
264
|
+
if deploy_args['fetchUrl'].nil?
|
|
265
|
+
raise_command_error "fetchUrl not specified. Please specify the url to fetch the deploy files from."
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
confirm_warning = ""
|
|
271
|
+
confirm_message = "Are you sure you want to perform this action?"
|
|
272
|
+
if deploy_type == "file" || deploy_type == "files"
|
|
273
|
+
confirm_warning = "This will create deployment #{deployment_name} version #{version_number} and deploy it to instance #{instance['name']}."
|
|
274
|
+
elsif deploy_type == "git"
|
|
275
|
+
confirm_warning = "This will create deployment #{deployment_name} version #{version_number} and deploy it to instance #{instance['name']}."
|
|
276
|
+
elsif deploy_type == "fetch"
|
|
277
|
+
confirm_warning = "This will create deployment #{deployment_name} version #{version_number} and deploy it to instance #{instance['name']}."
|
|
278
|
+
end
|
|
279
|
+
puts confirm_warning if !options[:quiet]
|
|
280
|
+
unless options[:yes] || MtnCloud::Cli::OptionTypes.confirm(confirm_message)
|
|
281
|
+
return 9, "aborted command"
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Find or Create Deployment
|
|
285
|
+
deployment = nil
|
|
286
|
+
deployments = @deployments_interface.list(name: deployment_name)['deployments']
|
|
287
|
+
|
|
288
|
+
@instances_interface.setopts(options)
|
|
289
|
+
@deploy_interface.setopts(options)
|
|
290
|
+
@deployments_interface.setopts(options)
|
|
291
|
+
|
|
292
|
+
if deployments.size > 1
|
|
293
|
+
raise_command_error "#{deployments.size} deployment versions found by deployment '#{name}'"
|
|
294
|
+
elsif deployments.size == 1
|
|
295
|
+
deployment = deployments[0]
|
|
296
|
+
# should update here, eg description
|
|
297
|
+
else
|
|
298
|
+
# create it
|
|
299
|
+
payload = {
|
|
300
|
+
'deployment' => {
|
|
301
|
+
'name' => deployment_name
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
payload['deployment']['description'] = deploy_args['description'] if deploy_args['description']
|
|
305
|
+
|
|
306
|
+
if options[:dry_run]
|
|
307
|
+
print_dry_run @deployments_interface.dry.create(payload)
|
|
308
|
+
# return 0, nil
|
|
309
|
+
deployment = {'id' => ':deploymentId', 'name' => deployment_name}
|
|
310
|
+
else
|
|
311
|
+
json_response = @deployments_interface.create(payload)
|
|
312
|
+
deployment = json_response['deployment']
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
# Find or Create Deployment Version
|
|
317
|
+
# Actually, for now this this errors if the version already exists, but it should update it.
|
|
318
|
+
|
|
319
|
+
@deployments_interface = @api_client.deployments
|
|
320
|
+
deployment_version = nil
|
|
321
|
+
if options[:dry_run]
|
|
322
|
+
print_dry_run @deployments_interface.dry.list_versions(deployment['id'], {userVersion: version_number})
|
|
323
|
+
# return 0, nil
|
|
324
|
+
#deployment_versions =[{'id' => ':versionId', 'version' => version_number}]
|
|
325
|
+
deployment_versions = []
|
|
326
|
+
else
|
|
327
|
+
deployment_versions = @deployments_interface.list_versions(deployment['id'], {userVersion: version_number})['versions']
|
|
328
|
+
@deployments_interface.setopts(options)
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
if deployment_versions.size > 0
|
|
333
|
+
raise_command_error "Deployment '#{deployment['name']}' version '#{version_number}' already exists. Specify a new version or delete the existing version."
|
|
334
|
+
# if deployment_versions.size > 1
|
|
335
|
+
# raise_command_error "#{deployment_versions.size} versions found by version '#{name}'"
|
|
336
|
+
# elsif deployment_versions.size == 1
|
|
337
|
+
# deployment_version = deployment_versions[0]
|
|
338
|
+
# # should update here, eg description
|
|
339
|
+
else
|
|
340
|
+
# create it
|
|
341
|
+
payload = {
|
|
342
|
+
'version' => {
|
|
343
|
+
'userVersion' => version_number,
|
|
344
|
+
'deployType' => deploy_type
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
payload['version']['fetchUrl'] = deploy_args['fetchUrl'] if deploy_args['fetchUrl']
|
|
348
|
+
payload['version']['gitUrl'] = deploy_args['gitUrl'] if deploy_args['gitUrl']
|
|
349
|
+
payload['version']['gitRef'] = deploy_args['gitRef'] if deploy_args['gitRef']
|
|
350
|
+
|
|
351
|
+
if options[:dry_run]
|
|
352
|
+
print_dry_run @deployments_interface.dry.create_version(deployment['id'], payload)
|
|
353
|
+
# return 0, nil
|
|
354
|
+
deployment_version = {'id' => ':versionId', 'version' => version_number}
|
|
355
|
+
else
|
|
356
|
+
json_response = @deployments_interface.create_version(deployment['id'], payload)
|
|
357
|
+
deployment_version = json_response['version']
|
|
358
|
+
end
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
# Upload Files
|
|
363
|
+
if deploy_type == "file" || deploy_type == "files"
|
|
364
|
+
if deploy_files && !deploy_files.empty?
|
|
365
|
+
print "\n",cyan, "Uploading #{deploy_files.size} Files...", reset, "\n" if !options[:quiet]
|
|
366
|
+
current_working_dir = Dir.pwd
|
|
367
|
+
deploy_files.each do |f|
|
|
368
|
+
destination = f[:destination]
|
|
369
|
+
if options[:dry_run]
|
|
370
|
+
print_dry_run @deployments_interface.upload_file(deployment['id'], deployment_version['id'], f[:filepath], f[:destination])
|
|
371
|
+
else
|
|
372
|
+
print cyan," - Uploading #{f[:destination]} ...", reset if !options[:quiet]
|
|
373
|
+
upload_result = @deployments_interface.upload_file(deployment['id'], deployment_version['id'], f[:filepath], f[:destination])
|
|
374
|
+
#print green + "SUCCESS" + reset + "\n" if !options[:quiet]
|
|
375
|
+
print reset, "\n" if !options[:quiet]
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
print cyan, "Upload Complete!", reset, "\n" if !options[:quiet]
|
|
379
|
+
Dir.chdir(current_working_dir)
|
|
380
|
+
else
|
|
381
|
+
print "\n",cyan, "0 files to upload", reset, "\n" if !options[:quiet]
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
if !deploy_args['post_script'].nil?
|
|
386
|
+
print cyan, "Executing Post Script...", reset, "\n" if !options[:quiet]
|
|
387
|
+
puts "running command: #{deploy_args['post_script']}" if !options[:quiet]
|
|
388
|
+
if !system(deploy_args['post_script'])
|
|
389
|
+
raise_command_error "Error executing post script..."
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
# JD: restart for evars eh?
|
|
394
|
+
if deploy_args['env']
|
|
395
|
+
evars = []
|
|
396
|
+
deploy_args['env'].each_pair do |key, value|
|
|
397
|
+
evars << {name: key, value: value, export: false}
|
|
398
|
+
end
|
|
399
|
+
payload = {envs: evars}
|
|
400
|
+
if options[:dry_run]
|
|
401
|
+
print_dry_run @instances_interface.dry.create_env(instance_id, payload)
|
|
402
|
+
print_dry_run @instances_interface.dry.restart(instance_id)
|
|
403
|
+
else
|
|
404
|
+
@instances_interface.create_env(instance_id, payload)
|
|
405
|
+
@instances_interface.restart(instance_id)
|
|
406
|
+
end
|
|
407
|
+
end
|
|
408
|
+
# Create the AppDeploy, this does the deploy async (as of 4.2.2-3)
|
|
409
|
+
payload = {'appDeploy' => {} }
|
|
410
|
+
payload['appDeploy']['versionId'] = deployment_version['id']
|
|
411
|
+
if deploy_args['options']
|
|
412
|
+
payload['appDeploy']['config'] = deploy_args['options']
|
|
413
|
+
end
|
|
414
|
+
# stageOnly means do not actually deploy yet, can invoke @deploy_interface.deploy(deployment['id']) later
|
|
415
|
+
# there is no cli command for that yet though..
|
|
416
|
+
stage_only = deploy_args['stage'] || deploy_args['stage_deploy'] || deploy_args['stage_only'] || deploy_args['stageOnly']
|
|
417
|
+
if stage_only
|
|
418
|
+
payload['appDeploy']['stageOnly'] = true
|
|
419
|
+
end
|
|
420
|
+
# config/options to apply to deployment
|
|
421
|
+
if deploy_config
|
|
422
|
+
payload['appDeploy']['config'] = deploy_config
|
|
423
|
+
end
|
|
424
|
+
app_deploy_id = nil
|
|
425
|
+
if options[:dry_run]
|
|
426
|
+
print_dry_run @deploy_interface.dry.create(instance_id, payload)
|
|
427
|
+
# return 0, nil
|
|
428
|
+
app_deploy_id = ':appDeployId'
|
|
429
|
+
else
|
|
430
|
+
# Create a new appDeploy record, without stageOnly, this actually does the deployment
|
|
431
|
+
#print cyan, "Deploying #{deployment_name} version #{version_number} to instance #{instance_name} ...", reset, "\n"
|
|
432
|
+
deploy_result = @deploy_interface.create(instance_id, payload)
|
|
433
|
+
app_deploy = deploy_result['appDeploy']
|
|
434
|
+
app_deploy_id = app_deploy['id']
|
|
435
|
+
if !options[:quiet]
|
|
436
|
+
if app_deploy['status'] == 'staged'
|
|
437
|
+
print_green_success "Staged Deploy #{deployment_name} version #{version_number} to instance #{instance_name}"
|
|
438
|
+
else
|
|
439
|
+
print_green_success "Deploying #{deployment_name} version #{version_number} to instance #{instance_name}"
|
|
440
|
+
end
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
return 0, nil
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
protected
|
|
447
|
+
|
|
448
|
+
# Loads a mtncloud.yml file from within the current working directory.
|
|
449
|
+
# A morpheus.yml file is still read when there is no mtncloud.yml, so existing projects keep working.
|
|
450
|
+
# This file contains information necessary to perform a deployment via the cli.
|
|
451
|
+
#
|
|
452
|
+
# === Example File Attributes
|
|
453
|
+
# * +script+ - The initial script to run before uploading files
|
|
454
|
+
# * +name+ - The instance name we are deploying to (can be overridden in CLI)
|
|
455
|
+
# * +files+ - List of file patterns to use for uploading files and their target destination
|
|
456
|
+
# * +options+ - Map of deployment options depending on deployment type
|
|
457
|
+
# * +post_script+ - A post operation script to be run on the local machine
|
|
458
|
+
# * +stage_deploy+ - If set to true the deploy will only be staged and not actually run
|
|
459
|
+
#
|
|
460
|
+
# +NOTE: + It is also possible to nest these properties in an "environments" map to override based on a passed environment deploy name
|
|
461
|
+
#
|
|
462
|
+
def load_deploy_file
|
|
463
|
+
deploy_filename = ["mtncloud.yml", "morpheus.yml"].find {|fn| File.exist?(fn) }
|
|
464
|
+
if deploy_filename.nil?
|
|
465
|
+
puts "No mtncloud.yml file detected in the current directory. Nothing to do."
|
|
466
|
+
return nil
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
@deploy_file = YAML.load_file(deploy_filename)
|
|
470
|
+
return @deploy_file
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
def merged_deploy_args(environment)
|
|
474
|
+
deploy_args = @deploy_file.reject { |key,value| key == 'environment'}
|
|
475
|
+
if environment && !@deploy_file['environment'].nil? && !@deploy_file['environment'][environment].nil?
|
|
476
|
+
deploy_args = deploy_args.merge(@deploy_file['environment'][environment])
|
|
477
|
+
end
|
|
478
|
+
return deploy_args
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
def default_deploy_environment
|
|
482
|
+
nil
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
end
|