morpheus-cli 5.3.2.3 → 5.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/account_users_interface.rb +68 -0
- data/lib/morpheus/api/api_client.rb +75 -8
- data/lib/morpheus/api/audit_interface.rb +9 -0
- data/lib/morpheus/api/clouds_interface.rb +4 -11
- data/lib/morpheus/api/health_interface.rb +37 -3
- data/lib/morpheus/api/instances_interface.rb +39 -5
- data/lib/morpheus/api/load_balancer_monitors_interface.rb +9 -0
- data/lib/morpheus/api/load_balancer_profiles_interface.rb +9 -0
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +9 -0
- data/lib/morpheus/api/load_balancers_interface.rb +5 -0
- data/lib/morpheus/api/network_dhcp_relays_interface.rb +36 -0
- data/lib/morpheus/api/network_dhcp_servers_interface.rb +36 -0
- data/lib/morpheus/api/network_edge_clusters_interface.rb +26 -0
- data/lib/morpheus/api/network_routers_interface.rb +30 -0
- data/lib/morpheus/api/network_servers_interface.rb +98 -0
- data/lib/morpheus/api/network_static_routes_interface.rb +36 -0
- data/lib/morpheus/api/read_interface.rb +4 -3
- data/lib/morpheus/api/rest_interface.rb +5 -4
- data/lib/morpheus/api/roles_interface.rb +7 -0
- data/lib/morpheus/api/secondary_read_interface.rb +1 -1
- data/lib/morpheus/api/secondary_rest_interface.rb +19 -19
- data/lib/morpheus/api/storage_server_types_interface.rb +14 -0
- data/lib/morpheus/api/storage_servers_interface.rb +9 -0
- data/lib/morpheus/api/storage_volume_types_interface.rb +9 -0
- data/lib/morpheus/api/storage_volumes_interface.rb +9 -0
- data/lib/morpheus/api/users_interface.rb +16 -63
- data/lib/morpheus/api/virtual_images_interface.rb +23 -2
- data/lib/morpheus/api/virtual_servers_interface.rb +9 -0
- data/lib/morpheus/cli/cli_command.rb +274 -19
- data/lib/morpheus/cli/cli_registry.rb +56 -2
- data/lib/morpheus/cli/{access_token_command.rb → commands/access_token_command.rb} +1 -1
- data/lib/morpheus/cli/{account_groups_command.rb → commands/account_groups_command.rb} +0 -8
- data/lib/morpheus/cli/{activity_command.rb → commands/activity_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/alias_command.rb → alias_command.rb} +1 -4
- data/lib/morpheus/cli/{appliance_settings_command.rb → commands/appliance_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{approvals_command.rb → commands/approvals_command.rb} +0 -0
- data/lib/morpheus/cli/{apps.rb → commands/apps.rb} +17 -89
- data/lib/morpheus/cli/{archives_command.rb → commands/archives_command.rb} +0 -6
- data/lib/morpheus/cli/commands/audit.rb +188 -0
- data/lib/morpheus/cli/{backup_jobs_command.rb → commands/backup_jobs_command.rb} +0 -0
- data/lib/morpheus/cli/{backup_settings_command.rb → commands/backup_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{backups_command.rb → commands/backups_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/benchmark_command.rb → benchmark_command.rb} +0 -3
- data/lib/morpheus/cli/{blueprints_command.rb → commands/blueprints_command.rb} +1 -1
- data/lib/morpheus/cli/{boot_scripts_command.rb → commands/boot_scripts_command.rb} +0 -3
- data/lib/morpheus/cli/{budgets_command.rb → commands/budgets_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/cat_command.rb → cat_command.rb} +0 -0
- data/lib/morpheus/cli/{catalog_item_types_command.rb → commands/catalog_item_types_command.rb} +0 -0
- data/lib/morpheus/cli/{certificates_command.rb → commands/certificates_command.rb} +0 -0
- data/lib/morpheus/cli/commands/change_password_command.rb +132 -0
- data/lib/morpheus/cli/{cloud_datastores_command.rb → commands/cloud_datastores_command.rb} +0 -4
- data/lib/morpheus/cli/{cloud_folders_command.rb → commands/cloud_folders_command.rb} +0 -4
- data/lib/morpheus/cli/{cloud_resource_pools_command.rb → commands/cloud_resource_pools_command.rb} +170 -138
- data/lib/morpheus/cli/{clouds.rb → commands/clouds.rb} +22 -47
- data/lib/morpheus/cli/{clusters.rb → commands/clusters.rb} +86 -49
- data/lib/morpheus/cli/commands/{standard/coloring_command.rb → coloring_command.rb} +0 -2
- data/lib/morpheus/cli/{containers_command.rb → commands/containers_command.rb} +0 -7
- data/lib/morpheus/cli/commands/{standard/curl_command.rb → curl_command.rb} +0 -3
- data/lib/morpheus/cli/{cypher_command.rb → commands/cypher_command.rb} +0 -1
- data/lib/morpheus/cli/{dashboard_command.rb → commands/dashboard_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/debug_command.rb → debug_command.rb} +0 -1
- data/lib/morpheus/cli/{deploy.rb → commands/deploy.rb} +0 -1
- data/lib/morpheus/cli/{deployments.rb → commands/deployments.rb} +0 -0
- data/lib/morpheus/cli/{deploys.rb → commands/deploys.rb} +0 -1
- data/lib/morpheus/cli/{doc.rb → commands/doc.rb} +1 -1
- data/lib/morpheus/cli/commands/{standard/echo_command.rb → echo_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/edit_profile_command.rb → edit_profile_command.rb} +15 -4
- data/lib/morpheus/cli/commands/{standard/edit_rc_command.rb → edit_rc_command.rb} +19 -3
- data/lib/morpheus/cli/{environments_command.rb → commands/environments_command.rb} +0 -5
- data/lib/morpheus/cli/{execute_schedules_command.rb → commands/execute_schedules_command.rb} +0 -0
- data/lib/morpheus/cli/{execution_request_command.rb → commands/execution_request_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/exit_command.rb → exit_command.rb} +0 -2
- data/lib/morpheus/cli/{file_copy_request_command.rb → commands/file_copy_request_command.rb} +0 -4
- data/lib/morpheus/cli/{forgot_password.rb → commands/forgot_password.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/get_prompt_command.rb → get_prompt_command.rb} +0 -3
- data/lib/morpheus/cli/{groups.rb → commands/groups.rb} +0 -7
- data/lib/morpheus/cli/{guidance_command.rb → commands/guidance_command.rb} +1 -1
- data/lib/morpheus/cli/{health_command.rb → commands/health_command.rb} +104 -19
- data/lib/morpheus/cli/commands/{standard/history_command.rb → history_command.rb} +0 -3
- data/lib/morpheus/cli/{hosts.rb → commands/hosts.rb} +15 -25
- data/lib/morpheus/cli/{image_builder_command.rb → commands/image_builder_command.rb} +2 -8
- data/lib/morpheus/cli/{instance_types.rb → commands/instance_types.rb} +0 -3
- data/lib/morpheus/cli/{instances.rb → commands/instances.rb} +473 -150
- data/lib/morpheus/cli/{integrations_command.rb → commands/integrations_command.rb} +0 -0
- data/lib/morpheus/cli/{invoices_command.rb → commands/invoices_command.rb} +118 -134
- data/lib/morpheus/cli/{jobs_command.rb → commands/jobs_command.rb} +0 -0
- data/lib/morpheus/cli/{key_pairs.rb → commands/key_pairs.rb} +0 -6
- data/lib/morpheus/cli/{library_cluster_layouts_command.rb → commands/library_cluster_layouts_command.rb} +20 -4
- data/lib/morpheus/cli/{library_container_scripts_command.rb → commands/library_container_scripts_command.rb} +0 -0
- data/lib/morpheus/cli/{library_container_templates_command.rb → commands/library_container_templates_command.rb} +0 -1
- data/lib/morpheus/cli/{library_container_types_command.rb → commands/library_container_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_instance_types_command.rb → commands/library_instance_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_layouts_command.rb → commands/library_layouts_command.rb} +0 -4
- data/lib/morpheus/cli/{library_option_lists_command.rb → commands/library_option_lists_command.rb} +3 -7
- data/lib/morpheus/cli/{library_option_types_command.rb → commands/library_option_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_spec_templates_command.rb → commands/library_spec_templates_command.rb} +0 -1
- data/lib/morpheus/cli/{library_upgrades_command.rb → commands/library_upgrades_command.rb} +0 -4
- data/lib/morpheus/cli/{license.rb → commands/license.rb} +0 -3
- data/lib/morpheus/cli/commands/load_balancer_monitors.rb +71 -0
- data/lib/morpheus/cli/commands/load_balancer_pools.rb +91 -0
- data/lib/morpheus/cli/commands/load_balancer_profiles.rb +65 -0
- data/lib/morpheus/cli/{load_balancer_types.rb → commands/load_balancer_types.rb} +9 -8
- data/lib/morpheus/cli/commands/load_balancer_virtual_servers.rb +156 -0
- data/lib/morpheus/cli/commands/load_balancers.rb +176 -0
- data/lib/morpheus/cli/commands/{standard/log_level_command.rb → log_level_command.rb} +0 -3
- data/lib/morpheus/cli/{log_settings_command.rb → commands/log_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{login.rb → commands/login.rb} +0 -5
- data/lib/morpheus/cli/commands/logout.rb +63 -0
- data/lib/morpheus/cli/{logs_command.rb → commands/logs_command.rb} +0 -3
- data/lib/morpheus/cli/commands/{standard/man_command.rb → man_command.rb} +0 -2
- data/lib/morpheus/cli/{monitoring_alerts_command.rb → commands/monitoring_alerts_command.rb} +0 -7
- data/lib/morpheus/cli/{monitoring_apps_command.rb → commands/monitoring_apps_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_checks_command.rb → commands/monitoring_checks_command.rb} +2 -1
- data/lib/morpheus/cli/{monitoring_contacts_command.rb → commands/monitoring_contacts_command.rb} +0 -7
- data/lib/morpheus/cli/{monitoring_groups_command.rb → commands/monitoring_groups_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_incidents_command.rb → commands/monitoring_incidents_command.rb} +0 -1
- data/lib/morpheus/cli/commands/network_dhcp_relays_command.rb +416 -0
- data/lib/morpheus/cli/commands/network_dhcp_servers_command.rb +407 -0
- data/lib/morpheus/cli/{network_domains_command.rb → commands/network_domains_command.rb} +0 -4
- data/lib/morpheus/cli/commands/network_edge_clusters_command.rb +329 -0
- data/lib/morpheus/cli/commands/network_firewalls_command.rb +823 -0
- data/lib/morpheus/cli/{network_groups_command.rb → commands/network_groups_command.rb} +0 -4
- data/lib/morpheus/cli/{network_pool_servers_command.rb → commands/network_pool_servers_command.rb} +0 -4
- data/lib/morpheus/cli/{network_pools_command.rb → commands/network_pools_command.rb} +0 -4
- data/lib/morpheus/cli/{network_proxies_command.rb → commands/network_proxies_command.rb} +0 -4
- data/lib/morpheus/cli/{network_routers_command.rb → commands/network_routers_command.rb} +387 -57
- data/lib/morpheus/cli/{network_services_command.rb → commands/network_services_command.rb} +0 -4
- data/lib/morpheus/cli/commands/network_static_routes_command.rb +446 -0
- data/lib/morpheus/cli/commands/network_transport_zones_command.rb +452 -0
- data/lib/morpheus/cli/{networks_command.rb → commands/networks_command.rb} +21 -21
- data/lib/morpheus/cli/commands/open_command.rb +30 -0
- data/lib/morpheus/cli/commands/options.rb +98 -0
- data/lib/morpheus/cli/{packages_command.rb → commands/packages_command.rb} +0 -2
- data/lib/morpheus/cli/{ping.rb → commands/ping.rb} +0 -7
- data/lib/morpheus/cli/{policies_command.rb → commands/policies_command.rb} +1 -8
- data/lib/morpheus/cli/{power_schedules_command.rb → commands/power_schedules_command.rb} +0 -0
- data/lib/morpheus/cli/{preseed_scripts_command.rb → commands/preseed_scripts_command.rb} +0 -3
- data/lib/morpheus/cli/{price_sets_command.rb → commands/price_sets_command.rb} +0 -0
- data/lib/morpheus/cli/{prices_command.rb → commands/prices_command.rb} +7 -7
- data/lib/morpheus/cli/{processes_command.rb → commands/processes_command.rb} +0 -1
- data/lib/morpheus/cli/{projects_command.rb → commands/projects_command.rb} +0 -0
- data/lib/morpheus/cli/{provisioning_licenses_command.rb → commands/provisioning_licenses_command.rb} +0 -0
- data/lib/morpheus/cli/{provisioning_settings_command.rb → commands/provisioning_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{recent_activity_command.rb → commands/recent_activity_command.rb} +0 -0
- data/lib/morpheus/cli/{remote.rb → commands/remote.rb} +5 -9
- data/lib/morpheus/cli/{reports_command.rb → commands/reports_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/rm_command.rb → rm_command.rb} +0 -0
- data/lib/morpheus/cli/{roles.rb → commands/roles.rb} +245 -40
- data/lib/morpheus/cli/{search_command.rb → commands/search_command.rb} +0 -0
- data/lib/morpheus/cli/{security_group_rules.rb → commands/security_group_rules.rb} +0 -5
- data/lib/morpheus/cli/{security_groups.rb → commands/security_groups.rb} +0 -6
- data/lib/morpheus/cli/{service_catalog_command.rb → commands/service_catalog_command.rb} +0 -0
- data/lib/morpheus/cli/{service_plans_command.rb → commands/service_plans_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/set_prompt_command.rb → set_prompt_command.rb} +0 -3
- data/lib/morpheus/cli/{setup.rb → commands/setup.rb} +0 -0
- data/lib/morpheus/cli/{shell.rb → commands/shell.rb} +4 -105
- data/lib/morpheus/cli/commands/{standard/sleep_command.rb → sleep_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/source_command.rb → source_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/ssl_verification_command.rb → ssl_verification_command.rb} +0 -3
- data/lib/morpheus/cli/{storage_providers_command.rb → commands/storage_providers_command.rb} +0 -4
- data/lib/morpheus/cli/commands/storage_server_types.rb +50 -0
- data/lib/morpheus/cli/commands/storage_servers.rb +122 -0
- data/lib/morpheus/cli/commands/storage_volume_types.rb +50 -0
- data/lib/morpheus/cli/commands/storage_volumes.rb +103 -0
- data/lib/morpheus/cli/{subnets_command.rb → commands/subnets_command.rb} +7 -6
- data/lib/morpheus/cli/{tasks.rb → commands/tasks.rb} +25 -6
- data/lib/morpheus/cli/commands/{standard/tee_command.rb → tee_command.rb} +0 -0
- data/lib/morpheus/cli/{tenants_command.rb → commands/tenants_command.rb} +1 -8
- data/lib/morpheus/cli/commands/{standard/update_command.rb → update_command.rb} +0 -1
- data/lib/morpheus/cli/{usage_command.rb → commands/usage_command.rb} +0 -0
- data/lib/morpheus/cli/{user_groups_command.rb → commands/user_groups_command.rb} +1 -2
- data/lib/morpheus/cli/{user_settings_command.rb → commands/user_settings_command.rb} +2 -1
- data/lib/morpheus/cli/{user_sources_command.rb → commands/user_sources_command.rb} +1 -2
- data/lib/morpheus/cli/{users.rb → commands/users.rb} +28 -35
- data/lib/morpheus/cli/{vdi_allocations_command.rb → commands/vdi_allocations_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_apps_command.rb → commands/vdi_apps_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_command.rb → commands/vdi_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_gateways_command.rb → commands/vdi_gateways_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_pools_command.rb → commands/vdi_pools_command.rb} +4 -1
- data/lib/morpheus/cli/commands/{standard/version_command.rb → version_command.rb} +0 -0
- data/lib/morpheus/cli/commands/view.rb +102 -0
- data/lib/morpheus/cli/{virtual_images.rb → commands/virtual_images.rb} +251 -33
- data/lib/morpheus/cli/{whitelabel_settings_command.rb → commands/whitelabel_settings_command.rb} +0 -1
- data/lib/morpheus/cli/{whoami.rb → commands/whoami.rb} +0 -4
- data/lib/morpheus/cli/{wiki_command.rb → commands/wiki_command.rb} +0 -5
- data/lib/morpheus/cli/{workflows.rb → commands/workflows.rb} +0 -3
- data/lib/morpheus/cli/mixins/accounts_helper.rb +5 -5
- data/lib/morpheus/cli/mixins/load_balancers_helper.rb +26 -6
- data/lib/morpheus/cli/mixins/logs_helper.rb +1 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +51 -18
- data/lib/morpheus/cli/mixins/processes_helper.rb +1 -2
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +167 -110
- data/lib/morpheus/cli/mixins/rest_command.rb +268 -94
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +668 -0
- data/lib/morpheus/cli/mixins/storage_servers_helper.rb +156 -0
- data/lib/morpheus/cli/mixins/storage_volumes_helper.rb +119 -0
- data/lib/morpheus/cli/option_parser.rb +25 -17
- data/lib/morpheus/cli/option_types.rb +137 -52
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +6 -128
- data/lib/morpheus/ext/string.rb +29 -6
- data/lib/morpheus/routes.rb +238 -0
- data/lib/morpheus/terminal.rb +5 -6
- data/lib/morpheus/util.rb +6 -1
- data/morpheus-cli.gemspec +1 -1
- metadata +183 -149
- data/lib/morpheus/cli/change_password_command.rb +0 -147
- data/lib/morpheus/cli/library.rb +0 -1
- data/lib/morpheus/cli/load_balancers.rb +0 -245
- data/lib/morpheus/cli/logout.rb +0 -81
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'morpheus/cli/cli_command'
|
2
|
-
require 'date'
|
2
|
+
require 'date' #needed?
|
3
3
|
|
4
4
|
class Morpheus::Cli::InvoicesCommand
|
5
5
|
include Morpheus::Cli::CliCommand
|
@@ -222,52 +222,52 @@ class Morpheus::Cli::InvoicesCommand
|
|
222
222
|
# {"LAST COST DATE" => lambda {|it| format_local_dt(it['lastCostDate']) } },
|
223
223
|
# {"LAST ACTUAL DATE" => lambda {|it| format_local_dt(it['lastActualDate']) } },
|
224
224
|
] : []) + [
|
225
|
-
{"COMPUTE PRICE" => lambda {|it| format_money(it['computePrice'], '
|
226
|
-
{"MEMORY PRICE" => lambda {|it| format_money(it['memoryPrice'], '
|
227
|
-
{"STORAGE PRICE" => lambda {|it| format_money(it['storagePrice'], '
|
228
|
-
{"NETWORK PRICE" => lambda {|it| format_money(it['networkPrice'], '
|
229
|
-
{"EXTRA PRICE" => lambda {|it| format_money(it['extraPrice'], '
|
230
|
-
{"MTD PRICE" => lambda {|it| format_money(it['runningPrice'], '
|
225
|
+
{"COMPUTE PRICE" => lambda {|it| format_money(it['computePrice'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
226
|
+
{"MEMORY PRICE" => lambda {|it| format_money(it['memoryPrice'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
227
|
+
{"STORAGE PRICE" => lambda {|it| format_money(it['storagePrice'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
228
|
+
{"NETWORK PRICE" => lambda {|it| format_money(it['networkPrice'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
229
|
+
{"EXTRA PRICE" => lambda {|it| format_money(it['extraPrice'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
230
|
+
{"MTD PRICE" => lambda {|it| format_money(it['runningPrice'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
231
231
|
{"TOTAL PRICE" => lambda {|it|
|
232
|
-
format_money(it['totalPrice'], '
|
232
|
+
format_money(it['totalPrice'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) + ((it['totalCost'].to_f > 0 && it['totalCost'] != it['runningCost']) ? " (Projected)" : "")
|
233
233
|
} }
|
234
234
|
]
|
235
235
|
|
236
236
|
if options[:show_costs] && json_response['masterAccount'] != false
|
237
237
|
columns += [
|
238
|
-
{"COMPUTE COST" => lambda {|it| format_money(it['computeCost'], '
|
238
|
+
{"COMPUTE COST" => lambda {|it| format_money(it['computeCost'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
239
239
|
{"MEMORY COST" => lambda {|it| format_money(it['memoryCost']) } },
|
240
|
-
{"STORAGE COST" => lambda {|it| format_money(it['storageCost'], '
|
241
|
-
{"NETWORK COST" => lambda {|it| format_money(it['networkCost'], '
|
242
|
-
{"EXTRA COST" => lambda {|it| format_money(it['extraCost'], '
|
243
|
-
{"MTD COST" => lambda {|it| format_money(it['runningCost'], '
|
240
|
+
{"STORAGE COST" => lambda {|it| format_money(it['storageCost'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
241
|
+
{"NETWORK COST" => lambda {|it| format_money(it['networkCost'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
242
|
+
{"EXTRA COST" => lambda {|it| format_money(it['extraCost'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
243
|
+
{"MTD COST" => lambda {|it| format_money(it['runningCost'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
244
244
|
{"TOTAL COST" => lambda {|it|
|
245
|
-
format_money(it['totalCost'], '
|
245
|
+
format_money(it['totalCost'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) + ((it['totalCost'].to_f > 0 && it['totalCost'] != it['runningCost']) ? " (Projected)" : "")
|
246
246
|
} }
|
247
247
|
]
|
248
248
|
end
|
249
249
|
if options[:show_estimates]
|
250
250
|
columns += [
|
251
|
-
{"METERED COMPUTE PRICE" => lambda {|it| format_money(it['estimatedComputePrice'], '
|
252
|
-
{"METERED MEMORY PRICE" => lambda {|it| format_money(it['estimatedMemoryPrice'], '
|
253
|
-
{"METERED STORAGE PRICE" => lambda {|it| format_money(it['estimatedStoragePrice'], '
|
254
|
-
{"METERED NETWORK PRICE" => lambda {|it| format_money(it['estimatedNetworkPrice'], '
|
255
|
-
{"METERED EXTRA PRICE" => lambda {|it| format_money(it['estimatedExtraPrice'], '
|
256
|
-
{"METERED MTD PRICE" => lambda {|it| format_money(it['estimatedRunningPrice'], '
|
251
|
+
{"METERED COMPUTE PRICE" => lambda {|it| format_money(it['estimatedComputePrice'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
252
|
+
{"METERED MEMORY PRICE" => lambda {|it| format_money(it['estimatedMemoryPrice'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
253
|
+
{"METERED STORAGE PRICE" => lambda {|it| format_money(it['estimatedStoragePrice'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
254
|
+
{"METERED NETWORK PRICE" => lambda {|it| format_money(it['estimatedNetworkPrice'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
255
|
+
{"METERED EXTRA PRICE" => lambda {|it| format_money(it['estimatedExtraPrice'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
256
|
+
{"METERED MTD PRICE" => lambda {|it| format_money(it['estimatedRunningPrice'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
257
257
|
{"METERED TOTAL PRICE" => lambda {|it|
|
258
|
-
format_money(it['estimatedTotalPrice'], '
|
258
|
+
format_money(it['estimatedTotalPrice'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) + ((it['estimatedTotalPrice'].to_f > 0 && it['estimatedTotalPrice'] != it['estimatedRunningPrice']) ? " (Projected)" : "")
|
259
259
|
} },
|
260
260
|
]
|
261
261
|
if options[:show_costs] && json_response['masterAccount'] != false
|
262
262
|
columns += [
|
263
|
-
{"METERED COMPUTE COST" => lambda {|it| format_money(it['estimatedComputeCost'], '
|
264
|
-
{"METERED MEMORY COST" => lambda {|it| format_money(it['estimatedMemoryCost'], '
|
265
|
-
{"METERED STORAGE COST" => lambda {|it| format_money(it['estimatedStorageCost'], '
|
266
|
-
{"METERED NETWORK COST" => lambda {|it| format_money(it['estimatedNetworkCost'], '
|
267
|
-
{"METERED EXTRA COST" => lambda {|it| format_money(it['estimatedExtraCost'], '
|
268
|
-
{"METERED MTD COST" => lambda {|it| format_money(it['estimatedRunningCost'], '
|
263
|
+
{"METERED COMPUTE COST" => lambda {|it| format_money(it['estimatedComputeCost'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
264
|
+
{"METERED MEMORY COST" => lambda {|it| format_money(it['estimatedMemoryCost'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
265
|
+
{"METERED STORAGE COST" => lambda {|it| format_money(it['estimatedStorageCost'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
266
|
+
{"METERED NETWORK COST" => lambda {|it| format_money(it['estimatedNetworkCost'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
267
|
+
{"METERED EXTRA COST" => lambda {|it| format_money(it['estimatedExtraCost'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
268
|
+
{"METERED MTD COST" => lambda {|it| format_money(it['estimatedRunningCost'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
269
269
|
{"METERED TOTAL COST" => lambda {|it|
|
270
|
-
format_money(it['estimatedTotalCost'], '
|
270
|
+
format_money(it['estimatedTotalCost'], it['estimatedCurrency'] || 'USD', {sigdig:options[:sigdig]}) + ((it['estimatedTotalCost'].to_f > 0 && it['estimatedTotalCost'] != it['estimatedRunningCost']) ? " (Projected)" : "")
|
271
271
|
} },
|
272
272
|
]
|
273
273
|
end
|
@@ -306,36 +306,37 @@ class Morpheus::Cli::InvoicesCommand
|
|
306
306
|
|
307
307
|
if invoice_totals
|
308
308
|
cost_rows = [
|
309
|
-
{label: 'Price'.upcase, compute: invoice_totals['actualComputePrice'], memory: invoice_totals['actualMemoryPrice'], storage: invoice_totals['actualStoragePrice'], network: invoice_totals['actualNetworkPrice'], license: invoice_totals['actualLicensePrice'], extra: invoice_totals['actualExtraPrice'], running: invoice_totals['actualRunningPrice'], total: invoice_totals['actualTotalPrice']},
|
309
|
+
{label: 'Price'.upcase, compute: invoice_totals['actualComputePrice'], memory: invoice_totals['actualMemoryPrice'], storage: invoice_totals['actualStoragePrice'], network: invoice_totals['actualNetworkPrice'], license: invoice_totals['actualLicensePrice'], extra: invoice_totals['actualExtraPrice'], running: invoice_totals['actualRunningPrice'], total: invoice_totals['actualTotalPrice'], currency: invoice_totals['actualCurrency']},
|
310
310
|
]
|
311
311
|
if options[:show_costs]
|
312
312
|
cost_rows += [
|
313
|
-
{label: 'Cost'.upcase, compute: invoice_totals['actualComputeCost'], memory: invoice_totals['actualMemoryCost'], storage: invoice_totals['actualStorageCost'], network: invoice_totals['actualNetworkCost'], license: invoice_totals['actualLicenseCost'], extra: invoice_totals['actualExtraCost'], running: invoice_totals['actualRunningCost'], total: invoice_totals['actualTotalCost']}
|
313
|
+
{label: 'Cost'.upcase, compute: invoice_totals['actualComputeCost'], memory: invoice_totals['actualMemoryCost'], storage: invoice_totals['actualStorageCost'], network: invoice_totals['actualNetworkCost'], license: invoice_totals['actualLicenseCost'], extra: invoice_totals['actualExtraCost'], running: invoice_totals['actualRunningCost'], total: invoice_totals['actualTotalCost'], currency: invoice_totals['actualCurrency']}
|
314
314
|
]
|
315
315
|
end
|
316
316
|
if options[:show_estimates]
|
317
317
|
cost_rows += [
|
318
|
-
{label: 'Metered Price'.upcase, compute: invoice_totals['estimatedComputePrice'], memory: invoice_totals['estimatedMemoryPrice'], storage: invoice_totals['estimatedStoragePrice'], network: invoice_totals['estimatedNetworkPrice'], license: invoice_totals['estimatedLicensePrice'], extra: invoice_totals['estimatedExtraPrice'], running: invoice_totals['estimatedRunningPrice'], total: invoice_totals['estimatedTotalPrice']}
|
318
|
+
{label: 'Metered Price'.upcase, compute: invoice_totals['estimatedComputePrice'], memory: invoice_totals['estimatedMemoryPrice'], storage: invoice_totals['estimatedStoragePrice'], network: invoice_totals['estimatedNetworkPrice'], license: invoice_totals['estimatedLicensePrice'], extra: invoice_totals['estimatedExtraPrice'], running: invoice_totals['estimatedRunningPrice'], total: invoice_totals['estimatedTotalPrice'], currency: invoice_totals['estimatedCurrency']}
|
319
319
|
]
|
320
320
|
if options[:show_costs]
|
321
321
|
cost_rows += [
|
322
|
-
{label: 'Metered Cost'.upcase, compute: invoice_totals['estimatedComputeCost'], memory: invoice_totals['estimatedMemoryCost'], storage: invoice_totals['estimatedStorageCost'], network: invoice_totals['estimatedNetworkCost'], license: invoice_totals['estimatedLicenseCost'], extra: invoice_totals['estimatedExtraCost'], running: invoice_totals['estimatedRunningCost'], total: invoice_totals['estimatedTotalCost']}
|
322
|
+
{label: 'Metered Cost'.upcase, compute: invoice_totals['estimatedComputeCost'], memory: invoice_totals['estimatedMemoryCost'], storage: invoice_totals['estimatedStorageCost'], network: invoice_totals['estimatedNetworkCost'], license: invoice_totals['estimatedLicenseCost'], extra: invoice_totals['estimatedExtraCost'], running: invoice_totals['estimatedRunningCost'], total: invoice_totals['estimatedTotalCost'], currency: invoice_totals['estimatedCurrency']}
|
323
323
|
]
|
324
324
|
end
|
325
325
|
end
|
326
326
|
cost_columns = {
|
327
327
|
"" => lambda {|it| it[:label] },
|
328
|
-
"Compute"
|
329
|
-
"Memory"
|
330
|
-
"Storage"
|
331
|
-
"Network"
|
332
|
-
"License"
|
333
|
-
"Extra"
|
334
|
-
"MTD"
|
335
|
-
"Total"
|
336
|
-
format_money(it[:total], '
|
328
|
+
"Compute" => lambda {|it| format_money(it[:compute], it[:currency] || it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
329
|
+
"Memory" => lambda {|it| format_money(it[:memory], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
330
|
+
"Storage" => lambda {|it| format_money(it[:storage], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
331
|
+
"Network" => lambda {|it| format_money(it[:network], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
332
|
+
"License" => lambda {|it| format_money(it[:license], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
333
|
+
"Extra" => lambda {|it| format_money(it[:extra], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
334
|
+
"MTD" => lambda {|it| format_money(it[:running], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
335
|
+
"Total" => lambda {|it|
|
336
|
+
format_money(it[:total], it[:currency] || 'USD', {sigdig:options[:sigdig]}) + ((it[:total].to_f > 0 && it[:total] != it[:running]) ? " (Projected)" : "")
|
337
337
|
},
|
338
|
-
|
338
|
+
"Currency" => lambda {|it| it[:currency] },
|
339
|
+
}.upcase_keys!
|
339
340
|
# remove columns that rarely have data...
|
340
341
|
if cost_rows.sum { |it| it[:memory].to_f } == 0
|
341
342
|
cost_columns.delete("Memory".upcase)
|
@@ -359,7 +360,7 @@ class Morpheus::Cli::InvoicesCommand
|
|
359
360
|
end
|
360
361
|
|
361
362
|
def get(args)
|
362
|
-
options = {}
|
363
|
+
options, params = {}, {}
|
363
364
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
364
365
|
opts.banner = subcommand_usage("[id]")
|
365
366
|
opts.on('-a', '--all', "Display all details, costs and prices." ) do
|
@@ -380,7 +381,6 @@ class Morpheus::Cli::InvoicesCommand
|
|
380
381
|
options[:sigdig] = val.to_i
|
381
382
|
end
|
382
383
|
build_standard_get_options(opts, options)
|
383
|
-
opts.footer = "Get details about a specific invoice."
|
384
384
|
opts.footer = <<-EOT
|
385
385
|
Get details about a specific invoice.
|
386
386
|
[id] is required. This is the id of an invoice.
|
@@ -389,32 +389,27 @@ EOT
|
|
389
389
|
optparse.parse!(args)
|
390
390
|
verify_args!(args:args, optparse:optparse, min:1)
|
391
391
|
connect(options)
|
392
|
+
params.merge!(parse_query_options(options))
|
392
393
|
id_list = parse_id_list(args)
|
393
394
|
return run_command_for_each_arg(id_list) do |arg|
|
394
|
-
_get(arg, options)
|
395
|
+
_get(arg, params, options)
|
395
396
|
end
|
396
397
|
end
|
397
398
|
|
398
|
-
def _get(id, options)
|
399
|
-
|
400
|
-
|
401
|
-
@invoices_interface.
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
json_response
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
end
|
411
|
-
render_result = render_with_format(json_response, options, 'invoice')
|
412
|
-
return 0 if render_result
|
413
|
-
|
399
|
+
def _get(id, params, options)
|
400
|
+
@invoices_interface.setopts(options)
|
401
|
+
if options[:dry_run]
|
402
|
+
print_dry_run @invoices_interface.dry.get(id, params)
|
403
|
+
return
|
404
|
+
end
|
405
|
+
json_response = @invoices_interface.get(id, params)
|
406
|
+
if options[:hide_line_items]
|
407
|
+
json_response['invoice'].delete('lineItems') rescue nil
|
408
|
+
end
|
409
|
+
render_response(json_response, options, invoice_object_key) do
|
410
|
+
invoice = json_response[invoice_object_key]
|
414
411
|
print_h1 "Invoice Details"
|
415
412
|
print cyan
|
416
|
-
|
417
|
-
|
418
413
|
description_cols = {
|
419
414
|
"Invoice ID" => lambda {|it| it['id'] },
|
420
415
|
"Type" => lambda {|it| format_invoice_ref_type(it) },
|
@@ -433,6 +428,10 @@ EOT
|
|
433
428
|
"End" => lambda {|it| format_date(it['endDate']) },
|
434
429
|
"Ref Start" => lambda {|it| format_dt(it['refStart']) },
|
435
430
|
"Ref End" => lambda {|it| format_dt(it['refEnd']) },
|
431
|
+
"Currency" => lambda {|it| (it['estimate'] ? it['estimatedCurrency'] : it['currency']) || 'USD' },
|
432
|
+
"Conversion Rate" => lambda {|it| (it['estimate'] ? it['estimatedConversionRate'] : it['conversionRate']) },
|
433
|
+
# "Estimated Currency" => lambda {|it| it['estimatedCurrency'] },
|
434
|
+
# "Estimated Conversion Rate" => lambda {|it| it['estimatedConversionRate'] },
|
436
435
|
"Items" => lambda {|it| (it['lineItemCount'] ? it['lineItemCount'] : it['lineItems'].size) rescue '' },
|
437
436
|
"Tags" => lambda {|it| (it['metadata'] || it['tags']) ? (it['metadata'] || it['tags']).collect {|m| "#{m['name']}: #{m['value']}" }.join(', ') : '' },
|
438
437
|
"Project ID" => lambda {|it| it['project'] ? it['project']['id'] : '' },
|
@@ -457,39 +456,13 @@ EOT
|
|
457
456
|
if !['ComputeServer','Instance','Container'].include?(invoice['refType'])
|
458
457
|
description_cols.delete("Power State")
|
459
458
|
end
|
459
|
+
# if invoice['currency'].nil? || invoice['currency'] == 'USD'
|
460
|
+
# description_cols.delete("Currency")
|
461
|
+
# end
|
462
|
+
# if invoice['actualConversionRate'].nil? || invoice['actualConversionRate'] == 1
|
463
|
+
# description_cols.delete("Conversion Rate")
|
464
|
+
# end
|
460
465
|
print_description_list(description_cols, invoice)
|
461
|
-
=begin
|
462
|
-
print_h2 "Costs"
|
463
|
-
cost_columns = {
|
464
|
-
"Compute" => lambda {|it| format_money(it['computeCost'], 'usd', {sigdig:options[:sigdig]}) },
|
465
|
-
"Memory" => lambda {|it| format_money(it['memoryCost'], 'usd', {sigdig:options[:sigdig]}) },
|
466
|
-
"Storage" => lambda {|it| format_money(it['storageCost'], 'usd', {sigdig:options[:sigdig]}) },
|
467
|
-
"Network" => lambda {|it| format_money(it['networkCost'], 'usd', {sigdig:options[:sigdig]}) },
|
468
|
-
"License" => lambda {|it| format_money(it['licenseCost'], 'usd', {sigdig:options[:sigdig]}) },
|
469
|
-
"Extra" => lambda {|it| format_money(it['extraCost'], 'usd', {sigdig:options[:sigdig]}) },
|
470
|
-
"Running" => lambda {|it| format_money(it['runningCost'], 'usd', {sigdig:options[:sigdig]}) },
|
471
|
-
"Total Cost" => lambda {|it| format_money(it['totalCost'], 'usd', {sigdig:options[:sigdig]}) },
|
472
|
-
}
|
473
|
-
print as_pretty_table([invoice], cost_columns, options)
|
474
|
-
|
475
|
-
print_h2 "Prices"
|
476
|
-
price_columns = {
|
477
|
-
"Compute" => lambda {|it| format_money(it['computePrice'], 'usd', {sigdig:options[:sigdig]}) },
|
478
|
-
"Memory" => lambda {|it| format_money(it['memoryPrice'], 'usd', {sigdig:options[:sigdig]}) },
|
479
|
-
"Storage" => lambda {|it| format_money(it['storagePrice'], 'usd', {sigdig:options[:sigdig]}) },
|
480
|
-
"Network" => lambda {|it| format_money(it['networkPrice'], 'usd', {sigdig:options[:sigdig]}) },
|
481
|
-
"License" => lambda {|it| format_money(it['licensePrice'], 'usd', {sigdig:options[:sigdig]}) },
|
482
|
-
"Extra" => lambda {|it| format_money(it['extraPrice'], 'usd', {sigdig:options[:sigdig]}) },
|
483
|
-
"Running" => lambda {|it| format_money(it['runningPrice'], 'usd', {sigdig:options[:sigdig]}) },
|
484
|
-
"Total Price" => lambda {|it| format_money(it['totalPrice'], 'usd', {sigdig:options[:sigdig]}) },
|
485
|
-
}
|
486
|
-
print as_pretty_table([invoice], price_columns, options)
|
487
|
-
=end
|
488
|
-
|
489
|
-
# current_date = Time.now
|
490
|
-
# current_period = "#{current_date.year}#{current_date.month.to_s.rjust(2, '0')}"
|
491
|
-
|
492
|
-
|
493
466
|
|
494
467
|
# Line Items
|
495
468
|
line_items = invoice['lineItems']
|
@@ -507,9 +480,9 @@ EOT
|
|
507
480
|
{"USAGE" => lambda {|it| it['itemUsage'] } },
|
508
481
|
{"RATE" => lambda {|it| it['itemRate'] } },
|
509
482
|
{"UNIT" => lambda {|it| it['rateUnit'] } },
|
510
|
-
{"COST" => lambda {|it| format_money(it['itemCost'], '
|
511
|
-
{"PRICE" => lambda {|it| format_money(it['itemPrice'], '
|
512
|
-
#{"TAX" => lambda {|it| format_money(it['itemTax'], '
|
483
|
+
{"COST" => lambda {|it| format_money(it['itemCost'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
484
|
+
{"PRICE" => lambda {|it| format_money(it['itemPrice'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
485
|
+
#{"TAX" => lambda {|it| format_money(it['itemTax'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
513
486
|
# {"TERM" => lambda {|it| it['itemTerm'] } },
|
514
487
|
{"ITEM ID" => lambda {|it| truncate_string_right(it['itemId'], 65) } },
|
515
488
|
{"ITEM NAME" => lambda {|it| it['itemName'] } },
|
@@ -529,36 +502,37 @@ EOT
|
|
529
502
|
print_h2 "Invoice Totals"
|
530
503
|
|
531
504
|
cost_rows = [
|
532
|
-
{label: 'Price'.upcase, compute: invoice['computePrice'], memory: invoice['memoryPrice'], storage: invoice['storagePrice'], network: invoice['networkPrice'], license: invoice['licensePrice'], extra: invoice['extraPrice'], running: invoice['runningPrice'], total: invoice['totalPrice']},
|
505
|
+
{label: 'Price'.upcase, compute: invoice['computePrice'], memory: invoice['memoryPrice'], storage: invoice['storagePrice'], network: invoice['networkPrice'], license: invoice['licensePrice'], extra: invoice['extraPrice'], running: invoice['runningPrice'], total: invoice['totalPrice'], currency: invoice['currency']},
|
533
506
|
]
|
534
507
|
if options[:show_costs] # && json_response['masterAccount'] != false
|
535
508
|
cost_rows += [
|
536
|
-
{label: 'Cost'.upcase, compute: invoice['computeCost'], memory: invoice['memoryCost'], storage: invoice['storageCost'], network: invoice['networkCost'], license: invoice['licenseCost'], extra: invoice['extraCost'], running: invoice['runningCost'], total: invoice['totalCost']},
|
509
|
+
{label: 'Cost'.upcase, compute: invoice['computeCost'], memory: invoice['memoryCost'], storage: invoice['storageCost'], network: invoice['networkCost'], license: invoice['licenseCost'], extra: invoice['extraCost'], running: invoice['runningCost'], total: invoice['totalCost'], currency: invoice['currency']},
|
537
510
|
]
|
538
511
|
end
|
539
512
|
if options[:show_estimates]
|
540
513
|
cost_rows += [
|
541
|
-
{label: 'Metered Price'.upcase, compute: invoice['estimatedComputePrice'], memory: invoice['estimatedMemoryPrice'], storage: invoice['estimatedStoragePrice'], network: invoice['estimatedNetworkPrice'], license: invoice['estimatedLicensePrice'], extra: invoice['estimatedExtraPrice'], running: invoice['estimatedRunningPrice'], total: invoice['estimatedTotalPrice']}
|
514
|
+
{label: 'Metered Price'.upcase, compute: invoice['estimatedComputePrice'], memory: invoice['estimatedMemoryPrice'], storage: invoice['estimatedStoragePrice'], network: invoice['estimatedNetworkPrice'], license: invoice['estimatedLicensePrice'], extra: invoice['estimatedExtraPrice'], running: invoice['estimatedRunningPrice'], total: invoice['estimatedTotalPrice'], currency: invoice['estimatedCurrency']}
|
542
515
|
]
|
543
516
|
if options[:show_costs] # && json_response['masterAccount'] != false
|
544
517
|
cost_rows += [
|
545
|
-
{label: 'Metered Cost'.upcase, compute: invoice['estimatedComputeCost'], memory: invoice['estimatedMemoryCost'], storage: invoice['estimatedStorageCost'], network: invoice['estimatedNetworkCost'], license: invoice['estimatedLicenseCost'], extra: invoice['estimatedExtraCost'], running: invoice['estimatedRunningCost'], total: invoice['estimatedTotalCost']},
|
518
|
+
{label: 'Metered Cost'.upcase, compute: invoice['estimatedComputeCost'], memory: invoice['estimatedMemoryCost'], storage: invoice['estimatedStorageCost'], network: invoice['estimatedNetworkCost'], license: invoice['estimatedLicenseCost'], extra: invoice['estimatedExtraCost'], running: invoice['estimatedRunningCost'], total: invoice['estimatedTotalCost'], currency: invoice['estimatedCurrency']},
|
546
519
|
]
|
547
520
|
end
|
548
521
|
end
|
549
522
|
cost_columns = {
|
550
523
|
"" => lambda {|it| it[:label] },
|
551
|
-
"Compute"
|
552
|
-
"Memory"
|
553
|
-
"Storage"
|
554
|
-
"Network"
|
555
|
-
"License"
|
556
|
-
"Extra"
|
557
|
-
"MTD" => lambda {|it| format_money(it[:running], '
|
558
|
-
"Total"
|
559
|
-
format_money(it[:total], '
|
524
|
+
"Compute" => lambda {|it| format_money(it[:compute], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
525
|
+
"Memory" => lambda {|it| format_money(it[:memory], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
526
|
+
"Storage" => lambda {|it| format_money(it[:storage], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
527
|
+
"Network" => lambda {|it| format_money(it[:network], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
528
|
+
"License" => lambda {|it| format_money(it[:license], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
529
|
+
"Extra" => lambda {|it| format_money(it[:extra], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
530
|
+
"MTD" => lambda {|it| format_money(it[:running], it[:currency] || 'USD', {sigdig:options[:sigdig]}) },
|
531
|
+
"Total" => lambda {|it|
|
532
|
+
format_money(it[:total], it[:currency] || 'USD', {sigdig:options[:sigdig]}) + ((it[:total].to_f > 0 && it[:total] != it[:running]) ? " (Projected)" : "")
|
560
533
|
},
|
561
|
-
|
534
|
+
"Currency" => lambda {|it| it[:currency] },
|
535
|
+
}.upcase_keys!
|
562
536
|
# remove columns that rarely have data...
|
563
537
|
if cost_rows.sum { |it| it[:memory].to_f } == 0
|
564
538
|
cost_columns.delete("Memory".upcase)
|
@@ -570,15 +544,9 @@ EOT
|
|
570
544
|
cost_columns.delete("Extra".upcase)
|
571
545
|
end
|
572
546
|
print as_pretty_table(cost_rows, cost_columns, options)
|
573
|
-
|
574
|
-
|
575
|
-
|
576
547
|
print reset,"\n"
|
577
|
-
return 0
|
578
|
-
rescue RestClient::Exception => e
|
579
|
-
print_rest_exception(e, options)
|
580
|
-
return 1
|
581
548
|
end
|
549
|
+
return 0, nil
|
582
550
|
end
|
583
551
|
|
584
552
|
def update(args)
|
@@ -638,7 +606,7 @@ Update an invoice.
|
|
638
606
|
invoice = json_response['invoice']
|
639
607
|
render_response(json_response, options, 'invoice') do
|
640
608
|
print_green_success "Updated invoice #{invoice['id']}"
|
641
|
-
return _get(invoice["id"], options)
|
609
|
+
return _get(invoice["id"], {}, options)
|
642
610
|
end
|
643
611
|
return 0, nil
|
644
612
|
end
|
@@ -888,10 +856,10 @@ EOT
|
|
888
856
|
{"USAGE" => lambda {|it| it['itemUsage'] } },
|
889
857
|
{"RATE" => lambda {|it| it['itemRate'] } },
|
890
858
|
{"UNIT" => lambda {|it| it['rateUnit'] } },
|
891
|
-
{"PRICE" => lambda {|it| format_money(it['itemPrice'], '
|
859
|
+
{"PRICE" => lambda {|it| format_money(it['itemPrice'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
892
860
|
] + (options[:show_costs] ? [
|
893
|
-
{"COST" => lambda {|it| format_money(it['itemCost'], '
|
894
|
-
{"TAX" => lambda {|it| format_money(it['itemTax'], '
|
861
|
+
{"COST" => lambda {|it| format_money(it['itemCost'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
862
|
+
{"TAX" => lambda {|it| format_money(it['itemTax'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
895
863
|
] : []) + [
|
896
864
|
{"ITEM ID" => lambda {|it| truncate_string_right(it['itemId'], 65) } },
|
897
865
|
{"ITEM NAME" => lambda {|it| it['itemName'] } },
|
@@ -923,10 +891,10 @@ EOT
|
|
923
891
|
invoice_totals_columns = [
|
924
892
|
{"Items" => lambda {|it| format_number(json_response['meta']['total']) rescue '' } },
|
925
893
|
#{"Usage" => lambda {|it| it['itemUsage'] } },
|
926
|
-
{"Price" => lambda {|it| format_money(it['itemPrice'], '
|
894
|
+
{"Price" => lambda {|it| format_money(it['itemPrice'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
927
895
|
] + (options[:show_costs] ? [
|
928
|
-
{"Cost" => lambda {|it| format_money(it['itemCost'], '
|
929
|
-
#{"Tax" => lambda {|it| format_money(it['itemTax'], '
|
896
|
+
{"Cost" => lambda {|it| format_money(it['itemCost'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
897
|
+
#{"Tax" => lambda {|it| format_money(it['itemTax'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) } },
|
930
898
|
|
931
899
|
] : [])
|
932
900
|
print_description_list(invoice_totals_columns, line_item_totals)
|
@@ -947,14 +915,13 @@ EOT
|
|
947
915
|
end
|
948
916
|
|
949
917
|
def get_line_item(args)
|
950
|
-
options = {}
|
918
|
+
options, params = {}, {}
|
951
919
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
952
920
|
opts.banner = subcommand_usage("[id]")
|
953
921
|
opts.on('--sigdig DIGITS', "Significant digits when rounding cost values for display as currency. Default is 2. eg. $3.50") do |val|
|
954
922
|
options[:sigdig] = val.to_i
|
955
923
|
end
|
956
924
|
build_standard_get_options(opts, options)
|
957
|
-
opts.footer = "Get details about a specific invoice line item."
|
958
925
|
opts.footer = <<-EOT
|
959
926
|
Get details about a specific invoice line item.
|
960
927
|
[id] is required. This is the id of an invoice line item.
|
@@ -963,14 +930,15 @@ EOT
|
|
963
930
|
optparse.parse!(args)
|
964
931
|
verify_args!(args:args, optparse:optparse, min:1)
|
965
932
|
connect(options)
|
933
|
+
params.merge!(parse_query_options(options))
|
966
934
|
id_list = parse_id_list(args)
|
967
935
|
return run_command_for_each_arg(id_list) do |arg|
|
968
|
-
_get_line_item(arg, options)
|
936
|
+
_get_line_item(arg, params, options)
|
969
937
|
end
|
970
938
|
end
|
971
939
|
|
972
|
-
|
973
|
-
|
940
|
+
|
941
|
+
def _get_line_item(id, params, options)
|
974
942
|
@invoice_line_items_interface.setopts(options)
|
975
943
|
if options[:dry_run]
|
976
944
|
print_dry_run @invoice_line_items_interface.dry.get(id, params)
|
@@ -993,9 +961,9 @@ EOT
|
|
993
961
|
"Usage Category" => lambda {|it| it['usageCategory'] },
|
994
962
|
"Item Usage" => lambda {|it| it['itemUsage'] },
|
995
963
|
"Item Rate" => lambda {|it| it['itemRate'] },
|
996
|
-
"Item Cost" => lambda {|it| format_money(it['itemCost'], '
|
997
|
-
"Item Price" => lambda {|it| format_money(it['itemPrice'], '
|
998
|
-
#"Item Tax" => lambda {|it| format_money(it['itemTax'], '
|
964
|
+
"Item Cost" => lambda {|it| format_money(it['itemCost'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) },
|
965
|
+
"Item Price" => lambda {|it| format_money(it['itemPrice'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) },
|
966
|
+
#"Item Tax" => lambda {|it| format_money(it['itemTax'], it['currency'] || 'USD', {sigdig:options[:sigdig]}) },
|
999
967
|
#"Tax Type" => lambda {|it| it['taxType'] },
|
1000
968
|
"Item Term" => lambda {|it| it['itemTerm'] },
|
1001
969
|
"Item ID" => lambda {|it| it['itemId'] },
|
@@ -1015,6 +983,22 @@ EOT
|
|
1015
983
|
|
1016
984
|
private
|
1017
985
|
|
986
|
+
def invoice_object_key
|
987
|
+
'invoice'
|
988
|
+
end
|
989
|
+
|
990
|
+
def invoice_list_key
|
991
|
+
'invoices'
|
992
|
+
end
|
993
|
+
|
994
|
+
def invoice_line_item_object_key
|
995
|
+
'lineItem'
|
996
|
+
end
|
997
|
+
|
998
|
+
def invoice_line_item_list_key
|
999
|
+
'lineItems'
|
1000
|
+
end
|
1001
|
+
|
1018
1002
|
# def find_invoice_by_name_or_id(val)
|
1019
1003
|
# if val.to_s =~ /\A\d{1,}\Z/
|
1020
1004
|
# return find_invoice_by_id(val)
|
File without changes
|
@@ -1,10 +1,4 @@
|
|
1
|
-
require 'io/console'
|
2
|
-
require 'rest_client'
|
3
|
-
require 'optparse'
|
4
1
|
require 'morpheus/cli/cli_command'
|
5
|
-
require 'morpheus/cli/option_types'
|
6
|
-
require 'morpheus/cli/mixins/accounts_helper'
|
7
|
-
require 'json'
|
8
2
|
|
9
3
|
class Morpheus::Cli::KeyPairs
|
10
4
|
include Morpheus::Cli::CliCommand
|
@@ -1,8 +1,4 @@
|
|
1
|
-
require 'io/console'
|
2
|
-
require 'optparse'
|
3
|
-
require 'filesize'
|
4
1
|
require 'morpheus/cli/cli_command'
|
5
|
-
require 'morpheus/cli/mixins/library_helper'
|
6
2
|
|
7
3
|
class Morpheus::Cli::LibraryClusterLayoutsCommand
|
8
4
|
include Morpheus::Cli::CliCommand
|
@@ -161,6 +157,7 @@ class Morpheus::Cli::LibraryClusterLayoutsCommand
|
|
161
157
|
"Workflow" => lambda {|it| it['taskSets'] && it['taskSets'].count > 0 ? it['taskSets'][0]['name'] : nil},
|
162
158
|
"Description" => lambda {|it| it['description']},
|
163
159
|
"Horizontal Scaling" => lambda {|it| format_boolean(it['hasAutoScale'])},
|
160
|
+
"Install Docker" => lambda {|it| it['installContainerRuntime'].nil? ? nil : format_boolean(it['installContainerRuntime'])},
|
164
161
|
}
|
165
162
|
|
166
163
|
print_description_list(description_cols, layout)
|
@@ -248,6 +245,13 @@ class Morpheus::Cli::LibraryClusterLayoutsCommand
|
|
248
245
|
opts.on('-s', '--auto-scale [on|off]', String, "Can be used to enable / disable horizontal scaling. Default is on") do |val|
|
249
246
|
params['hasAutoScale'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
250
247
|
end
|
248
|
+
opts.on('--install-docker [on|off]', String, "Install Docker container runtime. Default is off.") do |val|
|
249
|
+
params['installContainerRuntime'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
250
|
+
end
|
251
|
+
opts.on('--install-container-runtime [on|off]', String, "Install Docker container runtime. Default is off.") do |val|
|
252
|
+
params['installContainerRuntime'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
253
|
+
end
|
254
|
+
opts.add_hidden_option('--install-container-runtime')
|
251
255
|
opts.on('--evars-json JSON', String, 'Environment variables JSON: {"name":"Foo", "value":"Bar", "masked":true, "export":true}' ) do |val|
|
252
256
|
begin
|
253
257
|
evars = JSON.parse(val.to_s)
|
@@ -374,6 +378,11 @@ class Morpheus::Cli::LibraryClusterLayoutsCommand
|
|
374
378
|
params['hasAutoScale'] = Morpheus::Cli::OptionTypes.confirm("Enable scaling?", {:default => false}) == true
|
375
379
|
end
|
376
380
|
|
381
|
+
# install docker
|
382
|
+
if params['installContainerRuntime'].nil?
|
383
|
+
params['installContainerRuntime'] = Morpheus::Cli::OptionTypes.confirm("Install Docker?", {:default => false}) == true
|
384
|
+
end
|
385
|
+
|
377
386
|
# evars?
|
378
387
|
if params['environmentVariables'].nil?
|
379
388
|
evars = []
|
@@ -506,6 +515,13 @@ class Morpheus::Cli::LibraryClusterLayoutsCommand
|
|
506
515
|
opts.on('-s', '--auto-scale [on|off]', String, "Can be used to enable / disable horizontal scaling. Default is on") do |val|
|
507
516
|
params['hasAutoScale'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
508
517
|
end
|
518
|
+
opts.on('--install-docker [on|off]', String, "Install Docker container runtime. Default is off.") do |val|
|
519
|
+
params['installContainerRuntime'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
520
|
+
end
|
521
|
+
opts.on('--install-container-runtime [on|off]', String, "Install Docker container runtime. Default is off.") do |val|
|
522
|
+
params['installContainerRuntime'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
|
523
|
+
end
|
524
|
+
opts.add_hidden_option('--install-container-runtime')
|
509
525
|
opts.on('--evars-json JSON', String, 'Environment variables JSON: {"name":"Foo", "value":"Bar", "masked":true, "export":true}' ) do |val|
|
510
526
|
begin
|
511
527
|
evars = JSON.parse(val.to_s)
|
File without changes
|
data/lib/morpheus/cli/{library_option_lists_command.rb → commands/library_option_lists_command.rb}
RENAMED
@@ -1,8 +1,4 @@
|
|
1
|
-
require 'io/console'
|
2
|
-
require 'optparse'
|
3
|
-
require 'filesize'
|
4
1
|
require 'morpheus/cli/cli_command'
|
5
|
-
require 'morpheus/cli/mixins/library_helper'
|
6
2
|
|
7
3
|
class Morpheus::Cli::LibraryOptionListsCommand
|
8
4
|
include Morpheus::Cli::CliCommand
|
@@ -429,9 +425,9 @@ class Morpheus::Cli::LibraryOptionListsCommand
|
|
429
425
|
{'dependsOnCode' => 'optionTypeList.type:ldap', 'fieldName' => 'sourceUsername', 'fieldLabel' => 'Source Username', 'type' => 'text', 'description' => "An LDAP Username for use when type is 'ldap'.", 'displayOrder' => 10},
|
430
426
|
{'dependsOnCode' => 'optionTypeList.type:ldap', 'fieldName' => 'sourcePassword', 'fieldLabel' => 'Source Username', 'type' => 'text', 'description' => "An LDAP Password for use when type is 'ldap'.", 'displayOrder' => 11},
|
431
427
|
{'dependsOnCode' => 'optionTypeList.type:ldap', 'fieldName' => 'ldapQuery', 'fieldLabel' => 'LDAP Query', 'type' => 'text', 'description' => "LDAP Queries are standard LDAP formatted queries where different objects can be searched. Dependent parameters can be loaded into the query using the <%=phrase%> syntax.", 'displayOrder' => 12},
|
432
|
-
{'dependsOnCode' => 'optionTypeList.type:rest|api|manual', 'fieldName' => 'initialDataset', 'fieldLabel' => 'Initial Dataset', 'type' => 'code-editor', 'description' => "Create an initial json dataset to be used as the collection for this option list. It should be a list containing objects with properties 'name', and 'value'. However, if there is a translation script, that will also be passed through.", 'displayOrder' => 13},
|
433
|
-
{'dependsOnCode' => 'optionTypeList.type:rest|api|ldap', 'fieldName' => 'translationScript', 'fieldLabel' => 'Translation Script', 'type' => 'code-editor', 'description' => "Create a js script to translate the result data object into an Array containing objects with properties name, and value. The input data is provided as data and the result should be put on the global variable results.", 'displayOrder' => 14},
|
434
|
-
{'dependsOnCode' => 'optionTypeList.type:rest|api', 'fieldName' => 'requestScript', 'fieldLabel' => 'Request Script', 'type' => 'code-editor', 'description' => "Create a js script to prepare the request. Return a data object as the body for a post, and return an array containing properties name and value for a get. The input data is provided as data and the result should be put on the global variable results.", 'displayOrder' => 15},
|
428
|
+
{'dependsOnCode' => 'optionTypeList.type:rest|api|manual', 'fieldName' => 'initialDataset', 'fieldLabel' => 'Initial Dataset', 'type' => 'code-editor', 'description' => "Create an initial json dataset to be used as the collection for this option list. It should be a list containing objects with properties 'name', and 'value'. However, if there is a translation script, that will also be passed through.", 'displayOrder' => 13, 'dataType' => 'string'},
|
429
|
+
{'dependsOnCode' => 'optionTypeList.type:rest|api|ldap', 'fieldName' => 'translationScript', 'fieldLabel' => 'Translation Script', 'type' => 'code-editor', 'description' => "Create a js script to translate the result data object into an Array containing objects with properties name, and value. The input data is provided as data and the result should be put on the global variable results.", 'displayOrder' => 14, 'dataType' => 'string'},
|
430
|
+
{'dependsOnCode' => 'optionTypeList.type:rest|api', 'fieldName' => 'requestScript', 'fieldLabel' => 'Request Script', 'type' => 'code-editor', 'description' => "Create a js script to prepare the request. Return a data object as the body for a post, and return an array containing properties name and value for a get. The input data is provided as data and the result should be put on the global variable results.", 'displayOrder' => 15, 'dataType' => 'string'},
|
435
431
|
]
|
436
432
|
|
437
433
|
end
|