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,1197 @@
|
|
|
1
|
+
require 'mtncloud/cli/cli_command'
|
|
2
|
+
# require 'mtncloud/cli/commands/boot_scripts_command'
|
|
3
|
+
# require 'mtncloud/cli/commands/preseed_scripts_command'
|
|
4
|
+
|
|
5
|
+
class MtnCloud::Cli::ImageBuilderCommand
|
|
6
|
+
include MtnCloud::Cli::CliCommand
|
|
7
|
+
include MtnCloud::Cli::ProvisioningHelper
|
|
8
|
+
|
|
9
|
+
set_command_name :'image-builder' # :'image-builds'
|
|
10
|
+
|
|
11
|
+
register_subcommands :list, :get, :add, :update, :remove
|
|
12
|
+
register_subcommands :run
|
|
13
|
+
register_subcommands :'list-runs' => :list_executions
|
|
14
|
+
|
|
15
|
+
# err, these are kept under this namespace
|
|
16
|
+
register_subcommands :'boot-scripts' => :boot_scripts
|
|
17
|
+
register_subcommands :'preseed-scripts' => :preseed_scripts
|
|
18
|
+
|
|
19
|
+
# set_default_subcommand :list
|
|
20
|
+
|
|
21
|
+
def initialize()
|
|
22
|
+
# @appliance_name, @appliance_url = MtnCloud::Cli::Remote.active_appliance
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def connect(opts)
|
|
26
|
+
@api_client = establish_remote_appliance_connection(opts)
|
|
27
|
+
@image_builder_interface = @api_client.image_builder
|
|
28
|
+
@image_builds_interface = @image_builder_interface.image_builds
|
|
29
|
+
@boot_scripts_interface = @image_builder_interface.boot_scripts
|
|
30
|
+
@preseed_scripts_interface = @image_builder_interface.preseed_scripts
|
|
31
|
+
@groups_interface = @api_client.groups
|
|
32
|
+
@clouds_interface = @api_client.clouds
|
|
33
|
+
@instances_interface = @api_client.instances
|
|
34
|
+
@instance_types_interface = @api_client.instance_types
|
|
35
|
+
@options_interface = @api_client.options
|
|
36
|
+
@active_group_id = MtnCloud::Cli::Groups.active_groups[@appliance_name]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def handle(args)
|
|
40
|
+
handle_subcommand(args)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def boot_scripts(args)
|
|
44
|
+
MtnCloud::Cli::BootScriptsCommand.new.handle(args)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def preseed_scripts(args)
|
|
48
|
+
MtnCloud::Cli::PreseedScriptsCommand.new.handle(args)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def list(args)
|
|
52
|
+
options = {}
|
|
53
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
54
|
+
opts.banner = subcommand_usage()
|
|
55
|
+
build_common_options(opts, options, [:list, :json, :dry_run, :remote])
|
|
56
|
+
end
|
|
57
|
+
optparse.parse!(args)
|
|
58
|
+
connect(options)
|
|
59
|
+
begin
|
|
60
|
+
params = {}
|
|
61
|
+
[:phrase, :offset, :max, :sort, :direction].each do |k|
|
|
62
|
+
params[k] = options[k] unless options[k].nil?
|
|
63
|
+
end
|
|
64
|
+
@image_builds_interface.setopts(options)
|
|
65
|
+
if options[:dry_run]
|
|
66
|
+
print_dry_run @image_builds_interface.dry.list(params)
|
|
67
|
+
return
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
json_response = @image_builds_interface.list(params)
|
|
71
|
+
if options[:json]
|
|
72
|
+
print JSON.pretty_generate(json_response)
|
|
73
|
+
print "\n"
|
|
74
|
+
return
|
|
75
|
+
end
|
|
76
|
+
image_builds = json_response['imageBuilds']
|
|
77
|
+
title = "Image Builds"
|
|
78
|
+
subtitles = []
|
|
79
|
+
# if group
|
|
80
|
+
# subtitles << "Group: #{group['name']}".strip
|
|
81
|
+
# end
|
|
82
|
+
# if cloud
|
|
83
|
+
# subtitles << "Cloud: #{cloud['name']}".strip
|
|
84
|
+
# end
|
|
85
|
+
if params[:phrase]
|
|
86
|
+
subtitles << "Search: #{params[:phrase]}".strip
|
|
87
|
+
end
|
|
88
|
+
print_h1 title, subtitles
|
|
89
|
+
if image_builds.empty?
|
|
90
|
+
print cyan,"No image builds found.",reset,"\n"
|
|
91
|
+
else
|
|
92
|
+
rows = image_builds.collect {|image_build|
|
|
93
|
+
last_result = image_build['lastResult']
|
|
94
|
+
status_str = format_image_build_status(image_build, cyan)
|
|
95
|
+
result_str = format_image_build_execution_result(last_result, cyan)
|
|
96
|
+
row = {
|
|
97
|
+
id: image_build['id'],
|
|
98
|
+
name: image_build['name'],
|
|
99
|
+
# description: image_build['description'],
|
|
100
|
+
type: image_build['type'] ? image_build['type']['name'] : 'N/A',
|
|
101
|
+
group: image_build['site'] ? image_build['site']['name'] : '',
|
|
102
|
+
cloud: image_build['zone'] ? image_build['zone']['name'] : '',
|
|
103
|
+
executionCount: image_build['executionCount'] ? image_build['executionCount'].to_i : '',
|
|
104
|
+
lastRunDate: last_result ? format_local_dt(last_result['startDate']) : '',
|
|
105
|
+
status: status_str,
|
|
106
|
+
result: result_str
|
|
107
|
+
}
|
|
108
|
+
row
|
|
109
|
+
}
|
|
110
|
+
columns = [:id, :name, :type, {:lastRunDate => {label: 'Last Run Date'.upcase}},
|
|
111
|
+
:status, {:result => {max_width: 60}}]
|
|
112
|
+
# custom pretty table columns ...
|
|
113
|
+
if options[:include_fields]
|
|
114
|
+
columns = options[:include_fields]
|
|
115
|
+
end
|
|
116
|
+
print cyan
|
|
117
|
+
print as_pretty_table(rows, columns, options)
|
|
118
|
+
print reset
|
|
119
|
+
print_results_pagination(json_response)
|
|
120
|
+
end
|
|
121
|
+
print reset,"\n"
|
|
122
|
+
rescue RestClient::Exception => e
|
|
123
|
+
print_rest_exception(e, options)
|
|
124
|
+
exit 1
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def get(args)
|
|
129
|
+
options = {}
|
|
130
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
131
|
+
opts.banner = subcommand_usage("[image-build]")
|
|
132
|
+
build_common_options(opts, options, [:json, :dry_run, :remote])
|
|
133
|
+
end
|
|
134
|
+
optparse.parse!(args)
|
|
135
|
+
if args.count < 1
|
|
136
|
+
print_error MtnCloud::Terminal.angry_prompt
|
|
137
|
+
puts_error "#{command_name} missing argument: [image-build]\n#{optparse}"
|
|
138
|
+
return 1
|
|
139
|
+
end
|
|
140
|
+
connect(options)
|
|
141
|
+
begin
|
|
142
|
+
@image_builds_interface.setopts(options)
|
|
143
|
+
if options[:dry_run]
|
|
144
|
+
if args[0].to_s =~ /\A\d{1,}\Z/
|
|
145
|
+
print_dry_run @image_builds_interface.dry.get(args[0].to_i)
|
|
146
|
+
else
|
|
147
|
+
print_dry_run @image_builds_interface.dry.list({name:args[0]})
|
|
148
|
+
end
|
|
149
|
+
return
|
|
150
|
+
end
|
|
151
|
+
image_build = find_image_build_by_name_or_id(args[0])
|
|
152
|
+
return 1 if image_build.nil?
|
|
153
|
+
# json_response = {'imageBuild' => image_build} # skip redundant request
|
|
154
|
+
json_response = @image_builds_interface.get(image_build['id'])
|
|
155
|
+
image_build = json_response['imageBuild']
|
|
156
|
+
if options[:json]
|
|
157
|
+
print JSON.pretty_generate(json_response)
|
|
158
|
+
return
|
|
159
|
+
end
|
|
160
|
+
print_h1 "Image Build Details"
|
|
161
|
+
print cyan
|
|
162
|
+
description_cols = {
|
|
163
|
+
"ID" => 'id',
|
|
164
|
+
# "Account" => lambda {|it| it['account'] ? it['account']['name'] : '' },
|
|
165
|
+
"Name" => 'name',
|
|
166
|
+
"Description" => 'description',
|
|
167
|
+
"Group" => lambda {|it| it['site'] ? it['site']['name'] : '' },
|
|
168
|
+
"Cloud" => lambda {|it| it['zone'] ? it['zone']['name'] : '' },
|
|
169
|
+
"Plan" => lambda {|it|
|
|
170
|
+
if it['config'] && it['config']['plan']
|
|
171
|
+
it['config']['plan']['code'] # name needed!
|
|
172
|
+
else
|
|
173
|
+
""
|
|
174
|
+
end
|
|
175
|
+
},
|
|
176
|
+
"Image" => lambda {|it|
|
|
177
|
+
if it['config'] && it['config']['template']
|
|
178
|
+
it['config']['template']
|
|
179
|
+
elsif it['config'] && it['config']['image']
|
|
180
|
+
it['config']['image']
|
|
181
|
+
else
|
|
182
|
+
""
|
|
183
|
+
end
|
|
184
|
+
},
|
|
185
|
+
"Boot Script" => lambda {|it|
|
|
186
|
+
if it['bootScript']
|
|
187
|
+
if it['bootScript'].kind_of?(Hash)
|
|
188
|
+
it['bootScript']['fileName'] || it['bootScript']['name'] || it['bootScript']['id']
|
|
189
|
+
else
|
|
190
|
+
it['bootScript']
|
|
191
|
+
end
|
|
192
|
+
else
|
|
193
|
+
""
|
|
194
|
+
end
|
|
195
|
+
},
|
|
196
|
+
"Preseed Script" => lambda {|it|
|
|
197
|
+
if it['preseedScript']
|
|
198
|
+
if it['preseedScript'].kind_of?(Hash)
|
|
199
|
+
it['preseedScript']['fileName'] || it['preseedScript']['name'] || it['preseedScript']['id']
|
|
200
|
+
else
|
|
201
|
+
it['preseedScript']
|
|
202
|
+
end
|
|
203
|
+
else
|
|
204
|
+
""
|
|
205
|
+
end
|
|
206
|
+
},
|
|
207
|
+
# Additional Scripts
|
|
208
|
+
"Scripts" => lambda {|it|
|
|
209
|
+
if it['scripts']
|
|
210
|
+
script_names = it['scripts'].collect do |script|
|
|
211
|
+
if script.kind_of?(Hash)
|
|
212
|
+
script['name']
|
|
213
|
+
else
|
|
214
|
+
script
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
script_names.join(", ")
|
|
218
|
+
else
|
|
219
|
+
""
|
|
220
|
+
end
|
|
221
|
+
},
|
|
222
|
+
"SSH Username" => lambda {|it| it['sshUsername'] },
|
|
223
|
+
"SSH Password" => lambda {|it| it['sshPassword'].to_s.empty? ? '' : '(hidden)' }, # api returns masked
|
|
224
|
+
"Storage Provider" => lambda {|it|
|
|
225
|
+
if it['storageProvider']
|
|
226
|
+
if it['storageProvider'].kind_of?(Hash)
|
|
227
|
+
it['storageProvider']['name'] || it['storageProvider']['id']
|
|
228
|
+
else
|
|
229
|
+
it['storageProvider']
|
|
230
|
+
end
|
|
231
|
+
else
|
|
232
|
+
""
|
|
233
|
+
end
|
|
234
|
+
},
|
|
235
|
+
"Build Output Name" => lambda {|it| it['buildOutputName'] },
|
|
236
|
+
"Conversion Formats" => lambda {|it| it['conversionFormats'] },
|
|
237
|
+
"Cloud Init?" => lambda {|it| it['isCloudInit'] ? 'Yes' : 'No' },
|
|
238
|
+
"Keep Results" => lambda {|it| it['keepResults'].to_i == 0 ? 'All' : it['keepResults'] },
|
|
239
|
+
"Last Run Date" => lambda {|it|
|
|
240
|
+
last_result = it['lastResult']
|
|
241
|
+
last_result ? format_local_dt(last_result['startDate']) : ''
|
|
242
|
+
},
|
|
243
|
+
"Status" => lambda {|it| format_image_build_status(it) },
|
|
244
|
+
}
|
|
245
|
+
print_description_list(description_cols, image_build)
|
|
246
|
+
|
|
247
|
+
#json_response = @image_builds_interface.list_executions(image_build['id'], params)
|
|
248
|
+
image_build_executions = json_response['imageBuildExecutions'] # yep, show() returns the last 100 run
|
|
249
|
+
image_build_executions = image_build_executions.first(10) # limit to just 10
|
|
250
|
+
if image_build_executions && image_build_executions.size > 0
|
|
251
|
+
print_h2 "Recent Executions"
|
|
252
|
+
print_image_build_executions_table(image_build_executions, opts={})
|
|
253
|
+
print_results_pagination({size:image_build_executions.size,total:image_build['executionCount'].to_i}, {:label => "execution", :n_label => "executions"})
|
|
254
|
+
else
|
|
255
|
+
puts "\nNo executions found.\n"
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
print reset,"\n"
|
|
259
|
+
|
|
260
|
+
rescue RestClient::Exception => e
|
|
261
|
+
print_rest_exception(e, options)
|
|
262
|
+
return 1
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def add(args)
|
|
267
|
+
options = {}
|
|
268
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
269
|
+
opts.banner = subcommand_usage("[options]")
|
|
270
|
+
# build_option_type_options(opts, options, add_image_build_option_types(false))
|
|
271
|
+
opts.on( '-t', '--type TYPE', "Image Build Type" ) do |val|
|
|
272
|
+
options['type'] = val
|
|
273
|
+
end
|
|
274
|
+
opts.on('--name VALUE', String, "Name") do |val|
|
|
275
|
+
options['name'] = val
|
|
276
|
+
end
|
|
277
|
+
opts.on('--description VALUE', String, "Description") do |val|
|
|
278
|
+
options['description'] = val
|
|
279
|
+
end
|
|
280
|
+
opts.on( '-g', '--group GROUP', "Group Name or ID" ) do |val|
|
|
281
|
+
options['group'] = val
|
|
282
|
+
end
|
|
283
|
+
opts.on( '-c', '--cloud CLOUD', "Cloud Name or ID" ) do |val|
|
|
284
|
+
options['cloud'] = val
|
|
285
|
+
end
|
|
286
|
+
# opts.on( '-e', '--env ENVIRONMENT', "Environment" ) do |val|
|
|
287
|
+
# options[:cloud] = val
|
|
288
|
+
# end
|
|
289
|
+
opts.on('--config JSON', String, "Instance Config JSON") do |val|
|
|
290
|
+
options['config'] = JSON.parse(val.to_s)
|
|
291
|
+
end
|
|
292
|
+
opts.on('--config-yaml YAML', String, "Instance Config YAML") do |val|
|
|
293
|
+
options['config'] = YAML.load(val.to_s)
|
|
294
|
+
end
|
|
295
|
+
opts.on('--config-file FILE', String, "Instance Config from a local JSON or YAML file") do |val|
|
|
296
|
+
options['configFile'] = val.to_s
|
|
297
|
+
end
|
|
298
|
+
# opts.on('--configFile FILE', String, "Instance Config from a local file") do |val|
|
|
299
|
+
# options['configFile'] = val.to_s
|
|
300
|
+
# end
|
|
301
|
+
opts.on('--bootScript VALUE', String, "Boot Script ID") do |val|
|
|
302
|
+
options['bootScript'] = val.to_s
|
|
303
|
+
end
|
|
304
|
+
opts.on('--bootCommand VALUE', String, "Boot Command. This can be used in place of a bootScript") do |val|
|
|
305
|
+
options['bootCommand'] = val.to_s
|
|
306
|
+
end
|
|
307
|
+
opts.on('--preseedScript VALUE', String, "Preseed Script ID") do |val|
|
|
308
|
+
options['preseedScript'] = val.to_s
|
|
309
|
+
end
|
|
310
|
+
opts.on('--scripts LIST', String, "Additional Scripts (comma separated names or ids)") do |val|
|
|
311
|
+
# uh don't put commas or leading/trailing spaces in script names pl
|
|
312
|
+
options['scripts'] = val.to_s.split(",").collect {|it| it.to_s.strip }.select {|it| it }.compact
|
|
313
|
+
end
|
|
314
|
+
opts.on('--sshUsername VALUE', String, "SSH Username") do |val|
|
|
315
|
+
options['sshUsername'] = val.to_s
|
|
316
|
+
end
|
|
317
|
+
opts.on('--sshPassword VALUE', String, "SSH Password") do |val|
|
|
318
|
+
options['sshPassword'] = val.to_s
|
|
319
|
+
end
|
|
320
|
+
opts.on('--storageProvider VALUE', String, "Storage Provider ID") do |val|
|
|
321
|
+
options['storageProvider'] = val.to_s
|
|
322
|
+
end
|
|
323
|
+
opts.on('--isCloudInit [on|off]', String, "Cloud Init?") do |val|
|
|
324
|
+
options['isCloudInit'] = (val.to_s == 'on' || val.to_s == 'true')
|
|
325
|
+
end
|
|
326
|
+
opts.on('--buildOutputName VALUE', String, "Build Output Name") do |val|
|
|
327
|
+
options['buildOutputName'] = val.to_s
|
|
328
|
+
end
|
|
329
|
+
opts.on('--conversionFormats VALUE', String, "Conversion Formats ie. ovf, qcow2, vhd") do |val|
|
|
330
|
+
options['conversionFormats'] = val.to_s
|
|
331
|
+
end
|
|
332
|
+
opts.on('--keepResults VALUE', String, "Keep only the most recent builds. Older executions will be deleted along with their associated Virtual Images. The value 0 disables this functionality.") do |val|
|
|
333
|
+
options['keepResults'] = val.to_i
|
|
334
|
+
end
|
|
335
|
+
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote, :quiet])
|
|
336
|
+
end
|
|
337
|
+
optparse.parse!(args)
|
|
338
|
+
if args.count > 1
|
|
339
|
+
puts_error "#{MtnCloud::Terminal.angry_prompt}wrong number of arguments. Expected 0-1 and received #{args.count} #{args.inspect}\n#{optparse}"
|
|
340
|
+
return 1
|
|
341
|
+
end
|
|
342
|
+
connect(options)
|
|
343
|
+
begin
|
|
344
|
+
payload = nil
|
|
345
|
+
if options[:payload]
|
|
346
|
+
payload = options[:payload]
|
|
347
|
+
# support options top of --payload
|
|
348
|
+
options.merge!(options[:options]) if options[:options] # so -O var= works..
|
|
349
|
+
option_params = options.reject {|k,v| k.is_a?(Symbol) }
|
|
350
|
+
payload.deep_merge!({'imageBuild' => option_params}) unless option_params.empty?
|
|
351
|
+
else
|
|
352
|
+
options.merge!(options[:options]) if options[:options] # so -O var= works..
|
|
353
|
+
|
|
354
|
+
# use the -g GROUP or active group by default
|
|
355
|
+
# options['group'] ||= @active_group_id
|
|
356
|
+
|
|
357
|
+
# support first arg as name instead of --name
|
|
358
|
+
if args[0] && !options['name']
|
|
359
|
+
options['name'] = args[0]
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
image_build_payload = prompt_new_image_build(options)
|
|
363
|
+
return 1 if !image_build_payload
|
|
364
|
+
payload = {'imageBuild' => image_build_payload}
|
|
365
|
+
end
|
|
366
|
+
@image_builds_interface.setopts(options)
|
|
367
|
+
if options[:dry_run]
|
|
368
|
+
print_dry_run @image_builds_interface.dry.create(payload)
|
|
369
|
+
return
|
|
370
|
+
end
|
|
371
|
+
json_response = @image_builds_interface.create(payload)
|
|
372
|
+
if options[:json]
|
|
373
|
+
print JSON.pretty_generate(json_response)
|
|
374
|
+
print "\n"
|
|
375
|
+
elsif !options[:quiet]
|
|
376
|
+
new_image_build = json_response['imageBuild']
|
|
377
|
+
print_green_success "Added image build #{new_image_build['name']}"
|
|
378
|
+
get([new_image_build['id']])
|
|
379
|
+
# list([])
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
rescue RestClient::Exception => e
|
|
383
|
+
print_rest_exception(e, options)
|
|
384
|
+
return 1
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def update(args)
|
|
389
|
+
options = {}
|
|
390
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
391
|
+
opts.banner = subcommand_usage("[image-build] [options]")
|
|
392
|
+
# build_option_type_options(opts, options, update_image_build_option_types(false))
|
|
393
|
+
# cannot update type
|
|
394
|
+
opts.on( '-t', '--type TYPE', "Image Build Type" ) do |val|
|
|
395
|
+
options['type'] = val
|
|
396
|
+
end
|
|
397
|
+
opts.on('--name VALUE', String, "New Name") do |val|
|
|
398
|
+
options['name'] = val
|
|
399
|
+
end
|
|
400
|
+
opts.on('--description VALUE', String, "Description") do |val|
|
|
401
|
+
options['description'] = val
|
|
402
|
+
end
|
|
403
|
+
opts.on( '-g', '--group GROUP', "Group Name or ID" ) do |val|
|
|
404
|
+
options['group'] = val
|
|
405
|
+
end
|
|
406
|
+
opts.on( '-c', '--cloud CLOUD', "Cloud Name or ID" ) do |val|
|
|
407
|
+
options['cloud'] = val
|
|
408
|
+
end
|
|
409
|
+
# opts.on( '-e', '--env ENVIRONMENT', "Environment" ) do |val|
|
|
410
|
+
# options[:cloud] = val
|
|
411
|
+
# end
|
|
412
|
+
opts.on('--config JSON', String, "Instance Config JSON") do |val|
|
|
413
|
+
options['config'] = JSON.parse(val.to_s)
|
|
414
|
+
end
|
|
415
|
+
opts.on('--config-yaml YAML', String, "Instance Config YAML") do |val|
|
|
416
|
+
options['config'] = YAML.load(val.to_s)
|
|
417
|
+
end
|
|
418
|
+
opts.on('--config-file FILE', String, "Instance Config from a local JSON or YAML file") do |val|
|
|
419
|
+
options['configFile'] = val.to_s
|
|
420
|
+
end
|
|
421
|
+
# opts.on('--configFile FILE', String, "Instance Config from a local file") do |val|
|
|
422
|
+
# options['configFile'] = val.to_s
|
|
423
|
+
# end
|
|
424
|
+
opts.on('--bootScript VALUE', String, "Boot Script ID") do |val|
|
|
425
|
+
options['bootScript'] = val.to_s
|
|
426
|
+
end
|
|
427
|
+
opts.on('--bootCommand VALUE', String, "Boot Command. This can be used in place of a bootScript") do |val|
|
|
428
|
+
options['bootCommand'] = val.to_s
|
|
429
|
+
end
|
|
430
|
+
opts.on('--preseedScript VALUE', String, "Preseed Script ID") do |val|
|
|
431
|
+
options['preseedScript'] = val.to_s
|
|
432
|
+
end
|
|
433
|
+
opts.on('--scripts LIST', String, "Additional Scripts (comma separated names or ids)") do |val|
|
|
434
|
+
# uh don't put commas or leading/trailing spaces in script names pl
|
|
435
|
+
options['scripts'] = val.to_s.split(",").collect {|it| it.to_s.strip }.select {|it| it }.compact
|
|
436
|
+
end
|
|
437
|
+
opts.on('--sshUsername VALUE', String, "SSH Username") do |val|
|
|
438
|
+
options['sshUsername'] = val.to_s
|
|
439
|
+
end
|
|
440
|
+
opts.on('--sshPassword VALUE', String, "SSH Password") do |val|
|
|
441
|
+
options['sshPassword'] = val.to_s
|
|
442
|
+
end
|
|
443
|
+
opts.on('--storageProvider VALUE', String, "Storage Provider ID") do |val|
|
|
444
|
+
options['storageProvider'] = val.to_s
|
|
445
|
+
end
|
|
446
|
+
opts.on('--isCloudInit [on|off]', String, "Cloud Init?") do |val|
|
|
447
|
+
options['isCloudInit'] = (val.to_s == 'on' || val.to_s == 'true')
|
|
448
|
+
end
|
|
449
|
+
opts.on('--buildOutputName VALUE', String, "Build Output Name") do |val|
|
|
450
|
+
options['buildOutputName'] = val.to_s
|
|
451
|
+
end
|
|
452
|
+
opts.on('--conversionFormats VALUE', String, "Conversion Formats ie. ovf, qcow2, vhd") do |val|
|
|
453
|
+
options['conversionFormats'] = val.to_s
|
|
454
|
+
end
|
|
455
|
+
# opts.on('--keepResultsEnabled [on|off]', String, "Delete Old Results. Enables the Keep Results option") do |val|
|
|
456
|
+
# options['keepResultsEnabled'] = (val.to_s == 'on' || val.to_s == 'true')
|
|
457
|
+
# end
|
|
458
|
+
opts.on('--keepResults VALUE', String, "Keep only the most recent builds. Older executions will be deleted along with their associated Virtual Images. The value 0 disables this functionality.") do |val|
|
|
459
|
+
options['keepResults'] = val.to_i
|
|
460
|
+
# 0 disables it
|
|
461
|
+
# options['deleteOldResults'] = (options['keepResults'] > 0)
|
|
462
|
+
end
|
|
463
|
+
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote, :quiet])
|
|
464
|
+
end
|
|
465
|
+
optparse.parse!(args)
|
|
466
|
+
if args.count != 1
|
|
467
|
+
puts_error "#{MtnCloud::Terminal.angry_prompt}wrong number of arguments. Expected 1 and received #{args.count} #{args.inspect}\n#{optparse}"
|
|
468
|
+
return 1
|
|
469
|
+
end
|
|
470
|
+
connect(options)
|
|
471
|
+
begin
|
|
472
|
+
image_build = find_image_build_by_name_or_id(args[0])
|
|
473
|
+
return 1 if !image_build
|
|
474
|
+
payload = nil
|
|
475
|
+
if options[:payload]
|
|
476
|
+
payload = options[:payload]
|
|
477
|
+
# support options top of --payload
|
|
478
|
+
options.merge!(options[:options]) if options[:options] # so -O var= works..
|
|
479
|
+
option_params = options.reject {|k,v| k.is_a?(Symbol) }
|
|
480
|
+
payload.deep_merge!({'imageBuild' => option_params}) unless option_params.empty?
|
|
481
|
+
else
|
|
482
|
+
options.merge!(options[:options]) if options[:options] # so -O var= works..
|
|
483
|
+
image_build_payload = prompt_edit_image_build(image_build, options)
|
|
484
|
+
return 1 if !image_build_payload
|
|
485
|
+
payload = {'imageBuild' => image_build_payload}
|
|
486
|
+
end
|
|
487
|
+
@image_builds_interface.setopts(options)
|
|
488
|
+
if options[:dry_run]
|
|
489
|
+
print_dry_run @image_builds_interface.dry.update(image_build["id"], payload)
|
|
490
|
+
return
|
|
491
|
+
end
|
|
492
|
+
json_response = @image_builds_interface.update(image_build["id"], payload)
|
|
493
|
+
if options[:json]
|
|
494
|
+
print JSON.pretty_generate(json_response)
|
|
495
|
+
print "\n"
|
|
496
|
+
else
|
|
497
|
+
print_green_success "Updated image build #{image_build['name']}"
|
|
498
|
+
get([image_build['id']])
|
|
499
|
+
end
|
|
500
|
+
return 0
|
|
501
|
+
rescue RestClient::Exception => e
|
|
502
|
+
print_rest_exception(e, options)
|
|
503
|
+
return 1
|
|
504
|
+
end
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
def remove(args)
|
|
508
|
+
options = {}
|
|
509
|
+
query_params = {}
|
|
510
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
511
|
+
opts.banner = subcommand_usage("[image-build]")
|
|
512
|
+
opts.on( '-K', '--keep-virtual-images', "Preserve associated virtual images" ) do
|
|
513
|
+
query_params['keepVirtualImages'] = 'on'
|
|
514
|
+
end
|
|
515
|
+
build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
|
|
516
|
+
end
|
|
517
|
+
optparse.parse!(args)
|
|
518
|
+
|
|
519
|
+
if args.count < 1
|
|
520
|
+
print_error MtnCloud::Terminal.angry_prompt
|
|
521
|
+
puts_error "#{command_name} missing argument: [image-build]\n#{optparse}"
|
|
522
|
+
return 1
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
connect(options)
|
|
526
|
+
begin
|
|
527
|
+
image_build = find_image_build_by_name_or_id(args[0])
|
|
528
|
+
return 1 if image_build.nil?
|
|
529
|
+
|
|
530
|
+
unless options[:yes] || MtnCloud::Cli::OptionTypes.confirm("Are you sure you want to delete the image build: #{image_build['name']}?")
|
|
531
|
+
return 9, "aborted command"
|
|
532
|
+
end
|
|
533
|
+
if query_params['keepVirtualImages'].nil?
|
|
534
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'keepVirtualImages', 'type' => 'checkbox', 'fieldLabel' => 'Keep Virtual Images?', 'required' => false, 'defaultValue' => false, 'description' => 'Preserve associated virtual images. By default, they are deleted as well.'}],options,@api_client,{})
|
|
535
|
+
query_params['keepVirtualImages'] = v_prompt['keepVirtualImages']
|
|
536
|
+
end
|
|
537
|
+
@image_builds_interface.setopts(options)
|
|
538
|
+
if options[:dry_run]
|
|
539
|
+
print_dry_run @image_builds_interface.dry.destroy(image_build['id'], query_params)
|
|
540
|
+
return 0
|
|
541
|
+
end
|
|
542
|
+
json_response = @image_builds_interface.destroy(image_build['id'], query_params)
|
|
543
|
+
if options[:json]
|
|
544
|
+
print JSON.pretty_generate(json_response)
|
|
545
|
+
print "\n"
|
|
546
|
+
else
|
|
547
|
+
print_green_success "Removed image build #{image_build['name']}"
|
|
548
|
+
# list([])
|
|
549
|
+
end
|
|
550
|
+
return 0
|
|
551
|
+
rescue RestClient::Exception => e
|
|
552
|
+
print_rest_exception(e, options)
|
|
553
|
+
return 1
|
|
554
|
+
end
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
def run(args)
|
|
558
|
+
options = {}
|
|
559
|
+
query_params = {}
|
|
560
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
561
|
+
opts.banner = subcommand_usage("[image-build]")
|
|
562
|
+
build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
|
|
563
|
+
end
|
|
564
|
+
optparse.parse!(args)
|
|
565
|
+
|
|
566
|
+
if args.count < 1
|
|
567
|
+
print_error MtnCloud::Terminal.angry_prompt
|
|
568
|
+
puts_error "#{command_name} missing argument: [image-build]\n#{optparse}"
|
|
569
|
+
return 1
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
connect(options)
|
|
573
|
+
begin
|
|
574
|
+
image_build = find_image_build_by_name_or_id(args[0])
|
|
575
|
+
return 1 if image_build.nil?
|
|
576
|
+
|
|
577
|
+
unless options[:yes] || MtnCloud::Cli::OptionTypes.confirm("Are you sure you want to run the image build: #{image_build['name']}?")
|
|
578
|
+
return 9, "aborted command"
|
|
579
|
+
end
|
|
580
|
+
@image_builds_interface.setopts(options)
|
|
581
|
+
if options[:dry_run]
|
|
582
|
+
print_dry_run @image_builds_interface.dry.run(image_build['id'], query_params)
|
|
583
|
+
return 0
|
|
584
|
+
end
|
|
585
|
+
json_response = @image_builds_interface.run(image_build['id'], query_params)
|
|
586
|
+
if options[:json]
|
|
587
|
+
print JSON.pretty_generate(json_response)
|
|
588
|
+
print "\n"
|
|
589
|
+
else
|
|
590
|
+
print_green_success "New run started for image build #{image_build['name']}"
|
|
591
|
+
get([image_build['id']])
|
|
592
|
+
end
|
|
593
|
+
return 0
|
|
594
|
+
rescue RestClient::Exception => e
|
|
595
|
+
print_rest_exception(e, options)
|
|
596
|
+
return 1
|
|
597
|
+
end
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
def list_executions(args)
|
|
601
|
+
options = {}
|
|
602
|
+
optparse = MtnCloud::Cli::OptionParser.new do |opts|
|
|
603
|
+
opts.banner = subcommand_usage("[image-build]")
|
|
604
|
+
build_common_options(opts, options, [:list, :json, :dry_run, :remote])
|
|
605
|
+
opts.footer = "List executions for an image build."
|
|
606
|
+
opts.footer = "Display a list of executions for an image build.\n"
|
|
607
|
+
"[image-build] is the name or id of an image build."
|
|
608
|
+
end
|
|
609
|
+
optparse.parse!(args)
|
|
610
|
+
if args.count > 1
|
|
611
|
+
puts_error "#{MtnCloud::Terminal.angry_prompt}wrong number of arguments. Expected 1 and received #{args.count} #{args.inspect}\n#{optparse}"
|
|
612
|
+
return 1
|
|
613
|
+
end
|
|
614
|
+
connect(options)
|
|
615
|
+
|
|
616
|
+
image_build = find_image_build_by_name_or_id(args[0])
|
|
617
|
+
return 1 if image_build.nil?
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
params = {}
|
|
621
|
+
[:phrase, :offset, :max, :sort, :direction].each do |k|
|
|
622
|
+
params[k] = options[k] unless options[k].nil?
|
|
623
|
+
end
|
|
624
|
+
@image_builds_interface.setopts(options)
|
|
625
|
+
if options[:dry_run]
|
|
626
|
+
print_dry_run @image_builds_interface.dry.list_executions(image_build['id'], params)
|
|
627
|
+
return 0
|
|
628
|
+
end
|
|
629
|
+
json_response = @image_builds_interface.list_executions(image_build['id'], params)
|
|
630
|
+
if options[:json]
|
|
631
|
+
puts JSON.pretty_generate(json_response)
|
|
632
|
+
return 0
|
|
633
|
+
end
|
|
634
|
+
image_build = json_response['imageBuild']
|
|
635
|
+
image_build_executions = json_response['imageBuildExecutions']
|
|
636
|
+
print_h1 "Image Build Executions: [#{image_build['id']}] #{image_build['name']}"
|
|
637
|
+
print cyan
|
|
638
|
+
if image_build_executions && image_build_executions.size > 0
|
|
639
|
+
print_image_build_executions_table(image_build_executions, opts={})
|
|
640
|
+
print_results_pagination(json_response, {:label => "execution", :n_label => "executions"})
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
return 0
|
|
644
|
+
end
|
|
645
|
+
|
|
646
|
+
def delete_execution(args)
|
|
647
|
+
puts "todo: implement me"
|
|
648
|
+
return 0
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
private
|
|
652
|
+
|
|
653
|
+
def get_available_image_build_types()
|
|
654
|
+
[
|
|
655
|
+
{'name' => 'VMware', 'code' => 'vmware', 'instanceType' => {'code' => 'vmware'}},
|
|
656
|
+
{'name' => 'KVM', 'code' => 'kvm', 'instanceType' => {'code' => 'kvm'}}
|
|
657
|
+
]
|
|
658
|
+
end
|
|
659
|
+
|
|
660
|
+
def get_available_image_build_types_dropdown(group=nil, cloud=nil)
|
|
661
|
+
get_available_image_build_types().collect {|it|
|
|
662
|
+
{'name' => it['name'], 'value' => it['code']}
|
|
663
|
+
}
|
|
664
|
+
end
|
|
665
|
+
|
|
666
|
+
def add_image_build_option_types(connected=true)
|
|
667
|
+
[
|
|
668
|
+
{'fieldName' => 'type', 'fieldLabel' => 'Type', 'type' => 'select', 'selectOptions' => get_available_image_build_types_dropdown(), 'required' => true, 'description' => 'Choose the type of image build.'},
|
|
669
|
+
{'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'description' => 'Enter a name for this image build.'},
|
|
670
|
+
{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false},
|
|
671
|
+
{'fieldName' => 'group', 'fieldLabel' => 'Group', 'type' => 'select', 'selectOptions' => (connected ? get_available_groups() : []), 'required' => true},
|
|
672
|
+
#{'fieldName' => 'cloud', 'fieldLabel' => 'Cloud', 'type' => 'select', 'selectOptions' => [], 'required' => true},
|
|
673
|
+
# tons more, this isn't used anymore though..
|
|
674
|
+
]
|
|
675
|
+
end
|
|
676
|
+
|
|
677
|
+
def update_image_build_option_types(connected=true)
|
|
678
|
+
list = add_image_build_option_types(connected)
|
|
679
|
+
# list = list.reject {|it| ["group"].include? it['fieldName'] }
|
|
680
|
+
list.each {|it| it['required'] = false }
|
|
681
|
+
list
|
|
682
|
+
end
|
|
683
|
+
|
|
684
|
+
def find_image_build_by_name_or_id(val)
|
|
685
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
|
686
|
+
return find_image_build_by_id(val)
|
|
687
|
+
else
|
|
688
|
+
return find_image_build_by_name(val)
|
|
689
|
+
end
|
|
690
|
+
end
|
|
691
|
+
|
|
692
|
+
def find_image_build_by_id(id)
|
|
693
|
+
begin
|
|
694
|
+
json_response = @image_builds_interface.get(id.to_i)
|
|
695
|
+
return json_response['imageBuild']
|
|
696
|
+
rescue RestClient::Exception => e
|
|
697
|
+
if e.response && e.response.code == 404
|
|
698
|
+
print_red_alert "Image Build not found by id #{id}"
|
|
699
|
+
return nil
|
|
700
|
+
else
|
|
701
|
+
raise e
|
|
702
|
+
end
|
|
703
|
+
end
|
|
704
|
+
end
|
|
705
|
+
|
|
706
|
+
def find_image_build_by_name(name)
|
|
707
|
+
image_builds = @image_builds_interface.list({name: name.to_s})['imageBuilds']
|
|
708
|
+
if image_builds.empty?
|
|
709
|
+
print_red_alert "Image Build not found by name #{name}"
|
|
710
|
+
return nil
|
|
711
|
+
elsif image_builds.size > 1
|
|
712
|
+
print_red_alert "#{image_builds.size} image builds found by name #{name}"
|
|
713
|
+
# print_image_builds_table(image_builds, {color: red})
|
|
714
|
+
rows = image_builds.collect do |it|
|
|
715
|
+
{id: it['id'], name: it['name']}
|
|
716
|
+
end
|
|
717
|
+
print as_pretty_table(rows, [:id, :name], {color:red})
|
|
718
|
+
print reset,"\n"
|
|
719
|
+
return nil
|
|
720
|
+
else
|
|
721
|
+
return image_builds[0]
|
|
722
|
+
end
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
def format_image_build_status(image_build, return_color=cyan)
|
|
726
|
+
out = ""
|
|
727
|
+
return out if !image_build
|
|
728
|
+
if image_build && image_build['lastResult']
|
|
729
|
+
out << format_image_build_execution_status(image_build['lastResult'])
|
|
730
|
+
else
|
|
731
|
+
out << ""
|
|
732
|
+
end
|
|
733
|
+
out
|
|
734
|
+
end
|
|
735
|
+
|
|
736
|
+
def format_image_build_execution_status(image_build_execution, return_color=cyan)
|
|
737
|
+
return "" if !image_build_execution
|
|
738
|
+
out = ""
|
|
739
|
+
status_string = image_build_execution['status']
|
|
740
|
+
if status_string == 'running'
|
|
741
|
+
out << "#{cyan}#{bold}#{status_string.upcase}#{reset}#{return_color}"
|
|
742
|
+
elsif status_string == 'success'
|
|
743
|
+
out << "#{green}#{status_string.upcase}#{return_color}"
|
|
744
|
+
elsif status_string == 'failed'
|
|
745
|
+
out << "#{red}#{status_string.upcase}#{return_color}"
|
|
746
|
+
elsif status_string == 'pending'
|
|
747
|
+
out << "#{cyan}#{status_string.upcase}#{return_color}"
|
|
748
|
+
elsif !status_string.to_s.empty?
|
|
749
|
+
out << "#{yellow}#{status_string.upcase}#{return_color}"
|
|
750
|
+
else
|
|
751
|
+
#out << "#{cyan}No Executions#{return_color}"
|
|
752
|
+
end
|
|
753
|
+
out
|
|
754
|
+
end
|
|
755
|
+
|
|
756
|
+
def format_image_build_execution_result(image_build_execution, return_color=cyan)
|
|
757
|
+
return "" if !image_build_execution
|
|
758
|
+
out = ""
|
|
759
|
+
status_string = image_build_execution['status']
|
|
760
|
+
if status_string == 'running' # || status_string == 'pending'
|
|
761
|
+
out << generate_usage_bar(image_build_execution['statusPercent'], 100, {max_bars: 10, bar_color: cyan})
|
|
762
|
+
out << return_color if return_color
|
|
763
|
+
end
|
|
764
|
+
if image_build_execution['tempInstance'].to_s != ''
|
|
765
|
+
out << " Instance:"
|
|
766
|
+
out << " [#{image_build_execution['tempInstance']['id']}] #{image_build_execution['tempInstance']['name']}"
|
|
767
|
+
out << " -"
|
|
768
|
+
end
|
|
769
|
+
if image_build_execution['statusMessage'].to_s != ''
|
|
770
|
+
out << " #{image_build_execution['statusMessage']}"
|
|
771
|
+
end
|
|
772
|
+
if image_build_execution['errorMessage'].to_s != ''
|
|
773
|
+
out << " #{red}#{image_build_execution['errorMessage']}#{return_color}"
|
|
774
|
+
end
|
|
775
|
+
if image_build_execution['virtualImages']
|
|
776
|
+
img_count = image_build_execution['virtualImages'].size
|
|
777
|
+
if img_count == 1
|
|
778
|
+
out << " Virtual Image:"
|
|
779
|
+
elsif img_count > 1
|
|
780
|
+
out << "(#{img_count}) Virtual Images:"
|
|
781
|
+
end
|
|
782
|
+
image_build_execution['virtualImages'].each do |virtual_image|
|
|
783
|
+
out << " [#{virtual_image['id']}] #{virtual_image['name']}#{return_color}"
|
|
784
|
+
end
|
|
785
|
+
end
|
|
786
|
+
out.strip #.squeeze(' ')
|
|
787
|
+
end
|
|
788
|
+
|
|
789
|
+
def print_image_build_executions_table(executions, opts={})
|
|
790
|
+
table_color = opts[:color] || cyan
|
|
791
|
+
rows = executions.collect do |execution|
|
|
792
|
+
{
|
|
793
|
+
id: execution['id'],
|
|
794
|
+
build: execution['buildNumber'],
|
|
795
|
+
createdBy: execution['createdBy'] ? execution['createdBy']['username'] : nil,
|
|
796
|
+
start: execution['startDate'] ? format_local_dt(execution['startDate']) : '',
|
|
797
|
+
end: execution['endDate'] ? format_local_dt(execution['endDate']) : '',
|
|
798
|
+
duration: format_duration(execution['startDate'], execution['endDate']),
|
|
799
|
+
status: format_image_build_execution_status(execution, table_color),
|
|
800
|
+
result: format_image_build_execution_result(execution, table_color)
|
|
801
|
+
}
|
|
802
|
+
end
|
|
803
|
+
|
|
804
|
+
term_width = current_terminal_width()
|
|
805
|
+
result_col_width = 60
|
|
806
|
+
if term_width > 250
|
|
807
|
+
result_col_width += 100
|
|
808
|
+
end
|
|
809
|
+
columns = [
|
|
810
|
+
#:id,
|
|
811
|
+
:build,
|
|
812
|
+
{:createdBy => {:display_name => "CREATED BY"} },
|
|
813
|
+
:start,
|
|
814
|
+
:end,
|
|
815
|
+
:duration,
|
|
816
|
+
{:status => {:display_name => "STATUS"} },
|
|
817
|
+
{:result => {:display_name => "RESULT", :max_width => result_col_width} }
|
|
818
|
+
]
|
|
819
|
+
# # custom pretty table columns ...
|
|
820
|
+
# if options[:include_fields]
|
|
821
|
+
# columns = options[:include_fields]
|
|
822
|
+
# end
|
|
823
|
+
print table_color
|
|
824
|
+
print as_pretty_table(rows, columns, opts)
|
|
825
|
+
print reset
|
|
826
|
+
end
|
|
827
|
+
|
|
828
|
+
# def get_available_boot_scripts()
|
|
829
|
+
# boot_scripts_dropdown = []
|
|
830
|
+
# scripts = @boot_scripts_interface.list({max:1000})['bootScripts']
|
|
831
|
+
# scripts.each do |it|
|
|
832
|
+
# boot_scripts_dropdown << {'name'=>it['fileName'],'value'=>it['id']}
|
|
833
|
+
# end
|
|
834
|
+
# boot_scripts_dropdown << {'name'=>'Custom','value'=> 'custom'}
|
|
835
|
+
# return boot_scripts_dropdown
|
|
836
|
+
# end
|
|
837
|
+
|
|
838
|
+
def get_available_boot_scripts(refresh=false)
|
|
839
|
+
if !@available_boot_scripts || refresh
|
|
840
|
+
# option_results = options_interface.options_for_source('bootScripts',{})['data']
|
|
841
|
+
boot_scripts_dropdown = []
|
|
842
|
+
scripts = @boot_scripts_interface.list({max:1000})['bootScripts']
|
|
843
|
+
scripts.each do |it|
|
|
844
|
+
boot_scripts_dropdown << {'name'=>it['fileName'],'value'=>it['id'],'id'=>it['id']}
|
|
845
|
+
end
|
|
846
|
+
boot_scripts_dropdown << {'name'=>'Custom','value'=> 'custom','id'=> 'custom'}
|
|
847
|
+
@available_boot_scripts = boot_scripts_dropdown
|
|
848
|
+
end
|
|
849
|
+
#puts "available_boot_scripts() rtn: #{@available_boot_scripts.inspect}"
|
|
850
|
+
return @available_boot_scripts
|
|
851
|
+
end
|
|
852
|
+
|
|
853
|
+
def find_boot_script(val)
|
|
854
|
+
if val.nil? || val.to_s.empty?
|
|
855
|
+
return nil
|
|
856
|
+
else
|
|
857
|
+
return get_available_boot_scripts().find { |it|
|
|
858
|
+
(it['id'].to_s.downcase == val.to_s.downcase) ||
|
|
859
|
+
(it['name'].to_s.downcase == val.to_s.downcase)
|
|
860
|
+
}
|
|
861
|
+
end
|
|
862
|
+
end
|
|
863
|
+
|
|
864
|
+
def get_available_preseed_scripts(refresh=false)
|
|
865
|
+
if !@available_preseed_scripts || refresh
|
|
866
|
+
# option_results = options_interface.options_for_source('preseedScripts',{})['data']
|
|
867
|
+
preseed_scripts_dropdown = []
|
|
868
|
+
scripts = @preseed_scripts_interface.list({max:1000})['preseedScripts']
|
|
869
|
+
scripts.each do |it|
|
|
870
|
+
preseed_scripts_dropdown << {'name'=>it['fileName'],'value'=>it['id'],'id'=>it['id']}
|
|
871
|
+
end
|
|
872
|
+
# preseed_scripts_dropdown << {'name'=>'Custom','value'=> 'custom','value'=> 'custom'}
|
|
873
|
+
@available_preseed_scripts = preseed_scripts_dropdown
|
|
874
|
+
end
|
|
875
|
+
#puts "available_preseed_scripts() rtn: #{@available_preseed_scripts.inspect}"
|
|
876
|
+
return @available_preseed_scripts
|
|
877
|
+
end
|
|
878
|
+
|
|
879
|
+
def find_preseed_script(val)
|
|
880
|
+
if val.nil? || val.to_s.empty?
|
|
881
|
+
return nil
|
|
882
|
+
else
|
|
883
|
+
return get_available_preseed_scripts().find { |it|
|
|
884
|
+
(it['id'].to_s.downcase == val.to_s.downcase) ||
|
|
885
|
+
(it['name'].to_s.downcase == val.to_s.downcase)
|
|
886
|
+
}
|
|
887
|
+
end
|
|
888
|
+
end
|
|
889
|
+
|
|
890
|
+
def prompt_new_image_build(options={}, default_values={}, do_require=true)
|
|
891
|
+
payload = {}
|
|
892
|
+
|
|
893
|
+
# load to create-options data for help with prompting
|
|
894
|
+
create_options = nil
|
|
895
|
+
begin
|
|
896
|
+
create_options = @image_builds_interface.create_options({})
|
|
897
|
+
rescue => ex
|
|
898
|
+
MtnCloud::Logging::DarkPrinter.puts "Unable to load image build create options data" if MtnCloud::Logging.debug?
|
|
899
|
+
end
|
|
900
|
+
# Summary / Settings Tab
|
|
901
|
+
|
|
902
|
+
# Image Build Type
|
|
903
|
+
image_build_types = nil
|
|
904
|
+
if create_options && create_options['imageBuildTypes']
|
|
905
|
+
image_build_types = create_options['imageBuildTypes'].collect {|it| it.merge({'value' => it['code']}) }
|
|
906
|
+
else
|
|
907
|
+
image_build_types = get_available_image_build_types_dropdown
|
|
908
|
+
end
|
|
909
|
+
image_build_type = nil
|
|
910
|
+
if options['type']
|
|
911
|
+
image_build_type = image_build_types.find { |it| (it['code'].to_s.downcase == options['type'].to_s.downcase) || (it['name'].to_s.downcase == options['type'].to_s.downcase) }
|
|
912
|
+
else
|
|
913
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'type', 'fieldLabel' => 'Type', 'type' => 'select', 'selectOptions' => image_build_types, 'required' => do_require, 'description' => 'Choose the type of image build.', 'defaultValue' => default_values['type'], :fmt=>:natural}], options, @api_client)
|
|
914
|
+
image_build_type = MtnCloud::Cli::OptionTypes.get_last_select()
|
|
915
|
+
end
|
|
916
|
+
if !image_build_type
|
|
917
|
+
print_red_alert "Image Build Type not found!"
|
|
918
|
+
return false
|
|
919
|
+
end
|
|
920
|
+
payload['type'] = image_build_type['code'] # = {'id'=> image_build_type['id']}
|
|
921
|
+
|
|
922
|
+
# Name
|
|
923
|
+
if options['name']
|
|
924
|
+
payload['name'] = options['name']
|
|
925
|
+
else
|
|
926
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => do_require, 'description' => 'Enter a name for this image build.', 'defaultValue' => default_values['name'], :fmt=>:natural}], options, @api_client)
|
|
927
|
+
payload['name'] = v_prompt['name']
|
|
928
|
+
end
|
|
929
|
+
|
|
930
|
+
# Description
|
|
931
|
+
if options['description']
|
|
932
|
+
payload['description'] = options['description']
|
|
933
|
+
else
|
|
934
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'defaultValue' => default_values['description'], :fmt=>:natural}], options, @api_client)
|
|
935
|
+
payload['description'] = v_prompt['description']
|
|
936
|
+
end
|
|
937
|
+
|
|
938
|
+
# Group
|
|
939
|
+
group = nil
|
|
940
|
+
if options['group']
|
|
941
|
+
group = find_group_by_name_or_id_for_provisioning(options['group'])
|
|
942
|
+
else
|
|
943
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'group', 'type' => 'select', 'fieldLabel' => 'Group', 'selectOptions' => get_available_groups(), 'required' => do_require, 'description' => 'Select Group.', 'defaultValue' => default_values['group'], :fmt=>:natural}],options,@api_client,{})
|
|
944
|
+
group = find_group_by_name_or_id_for_provisioning(v_prompt['group'])
|
|
945
|
+
end
|
|
946
|
+
if !group
|
|
947
|
+
#print_red_alert "Group not found!"
|
|
948
|
+
return false
|
|
949
|
+
end
|
|
950
|
+
# pick one
|
|
951
|
+
#payload['group'] = {'id' => group['id']}
|
|
952
|
+
payload['site'] = {'id' => group['id']}
|
|
953
|
+
|
|
954
|
+
# Cloud
|
|
955
|
+
cloud = nil
|
|
956
|
+
if options['cloud']
|
|
957
|
+
cloud = find_cloud_by_name_or_id_for_provisioning(group['id'], options['cloud'])
|
|
958
|
+
else
|
|
959
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'cloud', 'type' => 'select', 'fieldLabel' => 'Cloud', 'selectOptions' => get_available_clouds(group['id']), 'required' => do_require, 'description' => 'Select Cloud.', 'defaultValue' => default_values['cloud'], :fmt=>:natural}],options,@api_client,{groupId: group['id']})
|
|
960
|
+
cloud = find_cloud_by_name_or_id_for_provisioning(group['id'], v_prompt['cloud'])
|
|
961
|
+
end
|
|
962
|
+
if !cloud
|
|
963
|
+
# print_red_alert "Cloud not found!"
|
|
964
|
+
return false
|
|
965
|
+
end
|
|
966
|
+
# pick one
|
|
967
|
+
#payload['cloud'] = {'id' => cloud['id']}
|
|
968
|
+
payload['zone'] = {'id' => cloud['id']}
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
# Configure Tab
|
|
972
|
+
# either pass --config, --configFile or be prompted..
|
|
973
|
+
if options['config']
|
|
974
|
+
payload['config'] = options['config']
|
|
975
|
+
elsif options['configFile']
|
|
976
|
+
config_file = File.expand_path(options['configFile'])
|
|
977
|
+
if !File.exist?(config_file) || !File.file?(config_file)
|
|
978
|
+
print_red_alert "File not found: #{config_file}"
|
|
979
|
+
return false
|
|
980
|
+
end
|
|
981
|
+
if config_file =~ /\.ya?ml\Z/
|
|
982
|
+
payload['config'] = YAML.load_file(config_file)
|
|
983
|
+
else
|
|
984
|
+
payload['config'] = JSON.parse(File.read(config_file))
|
|
985
|
+
end
|
|
986
|
+
elsif default_values['config']
|
|
987
|
+
# for now, skip this config prompting if updating existing record
|
|
988
|
+
# this is problematic, if they are changing the group or cloud though...
|
|
989
|
+
# payload['config'] = default_values['config']
|
|
990
|
+
else
|
|
991
|
+
# Instance Type is derived from the image build type
|
|
992
|
+
instance_type_code = image_build_type['instanceType']['code']
|
|
993
|
+
instance_type = find_instance_type_by_code(instance_type_code)
|
|
994
|
+
return false if !instance_type
|
|
995
|
+
|
|
996
|
+
instance_config_options = options.dup
|
|
997
|
+
#instance_config_options[:no_prompt] = options[:no_prompt]
|
|
998
|
+
# use active group by default
|
|
999
|
+
instance_config_options[:group] = group['id']
|
|
1000
|
+
instance_config_options[:cloud] = cloud['id']
|
|
1001
|
+
instance_config_options[:instance_type_code] = instance_type["code"] # instance_type_code
|
|
1002
|
+
instance_config_options[:name_required] = false
|
|
1003
|
+
# this provisioning helper method handles all (most) of the parsing and prompting
|
|
1004
|
+
# puts "instance_config_options is: #{instance_config_options.inspect}"
|
|
1005
|
+
instance_config_payload = prompt_new_instance(instance_config_options)
|
|
1006
|
+
# strip all empty string and nil, would be problematic for update()
|
|
1007
|
+
instance_config_payload.deep_compact!
|
|
1008
|
+
|
|
1009
|
+
payload['config'] = instance_config_payload
|
|
1010
|
+
end
|
|
1011
|
+
|
|
1012
|
+
# merge group and cloud parameters into config..
|
|
1013
|
+
payload['config'] ||= {}
|
|
1014
|
+
payload['config']['zoneId'] = cloud['id']
|
|
1015
|
+
# payload['config']['siteId'] = group['id']
|
|
1016
|
+
payload['config']['instance'] ||= {}
|
|
1017
|
+
payload['config']['instance']['site'] = {'id' => group['id']}
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
# Scripts tab
|
|
1021
|
+
boot_script = nil
|
|
1022
|
+
boot_script_id = nil
|
|
1023
|
+
boot_command = nil
|
|
1024
|
+
if options['bootScript']
|
|
1025
|
+
boot_script = find_boot_script(options['bootScript'])
|
|
1026
|
+
if !boot_script
|
|
1027
|
+
print_red_alert "Boot Script not found: #{options['bootScript']}"
|
|
1028
|
+
return false
|
|
1029
|
+
end
|
|
1030
|
+
boot_script_id = boot_script['id']
|
|
1031
|
+
else
|
|
1032
|
+
boot_script_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'bootScript', 'type' => 'select', 'fieldLabel' => 'Boot Script', 'selectOptions' => get_available_boot_scripts(), 'required' => do_require, 'description' => 'Select Boot Script.', 'defaultValue' => default_values['bootScript'], :fmt=>:natural}],options,api_client,{})
|
|
1033
|
+
# boot_script_id = boot_script_prompt['bootScript']
|
|
1034
|
+
boot_script = find_boot_script(boot_script_prompt['bootScript'])
|
|
1035
|
+
if !boot_script
|
|
1036
|
+
print_red_alert "Boot Script not found: '#{boot_script_prompt['bootScript']}'"
|
|
1037
|
+
return false
|
|
1038
|
+
end
|
|
1039
|
+
boot_script_id = boot_script['id']
|
|
1040
|
+
end
|
|
1041
|
+
|
|
1042
|
+
if boot_script_id == "custom" || options['bootCommand']
|
|
1043
|
+
if options['bootCommand']
|
|
1044
|
+
boot_command = options['bootCommand']
|
|
1045
|
+
else
|
|
1046
|
+
boot_command_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'bootCommand', 'type' => 'code-editor', 'fieldLabel' => 'Boot Command', 'required' => do_require, 'description' => 'Enter a boot command.', :fmt=>:natural}],options,api_client,{})
|
|
1047
|
+
boot_command = boot_command_prompt['bootCommand']
|
|
1048
|
+
end
|
|
1049
|
+
boot_script_id = nil
|
|
1050
|
+
else
|
|
1051
|
+
# boot_command = nil
|
|
1052
|
+
end
|
|
1053
|
+
|
|
1054
|
+
if boot_script_id
|
|
1055
|
+
# payload['bootScript'] = boot_script_id
|
|
1056
|
+
if boot_script_id == ""
|
|
1057
|
+
payload['bootScript'] = nil
|
|
1058
|
+
else
|
|
1059
|
+
payload['bootScript'] = {id: boot_script_id}
|
|
1060
|
+
end
|
|
1061
|
+
elsif boot_command
|
|
1062
|
+
payload['bootCommand'] = boot_command
|
|
1063
|
+
end
|
|
1064
|
+
|
|
1065
|
+
# Preseed Script
|
|
1066
|
+
preseed_script = nil
|
|
1067
|
+
preseed_script_id = nil
|
|
1068
|
+
if options['preseedScript']
|
|
1069
|
+
preseed_script = find_preseed_script(options['preseedScript'])
|
|
1070
|
+
if preseed_script
|
|
1071
|
+
preseed_script_id = preseed_script['id']
|
|
1072
|
+
end
|
|
1073
|
+
else
|
|
1074
|
+
preseed_script_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'preseedScript', 'type' => 'select', 'fieldLabel' => 'Preseed Script', 'selectOptions' => get_available_preseed_scripts(), 'required' => false, 'description' => 'Select Preseed Script.', 'defaultValue' => default_values['preseedScript'], :fmt=>:natural}],options,api_client,{})
|
|
1075
|
+
# preseed_script_id = preseed_script_prompt['preseedScript']
|
|
1076
|
+
preseed_script = find_preseed_script(preseed_script_prompt['preseedScript'])
|
|
1077
|
+
if preseed_script
|
|
1078
|
+
preseed_script_id = preseed_script['id']
|
|
1079
|
+
end
|
|
1080
|
+
end
|
|
1081
|
+
if preseed_script_id
|
|
1082
|
+
# payload['preseedScript'] = preseed_script_id
|
|
1083
|
+
if preseed_script_id == ""
|
|
1084
|
+
payload['preseedScript'] = nil
|
|
1085
|
+
else
|
|
1086
|
+
payload['preseedScript'] = {id: preseed_script_id}
|
|
1087
|
+
end
|
|
1088
|
+
end
|
|
1089
|
+
|
|
1090
|
+
# Additional Scripts
|
|
1091
|
+
if options['scripts']
|
|
1092
|
+
payload['scripts'] = options['scripts'] #.to_s.split(",").collect {|it| it.to_s.strip }.select {|it| it }.compact
|
|
1093
|
+
else
|
|
1094
|
+
scripts_default_value = default_values['scripts']
|
|
1095
|
+
if scripts_default_value.kind_of?(Array)
|
|
1096
|
+
scripts_default_value = scripts_default_value.collect {|it| it["name"] }.join(", ")
|
|
1097
|
+
end
|
|
1098
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'scripts', 'fieldLabel' => 'Additional Scripts', 'type' => 'text', 'description' => 'Additional Scripts (comma separated names or ids)', 'defaultValue' => scripts_default_value, :fmt=>:natural}], options, @api_client)
|
|
1099
|
+
payload['scripts'] = v_prompt['scripts'].to_s.split(",").collect {|it| it.to_s.strip }.select {|it| it }.compact
|
|
1100
|
+
end
|
|
1101
|
+
|
|
1102
|
+
# SSH Username
|
|
1103
|
+
if options['sshUsername']
|
|
1104
|
+
payload['sshUsername'] = options['sshUsername']
|
|
1105
|
+
else
|
|
1106
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'sshUsername', 'fieldLabel' => 'SSH Username', 'required' => do_require, 'type' => 'text', 'description' => 'SSH Username', 'defaultValue' => default_values['sshUsername'], :fmt=>:natural}], options, @api_client)
|
|
1107
|
+
payload['sshUsername'] = v_prompt['sshUsername']
|
|
1108
|
+
end
|
|
1109
|
+
|
|
1110
|
+
# SSH Password
|
|
1111
|
+
if options['sshPassword']
|
|
1112
|
+
payload['sshPassword'] = options['sshPassword']
|
|
1113
|
+
else
|
|
1114
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'sshPassword', 'fieldLabel' => 'SSH Password', 'required' => do_require, 'type' => 'password', 'description' => 'SSH Password', 'defaultValue' => default_values['sshPassword'], :fmt=>:natural}], options, @api_client)
|
|
1115
|
+
payload['sshPassword'] = v_prompt['sshPassword']
|
|
1116
|
+
end
|
|
1117
|
+
|
|
1118
|
+
# Storage Provider
|
|
1119
|
+
if options['storageProvider']
|
|
1120
|
+
payload['storageProvider'] = options['storageProvider']
|
|
1121
|
+
else
|
|
1122
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'storageProvider', 'fieldLabel' => 'Storage Provider', 'type' => 'select', 'optionSource' => 'storageProviders', 'description' => 'Storage Provider', 'defaultValue' => default_values['storageProvider'], :fmt=>:natural}], options, @api_client, {})
|
|
1123
|
+
payload['storageProvider'] = v_prompt['storageProvider']
|
|
1124
|
+
end
|
|
1125
|
+
|
|
1126
|
+
# Cloud Init
|
|
1127
|
+
if options['isCloudInit']
|
|
1128
|
+
payload['isCloudInit'] = options['isCloudInit']
|
|
1129
|
+
else
|
|
1130
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'isCloudInit', 'fieldLabel' => 'Cloud Init?', 'type' => 'checkbox', 'description' => 'Cloud Init', 'defaultValue' => (default_values['isCloudInit'].nil? ? false : default_values['isCloudInit']), :fmt=>:natural}], options, @api_client, {})
|
|
1131
|
+
payload['isCloudInit'] = v_prompt['isCloudInit']
|
|
1132
|
+
end
|
|
1133
|
+
|
|
1134
|
+
# Build Output Name
|
|
1135
|
+
if options['buildOutputName']
|
|
1136
|
+
payload['buildOutputName'] = options['buildOutputName']
|
|
1137
|
+
else
|
|
1138
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'buildOutputName', 'fieldLabel' => 'Build Output Name', 'type' => 'text', 'description' => 'Build Output Name', 'defaultValue' => default_values['buildOutputName'], :fmt=>:natural}], options, @api_client)
|
|
1139
|
+
payload['buildOutputName'] = v_prompt['buildOutputName']
|
|
1140
|
+
end
|
|
1141
|
+
|
|
1142
|
+
# Conversion Formats
|
|
1143
|
+
if options['conversionFormats']
|
|
1144
|
+
payload['conversionFormats'] = options['conversionFormats']
|
|
1145
|
+
else
|
|
1146
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'conversionFormats', 'fieldLabel' => 'Conversion Formats', 'type' => 'text', 'description' => 'Conversion Formats ie. ovf, qcow2, vhd', 'defaultValue' => default_values['conversionFormats'], :fmt=>:natural}], options, @api_client)
|
|
1147
|
+
payload['conversionFormats'] = v_prompt['conversionFormats']
|
|
1148
|
+
end
|
|
1149
|
+
|
|
1150
|
+
## Retention
|
|
1151
|
+
|
|
1152
|
+
# Delete Old Builds?
|
|
1153
|
+
# Keep Results
|
|
1154
|
+
if options['keepResults']
|
|
1155
|
+
payload['keepResults'] = options['keepResults'].to_i
|
|
1156
|
+
else
|
|
1157
|
+
default_keep_results = default_values['keepResults'] ? default_values['keepResults'] : nil # 0
|
|
1158
|
+
v_prompt = MtnCloud::Cli::OptionTypes.prompt([{'fieldName' => 'keepResults', 'fieldLabel' => 'Keep Results', 'type' => 'text', 'description' => 'Keep only the most recent builds. Older executions will be deleted along with their associated Virtual Images. The value 0 disables this functionality.', 'defaultValue' => default_keep_results, :fmt=>:natural}], options, @api_client)
|
|
1159
|
+
payload['keepResults'] = v_prompt['keepResults'].to_i
|
|
1160
|
+
end
|
|
1161
|
+
|
|
1162
|
+
return payload
|
|
1163
|
+
end
|
|
1164
|
+
|
|
1165
|
+
def prompt_edit_image_build(image_build, options={}, do_require=false)
|
|
1166
|
+
# populate default prompt values with the existing image build
|
|
1167
|
+
default_values = image_build.dup # lazy, but works as long as GET matches POST api structure
|
|
1168
|
+
if image_build['type'].kind_of?(Hash)
|
|
1169
|
+
default_values['type'] = image_build['type']['code']
|
|
1170
|
+
end
|
|
1171
|
+
if image_build['group'].kind_of?(Hash)
|
|
1172
|
+
default_values['group'] = image_build['group']['name'] # ['id']
|
|
1173
|
+
elsif image_build['site'].kind_of?(Hash)
|
|
1174
|
+
default_values['group'] = image_build['site']['name'] # ['id']
|
|
1175
|
+
end
|
|
1176
|
+
if image_build['cloud'].kind_of?(Hash)
|
|
1177
|
+
default_values['cloud'] = image_build['cloud']['name']# ['id']
|
|
1178
|
+
elsif image_build['zone'].kind_of?(Hash)
|
|
1179
|
+
default_values['cloud'] = image_build['zone']['name'] # ['id']
|
|
1180
|
+
end
|
|
1181
|
+
if image_build['bootCommand'] && !image_build['bootScript']
|
|
1182
|
+
default_values['bootScript'] = 'custom'
|
|
1183
|
+
end
|
|
1184
|
+
if image_build['bootScript'].kind_of?(Hash)
|
|
1185
|
+
default_values['bootScript'] = image_build['bootScript']['fileName'] # ['id']
|
|
1186
|
+
end
|
|
1187
|
+
if image_build['preseedScript'].kind_of?(Hash)
|
|
1188
|
+
default_values['preseedScript'] = image_build['preseedScript']['fileName'] # ['id']
|
|
1189
|
+
end
|
|
1190
|
+
if image_build['storageProvider']
|
|
1191
|
+
default_values['storageProvider'] = image_build['storageProvider']['name'] # ['id']
|
|
1192
|
+
end
|
|
1193
|
+
# any other mismatches? preseedScript, bootScript?
|
|
1194
|
+
return prompt_new_image_build(options, default_values, do_require)
|
|
1195
|
+
end
|
|
1196
|
+
|
|
1197
|
+
end
|