brightbox-cli 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/brightbox-cli/cloud_ips.rb +0 -6
- data/lib/brightbox-cli/commands/config-client-add.rb +4 -0
- 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/images-show.rb +1 -1
- data/lib/brightbox-cli/commands/images-update.rb +9 -2
- data/lib/brightbox-cli/commands/servers-list.rb +11 -0
- data/lib/brightbox-cli/error_parser.rb +13 -8
- data/lib/brightbox-cli/firewall_rule.rb +1 -1
- data/lib/brightbox-cli/images.rb +1 -3
- data/lib/brightbox-cli/load_balancers.rb +0 -7
- data/lib/brightbox-cli/server_groups.rb +0 -2
- data/lib/brightbox-cli/servers.rb +0 -2
- data/lib/brightbox-cli/users.rb +0 -2
- data/lib/brightbox-cli/version.rb +1 -1
- metadata +34 -7
@@ -11,10 +11,6 @@ module Brightbox
|
|
11
11
|
def self.create
|
12
12
|
r = conn.create_cloud_ip
|
13
13
|
new(r["id"])
|
14
|
-
rescue Excon::Errors::Forbidden => e
|
15
|
-
response = JSON.parse(e.response.body) rescue {}
|
16
|
-
response = response.fetch("error", {})
|
17
|
-
raise Forbidden, "#{response["details"]}: #{response["summary"]}"
|
18
14
|
end
|
19
15
|
|
20
16
|
def attributes
|
@@ -47,8 +43,6 @@ module Brightbox
|
|
47
43
|
self.class.conn.update_cloud_ip(id, options)
|
48
44
|
self.reload
|
49
45
|
self
|
50
|
-
rescue Excon::Errors::BadRequest => e
|
51
|
-
raise Conflict, JSON.parse(e.response.body)['error']['details']
|
52
46
|
end
|
53
47
|
|
54
48
|
end
|
@@ -23,6 +23,10 @@ module Brightbox
|
|
23
23
|
raise "You must specify the api client-id"
|
24
24
|
end
|
25
25
|
|
26
|
+
unless client_id[/^cli-.{5}$/]
|
27
|
+
raise "You must specify a valid api client-id in the format cli-xxxxx"
|
28
|
+
end
|
29
|
+
|
26
30
|
if secret.nil?
|
27
31
|
raise "You must specify the api secret"
|
28
32
|
end
|
@@ -10,7 +10,7 @@ module Brightbox
|
|
10
10
|
end
|
11
11
|
|
12
12
|
display_options = { :fields => [
|
13
|
-
:id, :protocol,:source, :sport
|
13
|
+
:id, :protocol,:source, :sport, :destination, :dport, :icmp_type, :firewall_policy, :description
|
14
14
|
],
|
15
15
|
:vertical => true
|
16
16
|
}
|
@@ -5,7 +5,7 @@ module Brightbox
|
|
5
5
|
|
6
6
|
c.action do |global_options, options, args|
|
7
7
|
grp_id = args.shift
|
8
|
-
raise "You must specify the server group and the server ids to add" unless grp_id && grp_id[/^grp-/] && !args.empty?
|
8
|
+
raise "You must specify the server group and then the server ids to add" unless grp_id && grp_id[/^grp-/] && !args.empty?
|
9
9
|
|
10
10
|
sg = ServerGroup.find grp_id
|
11
11
|
|
@@ -15,7 +15,7 @@ module Brightbox
|
|
15
15
|
|
16
16
|
table_opts = global_options.merge({
|
17
17
|
:vertical => true,
|
18
|
-
:fields => [:id, :type, :owner, :created_at, :status, :arch, :name, :description, :virtual_size, :disk_size, :public, :"compatibility_mode", :official, :ancestor_id ]
|
18
|
+
:fields => [:id, :type, :owner, :created_at, :status, :arch, :name, :description, :username, :virtual_size, :disk_size, :public, :"compatibility_mode", :official, :ancestor_id ]
|
19
19
|
})
|
20
20
|
|
21
21
|
render_table(images, table_opts)
|
@@ -12,13 +12,16 @@ module Brightbox
|
|
12
12
|
c.desc "Set image mode to be either 'virtio' or 'compatibility'"
|
13
13
|
c.flag [:m, "mode"]
|
14
14
|
|
15
|
-
c.desc "Set image to be
|
15
|
+
c.desc "Set image to be publicly visible (true or false)"
|
16
16
|
c.flag [:p, "public"]
|
17
17
|
|
18
|
+
c.desc "Set image to be deprecated (true or false)"
|
19
|
+
c.flag "deprecated"
|
20
|
+
|
18
21
|
c.desc "Image description"
|
19
22
|
c.flag [:d, "description"]
|
20
23
|
|
21
|
-
c.desc "Image
|
24
|
+
c.desc "Image Username"
|
22
25
|
c.flag [:u, "username"]
|
23
26
|
|
24
27
|
c.action do |global_options,options,args|
|
@@ -44,6 +47,10 @@ module Brightbox
|
|
44
47
|
params[:public] = true if options[:p] == "true"
|
45
48
|
params[:public] = false if options[:p] == "false"
|
46
49
|
|
50
|
+
# If options[:deprecated] isn't specified, leave the status alone
|
51
|
+
params[:status] = "deprecated" if options[:deprecated] == "true"
|
52
|
+
params[:status] = "available" if options[:deprecated] == "false"
|
53
|
+
|
47
54
|
image = Image.find img_id
|
48
55
|
|
49
56
|
info "Updating image #{image}"
|
@@ -2,7 +2,14 @@ module Brightbox
|
|
2
2
|
desc 'List servers'
|
3
3
|
arg_name '[server-id...]'
|
4
4
|
command [:list] do |c|
|
5
|
+
|
6
|
+
c.desc "Group identifier"
|
7
|
+
c.flag [:g, :group]
|
8
|
+
|
5
9
|
c.action do |global_options,options,args|
|
10
|
+
# Check this here before we make any network connections
|
11
|
+
raise "A valid server group identifier is required for the group argument" unless options[:g].nil? || options[:g] =~ /^grp-.{5}$/
|
12
|
+
|
6
13
|
if args.empty?
|
7
14
|
servers = Server.find(:all)
|
8
15
|
else
|
@@ -10,6 +17,10 @@ module Brightbox
|
|
10
17
|
warn "Couldn't find server #{id}"
|
11
18
|
end
|
12
19
|
end
|
20
|
+
|
21
|
+
# Scope by group if a group identifier is specified
|
22
|
+
servers = servers.select {|server| server.server_groups.any? {|grp| grp["id"] == options[:g] } } if options[:g]
|
23
|
+
|
13
24
|
render_table(servers, global_options)
|
14
25
|
end
|
15
26
|
end
|
@@ -11,24 +11,29 @@ module Brightbox
|
|
11
11
|
case socket_error
|
12
12
|
when Excon::Errors::ServiceUnavailable
|
13
13
|
error "Api currently unavailable"
|
14
|
-
when Excon::Errors::Error
|
15
|
-
parse_http_error(socket_error)
|
16
14
|
else
|
17
|
-
|
15
|
+
parse_http_error(socket_error)
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
def parse_http_error(e)
|
22
20
|
if e.respond_to?(:response) and e.response.respond_to?(:body)
|
23
21
|
json_response = JSON.parse(e.response.body) rescue {}
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
extract_response_from_json(json_response,e)
|
23
|
+
else
|
24
|
+
error "ERROR: #{e}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def extract_response_from_json(error_json,e)
|
29
|
+
json_error = error_json['errors'] || error_json['error']
|
30
|
+
if json_error && !json_error.empty?
|
31
|
+
error_string = Array(json_error).join(" ")
|
32
|
+
error "ERROR: #{error_string}"
|
29
33
|
else
|
30
34
|
error "ERROR: #{e}"
|
31
35
|
end
|
32
36
|
end
|
37
|
+
|
33
38
|
end
|
34
39
|
end
|
data/lib/brightbox-cli/images.rb
CHANGED
@@ -15,15 +15,13 @@ module Brightbox
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.default_field_order
|
18
|
-
[:id, :owner, :type, :created_on, :status, :size, :username
|
18
|
+
[:id, :owner, :type, :created_on, :status, :size, :username, :name]
|
19
19
|
end
|
20
20
|
|
21
21
|
def update options
|
22
22
|
self.class.conn.update_image(id, options)
|
23
23
|
self.reload
|
24
24
|
self
|
25
|
-
rescue Excon::Errors::BadRequest => e
|
26
|
-
raise Conflict, JSON.parse(e.response.body)['error']['details']
|
27
25
|
end
|
28
26
|
|
29
27
|
def to_row
|
@@ -50,24 +50,17 @@ module Brightbox
|
|
50
50
|
def add_nodes(nodes)
|
51
51
|
node_hashes = nodes.collect { |n| { :node => n.id } }
|
52
52
|
LoadBalancer.conn.add_nodes_load_balancer(id, :nodes => node_hashes)
|
53
|
-
rescue Excon::Errors::BadRequest => e
|
54
|
-
raise Conflict, JSON.parse(e.response.body)['error']['details']
|
55
53
|
end
|
56
54
|
|
57
55
|
def remove_nodes(nodes)
|
58
56
|
node_hashes = nodes.collect { |n| { :node => n.id } }
|
59
57
|
LoadBalancer.conn.remove_nodes_load_balancer(id, :nodes => node_hashes)
|
60
|
-
rescue Excon::Errors::BadRequest => e
|
61
|
-
raise Conflict, JSON.parse(e.response.body)['error']['details']
|
62
58
|
end
|
63
59
|
|
64
60
|
def update(options)
|
65
|
-
debug options.inspect
|
66
61
|
LoadBalancer.conn.update_load_balancer(id, options)
|
67
62
|
self.reload
|
68
63
|
self
|
69
|
-
rescue Excon::Errors::BadRequest => e
|
70
|
-
raise Conflict, JSON.parse(e.response.body)['error']['details']
|
71
64
|
end
|
72
65
|
|
73
66
|
def self.get(id)
|
data/lib/brightbox-cli/users.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brightbox-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 95
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 16
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.16.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Leach
|
@@ -15,7 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-01 00:00:00 +00:00
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: json
|
@@ -2283,6 +2284,7 @@ files:
|
|
2283
2284
|
- spec/spec_helper.rb
|
2284
2285
|
- spec/support/common_helpers.rb
|
2285
2286
|
- tools/bash_completion_script
|
2287
|
+
has_rdoc: true
|
2286
2288
|
homepage: http://docs.brightbox.com/cli
|
2287
2289
|
licenses: []
|
2288
2290
|
|
@@ -2312,9 +2314,34 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
2312
2314
|
requirements: []
|
2313
2315
|
|
2314
2316
|
rubyforge_project: brightbox-cli
|
2315
|
-
rubygems_version: 1.
|
2317
|
+
rubygems_version: 1.5.3
|
2316
2318
|
signing_key:
|
2317
2319
|
specification_version: 3
|
2318
2320
|
summary: The Brightbox cloud management system
|
2319
|
-
test_files:
|
2320
|
-
|
2321
|
+
test_files:
|
2322
|
+
- spec/brightbox/config.example
|
2323
|
+
- spec/cloud_ips_spec.rb
|
2324
|
+
- spec/firewall_policy_spec.rb
|
2325
|
+
- spec/firewall_rule_spec.rb
|
2326
|
+
- spec/fixtures/vcr_cassettes/apply_firewall_policy.yml
|
2327
|
+
- spec/fixtures/vcr_cassettes/create_firewall_policy.yml
|
2328
|
+
- spec/fixtures/vcr_cassettes/destroy_firewall_policy.yml
|
2329
|
+
- spec/fixtures/vcr_cassettes/firewall_rule.yml
|
2330
|
+
- spec/fixtures/vcr_cassettes/firewall_rule_create.yml
|
2331
|
+
- spec/fixtures/vcr_cassettes/firewall_rule_destroy.yml
|
2332
|
+
- spec/fixtures/vcr_cassettes/firewall_rule_list.yml
|
2333
|
+
- spec/fixtures/vcr_cassettes/firewall_rule_show.yml
|
2334
|
+
- spec/fixtures/vcr_cassettes/list_cloud_ip.yml
|
2335
|
+
- spec/fixtures/vcr_cassettes/list_firewall_policy.yml
|
2336
|
+
- spec/fixtures/vcr_cassettes/list_server_groups.yml
|
2337
|
+
- spec/fixtures/vcr_cassettes/server_destroy.yml
|
2338
|
+
- spec/fixtures/vcr_cassettes/server_list.yml
|
2339
|
+
- spec/fixtures/vcr_cassettes/server_show.yml
|
2340
|
+
- spec/fixtures/vcr_cassettes/server_shutdown.yml
|
2341
|
+
- spec/fixtures/vcr_cassettes/server_start.yml
|
2342
|
+
- spec/fixtures/vcr_cassettes/server_stop.yml
|
2343
|
+
- spec/fixtures/vcr_cassettes/show_firewall_policy.yml
|
2344
|
+
- spec/server_group_spec.rb
|
2345
|
+
- spec/servers_spec.rb
|
2346
|
+
- spec/spec_helper.rb
|
2347
|
+
- spec/support/common_helpers.rb
|