brightbox-cli 4.0.0 → 4.2.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 +22 -0
- data/Gemfile.lock +13 -11
- data/Jenkinsfile +12 -32
- data/brightbox-cli.gemspec +5 -5
- data/lib/brightbox-cli/commands/images/register.rb +32 -7
- data/lib/brightbox-cli/commands/servers/create.rb +9 -2
- data/lib/brightbox-cli/version.rb +1 -1
- data/locales/en.yml +2 -0
- data/spec/commands/images/register_spec.rb +137 -1
- data/spec/commands/servers/create_spec.rb +102 -0
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca69156ede91fd3e18f145220446de7c27201dab8cbfeaeb345e8ecb7e5a0b4d
|
4
|
+
data.tar.gz: 6d3490e0f8eabb5d92ed1df481f7ca2bba8a359d7fdf02b554b0265d1fee7294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e0d7038f22cf7dae99d961782761a587b7b3a13f3ad7bd00d17a95816c696b77463b681066993355c7478a935414068d98173110eefa17a38e00e24c2d9a3ec
|
7
|
+
data.tar.gz: 78db49f41e1d8d89fd1b69dfb70cd4d316a9d85b30f3c45c77af541934b2682b5c8e4eef07bafdaba19ca3cf29ea061fe0420c1a2c7b8221f754b7b0bafa154c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
### v4.2.0 / 2022-11-01
|
2
|
+
|
3
|
+
[Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v4.1.0...v4.2.0)
|
4
|
+
|
5
|
+
Changes:
|
6
|
+
|
7
|
+
* Adds three new, mutually exclusive options to `images create` to specify
|
8
|
+
different sources:
|
9
|
+
* `url` can specify source as a URL for a HTTP or HTTPS download rather than
|
10
|
+
an existing FTP upload.
|
11
|
+
* `server` can specify a server ID to create a snapshot image from.
|
12
|
+
* `volume` can specify a volume ID to create a snapshot image from.
|
13
|
+
|
14
|
+
### v4.1.0 / 2022-08-01
|
15
|
+
|
16
|
+
[Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v4.0.0...v4.1.0)
|
17
|
+
|
18
|
+
Changes:
|
19
|
+
|
20
|
+
* Adds `volume-size` to `servers create` to allow passing of arbitrary sizes for
|
21
|
+
network based storage types.
|
22
|
+
|
1
23
|
### v4.0.0 / 2022-08-01
|
2
24
|
|
3
25
|
[Full Changelog](https://github.com/brightbox/brightbox-cli/compare/v3.3.0...v4.0.0)
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
brightbox-cli (4.
|
4
|
+
brightbox-cli (4.2.0)
|
5
5
|
dry-inflector (= 0.2.0)
|
6
|
-
fog-brightbox (>= 1.
|
6
|
+
fog-brightbox (>= 1.8.0)
|
7
7
|
fog-core (< 2.0)
|
8
|
-
gli (~> 2.21
|
9
|
-
highline (~> 1.6
|
8
|
+
gli (~> 2.21)
|
9
|
+
highline (~> 1.6)
|
10
10
|
hirb (~> 0.6)
|
11
11
|
i18n (>= 0.6, < 1.11)
|
12
|
-
mime-types (~>
|
13
|
-
multi_json (~> 1.11
|
12
|
+
mime-types (~> 3.0)
|
13
|
+
multi_json (~> 1.11)
|
14
14
|
|
15
15
|
GEM
|
16
16
|
remote: https://rubygems.org/
|
@@ -25,8 +25,8 @@ GEM
|
|
25
25
|
rexml
|
26
26
|
diff-lcs (1.5.0)
|
27
27
|
dry-inflector (0.2.0)
|
28
|
-
excon (0.
|
29
|
-
fog-brightbox (1.
|
28
|
+
excon (0.93.1)
|
29
|
+
fog-brightbox (1.8.0)
|
30
30
|
dry-inflector
|
31
31
|
fog-core (>= 1.45, < 3.0)
|
32
32
|
fog-json
|
@@ -40,14 +40,16 @@ GEM
|
|
40
40
|
formatador (0.3.0)
|
41
41
|
gli (2.21.0)
|
42
42
|
hashdiff (1.0.1)
|
43
|
-
highline (1.
|
43
|
+
highline (1.7.10)
|
44
44
|
hirb (0.7.3)
|
45
45
|
i18n (1.10.0)
|
46
46
|
concurrent-ruby (~> 1.0)
|
47
47
|
method_source (1.0.0)
|
48
|
-
mime-types (
|
48
|
+
mime-types (3.4.1)
|
49
|
+
mime-types-data (~> 3.2015)
|
50
|
+
mime-types-data (3.2022.0105)
|
49
51
|
mocha (1.14.0)
|
50
|
-
multi_json (1.
|
52
|
+
multi_json (1.15.0)
|
51
53
|
parallel (1.22.1)
|
52
54
|
parser (3.1.2.0)
|
53
55
|
ast (~> 2.4.1)
|
data/Jenkinsfile
CHANGED
@@ -9,54 +9,34 @@ pipeline {
|
|
9
9
|
stages {
|
10
10
|
stage("Run tests") {
|
11
11
|
parallel {
|
12
|
-
stage("Ruby 2.
|
13
|
-
agent {
|
14
|
-
docker {
|
15
|
-
image 'ruby:2.0'
|
16
|
-
}
|
17
|
-
}
|
18
|
-
steps {
|
19
|
-
sh 'bundle install --deployment'
|
20
|
-
sh 'bundle exec rake spec'
|
21
|
-
}
|
22
|
-
}
|
23
|
-
stage("Ruby 2.1") {
|
24
|
-
agent {
|
25
|
-
docker {
|
26
|
-
image 'ruby:2.1'
|
27
|
-
}
|
28
|
-
}
|
29
|
-
steps {
|
30
|
-
sh 'bundle install --deployment'
|
31
|
-
sh 'bundle exec rake spec'
|
32
|
-
}
|
33
|
-
}
|
34
|
-
stage("Ruby 2.2") {
|
12
|
+
stage("Ruby 2.5") {
|
35
13
|
agent {
|
36
14
|
docker {
|
37
|
-
image 'ruby:2.
|
15
|
+
image 'ruby:2.5'
|
38
16
|
}
|
39
17
|
}
|
40
18
|
steps {
|
19
|
+
sh 'gem install bundler:2.1.4'
|
41
20
|
sh 'bundle install --deployment'
|
42
21
|
sh 'bundle exec rake spec'
|
43
22
|
}
|
44
23
|
}
|
45
|
-
stage("Ruby 2.
|
24
|
+
stage("Ruby 2.6") {
|
46
25
|
agent {
|
47
26
|
docker {
|
48
|
-
image 'ruby:2.
|
27
|
+
image 'ruby:2.6'
|
49
28
|
}
|
50
29
|
}
|
51
30
|
steps {
|
31
|
+
sh 'gem install bundler:2.1.4'
|
52
32
|
sh 'bundle install --deployment'
|
53
33
|
sh 'bundle exec rake spec'
|
54
34
|
}
|
55
35
|
}
|
56
|
-
stage("Ruby 2.
|
36
|
+
stage("Ruby 2.7") {
|
57
37
|
agent {
|
58
38
|
docker {
|
59
|
-
image 'ruby:2.
|
39
|
+
image 'ruby:2.7'
|
60
40
|
}
|
61
41
|
}
|
62
42
|
steps {
|
@@ -64,10 +44,10 @@ pipeline {
|
|
64
44
|
sh 'bundle exec rake spec'
|
65
45
|
}
|
66
46
|
}
|
67
|
-
stage("Ruby
|
47
|
+
stage("Ruby 3.0") {
|
68
48
|
agent {
|
69
49
|
docker {
|
70
|
-
image 'ruby:
|
50
|
+
image 'ruby:3.0'
|
71
51
|
}
|
72
52
|
}
|
73
53
|
steps {
|
@@ -75,10 +55,10 @@ pipeline {
|
|
75
55
|
sh 'bundle exec rake spec'
|
76
56
|
}
|
77
57
|
}
|
78
|
-
stage("Ruby
|
58
|
+
stage("Ruby 3.1") {
|
79
59
|
agent {
|
80
60
|
docker {
|
81
|
-
image 'ruby:
|
61
|
+
image 'ruby:3.1'
|
82
62
|
}
|
83
63
|
}
|
84
64
|
steps {
|
data/brightbox-cli.gemspec
CHANGED
@@ -21,14 +21,14 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
|
-
s.add_dependency "fog-brightbox", ">= 1.
|
24
|
+
s.add_dependency "fog-brightbox", ">= 1.8.0"
|
25
25
|
s.add_dependency "fog-core", "< 2.0"
|
26
|
-
s.add_dependency "gli", "~> 2.21
|
27
|
-
s.add_dependency "highline", "~> 1.6
|
26
|
+
s.add_dependency "gli", "~> 2.21"
|
27
|
+
s.add_dependency "highline", "~> 1.6"
|
28
28
|
s.add_dependency "hirb", "~> 0.6"
|
29
29
|
s.add_dependency "i18n", ">= 0.6", "< 1.11"
|
30
|
-
s.add_dependency "mime-types", "~>
|
31
|
-
s.add_dependency "multi_json", "~> 1.11
|
30
|
+
s.add_dependency "mime-types", "~> 3.0"
|
31
|
+
s.add_dependency "multi_json", "~> 1.11"
|
32
32
|
|
33
33
|
# Indirect dependency
|
34
34
|
# 0.3 drops support for Ruby < 2.7
|
@@ -11,17 +11,26 @@ module Brightbox
|
|
11
11
|
c.desc "Image Username"
|
12
12
|
c.flag [:u, "username"]
|
13
13
|
|
14
|
-
c.desc "
|
14
|
+
c.desc "Architecture of the image (i686 or x86_64)"
|
15
15
|
c.flag [:a, "arch"]
|
16
16
|
|
17
17
|
c.desc "Source filename of the image you uploaded to the image library"
|
18
18
|
c.flag [:s, "source"]
|
19
19
|
|
20
|
+
c.desc "Source server ID to create image from"
|
21
|
+
c.flag ["server"]
|
22
|
+
|
23
|
+
c.desc "Source URL of the image to download via HTTP"
|
24
|
+
c.flag ["url"]
|
25
|
+
|
26
|
+
c.desc "Source volume ID to create image from"
|
27
|
+
c.flag ["volume"]
|
28
|
+
|
20
29
|
c.desc "Set image mode to be either 'virtio' or 'compatibility'"
|
21
30
|
c.default_value "virtio"
|
22
31
|
c.flag [:m, "mode"]
|
23
32
|
|
24
|
-
c.desc "Set image to be
|
33
|
+
c.desc "Set image to be publicly visible (true or false)"
|
25
34
|
c.default_value "false"
|
26
35
|
c.flag [:p, "public"]
|
27
36
|
|
@@ -30,22 +39,38 @@ module Brightbox
|
|
30
39
|
|
31
40
|
c.action do |global_options, options, _args|
|
32
41
|
raise "You must specify the architecture" unless options[:a]
|
33
|
-
raise "You must specify the source filename" unless options[:s]
|
34
42
|
raise "Mode must be 'virtio' or 'compatibility'" unless options[:m] == "virtio" || options[:m] == "compatibility"
|
35
43
|
raise "Public must be true or false" unless options[:p] == "true" || options[:p] == "false"
|
36
44
|
|
45
|
+
# Sources are mutually exclusive but at least one is required from this list
|
46
|
+
source_options = [:s, :server, :url, :volume].map { |k| options[k] }
|
47
|
+
|
48
|
+
if source_options.none?
|
49
|
+
raise "You must specify one of 'server', 'source', 'url', or 'volume'"
|
50
|
+
elsif !source_options.one?
|
51
|
+
raise "You cannot register from multiple sources. Use either 'source', 'server', 'url', or 'volume'"
|
52
|
+
end
|
53
|
+
|
37
54
|
compatibility_flag = options[:m] == "compatibility"
|
38
55
|
|
39
56
|
public_flag = options[:p] == "true"
|
40
57
|
|
41
58
|
image_options = {
|
42
|
-
:
|
43
|
-
:username => options[:u], :source => options[:s],
|
59
|
+
:arch => options[:a],
|
44
60
|
:compatibility_mode => compatibility_flag,
|
45
|
-
:description => options[:d],
|
46
|
-
:min_ram => options["min-ram"].to_i
|
61
|
+
:description => options[:d],
|
62
|
+
:min_ram => options["min-ram"].to_i,
|
63
|
+
:name => options[:n],
|
64
|
+
:public => public_flag,
|
65
|
+
:username => options[:u]
|
47
66
|
}
|
48
67
|
|
68
|
+
# These should be limited to one by the mutually exclusive check earlier
|
69
|
+
image_options[:http_url] = options[:url] if options[:url]
|
70
|
+
image_options[:server] = options[:server] if options[:server]
|
71
|
+
image_options[:source] = options[:s] if options[:s]
|
72
|
+
image_options[:volume] = options[:volume] if options[:volume]
|
73
|
+
|
49
74
|
image = Image.register(image_options)
|
50
75
|
|
51
76
|
render_table([image], global_options)
|
@@ -37,6 +37,9 @@ module Brightbox
|
|
37
37
|
c.desc I18n.t("servers.create.cloud_ip.desc")
|
38
38
|
c.flag ["cloud-ip"]
|
39
39
|
|
40
|
+
c.desc I18n.t("servers.create.volume_size.desc")
|
41
|
+
c.flag ["volume-size"]
|
42
|
+
|
40
43
|
c.action do |global_options, options, args|
|
41
44
|
if args.empty?
|
42
45
|
raise "You must specify the image_id as the first argument"
|
@@ -114,13 +117,17 @@ module Brightbox
|
|
114
117
|
:flavor_id => type.id,
|
115
118
|
:zone_id => zone.to_s,
|
116
119
|
:name => options[:n],
|
117
|
-
:user_data => user_data
|
118
|
-
:server_groups => server_groups.map(&:id)
|
120
|
+
:user_data => user_data
|
119
121
|
}
|
120
122
|
|
123
|
+
params[:server_groups] = server_groups.map(&:id) if server_groups.any?
|
121
124
|
params[:cloud_ip] = options[:"cloud-ip"] if options.key?(:"cloud-ip")
|
122
125
|
params[:disk_encrypted] = options[:"disk-encrypted"] if options.key?(:"disk-encrypted")
|
123
126
|
|
127
|
+
if options.key?(:"volume-size") && !options[:"volume-size"].nil?
|
128
|
+
params[:volume_size] = options[:"volume-size"].to_i
|
129
|
+
end
|
130
|
+
|
124
131
|
servers = Server.create_servers options[:i], params
|
125
132
|
render_table(servers, global_options)
|
126
133
|
end
|
data/locales/en.yml
CHANGED
@@ -144,6 +144,8 @@ en:
|
|
144
144
|
desc: Create servers
|
145
145
|
cloud_ip:
|
146
146
|
desc: Immediately map a Cloud IP to new server? Either "true" or the identifier of the Cloud IP
|
147
|
+
volume_size:
|
148
|
+
desc: Specify a custom volume size (in MiB) when building a network block storage server
|
147
149
|
destroy:
|
148
150
|
desc: Destroy servers
|
149
151
|
lock:
|
@@ -23,7 +23,67 @@ describe "brightbox images" do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
context "
|
26
|
+
context "without any source" do
|
27
|
+
let(:argv) { %w[images register --arch x86_64] }
|
28
|
+
|
29
|
+
it "does not error" do
|
30
|
+
expect { output }.to_not raise_error
|
31
|
+
|
32
|
+
expect(stderr).to match("ERROR: You must specify one of 'server', 'source', 'url', or 'volume'")
|
33
|
+
expect(stdout).to match("")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with mutually exclusive arguments" do
|
38
|
+
let(:argv) { %w[images register --arch x86_64 --source test.img --url http://example.com/test.img] }
|
39
|
+
|
40
|
+
it "does not error" do
|
41
|
+
expect { output }.to_not raise_error
|
42
|
+
|
43
|
+
expect(stderr).to match("ERROR: You cannot register from multiple sources. Use either 'source', 'server', 'url', or 'volume'")
|
44
|
+
expect(stdout).to match("")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "with 'server' argument" do
|
49
|
+
let(:argv) { %w[images register --arch x86_64 --server srv-12345] }
|
50
|
+
|
51
|
+
before do
|
52
|
+
expect(Brightbox::Image).to receive(:register)
|
53
|
+
.with(hash_including(
|
54
|
+
arch: "x86_64",
|
55
|
+
server: "srv-12345"
|
56
|
+
))
|
57
|
+
.and_call_original
|
58
|
+
|
59
|
+
stub_request(:post, "#{api_url}/1.0/images?account_id=acc-12345")
|
60
|
+
.with(body: /"server":"srv-12345"/)
|
61
|
+
.to_return(
|
62
|
+
status: 201,
|
63
|
+
body: {
|
64
|
+
id: "img-12345"
|
65
|
+
}.to_json
|
66
|
+
)
|
67
|
+
|
68
|
+
stub_request(:get, "#{api_url}/1.0/images/img-12345?account_id=acc-12345")
|
69
|
+
.to_return(
|
70
|
+
status: 200,
|
71
|
+
body: {
|
72
|
+
id: "img-12345"
|
73
|
+
}.to_json
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "does not error" do
|
78
|
+
expect { output }.to_not raise_error
|
79
|
+
|
80
|
+
expect(stderr).to match("")
|
81
|
+
expect(stderr).not_to match("ERROR")
|
82
|
+
expect(stdout).to match("img-12345")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "with 'source' argument" do
|
27
87
|
let(:argv) { %w[images register --arch x86_64 --source custom.img] }
|
28
88
|
|
29
89
|
before do
|
@@ -61,6 +121,82 @@ describe "brightbox images" do
|
|
61
121
|
end
|
62
122
|
end
|
63
123
|
|
124
|
+
context "with 'url' argument" do
|
125
|
+
let(:argv) { %w[images register --arch x86_64 --url https://example.com/os-22.iso] }
|
126
|
+
|
127
|
+
before do
|
128
|
+
expect(Brightbox::Image).to receive(:register)
|
129
|
+
.with(hash_including(
|
130
|
+
arch: "x86_64",
|
131
|
+
http_url: "https://example.com/os-22.iso"
|
132
|
+
))
|
133
|
+
.and_call_original
|
134
|
+
|
135
|
+
stub_request(:post, "#{api_url}/1.0/images?account_id=acc-12345")
|
136
|
+
.with(body: %r{"http_url":"https://example.com/os-22.iso"})
|
137
|
+
.to_return(
|
138
|
+
status: 201,
|
139
|
+
body: {
|
140
|
+
id: "img-12345"
|
141
|
+
}.to_json
|
142
|
+
)
|
143
|
+
|
144
|
+
stub_request(:get, "#{api_url}/1.0/images/img-12345?account_id=acc-12345")
|
145
|
+
.to_return(
|
146
|
+
status: 200,
|
147
|
+
body: {
|
148
|
+
id: "img-12345"
|
149
|
+
}.to_json
|
150
|
+
)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "does not error" do
|
154
|
+
expect { output }.to_not raise_error
|
155
|
+
|
156
|
+
expect(stderr).to match("")
|
157
|
+
expect(stderr).not_to match("ERROR")
|
158
|
+
expect(stdout).to match("img-12345")
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context "with 'volume' argument" do
|
163
|
+
let(:argv) { %w[images register --arch x86_64 --volume vol-12345] }
|
164
|
+
|
165
|
+
before do
|
166
|
+
expect(Brightbox::Image).to receive(:register)
|
167
|
+
.with(hash_including(
|
168
|
+
arch: "x86_64",
|
169
|
+
volume: "vol-12345"
|
170
|
+
))
|
171
|
+
.and_call_original
|
172
|
+
|
173
|
+
stub_request(:post, "#{api_url}/1.0/images?account_id=acc-12345")
|
174
|
+
.with(body: /"volume":"vol-12345"/)
|
175
|
+
.to_return(
|
176
|
+
status: 201,
|
177
|
+
body: {
|
178
|
+
id: "img-12345"
|
179
|
+
}.to_json
|
180
|
+
)
|
181
|
+
|
182
|
+
stub_request(:get, "#{api_url}/1.0/images/img-12345?account_id=acc-12345")
|
183
|
+
.to_return(
|
184
|
+
status: 200,
|
185
|
+
body: {
|
186
|
+
id: "img-12345"
|
187
|
+
}.to_json
|
188
|
+
)
|
189
|
+
end
|
190
|
+
|
191
|
+
it "does not error" do
|
192
|
+
expect { output }.to_not raise_error
|
193
|
+
|
194
|
+
expect(stderr).to match("")
|
195
|
+
expect(stderr).not_to match("ERROR")
|
196
|
+
expect(stdout).to match("img-12345")
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
64
200
|
context "with min-ram argument" do
|
65
201
|
let(:argv) { %w[images register --arch x86_64 --source custom.img --min-ram 2048] }
|
66
202
|
|
@@ -28,6 +28,24 @@ describe "brightbox servers" do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
context "with image argument" do
|
32
|
+
let(:argv) { %w[servers create img-12345] }
|
33
|
+
|
34
|
+
before do
|
35
|
+
expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
|
36
|
+
expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "does not error" do
|
40
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
|
41
|
+
.with(:body => hash_including(image: "img-12345"))
|
42
|
+
.and_return(:status => 202, :body => sample_response)
|
43
|
+
|
44
|
+
expect(stderr).not_to match("ERROR")
|
45
|
+
expect(stdout).to match("srv-12345")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
31
49
|
context "with --cloud-ip with nominated IP argument" do
|
32
50
|
let(:argv) { %w[servers create --cloud-ip cip-12345 img-12345] }
|
33
51
|
|
@@ -86,6 +104,90 @@ describe "brightbox servers" do
|
|
86
104
|
end
|
87
105
|
end
|
88
106
|
|
107
|
+
context "with --server-groups flag" do
|
108
|
+
let(:argv) { %w[servers create --server-groups grp-12345,grp-67890 img-12345] }
|
109
|
+
let(:group_ids) { %w(grp-12345 grp-67890) }
|
110
|
+
let(:group_one) { double(:id => "grp-12345") }
|
111
|
+
let(:group_two) { double(:id => "grp-67890") }
|
112
|
+
|
113
|
+
before do
|
114
|
+
expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
|
115
|
+
expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
|
116
|
+
expect(Brightbox::ServerGroup).to receive(:find_or_call).with(group_ids).and_return([group_one, group_two])
|
117
|
+
end
|
118
|
+
|
119
|
+
it "requests new server be in both server groups" do
|
120
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
|
121
|
+
.with(:headers => { "Content-Type" => "application/json" },
|
122
|
+
:body => hash_including(:server_groups => group_ids))
|
123
|
+
.and_return(:status => 202, :body => sample_response)
|
124
|
+
|
125
|
+
expect(stderr).to match("Creating a nano")
|
126
|
+
expect(stderr).not_to match("ERROR")
|
127
|
+
expect(stdout).to match("srv-12345")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context "without --server-groups flag" do
|
132
|
+
let(:argv) { %w[servers create img-12345] }
|
133
|
+
|
134
|
+
before do
|
135
|
+
expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
|
136
|
+
expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "requests new server be in both server groups" do
|
140
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
|
141
|
+
.with(:headers => { "Content-Type" => "application/json" })
|
142
|
+
.with { |request| hash_excluding("server_groups") === JSON.parse(request.body) }
|
143
|
+
.and_return(:status => 202, :body => sample_response)
|
144
|
+
|
145
|
+
expect(stderr).to match("Creating a nano")
|
146
|
+
expect(stderr).not_to match("ERROR")
|
147
|
+
expect(stdout).to match("srv-12345")
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context "with --volume-size switch", vcr: false do
|
152
|
+
context "with network storage" do
|
153
|
+
let(:argv) { %w[servers create --type=2gb.nbs --volume-size=10000 img-12345] }
|
154
|
+
|
155
|
+
before do
|
156
|
+
expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
|
157
|
+
expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "requests new server with a custom volume size" do
|
161
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
|
162
|
+
.with(:headers => { "Content-Type" => "application/json" },
|
163
|
+
body: hash_including(volumes: [{ image: "img-12345", size: 10000 }]))
|
164
|
+
.and_return(status: 202, body: sample_response)
|
165
|
+
|
166
|
+
expect(stderr).not_to match("ERROR")
|
167
|
+
expect(stdout).to match("srv-12345")
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context "without network storage type" do
|
172
|
+
let(:argv) { %w[servers create --type=nano --volume-size=10000 img-12345] }
|
173
|
+
|
174
|
+
before do
|
175
|
+
expect(Brightbox::Image).to receive(:find).with("img-12345").and_return(image)
|
176
|
+
expect(Brightbox::Type).to receive(:find_by_handle).and_return(type)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "requests new server with a custom volume size" do
|
180
|
+
stub_request(:post, "http://api.brightbox.localhost/1.0/servers?account_id=acc-12345")
|
181
|
+
.with(:headers => { "Content-Type" => "application/json" },
|
182
|
+
body: hash_including(volumes: [{ image: "img-12345", size: 10000 }]))
|
183
|
+
.and_return(status: 202, body: sample_response)
|
184
|
+
|
185
|
+
expect(stderr).not_to match("ERROR")
|
186
|
+
expect(stdout).to match("srv-12345")
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
89
191
|
def sample_response
|
90
192
|
'{
|
91
193
|
"id": "srv-12345",
|
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.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Leach
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.
|
20
|
+
version: 1.8.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.
|
27
|
+
version: 1.8.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: fog-core
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,28 +45,28 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 2.21
|
48
|
+
version: '2.21'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 2.21
|
55
|
+
version: '2.21'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: highline
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 1.6
|
62
|
+
version: '1.6'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 1.6
|
69
|
+
version: '1.6'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: hirb
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,28 +107,28 @@ dependencies:
|
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '3.0'
|
111
111
|
type: :runtime
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '3.0'
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
119
|
name: multi_json
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.11
|
124
|
+
version: '1.11'
|
125
125
|
type: :runtime
|
126
126
|
prerelease: false
|
127
127
|
version_requirements: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.11
|
131
|
+
version: '1.11'
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
133
|
name: dry-inflector
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|