brightbox-cli 4.3.1 → 4.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +2 -2
- data/lib/brightbox-cli/commands/lbs/update.rb +1 -1
- data/lib/brightbox-cli/commands/servers/create.rb +0 -1
- data/lib/brightbox-cli/commands/servers/update.rb +1 -1
- data/lib/brightbox-cli/commands/volumes/attach.rb +1 -0
- data/lib/brightbox-cli/commands/volumes/update.rb +3 -4
- data/lib/brightbox-cli/version.rb +1 -1
- data/lib/brightbox_cli.rb +1 -0
- data/lib/gli_patches.rb +50 -0
- data/spec/commands/cloudips/update_spec.rb +144 -64
- data/spec/commands/lbs/update_spec.rb +55 -1
- data/spec/commands/servers/create_spec.rb +10 -3
- data/spec/commands/servers/update_spec.rb +267 -12
- data/spec/commands/sql/instances/update_spec.rb +12 -10
- data/spec/commands/volumes/update_spec.rb +0 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c813c009698fa955e24ce5399a95d658f8e0f657881071fcea65a3349d958676
|
4
|
+
data.tar.gz: b7d1cfd6faf802ea27599226aedf2632b7d33dff89b4a018b26bd4587cc5069a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccd5f260951570479dacfbd428abb919a5ab35447d2699f05ff8552ba1c2fb0d3b27dfc9a749a3b0c9b0e4522d5a21b4bf13cecf5c13560798505548a10a9e4d
|
7
|
+
data.tar.gz: '051800a849a0b1f62b6351866e3daa687016b4cb2b6eb62aa0dc7c057fb73896c6bc23a30dc7e0c01b5a9b5fc92c25a7a723daa0245e16cb733c4d40b10de03d'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
### v4.3.2 / 2023-01-12
|
2
|
+
|
3
|
+
[Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v4.3.1...v4.3.2)
|
4
|
+
|
5
|
+
Bug fixes:
|
6
|
+
|
7
|
+
* Declared top level help for `volumes` subcommand.
|
8
|
+
* Fix `volumes update --delete-with-server` switch.
|
9
|
+
* Fix `lbs update --sslv3` switch.
|
10
|
+
* Fix `servers update --compatibility-mode` switch.
|
11
|
+
|
12
|
+
Changes:
|
13
|
+
|
14
|
+
* Added a `ignore_default` option to GLI DSL, by monkey patching, to prevent
|
15
|
+
unexpected switches from interfering with API calls. In some cases it was
|
16
|
+
impossible to determine if `--feature` or `--no-feature` had been used in the
|
17
|
+
command OR added as a default in GLI. This meant `update` commands would always
|
18
|
+
send `feature: false` in API requests even when updating names and other fields.
|
19
|
+
This could clear setting unexpectedly due to the behaviour.
|
20
|
+
* Test `servers create --compatibility-mode` switch.
|
21
|
+
* Test `cloudips update --delete-reverse-dns` switch.
|
22
|
+
* Test `sql instances --remove-snapshots-schedule` switch.
|
23
|
+
|
1
24
|
### v4.3.1 / 2023-01-11
|
2
25
|
|
3
26
|
[Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v4.3.0...v4.3.1)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
brightbox-cli (4.3.
|
4
|
+
brightbox-cli (4.3.2)
|
5
5
|
dry-inflector (= 0.2.0)
|
6
6
|
fog-brightbox (>= 1.9.1)
|
7
7
|
fog-core (< 2.0)
|
@@ -25,7 +25,7 @@ GEM
|
|
25
25
|
rexml
|
26
26
|
diff-lcs (1.5.0)
|
27
27
|
dry-inflector (0.2.0)
|
28
|
-
excon (0.97.
|
28
|
+
excon (0.97.1)
|
29
29
|
fog-brightbox (1.9.1)
|
30
30
|
dry-inflector
|
31
31
|
fog-core (>= 1.45, < 3.0)
|
@@ -17,7 +17,7 @@ module Brightbox
|
|
17
17
|
c.switch %i[e base64], :negatable => true
|
18
18
|
|
19
19
|
c.desc "Use compatibility mode"
|
20
|
-
c.switch [:"compatibility-mode"], :
|
20
|
+
c.switch [:"compatibility-mode"], ignore_default: true
|
21
21
|
|
22
22
|
c.desc "Server groups to place server in - comma delimited list"
|
23
23
|
c.flag [:g, "server-groups"]
|
@@ -8,8 +8,7 @@ module Brightbox
|
|
8
8
|
c.flag %i[d description]
|
9
9
|
|
10
10
|
c.desc I18n.t("volumes.options.delete_with_server")
|
11
|
-
c.
|
12
|
-
c.switch ["delete-with-server"], negatable: true
|
11
|
+
c.switch [:"delete-with-server"], ignore_default: true
|
13
12
|
|
14
13
|
c.desc I18n.t("options.name.desc")
|
15
14
|
c.flag %i[n name]
|
@@ -28,8 +27,8 @@ module Brightbox
|
|
28
27
|
|
29
28
|
# Switches will always appear in the options so we need a non-boolean
|
30
29
|
# setting to determine if the user did not add it to their command
|
31
|
-
unless options["delete-with-server"]
|
32
|
-
params[:delete_with_server] = options["delete-with-server"]
|
30
|
+
unless options[:"delete-with-server"].nil?
|
31
|
+
params[:delete_with_server] = options[:"delete-with-server"]
|
33
32
|
end
|
34
33
|
|
35
34
|
params[:description] = options[:description] if options[:description]
|
data/lib/brightbox_cli.rb
CHANGED
data/lib/gli_patches.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require "gli/dsl"
|
2
|
+
require "gli/command_line_option"
|
3
|
+
require "gli/option_parser_factory"
|
4
|
+
|
5
|
+
module GLI
|
6
|
+
module DSL
|
7
|
+
def extract_options(names)
|
8
|
+
options = {}
|
9
|
+
options = names.pop if names.last.kind_of? Hash
|
10
|
+
options = {
|
11
|
+
:desc => @next_desc,
|
12
|
+
:long_desc => @next_long_desc,
|
13
|
+
:default_value => @next_default_value,
|
14
|
+
:ignore_default => @ignore_default,
|
15
|
+
:arg_name => @next_arg_name
|
16
|
+
}.merge(options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class CommandLineOption
|
21
|
+
def initialize(names, options = {})
|
22
|
+
# Disable returning a default for this option (needed for boolean updates)
|
23
|
+
# which should NOT be sent unless added by the user
|
24
|
+
@ignore_default = !!options[:ignore_default]
|
25
|
+
|
26
|
+
super(names, options[:desc], options[:long_desc])
|
27
|
+
@default_value = options[:default_value]
|
28
|
+
end
|
29
|
+
|
30
|
+
def ignore_default?
|
31
|
+
@ignore_default
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class OptionParserFactory
|
36
|
+
private
|
37
|
+
|
38
|
+
def set_defaults(options_by_name,options_hash)
|
39
|
+
options_by_name.values.each do |option|
|
40
|
+
option.names_and_aliases.each do |option_name|
|
41
|
+
[option_name,option_name.to_sym].each do |name|
|
42
|
+
next if option.ignore_default?
|
43
|
+
|
44
|
+
options_hash[name] = option.default_value if options_hash[name].nil?
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,82 +1,162 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "brightbox cloudips" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
let(:stderr) { output.stderr }
|
3
|
+
describe "brightbox cloudips update" do
|
4
|
+
let(:output) { FauxIO.new { Brightbox.run(argv) } }
|
5
|
+
let(:stdout) { output.stdout }
|
6
|
+
let(:stderr) { output.stderr }
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
before do
|
9
|
+
config_from_contents(API_CLIENT_CONFIG_CONTENTS)
|
10
|
+
|
11
|
+
stub_request(:post, "http://api.brightbox.localhost/token")
|
12
|
+
.to_return(
|
13
|
+
status: 200,
|
14
|
+
body: JSON.dump(
|
15
|
+
access_token: "ACCESS-TOKEN",
|
16
|
+
refresh_token: "REFRESH_TOKEN"
|
17
|
+
)
|
18
|
+
)
|
19
|
+
|
20
|
+
Brightbox.config.reauthenticate
|
21
|
+
end
|
22
|
+
|
23
|
+
context "" do
|
24
|
+
let(:argv) { %w[cloudips update] }
|
11
25
|
|
12
|
-
|
13
|
-
|
26
|
+
it "does not error" do
|
27
|
+
expect { output }.to_not raise_error
|
14
28
|
end
|
29
|
+
end
|
15
30
|
|
16
|
-
|
17
|
-
|
31
|
+
context "when name is updated" do
|
32
|
+
let(:argv) { ["cloudips", "update", "--name=#{new_name}", "cip-12345"] }
|
18
33
|
|
19
|
-
|
20
|
-
|
21
|
-
|
34
|
+
let(:json_response) do
|
35
|
+
<<-EOS
|
36
|
+
{
|
37
|
+
"id":"cip-12345",
|
38
|
+
"name":"#{new_name}"
|
39
|
+
}
|
40
|
+
EOS
|
22
41
|
end
|
23
42
|
|
24
|
-
context "
|
25
|
-
let(:
|
43
|
+
context "--name 'New name'" do
|
44
|
+
let(:new_name) { "New name" }
|
45
|
+
let(:expected_args) { ["cip-12345", { :name => new_name }] }
|
46
|
+
|
47
|
+
before do
|
48
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
49
|
+
.with(:headers => { "Content-Type" => "application/json" },
|
50
|
+
:body => {
|
51
|
+
name: "New name"
|
52
|
+
})
|
53
|
+
.and_return(:status => 200, :body => json_response)
|
26
54
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
"id":"cip-12345",
|
31
|
-
"name":"#{new_name}"
|
32
|
-
}
|
33
|
-
EOS
|
55
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
56
|
+
.with(:headers => { "Content-Type" => "application/json" })
|
57
|
+
.and_return(:status => 200, :body => json_response)
|
34
58
|
end
|
35
59
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
stub_request(:put, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
42
|
-
.with(:headers => { "Content-Type" => "application/json" },
|
43
|
-
:body => hash_including("name" => "New name"))
|
44
|
-
.and_return(:status => 200, :body => json_response)
|
45
|
-
|
46
|
-
stub_request(:get, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
47
|
-
.with(:headers => { "Content-Type" => "application/json" })
|
48
|
-
.and_return(:status => 200, :body => json_response)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "puts new name in update" do
|
52
|
-
expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
|
53
|
-
expect(stderr).to eq("")
|
54
|
-
expect(stdout).to include("cip-12345")
|
55
|
-
expect(stdout).to include("New name")
|
56
|
-
end
|
60
|
+
it "puts new name in update" do
|
61
|
+
expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
|
62
|
+
expect(stderr).to eq("")
|
63
|
+
expect(stdout).to include("cip-12345")
|
64
|
+
expect(stdout).to include("New name")
|
57
65
|
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "--name ''" do
|
69
|
+
let(:new_name) { "" }
|
70
|
+
let(:expected_args) { ["cip-12345", { :name => "" }] }
|
58
71
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
it "puts new name in update" do
|
75
|
-
expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
|
76
|
-
expect(stderr).to eq("")
|
77
|
-
expect(stdout).to include("cip-12345")
|
78
|
-
end
|
72
|
+
before do
|
73
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
74
|
+
.with(:headers => { "Content-Type" => "application/json" },
|
75
|
+
:body => hash_including("name" => ""))
|
76
|
+
.and_return(:status => 200, :body => json_response)
|
77
|
+
|
78
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/cloud_ips/cip-12345?account_id=acc-12345")
|
79
|
+
.with(:headers => { "Content-Type" => "application/json" })
|
80
|
+
.and_return(:status => 200, :body => json_response)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "puts new name in update" do
|
84
|
+
expect(Brightbox::CloudIP.conn).to receive(:update_cloud_ip).with(*expected_args).and_call_original
|
85
|
+
expect(stderr).to eq("")
|
86
|
+
expect(stdout).to include("cip-12345")
|
79
87
|
end
|
80
88
|
end
|
81
89
|
end
|
90
|
+
|
91
|
+
context "--reverse-dns" do
|
92
|
+
let(:argv) { ["cloudips", "update", "--reverse-dns", "domain.example", "cip-dfsa3"] }
|
93
|
+
|
94
|
+
let(:json_response) do
|
95
|
+
<<-EOS
|
96
|
+
{
|
97
|
+
"id":"cip-dfsa3",
|
98
|
+
"reverse_dns":"domain.example"
|
99
|
+
}
|
100
|
+
EOS
|
101
|
+
end
|
102
|
+
|
103
|
+
before do
|
104
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/cloud_ips/cip-dfsa3?account_id=acc-12345")
|
105
|
+
.with(:headers => { "Content-Type" => "application/json" },
|
106
|
+
:body => {
|
107
|
+
reverse_dns: "domain.example"
|
108
|
+
})
|
109
|
+
.and_return(:status => 200, :body => json_response)
|
110
|
+
|
111
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/cloud_ips/cip-dfsa3?account_id=acc-12345")
|
112
|
+
.with(:headers => { "Content-Type" => "application/json" })
|
113
|
+
.and_return(:status => 200, :body => json_response)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "puts new name in update" do
|
117
|
+
expect(stderr).to eq("")
|
118
|
+
expect(stdout).to include("cip-dfsa3")
|
119
|
+
expect(stdout).to include("domain.example")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "--delete-reverse-dns" do
|
124
|
+
let(:argv) { ["cloudips", "update", "--delete-reverse-dns", "cip-dfsa3"] }
|
125
|
+
|
126
|
+
let(:json_response) do
|
127
|
+
<<-EOS
|
128
|
+
{
|
129
|
+
"id":"cip-dfsa3",
|
130
|
+
"reverse_dns":""
|
131
|
+
}
|
132
|
+
EOS
|
133
|
+
end
|
134
|
+
|
135
|
+
before do
|
136
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/cloud_ips/cip-dfsa3?account_id=acc-12345")
|
137
|
+
.with(:headers => { "Content-Type" => "application/json" },
|
138
|
+
:body => {
|
139
|
+
reverse_dns: ""
|
140
|
+
})
|
141
|
+
.and_return(:status => 200, :body => json_response)
|
142
|
+
|
143
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/cloud_ips/cip-dfsa3?account_id=acc-12345")
|
144
|
+
.with(:headers => { "Content-Type" => "application/json" })
|
145
|
+
.and_return(:status => 200, :body => json_response)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "puts new name in update" do
|
149
|
+
expect(stderr).to eq("")
|
150
|
+
expect(stdout).to include("cip-dfsa3")
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context "--reverse-dns and --delete-reverse-dns options" do
|
155
|
+
let(:argv) { ["cloudips", "update", "--reverse-dns", "domain.example", "--delete-reverse-dns", "cip-dfsa3"] }
|
156
|
+
|
157
|
+
it "puts new name in update" do
|
158
|
+
expect(stderr).to eq("ERROR: You must either specify a reverse DNS record or --delete-reverse-dns\n")
|
159
|
+
expect(stdout).to eq("")
|
160
|
+
end
|
161
|
+
end
|
82
162
|
end
|
@@ -36,7 +36,7 @@ describe "brightbox lbs" do
|
|
36
36
|
.to_return(:status => 200, :body => '{"id":"lba-12345"}')
|
37
37
|
|
38
38
|
stub_request(:put, "http://api.brightbox.localhost/1.0/load_balancers/lba-12345?account_id=acc-12345")
|
39
|
-
.with(:body =>
|
39
|
+
.with(:body => { ssl_minimum_version: "TLSv1.0" })
|
40
40
|
.to_return(:status => 202, :body => json_response)
|
41
41
|
end
|
42
42
|
|
@@ -45,5 +45,59 @@ describe "brightbox lbs" do
|
|
45
45
|
expect(stdout).to include("lba-12345")
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
context "--sslv3" do
|
50
|
+
let(:argv) { ["lbs", "update", "--sslv3", "lba-grt24"] }
|
51
|
+
|
52
|
+
let(:json_response) do
|
53
|
+
<<-EOS
|
54
|
+
{
|
55
|
+
"id":"lba-grt24",
|
56
|
+
"ssl_minimum_version":"TLSv1.0"
|
57
|
+
}
|
58
|
+
EOS
|
59
|
+
end
|
60
|
+
|
61
|
+
before do
|
62
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/load_balancers/lba-grt24?account_id=acc-12345")
|
63
|
+
.to_return(:status => 200, :body => '{"id":"lba-grt24"}')
|
64
|
+
|
65
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/load_balancers/lba-grt24?account_id=acc-12345")
|
66
|
+
.with(:body => { sslv3: true })
|
67
|
+
.to_return(:status => 202, :body => json_response)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "includes ssl_minimum_version in response" do
|
71
|
+
expect(stderr).to eq("Updating load balancer lba-grt24\n")
|
72
|
+
expect(stdout).to include("lba-grt24")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "--no-sslv3" do
|
77
|
+
let(:argv) { ["lbs", "update", "--no-sslv3", "lba-kl432"] }
|
78
|
+
|
79
|
+
let(:json_response) do
|
80
|
+
<<-EOS
|
81
|
+
{
|
82
|
+
"id":"lba-kl432",
|
83
|
+
"ssl_minimum_version":"TLSv1.0"
|
84
|
+
}
|
85
|
+
EOS
|
86
|
+
end
|
87
|
+
|
88
|
+
before do
|
89
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/load_balancers/lba-kl432?account_id=acc-12345")
|
90
|
+
.to_return(:status => 200, :body => '{"id":"lba-kl432"}')
|
91
|
+
|
92
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/load_balancers/lba-kl432?account_id=acc-12345")
|
93
|
+
.with(:body => { sslv3: false })
|
94
|
+
.to_return(:status => 202, :body => json_response)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "includes ssl_minimum_version in response" do
|
98
|
+
expect(stderr).to eq("Updating load balancer lba-kl432\n")
|
99
|
+
expect(stdout).to include("lba-kl432")
|
100
|
+
end
|
101
|
+
end
|
48
102
|
end
|
49
103
|
end
|
@@ -38,7 +38,10 @@ describe "brightbox servers" do
|
|
38
38
|
|
39
39
|
it "does not error" do
|
40
40
|
stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
|
41
|
-
.with(:body =>
|
41
|
+
.with(:body => {
|
42
|
+
image: "img-12345",
|
43
|
+
server_type: "typ-12345"
|
44
|
+
})
|
42
45
|
.and_return(:status => 202, :body => sample_response)
|
43
46
|
|
44
47
|
expect(stderr).not_to match("ERROR")
|
@@ -94,8 +97,12 @@ describe "brightbox servers" do
|
|
94
97
|
|
95
98
|
it "requests new server with encryption at rest enabled" do
|
96
99
|
stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
|
97
|
-
.with(:
|
98
|
-
|
100
|
+
.with(headers: { "Content-Type" => "application/json" },
|
101
|
+
body: {
|
102
|
+
disk_encrypted: true,
|
103
|
+
image: "img-12345",
|
104
|
+
server_type: "typ-12345"
|
105
|
+
})
|
99
106
|
.and_return(:status => 202, :body => sample_response)
|
100
107
|
|
101
108
|
expect(stderr).to match("Creating a nano")
|
@@ -1,17 +1,272 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe "brightbox servers" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
describe "brightbox servers update" do
|
4
|
+
let(:output) { FauxIO.new { Brightbox.run(argv) } }
|
5
|
+
let(:stdout) { output.stdout }
|
6
|
+
let(:stderr) { output.stderr }
|
7
|
+
|
8
|
+
before do
|
9
|
+
config_from_contents(API_CLIENT_CONFIG_CONTENTS)
|
10
|
+
|
11
|
+
stub_request(:post, "http://api.brightbox.localhost/token")
|
12
|
+
.to_return(
|
13
|
+
status: 200,
|
14
|
+
body: JSON.dump(
|
15
|
+
access_token: "ACCESS-TOKEN",
|
16
|
+
refresh_token: "REFRESH_TOKEN"
|
17
|
+
)
|
18
|
+
)
|
19
|
+
|
20
|
+
Brightbox.config.reauthenticate
|
21
|
+
end
|
22
|
+
|
23
|
+
context "without arguments" do
|
24
|
+
let(:argv) { %w[servers update] }
|
25
|
+
|
26
|
+
it "does not error" do
|
27
|
+
expect { output }.to_not raise_error
|
28
|
+
|
29
|
+
expect(stderr).to eq("ERROR: You must specify a valid server id as the first argument\n")
|
30
|
+
|
31
|
+
expect(stdout).to match("")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "without options" do
|
36
|
+
let(:argv) { %w[servers update srv-klfkd] }
|
37
|
+
|
38
|
+
before do
|
39
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-klfkd?account_id=acc-12345")
|
40
|
+
.to_return(:status => 200, :body => {
|
41
|
+
id: "srv-klfkd",
|
42
|
+
server_type: {
|
43
|
+
id: "typ-12345"
|
44
|
+
},
|
45
|
+
cloud_ips: [],
|
46
|
+
interfaces: []
|
47
|
+
}.to_json)
|
48
|
+
|
49
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
|
50
|
+
.to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
|
51
|
+
|
52
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-klfkd?account_id=acc-12345")
|
53
|
+
.with(:body => {
|
54
|
+
compatibility_mode: false
|
55
|
+
})
|
56
|
+
.to_return(:status => 200, :body => {
|
57
|
+
id: "srv-klfkd",
|
58
|
+
server_type: {
|
59
|
+
id: "typ-12345"
|
60
|
+
},
|
61
|
+
cloud_ips: [],
|
62
|
+
interfaces: []
|
63
|
+
}.to_json)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "does not error" do
|
67
|
+
expect { output }.to_not raise_error
|
68
|
+
|
69
|
+
expect(stderr).to eq("Updating server srv-klfkd\n")
|
70
|
+
|
71
|
+
expect(stdout).to match("srv-klfkd")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "with --compatibility-mode" do
|
76
|
+
let(:argv) { %w[servers update --compatibility-mode srv-ds321] }
|
77
|
+
|
78
|
+
before do
|
79
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
|
80
|
+
.to_return(:status => 200, :body => {
|
81
|
+
id: "srv-ds321",
|
82
|
+
server_type: {
|
83
|
+
id: "typ-12345"
|
84
|
+
},
|
85
|
+
cloud_ips: [],
|
86
|
+
interfaces: []
|
87
|
+
}.to_json)
|
88
|
+
|
89
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
|
90
|
+
.to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
|
91
|
+
|
92
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
|
93
|
+
.with(:body => {})
|
94
|
+
.to_return(:status => 200, :body => {
|
95
|
+
id: "srv-ds321",
|
96
|
+
server_type: {
|
97
|
+
id: "typ-12345"
|
98
|
+
},
|
99
|
+
cloud_ips: [],
|
100
|
+
interfaces: []
|
101
|
+
}.to_json)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "does not error" do
|
105
|
+
expect { output }.to_not raise_error
|
106
|
+
|
107
|
+
expect(stderr).to eq("Updating server srv-ds321\n")
|
108
|
+
|
109
|
+
expect(stdout).to match("srv-ds321")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "with --no-compatibility-mode" do
|
114
|
+
let(:argv) { %w[servers update --no-compatibility-mode srv-ds321] }
|
115
|
+
|
116
|
+
before do
|
117
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
|
118
|
+
.to_return(:status => 200, :body => {
|
119
|
+
id: "srv-ds321",
|
120
|
+
server_type: {
|
121
|
+
id: "typ-12345"
|
122
|
+
},
|
123
|
+
cloud_ips: [],
|
124
|
+
interfaces: []
|
125
|
+
}.to_json)
|
126
|
+
|
127
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
|
128
|
+
.to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
|
129
|
+
|
130
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
|
131
|
+
.with(:body => {
|
132
|
+
compatibility_mode: false
|
133
|
+
})
|
134
|
+
.to_return(:status => 200, :body => {
|
135
|
+
id: "srv-ds321",
|
136
|
+
server_type: {
|
137
|
+
id: "typ-12345"
|
138
|
+
},
|
139
|
+
cloud_ips: [],
|
140
|
+
interfaces: []
|
141
|
+
}.to_json)
|
142
|
+
end
|
143
|
+
|
144
|
+
it "does not error" do
|
145
|
+
expect { output }.to_not raise_error
|
146
|
+
|
147
|
+
expect(stderr).to eq("Updating server srv-ds321\n")
|
148
|
+
|
149
|
+
expect(stdout).to match("srv-ds321")
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context "with --base64" do
|
154
|
+
let(:argv) { %w[servers update --base64 srv-ds321] }
|
155
|
+
|
156
|
+
before do
|
157
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
|
158
|
+
.to_return(:status => 200, :body => {
|
159
|
+
id: "srv-ds321",
|
160
|
+
server_type: {
|
161
|
+
id: "typ-12345"
|
162
|
+
},
|
163
|
+
cloud_ips: [],
|
164
|
+
interfaces: []
|
165
|
+
}.to_json)
|
166
|
+
|
167
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
|
168
|
+
.to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
|
169
|
+
|
170
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
|
171
|
+
.with(:body => {
|
172
|
+
compatibility_mode: false
|
173
|
+
})
|
174
|
+
.to_return(:status => 200, :body => {
|
175
|
+
id: "srv-ds321",
|
176
|
+
server_type: {
|
177
|
+
id: "typ-12345"
|
178
|
+
},
|
179
|
+
cloud_ips: [],
|
180
|
+
interfaces: []
|
181
|
+
}.to_json)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "does not error" do
|
185
|
+
expect { output }.to_not raise_error
|
186
|
+
|
187
|
+
expect(stderr).to eq("Updating server srv-ds321\n")
|
188
|
+
|
189
|
+
expect(stdout).to match("srv-ds321")
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
context "with --base64 --user-data" do
|
194
|
+
let(:argv) { %w[servers update --base64 --user-data hello srv-ds321] }
|
195
|
+
|
196
|
+
before do
|
197
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
|
198
|
+
.to_return(:status => 200, :body => {
|
199
|
+
id: "srv-ds321",
|
200
|
+
server_type: {
|
201
|
+
id: "typ-12345"
|
202
|
+
},
|
203
|
+
cloud_ips: [],
|
204
|
+
interfaces: []
|
205
|
+
}.to_json)
|
206
|
+
|
207
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
|
208
|
+
.to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
|
209
|
+
|
210
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
|
211
|
+
.with(:body => {
|
212
|
+
user_data: "aGVsbG8=\n"
|
213
|
+
})
|
214
|
+
.to_return(:status => 200, :body => {
|
215
|
+
id: "srv-ds321",
|
216
|
+
server_type: {
|
217
|
+
id: "typ-12345"
|
218
|
+
},
|
219
|
+
cloud_ips: [],
|
220
|
+
interfaces: []
|
221
|
+
}.to_json)
|
222
|
+
end
|
223
|
+
|
224
|
+
it "does not error" do
|
225
|
+
expect { output }.to_not raise_error
|
226
|
+
|
227
|
+
expect(stderr).to eq("Updating server srv-ds321 with 0.01k of user data\n")
|
228
|
+
|
229
|
+
expect(stdout).to match("srv-ds321")
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
context "with --no-base64 --user-data" do
|
234
|
+
let(:argv) { %w[servers update --no-base64 --user-data hello srv-ds321] }
|
235
|
+
|
236
|
+
before do
|
237
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
|
238
|
+
.to_return(:status => 200, :body => {
|
239
|
+
id: "srv-ds321",
|
240
|
+
server_type: {
|
241
|
+
id: "typ-12345"
|
242
|
+
},
|
243
|
+
cloud_ips: [],
|
244
|
+
interfaces: []
|
245
|
+
}.to_json)
|
246
|
+
|
247
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/images?account_id=acc-12345")
|
248
|
+
.to_return(:status => 200, :body => [{id: "img-12345" }].to_json)
|
249
|
+
|
250
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/servers/srv-ds321?account_id=acc-12345")
|
251
|
+
.with(:body => {
|
252
|
+
user_data: "hello"
|
253
|
+
})
|
254
|
+
.to_return(:status => 200, :body => {
|
255
|
+
id: "srv-ds321",
|
256
|
+
server_type: {
|
257
|
+
id: "typ-12345"
|
258
|
+
},
|
259
|
+
cloud_ips: [],
|
260
|
+
interfaces: []
|
261
|
+
}.to_json)
|
262
|
+
end
|
263
|
+
|
264
|
+
it "does not error" do
|
265
|
+
expect { output }.to_not raise_error
|
266
|
+
|
267
|
+
expect(stderr).to eq("Updating server srv-ds321 with 0.00k of user data\n")
|
268
|
+
|
269
|
+
expect(stdout).to match("srv-ds321")
|
15
270
|
end
|
16
271
|
end
|
17
272
|
end
|
@@ -26,7 +26,7 @@ describe "brightbox sql instances" do
|
|
26
26
|
"maintenance_hour":6}')
|
27
27
|
|
28
28
|
stub_request(:put, "http://api.brightbox.localhost/1.0/database_servers/dbs-12345?account_id=acc-12345")
|
29
|
-
.with(:
|
29
|
+
.with(body: { maintenance_weekday: "1" }.to_json)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "sets custom maintenance window settings" do
|
@@ -46,6 +46,7 @@ describe "brightbox sql instances" do
|
|
46
46
|
.to_return(:status => 200, :body => '{"id":"dbs-12345","snapshots_schedule":"34 12 * * 4","snapshots_schedule_next_at":"2016-07-07T12:34:56Z"}')
|
47
47
|
|
48
48
|
stub_request(:put, "http://api.brightbox.localhost/1.0/database_servers/dbs-12345?account_id=acc-12345")
|
49
|
+
.with(body: { snapshots_schedule: "0 12 * * 4" }.to_json)
|
49
50
|
.to_return(:status => 200, :body => '{"id":"dbs-12345","snapshots_schedule":"34 12 * * 4","snapshots_schedule_next_at":"2016-07-07T12:34:56Z"}')
|
50
51
|
end
|
51
52
|
|
@@ -59,25 +60,26 @@ describe "brightbox sql instances" do
|
|
59
60
|
end
|
60
61
|
|
61
62
|
context "--remove-snapshots-schedule" do
|
62
|
-
let(:dbs) { Brightbox::DatabaseServer.find("dbs-
|
63
|
-
let(:argv) { %w[sql instances update --remove-snapshots-schedule dbs-
|
63
|
+
let(:dbs) { Brightbox::DatabaseServer.find("dbs-432sf") }
|
64
|
+
let(:argv) { %w[sql instances update --remove-snapshots-schedule dbs-432sf] }
|
64
65
|
let(:expected_args) { { :snapshots_schedule => nil } }
|
65
66
|
|
66
67
|
before do
|
67
|
-
stub_request(:get, "http://api.brightbox.localhost/1.0/database_servers/dbs-
|
68
|
-
.to_return(:status => 200, :body => '{"id":"dbs-
|
69
|
-
.to_return(:status => 200, :body => '{"id":"dbs-
|
68
|
+
stub_request(:get, "http://api.brightbox.localhost/1.0/database_servers/dbs-432sf?account_id=acc-12345")
|
69
|
+
.to_return(:status => 200, :body => '{"id":"dbs-432sf","snapshots_schedule":"34 12 * * 4","snapshots_schedule_next_at":"2016-07-07T12:34:56Z"}')
|
70
|
+
.to_return(:status => 200, :body => '{"id":"dbs-432sf","snapshots_schedule":null,"snapshots_schedule_next_at":null}')
|
70
71
|
|
71
|
-
stub_request(:put, "http://api.brightbox.localhost/1.0/database_servers/dbs-
|
72
|
-
.
|
72
|
+
stub_request(:put, "http://api.brightbox.localhost/1.0/database_servers/dbs-432sf?account_id=acc-12345")
|
73
|
+
.with(body: { snapshots_schedule: nil }.to_json)
|
74
|
+
.to_return(:status => 200, :body => '{"id":"dbs-432sf","snapshots_schedule":null,"snapshots_schedule_next_at":null}')
|
73
75
|
end
|
74
76
|
|
75
77
|
it "clears snapshots schedule" do
|
76
78
|
expect(Brightbox::DatabaseServer).to receive(:find).and_return(dbs)
|
77
79
|
expect(dbs).to receive(:update).with(expected_args).and_call_original
|
78
80
|
|
79
|
-
expect(stderr).to eq("Updating dbs-
|
80
|
-
expect(stdout).to include("dbs-
|
81
|
+
expect(stderr).to eq("Updating dbs-432sf\n")
|
82
|
+
expect(stdout).to include("dbs-432sf")
|
81
83
|
end
|
82
84
|
end
|
83
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brightbox-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.
|
4
|
+
version: 4.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Leach
|
@@ -451,6 +451,7 @@ files:
|
|
451
451
|
- lib/brightbox-cli/zones.rb
|
452
452
|
- lib/brightbox/cli/config.rb
|
453
453
|
- lib/brightbox_cli.rb
|
454
|
+
- lib/gli_patches.rb
|
454
455
|
- locales/en.yml
|
455
456
|
- spec/brightbox_spec.rb
|
456
457
|
- spec/cassettes/Brightbox_Account/_all/when_connected_using_an_application/returns_a_collection_of_Accounts.yml
|