brightbox-cli 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +25 -23
- data/Rakefile +1 -1
- data/bin/_brightbox-bash-completer +327 -328
- data/bin/brightbox +2 -2
- data/bin/brightbox-accounts +2 -2
- data/bin/brightbox-cloudips +2 -2
- data/bin/brightbox-config +2 -2
- data/bin/brightbox-firewall-policies +2 -2
- data/bin/brightbox-firewall-rules +2 -2
- data/bin/brightbox-groups +2 -2
- data/bin/brightbox-images +2 -2
- data/bin/brightbox-lbs +2 -2
- data/bin/brightbox-servers +2 -2
- data/bin/brightbox-types +2 -2
- data/bin/brightbox-users +2 -2
- data/bin/brightbox-zones +2 -2
- data/brightbox-cli.gemspec +14 -15
- data/lib/brightbox-cli/api.rb +4 -6
- data/lib/brightbox-cli/collaboration.rb +1 -3
- data/lib/brightbox-cli/commands/accounts/accept-invite.rb +1 -1
- data/lib/brightbox-cli/commands/accounts/default.rb +1 -1
- data/lib/brightbox-cli/commands/accounts/list.rb +1 -1
- data/lib/brightbox-cli/commands/accounts/remove.rb +1 -1
- data/lib/brightbox-cli/commands/accounts/reset-ftp-password.rb +1 -1
- data/lib/brightbox-cli/commands/accounts/show.rb +1 -1
- data/lib/brightbox-cli/commands/cloudips/create.rb +1 -1
- data/lib/brightbox-cli/commands/cloudips/destroy.rb +1 -1
- data/lib/brightbox-cli/commands/cloudips/list.rb +1 -1
- data/lib/brightbox-cli/commands/cloudips/show.rb +1 -1
- data/lib/brightbox-cli/commands/cloudips/unmap.rb +1 -1
- data/lib/brightbox-cli/commands/collaborations.rb +4 -4
- data/lib/brightbox-cli/commands/config/client-add.rb +1 -1
- data/lib/brightbox-cli/commands/config/client-default.rb +1 -1
- data/lib/brightbox-cli/commands/config/client-list.rb +1 -1
- data/lib/brightbox-cli/commands/config/client-remove.rb +1 -1
- data/lib/brightbox-cli/commands/config/user-add.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies-destroy.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies-list.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies-show.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/rules-destroy.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/rules-list.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/rules-show.rb +1 -1
- data/lib/brightbox-cli/commands/groups/add-server.rb +1 -1
- data/lib/brightbox-cli/commands/groups/create.rb +1 -1
- data/lib/brightbox-cli/commands/groups/destroy.rb +1 -1
- data/lib/brightbox-cli/commands/groups/list.rb +1 -1
- data/lib/brightbox-cli/commands/groups/show.rb +1 -1
- data/lib/brightbox-cli/commands/images/destroy.rb +1 -1
- data/lib/brightbox-cli/commands/images/locking.rb +37 -0
- data/lib/brightbox-cli/commands/images/register.rb +1 -1
- data/lib/brightbox-cli/commands/images/show.rb +18 -4
- data/lib/brightbox-cli/commands/lbs/add-nodes.rb +1 -1
- data/lib/brightbox-cli/commands/lbs/destroy.rb +1 -1
- data/lib/brightbox-cli/commands/lbs/list.rb +1 -1
- data/lib/brightbox-cli/commands/lbs/locking.rb +37 -0
- data/lib/brightbox-cli/commands/lbs/remove-nodes.rb +1 -1
- data/lib/brightbox-cli/commands/lbs/show.rb +3 -2
- data/lib/brightbox-cli/commands/servers/activate-console.rb +1 -1
- data/lib/brightbox-cli/commands/servers/destroy.rb +1 -1
- data/lib/brightbox-cli/commands/servers/locking.rb +37 -0
- data/lib/brightbox-cli/commands/servers/reboot.rb +20 -0
- data/lib/brightbox-cli/commands/servers/reset.rb +20 -0
- data/lib/brightbox-cli/commands/servers/show.rb +1 -1
- data/lib/brightbox-cli/commands/servers/shutdown.rb +1 -1
- data/lib/brightbox-cli/commands/servers/snapshot.rb +1 -1
- data/lib/brightbox-cli/commands/servers/start.rb +1 -1
- data/lib/brightbox-cli/commands/servers/stop.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_create.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_destroy.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_list.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_locking.rb +39 -0
- data/lib/brightbox-cli/commands/sql/instances_reset_password.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_show.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_snapshot.rb +1 -1
- data/lib/brightbox-cli/commands/sql/snapshots_destroy.rb +1 -1
- data/lib/brightbox-cli/commands/sql/snapshots_list.rb +1 -1
- data/lib/brightbox-cli/commands/sql/snapshots_locking.rb +39 -0
- data/lib/brightbox-cli/commands/sql/snapshots_show.rb +9 -2
- data/lib/brightbox-cli/commands/sql/types.rb +2 -2
- data/lib/brightbox-cli/commands/types.rb +2 -2
- data/lib/brightbox-cli/commands/user-collaborations.rb +2 -2
- data/lib/brightbox-cli/commands/users/list.rb +1 -1
- data/lib/brightbox-cli/commands/users/show.rb +1 -1
- data/lib/brightbox-cli/commands/zones.rb +1 -1
- data/lib/brightbox-cli/config/accounts.rb +1 -1
- data/lib/brightbox-cli/config/api_client.rb +3 -3
- data/lib/brightbox-cli/config/authentication_tokens.rb +2 -2
- data/lib/brightbox-cli/config/cache.rb +1 -1
- data/lib/brightbox-cli/config/dirty.rb +1 -1
- data/lib/brightbox-cli/config/user_application.rb +3 -3
- data/lib/brightbox-cli/config.rb +2 -2
- data/lib/brightbox-cli/database_server.rb +2 -1
- data/lib/brightbox-cli/database_snapshot.rb +1 -0
- data/lib/brightbox-cli/detailed_server.rb +1 -0
- data/lib/brightbox-cli/gli_global_hooks.rb +2 -2
- data/lib/brightbox-cli/images.rb +2 -1
- data/lib/brightbox-cli/legacy/args_adjuster.rb +3 -3
- data/lib/brightbox-cli/load_balancers.rb +1 -0
- data/lib/brightbox-cli/servers.rb +2 -1
- data/lib/brightbox-cli/user_collaboration.rb +1 -1
- data/lib/brightbox-cli/version.rb +1 -1
- data/lib/brightbox_cli.rb +3 -3
- data/locales/en.yml +24 -0
- data/spec/commands/accounts/default_spec.rb +2 -2
- data/spec/commands/accounts/list_spec.rb +7 -7
- data/spec/commands/accounts/reset_ftp_password_spec.rb +2 -2
- data/spec/commands/accounts/show_spec.rb +2 -2
- data/spec/commands/cloudips/create_spec.rb +2 -2
- data/spec/commands/cloudips/destroy_spec.rb +2 -2
- data/spec/commands/cloudips/list_spec.rb +2 -2
- data/spec/commands/cloudips/map_spec.rb +3 -3
- data/spec/commands/cloudips/show_spec.rb +2 -2
- data/spec/commands/cloudips/unmap_spec.rb +2 -2
- data/spec/commands/cloudips/update_spec.rb +2 -2
- data/spec/commands/config/client_add_spec.rb +2 -2
- data/spec/commands/config/client_default_spec.rb +2 -2
- data/spec/commands/config/client_list_spec.rb +2 -2
- data/spec/commands/config/client_remove_spec.rb +2 -2
- data/spec/commands/config/user_add_spec.rb +3 -6
- data/spec/commands/firewall_policies/update_spec.rb +7 -7
- data/spec/commands/groups/add_server_spec.rb +2 -2
- data/spec/commands/groups/create_spec.rb +2 -2
- data/spec/commands/groups/destroy_spec.rb +2 -2
- data/spec/commands/groups/list_spec.rb +2 -2
- data/spec/commands/groups/move_servers_spec.rb +2 -2
- data/spec/commands/groups/remove_servers_spec.rb +2 -2
- data/spec/commands/groups/show_spec.rb +2 -2
- data/spec/commands/groups/update_spec.rb +2 -2
- data/spec/commands/images/destroy_spec.rb +2 -2
- data/spec/commands/images/list_spec.rb +2 -2
- data/spec/commands/images/locking_spec.rb +73 -0
- data/spec/commands/images/register_spec.rb +2 -2
- data/spec/commands/images/show_spec.rb +2 -2
- data/spec/commands/images/update_spec.rb +2 -2
- data/spec/commands/lbs/add_nodes_spec.rb +2 -2
- data/spec/commands/lbs/create_spec.rb +2 -2
- data/spec/commands/lbs/destroy_spec.rb +2 -2
- data/spec/commands/lbs/list_spec.rb +2 -2
- data/spec/commands/lbs/locking_spec.rb +73 -0
- data/spec/commands/lbs/remove_nodes_spec.rb +2 -2
- data/spec/commands/lbs/show_spec.rb +2 -2
- data/spec/commands/lbs/update_spec.rb +2 -2
- data/spec/commands/policies/apply_spec.rb +2 -2
- data/spec/commands/policies/create_spec.rb +2 -2
- data/spec/commands/policies/destroy_spec.rb +2 -2
- data/spec/commands/policies/list_spec.rb +2 -2
- data/spec/commands/policies/remove_spec.rb +2 -2
- data/spec/commands/policies/show_spec.rb +2 -2
- data/spec/commands/policies/update_spec.rb +2 -2
- data/spec/commands/rules/create_spec.rb +2 -2
- data/spec/commands/rules/destroy_spec.rb +2 -2
- data/spec/commands/rules/list_spec.rb +2 -2
- data/spec/commands/rules/show_spec.rb +2 -2
- data/spec/commands/rules/update_spec.rb +2 -2
- data/spec/commands/servers/activate_console_spec.rb +2 -2
- data/spec/commands/servers/create_spec.rb +2 -2
- data/spec/commands/servers/destroy_spec.rb +2 -2
- data/spec/commands/servers/list_spec.rb +2 -2
- data/spec/commands/servers/locking_spec.rb +73 -0
- data/spec/commands/servers/reboot_spec.rb +55 -0
- data/spec/commands/servers/reset_spec.rb +55 -0
- data/spec/commands/servers/show_spec.rb +2 -2
- data/spec/commands/servers/shutdown_spec.rb +2 -2
- data/spec/commands/servers/snapshot_spec.rb +2 -2
- data/spec/commands/servers/start_spec.rb +2 -2
- data/spec/commands/servers/stop_spec.rb +2 -2
- data/spec/commands/servers/update_spec.rb +2 -2
- data/spec/commands/sql/instances/create_spec.rb +4 -4
- data/spec/commands/sql/instances/locking_spec.rb +73 -0
- data/spec/commands/sql/instances/snapshot_spec.rb +2 -2
- data/spec/commands/sql/snapshots/list_spec.rb +1 -1
- data/spec/commands/sql/snapshots/locking_spec.rb +73 -0
- data/spec/commands/sql/snapshots/show_spec.rb +1 -1
- data/spec/commands/sql/types/list_spec.rb +1 -1
- data/spec/commands/types/list_spec.rb +2 -2
- data/spec/commands/users/list_spec.rb +2 -2
- data/spec/commands/users/show_spec.rb +2 -2
- data/spec/commands/users/update_spec.rb +2 -2
- data/spec/commands/zones/list_spec.rb +2 -2
- data/spec/spec_helper.rb +8 -9
- data/spec/support/common_helpers.rb +10 -10
- data/spec/support/config_helpers.rb +0 -1
- data/spec/support/faux_io.rb +10 -14
- data/spec/support/password_prompt_helpers.rb +1 -2
- data/spec/support/server_helper.rb +1 -1
- data/spec/support/shared/api_resource_examples.rb +8 -8
- data/spec/support/shared/collaborating_accounts_context.rb +2 -2
- data/spec/support/shared/config_section_types.rb +2 -2
- data/spec/support/tmp_config.rb +4 -8
- data/spec/support/token_helpers.rb +1 -1
- data/spec/support/vcr.rb +1 -1
- data/spec/unit/brightbox/account/get_spec.rb +1 -1
- data/spec/unit/brightbox/account_spec.rb +3 -3
- data/spec/unit/brightbox/api/find_spec.rb +6 -6
- data/spec/unit/brightbox/api/require_account_spec.rb +1 -1
- data/spec/unit/brightbox/bb_config/account_spec.rb +3 -3
- data/spec/unit/brightbox/bb_config/clear_default_client_spec.rb +8 -8
- data/spec/unit/brightbox/bb_config/client_has_alias_spec.rb +3 -3
- data/spec/unit/brightbox/bb_config/client_name_spec.rb +5 -5
- data/spec/unit/brightbox/bb_config/client_named_spec.rb +6 -6
- data/spec/unit/brightbox/bb_config/config_directory_exists_spec.rb +3 -3
- data/spec/unit/brightbox/bb_config/config_spec.rb +5 -5
- data/spec/unit/brightbox/bb_config/default_account_spec.rb +6 -6
- data/spec/unit/brightbox/bb_config/default_client_spec.rb +2 -2
- data/spec/unit/brightbox/bb_config/find_or_set_default_account_spec.rb +14 -14
- data/spec/unit/brightbox/bb_config/has_multiple_clients_spec.rb +2 -2
- data/spec/unit/brightbox/bb_config/renew_tokens_spec.rb +4 -5
- data/spec/unit/brightbox/bb_config/save_spec.rb +2 -2
- data/spec/unit/brightbox/bb_config/to_fog_spec.rb +2 -2
- data/spec/unit/brightbox/bb_config/using_client_spec.rb +10 -10
- data/spec/unit/brightbox/collaborating_account/resource_type_spec.rb +4 -4
- data/spec/unit/brightbox/collaborating_account_spec.rb +3 -3
- data/spec/unit/brightbox/config/api_client/to_fog_spec.rb +2 -2
- data/spec/unit/brightbox/config/api_client/valid_spec.rb +5 -5
- data/spec/unit/brightbox/config/section_name_deduplicator_spec.rb +1 -1
- data/spec/unit/brightbox/config/to_fog_spec.rb +3 -3
- data/spec/unit/brightbox/config/user_application/to_fog_spec.rb +2 -2
- data/spec/unit/brightbox/config/user_application/valid_spec.rb +6 -6
- data/spec/unit/brightbox/connection_manager/fetch_connection_spec.rb +17 -17
- data/spec/unit/brightbox/firewall_policy/apply_to_spec.rb +3 -3
- data/spec/unit/brightbox/firewall_policy/create_spec.rb +5 -5
- data/spec/unit/brightbox/firewall_policy/destroy_spec.rb +4 -4
- data/spec/unit/brightbox/firewall_policy/find_or_call_spec.rb +1 -1
- data/spec/unit/brightbox/firewall_policy/find_spec.rb +1 -1
- data/spec/unit/brightbox/firewall_rule/create_spec.rb +1 -1
- data/spec/unit/brightbox/firewall_rule/destroy_spec.rb +2 -2
- data/spec/unit/brightbox/firewall_rule/find_spec.rb +3 -3
- data/spec/unit/brightbox/firewall_rule/from_policy_spec.rb +2 -2
- data/spec/unit/brightbox/legacy/args_adjuster_spec.rb +12 -12
- data/spec/unit/brightbox/server/create_spec.rb +2 -2
- data/spec/unit/brightbox/server/destroy_spec.rb +3 -3
- data/spec/unit/brightbox/server/find_or_call_spec.rb +1 -1
- data/spec/unit/brightbox/server/shutdown_spec.rb +2 -4
- data/spec/unit/brightbox/server/start_spec.rb +4 -4
- data/spec/unit/brightbox/server/stop_spec.rb +2 -4
- data/spec/unit/brightbox/server/update_spec.rb +2 -2
- data/spec/unit/brightbox/server_group/find_spec.rb +1 -1
- data/spec/unit/brightbox/user_collaboration/get_for_account_spec.rb +4 -4
- data/spec/unit/brightbox/user_collaboration/remove_spec.rb +11 -11
- data/spec/unit/nilable_hash_spec.rb +6 -6
- data/spec/unit/tmp_config_spec.rb +1 -1
- metadata +67 -31
@@ -6,7 +6,7 @@ require 'shellwords'
|
|
6
6
|
|
7
7
|
class String
|
8
8
|
def shellunescape
|
9
|
-
|
9
|
+
gsub(/\\([^A-Za-z0-9_\-.,:\/@\n])/, '\1')
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -67,7 +67,7 @@ class IcmpTypeName
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def find_network_services
|
70
|
-
File.read("/etc/services").scan(/([0-9]+)\/(tcp|udp)/).
|
70
|
+
File.read("/etc/services").scan(/([0-9]+)\/(tcp|udp)/).map { |tuple| tuple.first }.uniq
|
71
71
|
rescue
|
72
72
|
[]
|
73
73
|
end
|
@@ -78,18 +78,18 @@ end
|
|
78
78
|
|
79
79
|
def find_identifiers(prefix, extras = nil, flag = nil)
|
80
80
|
if prefix.is_a? Array
|
81
|
-
lambda do |c,p|
|
82
|
-
all = prefix.
|
81
|
+
lambda do |c, p|
|
82
|
+
all = prefix.map { |pfx| find_identifiers(pfx, extras, flag).call(c, p) }
|
83
83
|
all += extras if extras.is_a? Array
|
84
84
|
return all.flatten
|
85
85
|
end
|
86
86
|
else
|
87
|
-
lambda do |
|
88
|
-
if (extras == :once
|
87
|
+
lambda do |_cur, prev|
|
88
|
+
if (extras == :once || flag == :once) && prev =~ /^#{prefix}/
|
89
89
|
return []
|
90
90
|
else
|
91
|
-
all = Dir.glob(File.join(ENV['HOME'], '.brightbox', 'cache', prefix+'*'))
|
92
|
-
all.
|
91
|
+
all = Dir.glob(File.join(ENV['HOME'], '.brightbox', 'cache', prefix + '*'))
|
92
|
+
all.map! { |f| File.basename(f) }
|
93
93
|
all += extras if extras.is_a? Array
|
94
94
|
return all
|
95
95
|
end
|
@@ -98,24 +98,24 @@ def find_identifiers(prefix, extras = nil, flag = nil)
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def find_server_types
|
101
|
-
find_identifiers("typ-", %w
|
101
|
+
find_identifiers("typ-", %w(nano mini small medium large xl xxl nano.high-io mini.high-io small.high-io medium.high0io large.high-io xl.high-io xxl.high-io))
|
102
102
|
end
|
103
103
|
|
104
104
|
def find_clients
|
105
|
-
lambda do |
|
105
|
+
lambda do |_c, _p|
|
106
106
|
config = File.read(File.join(ENV['HOME'], '.brightbox', 'config')) rescue []
|
107
107
|
config.scan(/^\[(.*)\]/).flatten - ["core"]
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
def find_zones
|
112
|
-
[find_identifiers("zon-", %w
|
112
|
+
[find_identifiers("zon-", %w(gb1-a gb1-b))]
|
113
113
|
end
|
114
114
|
|
115
115
|
def find_filename
|
116
|
-
lambda do |cur,
|
116
|
+
lambda do |cur, _prev|
|
117
117
|
files = Dir.glob(cur + '*')
|
118
|
-
if files.size == 1
|
118
|
+
if files.size == 1 && File.directory?(files.first)
|
119
119
|
files = [File.join(files.first, '')]
|
120
120
|
files += Dir.glob(File.join(files.first, '*'))
|
121
121
|
end
|
@@ -125,382 +125,381 @@ end
|
|
125
125
|
|
126
126
|
SPEC = { "brightbox" =>
|
127
127
|
{
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
128
|
+
"account-access" =>
|
129
|
+
{
|
130
|
+
"list" => find_identifiers("col-"),
|
131
|
+
"show" => find_identifiers("col-")
|
132
|
+
},
|
133
|
+
"accounts" =>
|
134
134
|
{
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
135
|
+
"accept_invite" => find_identifiers("acc-"),
|
136
|
+
"default" => find_identifiers("acc-"),
|
137
|
+
"list" => true,
|
138
|
+
"remove" => find_identifiers("acc-"),
|
139
|
+
"reset_ftp_password" => find_identifiers("acc-"),
|
140
|
+
"show" => find_identifiers("acc-")
|
141
141
|
},
|
142
|
-
|
142
|
+
"cloudips" =>
|
143
143
|
{
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
144
|
+
"create" =>
|
145
|
+
{
|
146
|
+
"-i=" => "--count=",
|
147
|
+
"--count=" => true,
|
148
|
+
"-n=" => "--name=",
|
149
|
+
"--name=" => true,
|
150
|
+
"-t=" => "--port-translators=",
|
151
|
+
"--port-translators" => true
|
152
|
+
},
|
153
|
+
"update" =>
|
154
154
|
{
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
155
|
+
"-n" => "--name=",
|
156
|
+
"--name=" => true,
|
157
|
+
"-r=" => "--reverse-dns=",
|
158
|
+
"--reverse-dns=" => true,
|
159
|
+
"-t=" => "--port-translators=",
|
160
|
+
"--port-translators=" => true,
|
161
|
+
:include => find_identifiers("cip-")
|
162
162
|
},
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
163
|
+
"destroy" => find_identifiers("cip-"),
|
164
|
+
"list" => find_identifiers("cip-"),
|
165
|
+
"map" => [find_identifiers('cip-'), find_identifiers("srv-"), nil],
|
166
|
+
"show" => find_identifiers("cip-"),
|
167
|
+
"unmap" => find_identifiers("cip-")
|
168
168
|
},
|
169
|
-
|
169
|
+
"collaborators" =>
|
170
170
|
{
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
171
|
+
"invite" => true,
|
172
|
+
"list" => find_identifiers("col-"),
|
173
|
+
"destroy" => find_identifiers("col-"),
|
174
|
+
"resend" => find_identifiers("col-"),
|
175
|
+
"show" => find_identifiers("col-")
|
176
176
|
},
|
177
|
-
|
177
|
+
"config" =>
|
178
178
|
{
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
179
|
+
"client_add" =>
|
180
|
+
{
|
181
|
+
"-a=" => "--alias=",
|
182
|
+
"--alias=" => true,
|
183
|
+
"-t=" => "--auth-url=",
|
184
|
+
"--auth-url=" => true
|
185
|
+
},
|
186
|
+
"client_default" => [find_clients, nil],
|
187
|
+
"client_list" => true,
|
188
|
+
"client_remove" => [find_clients, nil],
|
189
|
+
"user_add" =>
|
190
190
|
{
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
191
|
+
"-a=" => "--alias=",
|
192
|
+
"--alias=" => true,
|
193
|
+
"-p=" => "--password=",
|
194
|
+
"--password=" => true
|
195
195
|
}
|
196
196
|
},
|
197
|
-
|
197
|
+
"firewall-policies" =>
|
198
198
|
{
|
199
|
-
|
200
|
-
|
201
|
-
|
199
|
+
"list" => find_identifiers("fwp-"),
|
200
|
+
"apply" => [find_identifiers("fwp-"), find_identifiers("grp-"), nil],
|
201
|
+
"create" =>
|
202
202
|
{
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
203
|
+
"-d=" => "--description=",
|
204
|
+
"--description=" => true,
|
205
|
+
"-n=" => "--name=",
|
206
|
+
"--name=" => true,
|
207
|
+
:include => find_identifiers("grp-")
|
208
208
|
},
|
209
|
-
|
209
|
+
"update" =>
|
210
210
|
{
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
211
|
+
"-d=" => "--description=",
|
212
|
+
"--description=" => true,
|
213
|
+
"-n=" => "--name=",
|
214
|
+
"--name=" => true,
|
215
|
+
:include => find_identifiers("fwp-")
|
216
216
|
},
|
217
|
-
|
218
|
-
|
219
|
-
|
217
|
+
"destroy" => find_identifiers("fwp-"),
|
218
|
+
"remove" => [find_identifiers("fwp-"), find_identifiers("grp-"), nil],
|
219
|
+
"show" => find_identifiers("fwp-")
|
220
220
|
},
|
221
|
-
|
221
|
+
"firewall-rules" =>
|
222
222
|
{
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
223
|
+
"create" =>
|
224
|
+
{
|
225
|
+
"-d=" => "--destination",
|
226
|
+
"--destination=" => [find_identifiers(%w(grp- srv-), %w(any))],
|
227
|
+
"-s=" => "--source",
|
228
|
+
"--source=" => [find_identifiers(%w(grp- srv-), %w(any))],
|
229
|
+
"-e=" => "--dport=",
|
230
|
+
"--dport=" => [find_network_services],
|
231
|
+
"-t=" => "--sport=",
|
232
|
+
"--sport=" => true,
|
233
|
+
"-i=" => "--icmptype=",
|
234
|
+
"--icmptype=" => [find_icmp_types],
|
235
|
+
"-p=" => "--protocol=",
|
236
|
+
"--protocol=" => [%w(tcp udp icmp)]
|
237
|
+
}
|
238
238
|
},
|
239
|
-
|
239
|
+
"groups" =>
|
240
240
|
{
|
241
|
-
|
242
|
-
|
241
|
+
"add_servers" => find_identifiers(%w(grp- srv-)),
|
242
|
+
"create" =>
|
243
243
|
{
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
244
|
+
"-d=" => "--description=",
|
245
|
+
"--description=" => true,
|
246
|
+
"-n=" => "--name=",
|
247
|
+
"--name=" => true
|
248
248
|
},
|
249
|
-
|
249
|
+
"update" =>
|
250
250
|
{
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
251
|
+
"-d=" => "--description=",
|
252
|
+
"--description=" => true,
|
253
|
+
"-n=" => "--name=",
|
254
|
+
"--name=" => true,
|
255
|
+
:include => find_identifiers("grp-")
|
256
256
|
},
|
257
|
-
|
258
|
-
|
259
|
-
|
257
|
+
"destroy" => find_identifiers("grp-"),
|
258
|
+
"list" => find_identifiers("grp-"),
|
259
|
+
"move_servers" =>
|
260
260
|
{
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
261
|
+
"-f=" => "--from=",
|
262
|
+
"--from=" => find_identifiers("grp-"),
|
263
|
+
"-t=" => "--to=",
|
264
|
+
"--to=" => find_identifiers("grp-"),
|
265
|
+
:include => find_identifiers("srv-")
|
266
266
|
},
|
267
|
-
|
267
|
+
"remove_servers" =>
|
268
268
|
{
|
269
|
-
|
270
|
-
|
271
|
-
|
269
|
+
"-a" => "--all",
|
270
|
+
"--all" => true,
|
271
|
+
:include => find_identifiers(%w(grp- srv-))
|
272
272
|
},
|
273
|
-
|
273
|
+
"show" => find_identifiers("grp-")
|
274
274
|
},
|
275
|
-
|
276
|
-
|
275
|
+
"help" => self,
|
276
|
+
"images" =>
|
277
277
|
{
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
278
|
+
"show" => find_identifiers("img-"),
|
279
|
+
"list" => find_identifiers("img-"),
|
280
|
+
"destroy" => find_identifiers("img-"),
|
281
|
+
"register" =>
|
282
282
|
{
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
283
|
+
"-a=" => "--arch=",
|
284
|
+
"--arch=" => [%w(i686 x86_64)],
|
285
|
+
"-d=" => "--description=",
|
286
|
+
"--description=" => true,
|
287
|
+
"-m=" => "--mode",
|
288
|
+
"--mode=" => [%w(virtio compatibility)],
|
289
|
+
"-n=" => "--name=",
|
290
|
+
"--name=" => true,
|
291
|
+
"-p=" => "--public=",
|
292
|
+
"--public=" => [%w(true false)],
|
293
|
+
"-s=" => "--source=",
|
294
|
+
"--source=" => true,
|
295
|
+
"-u=" => "--username=",
|
296
|
+
"--username=" => true
|
297
297
|
},
|
298
|
-
|
298
|
+
"update" =>
|
299
299
|
{
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
}
|
314
|
-
|
300
|
+
"-a=" => "--arch=",
|
301
|
+
"--arch=" => [%w(i686 x86_64)],
|
302
|
+
"-d=" => "--description=",
|
303
|
+
"--description=" => true,
|
304
|
+
"-m=" => "--mode",
|
305
|
+
"--mode=" => [%w(virtio compatibility)],
|
306
|
+
"-n=" => "--name=",
|
307
|
+
"--name=" => true,
|
308
|
+
"-p=" => "--public=",
|
309
|
+
"--public=" => [%w(true false)],
|
310
|
+
"-u=" => "--username=",
|
311
|
+
"--username=" => true,
|
312
|
+
"--deprecated=" => [%w(true false)]
|
313
|
+
}
|
315
314
|
},
|
316
|
-
|
315
|
+
"lbs" =>
|
317
316
|
{
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
317
|
+
"create" =>
|
318
|
+
{
|
319
|
+
"-d=" => "--hc-down=",
|
320
|
+
"--hc-down" => [%w(1 2 3 4 5 7 8 9)],
|
321
|
+
"-u=" => "--hc-up=",
|
322
|
+
"--hc-up=" => [%w(1 2 3 4 5 6 7 8 9)],
|
323
|
+
"-e=" => "--hc-interval=",
|
324
|
+
"--hc-interval=" => [%w(5000 10000 15000)],
|
325
|
+
"-k=" => "--hc-port=",
|
326
|
+
"--hc-port=" => find_network_services,
|
327
|
+
"-l=" => "--listeners=",
|
328
|
+
"--listeners=" => true,
|
329
|
+
"-n=" => "--name=",
|
330
|
+
"--name=" => true,
|
331
|
+
"-p=" => "--policy=",
|
332
|
+
"--policy=" => [%w(least-connections round-robin)],
|
333
|
+
"-s=" => "--hc-request=",
|
334
|
+
"--hc-request=" => true,
|
335
|
+
"-t=" => "--hc-timeout=",
|
336
|
+
"--hc-timeout=" => [%w(5000 10000 15000)],
|
337
|
+
"-y=" => "--hc-type=",
|
338
|
+
"--hc-type=" => [%w(http tcp)],
|
339
|
+
"--ssl-cert" => true,
|
340
|
+
"--ssl-key" => true
|
341
|
+
},
|
342
|
+
"update" =>
|
344
343
|
{
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
344
|
+
"-d=" => "--hc-down=",
|
345
|
+
"--hc-down" => [%w(1 2 3 4 5 7 8 9)],
|
346
|
+
"-u=" => "--hc-up=",
|
347
|
+
"--hc-up=" => [%w(1 2 3 4 5 6 7 8 9)],
|
348
|
+
"-e=" => "--hc-interval=",
|
349
|
+
"--hc-interval=" => [%w(5000 10000 15000)],
|
350
|
+
"-k=" => "--hc-port=",
|
351
|
+
"--hc-port=" => find_network_services,
|
352
|
+
"-l=" => "--listeners=",
|
353
|
+
"--listeners=" => true,
|
354
|
+
"-n=" => "--name=",
|
355
|
+
"--name=" => true,
|
356
|
+
"-p=" => "--policy=",
|
357
|
+
"--policy=" => [%w(least-connections round-robin)],
|
358
|
+
"-s=" => "--hc-request=",
|
359
|
+
"--hc-request=" => true,
|
360
|
+
"-t=" => "--hc-timeout=",
|
361
|
+
"--hc-timeout=" => [%w(5000 10000 15000)],
|
362
|
+
"-y=" => "--hc-type=",
|
363
|
+
"--hc-type=" => [%w(http tcp)],
|
364
|
+
"--ssl-cert" => true,
|
365
|
+
"--ssl-key" => true,
|
366
|
+
"--remove-ssl" => true,
|
367
|
+
:include => find_identifiers("lba-")
|
369
368
|
},
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
369
|
+
"list" => find_identifiers("lba-"),
|
370
|
+
"show" => find_identifiers("lba-"),
|
371
|
+
"destroy" => find_identifiers("lba-"),
|
372
|
+
"add_nodes" => find_identifiers(%w(lba- srv-)),
|
373
|
+
"remove_nodes" => find_identifiers(%w(lba- srv-)),
|
375
374
|
},
|
376
|
-
|
375
|
+
"servers" =>
|
377
376
|
{
|
378
|
-
|
379
|
-
"-e" => "--no-base64",
|
380
|
-
"--no-base64" => true,
|
381
|
-
"--base-64" => true,
|
382
|
-
"-f=" => "--user-data-file=",
|
383
|
-
"--user-data-file=" => [find_filename],
|
384
|
-
"-g=" => "--server-groups=",
|
385
|
-
"--server-groups=" => [find_identifiers("grp-")],
|
386
|
-
"-i=" => "--server-count=",
|
387
|
-
"--server-count=" => true,
|
388
|
-
"-m=" => "--user-data=",
|
389
|
-
"--user-data=" => true,
|
390
|
-
"-n=" => "--name=",
|
391
|
-
"--name=" => true,
|
392
|
-
"-t=" => "--type=",
|
393
|
-
"--type=" => [find_server_types],
|
394
|
-
"-z=" => "--zone=",
|
395
|
-
"--zone=" => find_zones,
|
396
|
-
:include => [find_identifiers("img-")]
|
397
|
-
},
|
398
|
-
"update" =>
|
399
|
-
{
|
400
|
-
"--no-compatability-mode" => true,
|
401
|
-
"--compatability-mode" => true,
|
377
|
+
"create" => {
|
402
378
|
"-e" => "--no-base64",
|
403
379
|
"--no-base64" => true,
|
380
|
+
"--base-64" => true,
|
404
381
|
"-f=" => "--user-data-file=",
|
405
382
|
"--user-data-file=" => [find_filename],
|
406
|
-
"-g=" => "--server-groups",
|
383
|
+
"-g=" => "--server-groups=",
|
407
384
|
"--server-groups=" => [find_identifiers("grp-")],
|
408
|
-
"-
|
385
|
+
"-i=" => "--server-count=",
|
386
|
+
"--server-count=" => true,
|
387
|
+
"-m=" => "--user-data=",
|
409
388
|
"--user-data=" => true,
|
410
389
|
"-n=" => "--name=",
|
411
390
|
"--name=" => true,
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
"show" => find_identifiers("srv-"),
|
418
|
-
"shutdown" => find_identifiers("srv-"),
|
419
|
-
"snapshot" => find_identifiers("srv-"),
|
420
|
-
"start" => find_identifiers("srv-"),
|
421
|
-
"stop" => find_identifiers("srv-")
|
422
|
-
},
|
423
|
-
"sql" => {
|
424
|
-
"instances" => {
|
425
|
-
"create" => {
|
426
|
-
"-n=" => "--name=",
|
427
|
-
"--name" => true,
|
428
|
-
"-d=" => "--description",
|
429
|
-
"--description" => true,
|
430
|
-
"-t" => "--type",
|
431
|
-
"--type" => true,
|
432
|
-
"--allow-access" => true,
|
433
|
-
"--snapshot" => find_identifiers("dbi-")
|
434
|
-
},
|
435
|
-
"destroy" => find_identifiers("dbs-"),
|
436
|
-
"list" => find_identifiers("dbs-"),
|
437
|
-
"reset_password" => find_identifiers("dbs-"),
|
438
|
-
"show" => find_identifiers("dbs-"),
|
439
|
-
"snapshot" => find_identifiers("dbs-"),
|
440
|
-
"update" => {
|
441
|
-
"-n=" => "--name=",
|
442
|
-
"--name" => true,
|
443
|
-
"-d=" => "--description",
|
444
|
-
"--description" => true,
|
445
|
-
"--allow-access" => true,
|
446
|
-
:include => find_identifiers("dbs-")
|
447
|
-
},
|
448
|
-
},
|
449
|
-
"snapshots" => {
|
450
|
-
"destroy" => find_identifiers("dbi-"),
|
451
|
-
"list" => find_identifiers("dbi-"),
|
452
|
-
"update" => {
|
453
|
-
"-n=" => "--name=",
|
454
|
-
"--name" => true,
|
455
|
-
"-d=" => "--description",
|
456
|
-
"--description" => true,
|
457
|
-
:include => find_identifiers("dbi-")
|
458
|
-
},
|
459
|
-
},
|
460
|
-
"types" => {
|
461
|
-
"list" => find_identifiers("dbt-"),
|
462
|
-
"show" => find_identifiers("dbt-")
|
391
|
+
"-t=" => "--type=",
|
392
|
+
"--type=" => [find_server_types],
|
393
|
+
"-z=" => "--zone=",
|
394
|
+
"--zone=" => find_zones,
|
395
|
+
:include => [find_identifiers("img-")]
|
463
396
|
},
|
397
|
+
"update" =>
|
398
|
+
{
|
399
|
+
"--no-compatability-mode" => true,
|
400
|
+
"--compatability-mode" => true,
|
401
|
+
"-e" => "--no-base64",
|
402
|
+
"--no-base64" => true,
|
403
|
+
"-f=" => "--user-data-file=",
|
404
|
+
"--user-data-file=" => [find_filename],
|
405
|
+
"-g=" => "--server-groups",
|
406
|
+
"--server-groups=" => [find_identifiers("grp-")],
|
407
|
+
"-m=" => "--user-data",
|
408
|
+
"--user-data=" => true,
|
409
|
+
"-n=" => "--name=",
|
410
|
+
"--name=" => true,
|
411
|
+
:include => find_identifiers("srv-")
|
412
|
+
},
|
413
|
+
"activate_console" => find_identifiers("srv-"),
|
414
|
+
"destroy" => find_identifiers("srv-"),
|
415
|
+
"list" => find_identifiers("srv-"),
|
416
|
+
"show" => find_identifiers("srv-"),
|
417
|
+
"shutdown" => find_identifiers("srv-"),
|
418
|
+
"snapshot" => find_identifiers("srv-"),
|
419
|
+
"start" => find_identifiers("srv-"),
|
420
|
+
"stop" => find_identifiers("srv-")
|
464
421
|
},
|
465
|
-
|
422
|
+
"sql" => {
|
423
|
+
"instances" => {
|
424
|
+
"create" => {
|
425
|
+
"-n=" => "--name=",
|
426
|
+
"--name" => true,
|
427
|
+
"-d=" => "--description",
|
428
|
+
"--description" => true,
|
429
|
+
"-t" => "--type",
|
430
|
+
"--type" => true,
|
431
|
+
"--allow-access" => true,
|
432
|
+
"--snapshot" => find_identifiers("dbi-")
|
433
|
+
},
|
434
|
+
"destroy" => find_identifiers("dbs-"),
|
435
|
+
"list" => find_identifiers("dbs-"),
|
436
|
+
"reset_password" => find_identifiers("dbs-"),
|
437
|
+
"show" => find_identifiers("dbs-"),
|
438
|
+
"snapshot" => find_identifiers("dbs-"),
|
439
|
+
"update" => {
|
440
|
+
"-n=" => "--name=",
|
441
|
+
"--name" => true,
|
442
|
+
"-d=" => "--description",
|
443
|
+
"--description" => true,
|
444
|
+
"--allow-access" => true,
|
445
|
+
:include => find_identifiers("dbs-")
|
446
|
+
},
|
447
|
+
},
|
448
|
+
"snapshots" => {
|
449
|
+
"destroy" => find_identifiers("dbi-"),
|
450
|
+
"list" => find_identifiers("dbi-"),
|
451
|
+
"update" => {
|
452
|
+
"-n=" => "--name=",
|
453
|
+
"--name" => true,
|
454
|
+
"-d=" => "--description",
|
455
|
+
"--description" => true,
|
456
|
+
:include => find_identifiers("dbi-")
|
457
|
+
},
|
458
|
+
},
|
459
|
+
"types" => {
|
460
|
+
"list" => find_identifiers("dbt-"),
|
461
|
+
"show" => find_identifiers("dbt-")
|
462
|
+
},
|
463
|
+
},
|
464
|
+
"types" =>
|
466
465
|
{
|
467
|
-
|
468
|
-
|
466
|
+
"list" => find_server_types,
|
467
|
+
"show" => find_server_types
|
469
468
|
},
|
470
|
-
|
469
|
+
"users" =>
|
471
470
|
{
|
472
|
-
|
473
|
-
|
474
|
-
|
471
|
+
"list" => find_identifiers("usr-"),
|
472
|
+
"show" => find_identifiers("usr-"),
|
473
|
+
"update" =>
|
475
474
|
{
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
475
|
+
"-f=" => "--ssh-key=",
|
476
|
+
"--ssh-key=" => find_filename,
|
477
|
+
"-n=" => "--name=",
|
478
|
+
"--name=" => true,
|
479
|
+
:include => find_identifiers("usr-")
|
481
480
|
}
|
482
481
|
},
|
483
|
-
|
482
|
+
"zones" =>
|
484
483
|
{
|
485
|
-
|
484
|
+
"list" => find_zones
|
486
485
|
},
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
486
|
+
"-a" => "--account=",
|
487
|
+
"--account=" => [find_identifiers("acc-")],
|
488
|
+
"-c=" => "--client=",
|
489
|
+
"--client=" => [find_clients],
|
490
|
+
"-k" => "--insecure",
|
491
|
+
"--insecure" => true
|
493
492
|
}
|
494
493
|
}
|
495
494
|
|
496
495
|
def complete!(a, cur = nil)
|
497
496
|
a = a.keys if a.is_a? Hash
|
498
|
-
matches = a.
|
497
|
+
matches = a.select { |e| e.index(cur) == 0 }
|
499
498
|
# exclude all option args unless specifically looking for them
|
500
499
|
if cur.index('-') != 0
|
501
|
-
matches = matches.
|
500
|
+
matches = matches.select { |e| e.index('-') != 0 }
|
502
501
|
end
|
503
|
-
matches.
|
502
|
+
matches.map! { |m| m.chomp("=") }
|
504
503
|
puts matches.join("\n")
|
505
504
|
exit 0
|
506
505
|
end
|
@@ -510,14 +509,14 @@ def subwalk(a, toks, cur, prev)
|
|
510
509
|
next if toks.shift
|
511
510
|
case s
|
512
511
|
when Proc
|
513
|
-
return s.call(cur,prev)
|
512
|
+
return s.call(cur, prev)
|
514
513
|
when Array
|
515
514
|
return s
|
516
515
|
when nil
|
517
516
|
return []
|
518
517
|
end
|
519
518
|
end
|
520
|
-
|
519
|
+
nil
|
521
520
|
end
|
522
521
|
|
523
522
|
def walk(toks, cur, prev, spec)
|
@@ -530,12 +529,12 @@ def walk(toks, cur, prev, spec)
|
|
530
529
|
when :_default
|
531
530
|
# end of the line
|
532
531
|
# exclude any aliases
|
533
|
-
spec.reject! { |
|
532
|
+
spec.reject! { |_k, v| v.is_a? String }
|
534
533
|
options = {}
|
535
534
|
if spec.include? :include
|
536
535
|
r = subwalk(Array(spec[:include]), toks, cur, prev)
|
537
536
|
unless r.nil?
|
538
|
-
r.each do |k,v|
|
537
|
+
r.each do |k, v|
|
539
538
|
options[k] = v
|
540
539
|
end
|
541
540
|
end
|
@@ -570,7 +569,7 @@ cmd = ARGV[0]
|
|
570
569
|
cur = ARGV[1].shellunescape
|
571
570
|
prev = ARGV[2].shellunescape
|
572
571
|
point = ENV['COMP_POINT'].to_i
|
573
|
-
line = ENV['COMP_LINE'][0..point-1].shellunescape
|
572
|
+
line = ENV['COMP_LINE'][0..point - 1].shellunescape
|
574
573
|
begin
|
575
574
|
toks = line.shellsplit
|
576
575
|
rescue ArgumentError
|