brightbox-cli 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile.lock +18 -19
- data/bin/_brightbox-bash-completer +42 -0
- data/brightbox-cli.gemspec +5 -5
- data/lib/brightbox-cli/accounts.rb +1 -3
- data/lib/brightbox-cli/api.rb +27 -8
- data/lib/brightbox-cli/cloud_ips.rb +11 -15
- data/lib/brightbox-cli/collaborating_account.rb +23 -26
- data/lib/brightbox-cli/collaboration.rb +1 -1
- data/lib/brightbox-cli/commands/{accounts-accept-invite.rb → accounts/accept-invite.rb} +2 -3
- data/lib/brightbox-cli/commands/{accounts-default.rb → accounts/default.rb} +1 -3
- data/lib/brightbox-cli/commands/{accounts-list.rb → accounts/list.rb} +1 -1
- data/lib/brightbox-cli/commands/{accounts-remove.rb → accounts/remove.rb} +1 -2
- data/lib/brightbox-cli/commands/{accounts-reset-ftp-password.rb → accounts/reset-ftp-password.rb} +10 -5
- data/lib/brightbox-cli/commands/{accounts-show.rb → accounts/show.rb} +14 -6
- data/lib/brightbox-cli/commands/{cloudips-create.rb → cloudips/create.rb} +4 -4
- data/lib/brightbox-cli/commands/{cloudips-destroy.rb → cloudips/destroy.rb} +1 -1
- data/lib/brightbox-cli/commands/{cloudips-list.rb → cloudips/list.rb} +2 -10
- data/lib/brightbox-cli/commands/{cloudips-map.rb → cloudips/map.rb} +2 -8
- data/lib/brightbox-cli/commands/{cloudips-show.rb → cloudips/show.rb} +13 -3
- data/lib/brightbox-cli/commands/{cloudips-unmap.rb → cloudips/unmap.rb} +1 -1
- data/lib/brightbox-cli/commands/{cloudips-update.rb → cloudips/update.rb} +5 -6
- data/lib/brightbox-cli/commands/collaborations.rb +3 -9
- data/lib/brightbox-cli/commands/{config-client-add.rb → config/client-add.rb} +2 -2
- data/lib/brightbox-cli/commands/{config-client-default.rb → config/client-default.rb} +1 -1
- data/lib/brightbox-cli/commands/{config-client-list.rb → config/client-list.rb} +3 -3
- data/lib/brightbox-cli/commands/{config-client-remove.rb → config/client-remove.rb} +4 -1
- data/lib/brightbox-cli/commands/{config-user-add.rb → config/user-add.rb} +1 -1
- data/lib/brightbox-cli/commands/{firewall-policies-apply.rb → firewall/policies-apply.rb} +3 -4
- data/lib/brightbox-cli/commands/{firewall-policies-create.rb → firewall/policies-create.rb} +3 -4
- data/lib/brightbox-cli/commands/{firewall-policies-destroy.rb → firewall/policies-destroy.rb} +2 -3
- data/lib/brightbox-cli/commands/{firewall-policies-list.rb → firewall/policies-list.rb} +2 -9
- data/lib/brightbox-cli/commands/{firewall-policies-remove.rb → firewall/policies-remove.rb} +2 -3
- data/lib/brightbox-cli/commands/{firewall-policies-show.rb → firewall/policies-show.rb} +11 -3
- data/lib/brightbox-cli/commands/{firewall-policies-update.rb → firewall/policies-update.rb} +3 -3
- data/lib/brightbox-cli/commands/{firewall-rules-create.rb → firewall/rules-create.rb} +4 -4
- data/lib/brightbox-cli/commands/{firewall-rules-destroy.rb → firewall/rules-destroy.rb} +2 -4
- data/lib/brightbox-cli/commands/{firewall-rules-list.rb → firewall/rules-list.rb} +2 -2
- data/lib/brightbox-cli/commands/{firewall-rules-show.rb → firewall/rules-show.rb} +10 -4
- data/lib/brightbox-cli/commands/{firewall-rules-update.rb → firewall/rules-update.rb} +3 -3
- data/lib/brightbox-cli/commands/{groups-add-server.rb → groups/add-server.rb} +2 -2
- data/lib/brightbox-cli/commands/{groups-create.rb → groups/create.rb} +3 -3
- data/lib/brightbox-cli/commands/{groups-destroy.rb → groups/destroy.rb} +2 -2
- data/lib/brightbox-cli/commands/groups/list.rb +14 -0
- data/lib/brightbox-cli/commands/{groups-move_servers.rb → groups/move_servers.rb} +1 -2
- data/lib/brightbox-cli/commands/{groups-remove-servers.rb → groups/remove-servers.rb} +1 -1
- data/lib/brightbox-cli/commands/{groups-show.rb → groups/show.rb} +1 -1
- data/lib/brightbox-cli/commands/{groups-update.rb → groups/update.rb} +5 -10
- data/lib/brightbox-cli/commands/{images-destroy.rb → images/destroy.rb} +2 -2
- data/lib/brightbox-cli/commands/{images-list.rb → images/list.rb} +2 -10
- data/lib/brightbox-cli/commands/{images-register.rb → images/register.rb} +6 -6
- data/lib/brightbox-cli/commands/{images-show.rb → images/show.rb} +2 -11
- data/lib/brightbox-cli/commands/{images-update.rb → images/update.rb} +8 -8
- data/lib/brightbox-cli/commands/{lbs-add-nodes.rb → lbs/add-nodes.rb} +2 -2
- data/lib/brightbox-cli/commands/{lbs-create.rb → lbs/create.rb} +16 -10
- data/lib/brightbox-cli/commands/{lbs-destroy.rb → lbs/destroy.rb} +1 -1
- data/lib/brightbox-cli/commands/{lbs-list.rb → lbs/list.rb} +2 -10
- data/lib/brightbox-cli/commands/{lbs-remove-nodes.rb → lbs/remove-nodes.rb} +2 -2
- data/lib/brightbox-cli/commands/{lbs-show.rb → lbs/show.rb} +4 -7
- data/lib/brightbox-cli/commands/{lbs-update.rb → lbs/update.rb} +16 -10
- data/lib/brightbox-cli/commands/{servers-activate-console.rb → servers/activate-console.rb} +3 -3
- data/lib/brightbox-cli/commands/{servers-create.rb → servers/create.rb} +4 -4
- data/lib/brightbox-cli/commands/{servers-destroy.rb → servers/destroy.rb} +2 -2
- data/lib/brightbox-cli/commands/{servers-list.rb → servers/list.rb} +7 -8
- data/lib/brightbox-cli/commands/{servers-show.rb → servers/show.rb} +1 -6
- data/lib/brightbox-cli/commands/{servers-shutdown.rb → servers/shutdown.rb} +1 -1
- data/lib/brightbox-cli/commands/{servers-snapshot.rb → servers/snapshot.rb} +1 -1
- data/lib/brightbox-cli/commands/{servers-start.rb → servers/start.rb} +1 -1
- data/lib/brightbox-cli/commands/{servers-stop.rb → servers/stop.rb} +1 -1
- data/lib/brightbox-cli/commands/{servers-update.rb → servers/update.rb} +2 -2
- data/lib/brightbox-cli/commands/sql/instances_create.rb +66 -0
- data/lib/brightbox-cli/commands/sql/instances_destroy.rb +28 -0
- data/lib/brightbox-cli/commands/sql/instances_list.rb +27 -0
- data/lib/brightbox-cli/commands/sql/instances_reset_password.rb +33 -0
- data/lib/brightbox-cli/commands/sql/instances_show.rb +26 -0
- data/lib/brightbox-cli/commands/sql/instances_snapshot.rb +25 -0
- data/lib/brightbox-cli/commands/sql/instances_update.rb +45 -0
- data/lib/brightbox-cli/commands/sql/snapshots_destroy.rb +31 -0
- data/lib/brightbox-cli/commands/sql/snapshots_list.rb +25 -0
- data/lib/brightbox-cli/commands/sql/snapshots_show.rb +26 -0
- data/lib/brightbox-cli/commands/sql/snapshots_update.rb +37 -0
- data/lib/brightbox-cli/commands/sql/types.rb +53 -0
- data/lib/brightbox-cli/commands/types.rb +1 -1
- data/lib/brightbox-cli/commands/users/list.rb +17 -0
- data/lib/brightbox-cli/commands/{users-show.rb → users/show.rb} +5 -13
- data/lib/brightbox-cli/commands/{users-update.rb → users/update.rb} +3 -3
- data/lib/brightbox-cli/config.rb +4 -7
- data/lib/brightbox-cli/config/accounts.rb +3 -6
- data/lib/brightbox-cli/config/api_client.rb +12 -4
- data/lib/brightbox-cli/config/authentication_tokens.rb +8 -14
- data/lib/brightbox-cli/config/clients.rb +6 -7
- data/lib/brightbox-cli/config/section_name_deduplicator.rb +4 -5
- data/lib/brightbox-cli/config/sections.rb +7 -10
- data/lib/brightbox-cli/config/user_application.rb +15 -7
- data/lib/brightbox-cli/connection_manager.rb +1 -2
- data/lib/brightbox-cli/database_server.rb +100 -0
- data/lib/brightbox-cli/database_snapshot.rb +36 -0
- data/lib/brightbox-cli/database_type.rb +44 -0
- data/lib/brightbox-cli/detailed_server.rb +8 -7
- data/lib/brightbox-cli/error_parser.rb +8 -4
- data/lib/brightbox-cli/firewall_rule.rb +5 -5
- data/lib/brightbox-cli/firewall_rules.rb +2 -3
- data/lib/brightbox-cli/gli_global_hooks.rb +7 -7
- data/lib/brightbox-cli/images.rb +13 -14
- data/lib/brightbox-cli/legacy/args_adjuster.rb +5 -6
- data/lib/brightbox-cli/load_balancers.rb +10 -13
- data/lib/brightbox-cli/logging.rb +3 -3
- data/lib/brightbox-cli/nilable_hash.rb +1 -1
- data/lib/brightbox-cli/ruby_core_ext.rb +1 -2
- data/lib/brightbox-cli/server_groups.rb +5 -5
- data/lib/brightbox-cli/servers.rb +9 -9
- data/lib/brightbox-cli/tables.rb +24 -25
- data/lib/brightbox-cli/types.rb +6 -5
- data/lib/brightbox-cli/user_collaboration.rb +2 -3
- data/lib/brightbox-cli/users.rb +3 -3
- data/lib/brightbox-cli/version.rb +1 -1
- data/lib/brightbox_cli.rb +10 -2
- data/locales/en.yml +205 -0
- data/spec/cassettes/Brightbox_Account/_all/when_connected_using_an_application/returns_a_collection_of_Accounts.yml +10 -10
- data/spec/cassettes/Brightbox_Account/_all/when_connected_using_an_application/returns_resources_on_the_same_connection.yml +4 -4
- data/spec/cassettes/Brightbox_Account/_all/when_connected_using_an_client/returns_a_collection_of_Accounts.yml +8 -8
- data/spec/cassettes/Brightbox_Account/_all/when_connected_using_an_client/returns_resources_on_the_same_connection.yml +4 -4
- data/spec/cassettes/Brightbox_BBConfig/_add_section/when_first_and_only_client/saves_changes_to_the_config_file.yml +4 -4
- data/spec/cassettes/Brightbox_BBConfig/_add_section/when_first_and_only_client/saves_the_default_account.yml +4 -4
- data/spec/cassettes/Brightbox_BBConfig/_add_section/when_first_and_only_client/saves_the_new_client_as_the_default.yml +4 -4
- data/spec/cassettes/Brightbox_BBConfig/_find_or_set_default_account/when_client_is_not_authenticated/does_not_raise_an_error.yml +176 -176
- data/spec/cassettes/Brightbox_BBConfig/_find_or_set_default_account/when_client_may_access_one_account/updates_the_setting.yml +176 -176
- data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_config_in_use_is_not_the_default/uses_correct_credentials.yml +2 -2
- data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_using_a_user_app_with_a_cached_refresh_token/caches_the_new_tokens.yml +2 -2
- data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_using_a_user_app_with_an_expired_refresh_token/caches_the_new_tokens.yml +4 -4
- data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_using_a_user_app_with_no_tokens/caches_the_new_tokens.yml +2 -2
- data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_using_a_user_app_with_no_tokens/prompts_user_to_retry_command.yml +2 -2
- data/spec/cassettes/Brightbox_BBConfig/_renew_tokens/when_using_an_API_client_with_no_tokens/caches_a_new_access_token.yml +2 -2
- data/spec/cassettes/Brightbox_CloudIP/_find_all_/when_a_Cloud_IP_exists/returns_a_suitable.yml +28 -28
- data/spec/cassettes/Brightbox_FirewallPolicy/_apply_to/should_apply_firewall_policy.yml +24 -24
- data/spec/cassettes/Brightbox_FirewallPolicy/_create/should_create_firewall_policy.yml +24 -24
- data/spec/cassettes/Brightbox_FirewallPolicy/_destroy/should_destroy_firewall_policy.yml +28 -28
- data/spec/cassettes/Brightbox_FirewallPolicy/_find_all_/when_a_policy_exists/should_list_firewall_policy.yml +24 -24
- data/spec/cassettes/Brightbox_FirewallPolicy/_find_or_call/when_a_policy_exists/should_show_firewall_policy.yml +20 -20
- data/spec/cassettes/Brightbox_FirewallRule/_create/when_policy_exists/creates_the_rule_successfully.yml +24 -24
- data/spec/cassettes/Brightbox_FirewallRule/_destroy/when_rule_exists/destroys_a_rule.yml +20 -20
- data/spec/cassettes/Brightbox_FirewallRule/_find/when_rule_exists/can_display_the_result.yml +24 -24
- data/spec/cassettes/Brightbox_FirewallRule/_from_policy/when_policy_exists_with_a_rule/lists_all_rules.yml +32 -32
- data/spec/cassettes/Brightbox_Server/_destroy/when_server_exists/should_work.yml +20 -20
- data/spec/cassettes/Brightbox_Server/_find_all_/when_a_server_exists/should_print_server_list.yml +28 -28
- data/spec/cassettes/Brightbox_Server/_show/when_server_exists/shows_detailed_attributes_of_a_server.yml +32 -32
- data/spec/cassettes/Brightbox_Server/_shutdown/should_work.yml +32 -32
- data/spec/cassettes/Brightbox_Server/_start/should_work.yml +44 -44
- data/spec/cassettes/Brightbox_Server/_stop/should_work.yml +32 -32
- data/spec/cassettes/Brightbox_Server/_update/when_passing_new_group_membership/should_update_with_group.yml +40 -40
- data/spec/cassettes/Brightbox_ServerGroup/_find_all_/when_a_group_exists/list_server_groups.yml +24 -24
- data/spec/cassettes/Firewall_policies/update/when_the_policy_does_not_exist/prints_error_to_STDERR.yml +6 -6
- data/spec/cassettes/brightbox_accounts/list/_when_access_token_expired_/does_not_report_invalid_token_errors.yml +18 -18
- data/spec/cassettes/brightbox_accounts/list/_when_both_tokens_expired_/does_not_report_invalid_token_errors.yml +18 -18
- data/spec/cassettes/brightbox_accounts/list/_when_invalid_tokens_/does_not_report_invalid_token_errors.yml +18 -18
- data/spec/cassettes/brightbox_accounts/list/_when_no_tokens_/does_not_report_invalid_token_errors.yml +16 -16
- data/spec/cassettes/brightbox_accounts/list/_when_no_tokens_/reports_they_were_updated.yml +14 -14
- data/spec/cassettes/brightbox_accounts/list/_when_no_tokens_and_password_incorrect_/does_not_report_invalid_token_errors.yml +14 -14
- data/spec/cassettes/brightbox_accounts/list/_when_no_tokens_and_password_incorrect_/reports_unable_to_authenticate.yml +12 -12
- data/spec/cassettes/brightbox_accounts/list/does_not_error.yml +6 -6
- data/spec/cassettes/brightbox_cloudips/map/when_destination_is_a_server_ID/passes_the_interface_identifier_to_the_API.yml +542 -0
- data/spec/cassettes/brightbox_cloudips/map/when_destination_is_another_value/passes_the_identifier_to_the_API.yml +317 -0
- data/spec/cassettes/brightbox_config/client_add/when_adding_a_new_client/does_not_error.yml +154 -154
- data/spec/cassettes/brightbox_config/client_add/when_adding_a_new_client/sets_up_the_config.yml +154 -154
- data/spec/cassettes/brightbox_config/client_add/when_new_client_is_first_and_only_client/does_not_change_the_default_client.yml +154 -154
- data/spec/cassettes/brightbox_config/client_add/when_new_client_is_first_and_only_client/does_not_error.yml +154 -154
- data/spec/cassettes/brightbox_config/client_add/when_new_client_is_first_and_only_client/sets_this_as_the_default_client.yml +154 -154
- data/spec/cassettes/brightbox_config/client_add/when_new_client_is_first_and_only_client/sets_up_the_config.yml +154 -154
- data/spec/cassettes/brightbox_config/user_add/when_NO_config_file_on_disk/sets_up_the_config.yml +10 -10
- data/spec/cassettes/brightbox_config/user_add/when_a_default_client_is_already_set/does_not_change_the_default_client.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_application_details_in_config/does_not_error.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_application_details_in_config/sets_up_the_config.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_application_has_access_only_one_active_account/display_an_warning_about_preselected_default.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_application_has_access_only_one_active_account/does_not_error.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_application_has_access_only_one_active_account/selects_the_active_account_for_the_default.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_application_has_access_only_one_active_account/sets_up_the_config.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_application_has_access_to_multiple_accounts/display_an_warning_about_preselected_default.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_application_has_access_to_multiple_accounts/does_not_error.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_application_has_access_to_multiple_accounts/sets_up_the_config.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_new_client_is_first_and_only_client/does_not_error.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_new_client_is_first_and_only_client/does_not_prompt_to_rerun_the_command.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_new_client_is_first_and_only_client/requests_access_tokens.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_new_client_is_first_and_only_client/sets_this_as_the_default_client.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_new_client_is_first_and_only_client/sets_up_the_config.yml +10 -10
- data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments/does_not_error.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments/does_not_prompt_to_rerun_the_command.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments/requests_access_tokens.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments/sets_up_the_config.yml +6 -6
- data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments_and_api_url/does_not_error.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments_and_api_url/requests_access_tokens.yml +4 -4
- data/spec/cassettes/brightbox_config/user_add/when_passing_in_required_arguments_and_api_url/sets_up_the_config.yml +4 -4
- data/spec/cassettes/brightbox_database-servers/create/--allow-access_10_0_0_0/correctly_sends_API_parameters.yml +93 -0
- data/spec/cassettes/brightbox_database-servers/create/--allow-access_srv-12345_grp-12345/correctly_sends_API_parameters.yml +93 -0
- data/spec/cassettes/brightbox_database-servers/create/--engine_mysql/correctly_sends_API_parameters.yml +93 -0
- data/spec/cassettes/brightbox_database-servers/create/--engine_mysql_--engine-version_5_6/correctly_sends_API_parameters.yml +93 -0
- data/spec/cassettes/brightbox_database-servers/create/without_arguments/reports_the_new_admin_password.yml +93 -0
- data/spec/cassettes/brightbox_database-servers/create/without_arguments/reports_the_new_admin_username.yml +93 -0
- data/spec/cassettes/brightbox_database-servers/snapshot/when_database_server_active/correctly_sends_API_parameters.yml +181 -0
- data/spec/cassettes/brightbox_database-servers/snapshot/when_database_server_can_not_be_snapshotted/reports_an_error_to_the_user.yml +91 -0
- data/spec/cassettes/brightbox_database-snapshots/list/when_resources_are_available/does_not_output_to_stderr.yml +93 -0
- data/spec/cassettes/brightbox_database-snapshots/list/when_resources_are_available/outputs_table_details_to_stdout.yml +93 -0
- data/spec/cassettes/brightbox_database-snapshots/show/when_resource_exists/does_not_output_to_stderr.yml +93 -0
- data/spec/commands/accounts/list_spec.rb +1 -1
- data/spec/commands/cloudips/map_spec.rb +23 -4
- data/spec/commands/config/user_add_spec.rb +1 -1
- data/spec/commands/sql/instances/create_spec.rb +69 -0
- data/spec/commands/sql/instances/snapshot_spec.rb +36 -0
- data/spec/commands/sql/snapshots/list_spec.rb +29 -0
- data/spec/commands/sql/snapshots/show_spec.rb +29 -0
- data/spec/commands/sql/types/list_spec.rb +18 -0
- data/spec/spec_helper.rb +1 -3
- data/spec/support/vcr.rb +1 -1
- data/spec/unit/brightbox/api/conn_spec.rb +1 -1
- data/spec/unit/brightbox/bb_config/add_section_spec.rb +1 -1
- data/spec/unit/brightbox/bb_config/renew_tokens_spec.rb +1 -1
- data/spec/unit/brightbox/database_server_spec.rb +9 -0
- data/spec/unit/brightbox/database_snapshot_spec.rb +9 -0
- data/spec/unit/brightbox/database_type_spec.rb +9 -0
- data/spec/unit/brightbox/firewall_policy/create_spec.rb +1 -1
- data/spec/unit/brightbox/firewall_policy/destroy_spec.rb +1 -1
- data/spec/unit/brightbox/firewall_rule/create_spec.rb +1 -1
- data/spec/unit/brightbox/firewall_rule/destroy_spec.rb +1 -1
- data/spec/unit/brightbox/firewall_rule/find_spec.rb +1 -1
- data/spec/unit/brightbox/firewall_rule/from_policy_spec.rb +1 -1
- data/spec/unit/brightbox/server/destroy_spec.rb +1 -1
- data/spec/unit/brightbox/server/find_or_call_spec.rb +1 -1
- data/spec/unit/brightbox/server/shutdown_spec.rb +1 -1
- data/spec/unit/brightbox/server/start_spec.rb +1 -1
- data/spec/unit/brightbox/server/stop_spec.rb +1 -1
- data/spec/unit/brightbox/server/update_spec.rb +1 -1
- data/spec/unit/brightbox/server_group/find_spec.rb +1 -1
- data/spec/unit/brightbox/user_collaboration/get_for_account_spec.rb +3 -3
- metadata +160 -115
- data/lib/brightbox-cli/commands/groups-list.rb +0 -21
- data/lib/brightbox-cli/commands/users-list.rb +0 -25
@@ -0,0 +1,36 @@
|
|
1
|
+
module Brightbox
|
2
|
+
class DatabaseSnapshot < Api
|
3
|
+
def self.require_account?
|
4
|
+
true
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.all
|
8
|
+
conn.database_snapshots.all
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.get(id)
|
12
|
+
conn.database_snapshots.get(id)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(options)
|
16
|
+
self.class.conn.update_database_snapshot(id, options)
|
17
|
+
reload
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def destroy
|
22
|
+
fog_model.destroy
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.default_field_order
|
26
|
+
[:id, :status, :created_on, :name]
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_row
|
30
|
+
a = fog_model.attributes
|
31
|
+
a[:status] = fog_model.state
|
32
|
+
a[:created_on] = fog_model.created_at.strftime("%Y-%m-%d")
|
33
|
+
a
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Brightbox
|
2
|
+
class DatabaseType < Api
|
3
|
+
def self.require_account?; true; end
|
4
|
+
|
5
|
+
def attributes
|
6
|
+
o = fog_model.attributes
|
7
|
+
o[:ram] = ram
|
8
|
+
o[:disk] = disk
|
9
|
+
o
|
10
|
+
end
|
11
|
+
|
12
|
+
def ram
|
13
|
+
fog_model.ram.to_i
|
14
|
+
end
|
15
|
+
|
16
|
+
def disk
|
17
|
+
fog_model.disk.to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_row
|
21
|
+
attributes
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.all
|
25
|
+
conn.database_types
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.get(id)
|
29
|
+
conn.database_types.get id
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.default_field_order
|
33
|
+
[:id, :name, :ram, :disk]
|
34
|
+
end
|
35
|
+
|
36
|
+
def <=>(other)
|
37
|
+
if other.is_a? DatabaseType
|
38
|
+
ram <=> other.ram
|
39
|
+
else
|
40
|
+
ram <=> other
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -19,15 +19,15 @@ module Brightbox
|
|
19
19
|
row_attributes[:arch] = image.arch
|
20
20
|
end
|
21
21
|
|
22
|
-
row_attributes[:private_ips] = interfaces.
|
23
|
-
row_attributes[:ipv6_address] = interfaces.
|
22
|
+
row_attributes[:private_ips] = interfaces.map { |i| i['ipv4_address'] }.join(", ")
|
23
|
+
row_attributes[:ipv6_address] = interfaces.map { |i| i['ipv6_address'] }.join(", ")
|
24
24
|
|
25
|
-
row_attributes[:cloud_ip_ids] = cloud_ips.
|
26
|
-
row_attributes[:cloud_ips] = cloud_ips.
|
27
|
-
row_attributes[:snapshots] = snapshots.
|
25
|
+
row_attributes[:cloud_ip_ids] = cloud_ips.map { |i| i['id'] }.join(", ")
|
26
|
+
row_attributes[:cloud_ips] = cloud_ips.map { |i| i['public_ip'] }.join(", ")
|
27
|
+
row_attributes[:snapshots] = snapshots.map { |i| i['id'] }.join(", ")
|
28
28
|
|
29
29
|
if server_groups
|
30
|
-
row_attributes[:server_groups] = server_groups.map { |sg| sg['id']}.join(", ")
|
30
|
+
row_attributes[:server_groups] = server_groups.map { |sg| sg['id'] }.join(", ")
|
31
31
|
end
|
32
32
|
|
33
33
|
row_attributes
|
@@ -56,7 +56,8 @@ module Brightbox
|
|
56
56
|
:ipv6_address,
|
57
57
|
:cloud_ip_ids,
|
58
58
|
:hostname,
|
59
|
-
:fqdn
|
59
|
+
:fqdn,
|
60
|
+
:public_hostname,
|
60
61
|
:ipv6_hostname,
|
61
62
|
:snapshots,
|
62
63
|
:server_groups
|
@@ -17,15 +17,19 @@ module Brightbox
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def parse_http_error(e)
|
20
|
-
if e.respond_to?(:response)
|
21
|
-
|
22
|
-
|
20
|
+
if e.respond_to?(:response) && e.response.respond_to?(:body)
|
21
|
+
begin
|
22
|
+
json_response = MultiJson.load(e.response.body)
|
23
|
+
extract_response_from_json(json_response, e)
|
24
|
+
rescue
|
25
|
+
{}
|
26
|
+
end
|
23
27
|
else
|
24
28
|
error "ERROR: #{e}"
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
28
|
-
def extract_response_from_json(error_json,e)
|
32
|
+
def extract_response_from_json(error_json, e)
|
29
33
|
json_error = error_json['errors'] || error_json['error']
|
30
34
|
if json_error && !json_error.empty?
|
31
35
|
error_string = Array(json_error).join(" ")
|
@@ -12,9 +12,9 @@ module Brightbox
|
|
12
12
|
conn.firewall_rules.get(id)
|
13
13
|
end
|
14
14
|
|
15
|
-
def update
|
15
|
+
def update(params)
|
16
16
|
self.class.conn.update_firewall_rule id, params
|
17
|
-
|
17
|
+
reload
|
18
18
|
self
|
19
19
|
end
|
20
20
|
|
@@ -29,18 +29,18 @@ module Brightbox
|
|
29
29
|
|
30
30
|
def to_row
|
31
31
|
attrs = attributes.dup
|
32
|
-
[:protocol
|
32
|
+
[:protocol, :source, :sport, :destination, :dport, :icmp_type].each do |key|
|
33
33
|
attrs[key] = attributes[key] || '-'
|
34
34
|
end
|
35
35
|
attrs
|
36
36
|
end
|
37
37
|
|
38
|
-
def ret_val(attributes,key)
|
38
|
+
def ret_val(attributes, key)
|
39
39
|
attributes[key] || "-"
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.default_field_order
|
43
|
-
[:id, :protocol
|
43
|
+
[:id, :protocol, :source, :sport, :destination, :dport, :icmp_type, :description]
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -16,11 +16,10 @@ module Brightbox
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.modify_keys(object, &modifier) #:nodoc:
|
19
|
-
object.
|
20
|
-
new_key
|
19
|
+
object.reduce({}) do |result, (key, value)|
|
20
|
+
new_key = modifier.call(key)
|
21
21
|
result.merge! new_key => value
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
25
24
|
end
|
26
25
|
end
|
@@ -5,15 +5,15 @@ module Brightbox
|
|
5
5
|
|
6
6
|
subcommand_option_handling :normal
|
7
7
|
|
8
|
-
# FIXME The official "commands_from" uses require which is slower
|
8
|
+
# FIXME: The official "commands_from" uses require which is slower
|
9
9
|
# than require_relative when running under ruby gems. So we'll just
|
10
10
|
# implement this ourselves.
|
11
11
|
#
|
12
12
|
# Need to locate the source of double loading under Aruba
|
13
13
|
#
|
14
|
-
subcommand_files = Dir.glob(File.expand_path("../commands
|
15
|
-
subcommand_files.sort.each do |
|
16
|
-
|
14
|
+
subcommand_files = Dir.glob(File.expand_path("../commands/**/*.rb", __FILE__))
|
15
|
+
subcommand_files.sort.each do |cmd_file|
|
16
|
+
require cmd_file
|
17
17
|
end
|
18
18
|
|
19
19
|
sort_help :manually
|
@@ -54,7 +54,7 @@ module Brightbox
|
|
54
54
|
|
55
55
|
Excon.defaults[:headers]['User-Agent'] ||= "brightbox-cli/#{Brightbox::VERSION}"
|
56
56
|
|
57
|
-
if global_options[:k]
|
57
|
+
if global_options[:k] || ENV["INSECURE"]
|
58
58
|
Excon.defaults[:ssl_verify_peer] = false
|
59
59
|
end
|
60
60
|
|
@@ -85,7 +85,7 @@ module Brightbox
|
|
85
85
|
$config.save
|
86
86
|
rescue BBConfigError
|
87
87
|
rescue StandardError => e
|
88
|
-
# FIXME Other StandardErrors are available
|
88
|
+
# FIXME: Other StandardErrors are available
|
89
89
|
warn "Error writing auth token #{$config.access_token_filename}: #{e.class}: #{e}"
|
90
90
|
end
|
91
91
|
end
|
@@ -96,7 +96,7 @@ module Brightbox
|
|
96
96
|
begin
|
97
97
|
debug "Refused access token: #{$config.access_token}"
|
98
98
|
returned = $config.reauthenticate
|
99
|
-
# FIXME Curious output from info
|
99
|
+
# FIXME: Curious output from info
|
100
100
|
info "Your API credentials have been updated, please re-run your command."
|
101
101
|
returned
|
102
102
|
rescue Brightbox::Api::ApiError
|
data/lib/brightbox-cli/images.rb
CHANGED
@@ -19,7 +19,7 @@ module Brightbox
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# Filter out images that are not of the right type, account or status if the option is passed
|
22
|
-
def self.filter_images(images, options={})
|
22
|
+
def self.filter_images(images, options = {})
|
23
23
|
# Remove images that don't match the given type
|
24
24
|
if options[:t]
|
25
25
|
images.reject! { |i| i.type != options[:t] }
|
@@ -41,7 +41,7 @@ module Brightbox
|
|
41
41
|
|
42
42
|
unless options[:a]
|
43
43
|
account = Account.conn.account
|
44
|
-
images.reject! { |i| !i.official
|
44
|
+
images.reject! { |i| !i.official && i.owner_id != account.id }
|
45
45
|
end
|
46
46
|
|
47
47
|
snapshots = images.select { |i| i.source_type == 'snapshot' }
|
@@ -52,9 +52,9 @@ module Brightbox
|
|
52
52
|
images + snapshots
|
53
53
|
end
|
54
54
|
|
55
|
-
def update
|
55
|
+
def update(options)
|
56
56
|
self.class.conn.update_image(id, options)
|
57
|
-
|
57
|
+
reload
|
58
58
|
self
|
59
59
|
end
|
60
60
|
|
@@ -68,7 +68,7 @@ module Brightbox
|
|
68
68
|
|
69
69
|
def status
|
70
70
|
if fog_model.attributes[:status] == "available"
|
71
|
-
public ? 'public' : 'private'
|
71
|
+
public? ? 'public' : 'private'
|
72
72
|
else
|
73
73
|
fog_model.attributes[:status]
|
74
74
|
end
|
@@ -85,7 +85,7 @@ module Brightbox
|
|
85
85
|
o[:owner] = "brightbox" if official
|
86
86
|
o[:type] = type
|
87
87
|
o[:created_at] = created_at
|
88
|
-
o[:created_on] =
|
88
|
+
o[:created_on] = created_on
|
89
89
|
o[:description] = description if description
|
90
90
|
o[:licence_name] = licence_name
|
91
91
|
o[:size] = virtual_size
|
@@ -97,9 +97,9 @@ module Brightbox
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def status_sort_code
|
100
|
-
case
|
100
|
+
case status
|
101
101
|
when 'available'
|
102
|
-
(
|
102
|
+
(public? ? 1 : 2)
|
103
103
|
when 'deprecated'
|
104
104
|
3
|
105
105
|
else
|
@@ -109,13 +109,12 @@ module Brightbox
|
|
109
109
|
|
110
110
|
def default_sort_fields
|
111
111
|
[
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
-
|
112
|
+
official ? 0 : 1,
|
113
|
+
name,
|
114
|
+
arch,
|
115
|
+
status_sort_code,
|
116
|
+
- created_at.to_i
|
117
117
|
]
|
118
118
|
end
|
119
|
-
|
120
119
|
end
|
121
120
|
end
|
@@ -2,7 +2,6 @@ require "optparse"
|
|
2
2
|
|
3
3
|
module Brightbox
|
4
4
|
module Legacy
|
5
|
-
|
6
5
|
# This is a simple class to take the ARGV array and inject a command in the
|
7
6
|
# correct position (after global options but before anything else)
|
8
7
|
#
|
@@ -17,11 +16,11 @@ module Brightbox
|
|
17
16
|
@globals = []
|
18
17
|
|
19
18
|
parser = OptionParser.new do |opts|
|
20
|
-
opts.on("-v", "--version") {|op| @globals << "-v" }
|
21
|
-
opts.on("-s", "--simple") {|op| @globals << "-s" }
|
22
|
-
opts.on("-k", "--insecure") {|op| @globals << "-k" }
|
23
|
-
opts.on("-c", "--client CLIENT") {|op| @globals << "-c" << op }
|
24
|
-
opts.on("--account ACCOUNT") {|op| @globals << "--account" << op }
|
19
|
+
opts.on("-v", "--version") { |op| @globals << "-v" }
|
20
|
+
opts.on("-s", "--simple") { |op| @globals << "-s" }
|
21
|
+
opts.on("-k", "--insecure") { |op| @globals << "-k" }
|
22
|
+
opts.on("-c", "--client CLIENT") { |op| @globals << "-c" << op }
|
23
|
+
opts.on("--account ACCOUNT") { |op| @globals << "--account" << op }
|
25
24
|
end
|
26
25
|
|
27
26
|
remaining = parser.order(@args)
|
@@ -11,7 +11,9 @@ module Brightbox
|
|
11
11
|
|
12
12
|
def to_row
|
13
13
|
attributes.merge(
|
14
|
+
:ssl_issuer => certificate_issuer,
|
14
15
|
:ssl_subject => certificate_subject,
|
16
|
+
:ssl_valid_from => certificate_valid_from,
|
15
17
|
:ssl_expires_at => certificate_expires_at,
|
16
18
|
:nodes => node_ids,
|
17
19
|
:created_on => created_on,
|
@@ -20,25 +22,21 @@ module Brightbox
|
|
20
22
|
)
|
21
23
|
end
|
22
24
|
|
23
|
-
def created_on
|
24
|
-
attributes["created_at"].to_s.split('T').first
|
25
|
-
end
|
26
|
-
|
27
25
|
def node_ids
|
28
|
-
@node_ids ||= attributes[:nodes].
|
26
|
+
@node_ids ||= attributes[:nodes].map { |n| n["id"] } if attributes[:nodes]
|
29
27
|
end
|
30
28
|
|
31
29
|
def cloud_ip_ids
|
32
|
-
@cloud_ip_ids ||= attributes["cloud_ips"].
|
30
|
+
@cloud_ip_ids ||= attributes["cloud_ips"].map { |n| n["id"] } if attributes["cloud_ips"]
|
33
31
|
end
|
34
32
|
|
35
33
|
def cloud_ips
|
36
|
-
@cloud_ips ||= attributes["cloud_ips"].
|
34
|
+
@cloud_ips ||= attributes["cloud_ips"].map { |n| n["public_ip"] } if attributes["cloud_ips"]
|
37
35
|
end
|
38
36
|
|
39
37
|
def listeners
|
40
38
|
if attributes[:listeners]
|
41
|
-
attributes[:listeners].
|
39
|
+
attributes[:listeners].map { |l| [l["in"], l["out"], l["protocol"], l['timeout']].join(":") }
|
42
40
|
else
|
43
41
|
nil
|
44
42
|
end
|
@@ -46,23 +44,23 @@ module Brightbox
|
|
46
44
|
|
47
45
|
def destroy
|
48
46
|
fog_model.destroy
|
49
|
-
rescue Excon::Errors::Conflict
|
47
|
+
rescue Excon::Errors::Conflict
|
50
48
|
raise Conflict, "Cannot delete load balancer #{id}"
|
51
49
|
end
|
52
50
|
|
53
51
|
def add_nodes(nodes)
|
54
|
-
node_hashes = nodes.
|
52
|
+
node_hashes = nodes.map { |n| { :node => n.id } }
|
55
53
|
LoadBalancer.conn.add_nodes_load_balancer(id, :nodes => node_hashes)
|
56
54
|
end
|
57
55
|
|
58
56
|
def remove_nodes(nodes)
|
59
|
-
node_hashes = nodes.
|
57
|
+
node_hashes = nodes.map { |n| { :node => n.id } }
|
60
58
|
LoadBalancer.conn.remove_nodes_load_balancer(id, :nodes => node_hashes)
|
61
59
|
end
|
62
60
|
|
63
61
|
def update(options)
|
64
62
|
LoadBalancer.conn.update_load_balancer(id, options)
|
65
|
-
|
63
|
+
reload
|
66
64
|
self
|
67
65
|
end
|
68
66
|
|
@@ -77,6 +75,5 @@ module Brightbox
|
|
77
75
|
def self.default_field_order
|
78
76
|
[:id, :status, :created_on, :cloud_ips, :nodes, :name]
|
79
77
|
end
|
80
|
-
|
81
78
|
end
|
82
79
|
end
|
@@ -6,19 +6,19 @@ module Brightbox
|
|
6
6
|
end
|
7
7
|
|
8
8
|
module MixinMethods
|
9
|
-
def error(s=
|
9
|
+
def error(s = "")
|
10
10
|
$stderr.write s
|
11
11
|
$stderr.write "\n"
|
12
12
|
$stderr.flush
|
13
13
|
end
|
14
14
|
|
15
|
-
def info(s=
|
15
|
+
def info(s = "")
|
16
16
|
$stderr.write s
|
17
17
|
$stderr.write "\n"
|
18
18
|
$stderr.flush
|
19
19
|
end
|
20
20
|
|
21
|
-
def warn(s=
|
21
|
+
def warn(s = "")
|
22
22
|
info "WARN: #{s}"
|
23
23
|
end
|
24
24
|
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class Time
|
2
|
-
|
3
2
|
# Returns a shortened version of ISO 8601 omitting the seconds and timezone
|
4
3
|
# information.
|
5
4
|
#
|
@@ -9,7 +8,7 @@ class Time
|
|
9
8
|
# @return [String] A clipped form of date, ISO 8601 without seconds
|
10
9
|
#
|
11
10
|
def clipped_iso_8601
|
12
|
-
|
11
|
+
strftime(self.utc? ? "%Y-%m-%dT%H:%MZ" : "%Y-%m-%dT%H:%M")
|
13
12
|
end
|
14
13
|
|
15
14
|
def to_s
|