stork 0.1.0.pre
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 +7 -0
- data/.gitignore +21 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +75 -0
- data/LICENSE +201 -0
- data/README.md +61 -0
- data/Rakefile +25 -0
- data/bin/stork +97 -0
- data/bin/storkctl +62 -0
- data/lib/stork/builder.rb +104 -0
- data/lib/stork/client/plugins/host_install.rb +19 -0
- data/lib/stork/client/plugins/host_list.rb +12 -0
- data/lib/stork/client/plugins/host_localboot.rb +19 -0
- data/lib/stork/client/plugins/host_show.rb +19 -0
- data/lib/stork/collection/base.rb +45 -0
- data/lib/stork/collection/chefs.rb +6 -0
- data/lib/stork/collection/distros.rb +6 -0
- data/lib/stork/collection/hosts.rb +6 -0
- data/lib/stork/collection/layouts.rb +6 -0
- data/lib/stork/collection/networks.rb +6 -0
- data/lib/stork/collection/snippets.rb +6 -0
- data/lib/stork/collection/templates.rb +6 -0
- data/lib/stork/collections.rb +38 -0
- data/lib/stork/configuration.rb +98 -0
- data/lib/stork/deploy/command.rb +59 -0
- data/lib/stork/deploy/install_script.rb +39 -0
- data/lib/stork/deploy/kickstart_binding.rb +222 -0
- data/lib/stork/deploy/section.rb +30 -0
- data/lib/stork/deploy/snippet_binding.rb +49 -0
- data/lib/stork/plugin.rb +54 -0
- data/lib/stork/pxe.rb +70 -0
- data/lib/stork/resource/base.rb +42 -0
- data/lib/stork/resource/chef.rb +81 -0
- data/lib/stork/resource/delegator.rb +50 -0
- data/lib/stork/resource/distro.rb +30 -0
- data/lib/stork/resource/firewall.rb +47 -0
- data/lib/stork/resource/host.rb +202 -0
- data/lib/stork/resource/interface.rb +125 -0
- data/lib/stork/resource/layout.rb +50 -0
- data/lib/stork/resource/logical_volume.rb +49 -0
- data/lib/stork/resource/network.rb +36 -0
- data/lib/stork/resource/partition.rb +47 -0
- data/lib/stork/resource/password.rb +26 -0
- data/lib/stork/resource/repo.rb +29 -0
- data/lib/stork/resource/snippet.rb +20 -0
- data/lib/stork/resource/template.rb +24 -0
- data/lib/stork/resource/timezone.rb +31 -0
- data/lib/stork/resource/volume_group.rb +31 -0
- data/lib/stork/resources.rb +17 -0
- data/lib/stork/server/application.rb +127 -0
- data/lib/stork/server/control.rb +38 -0
- data/lib/stork/version.rb +4 -0
- data/lib/stork.rb +30 -0
- data/specs/builder_spec.rb +14 -0
- data/specs/collections_spec.rb +72 -0
- data/specs/configuration_spec.rb +151 -0
- data/specs/keys/snakeoil-root.pem +27 -0
- data/specs/keys/snakeoil-validation.pem +27 -0
- data/specs/kickstart_spec.rb +36 -0
- data/specs/pxe_spec.rb +57 -0
- data/specs/resource_chef_spec.rb +122 -0
- data/specs/resource_distro_spec.rb +38 -0
- data/specs/resource_firewall_spec.rb +71 -0
- data/specs/resource_host_spec.rb +323 -0
- data/specs/resource_interface_spec.rb +158 -0
- data/specs/resource_layout_spec.rb +78 -0
- data/specs/resource_logical_volume_spec.rb +44 -0
- data/specs/resource_network_spec.rb +45 -0
- data/specs/resource_partition_spec.rb +51 -0
- data/specs/resource_password_spec.rb +10 -0
- data/specs/resource_repo_spec.rb +43 -0
- data/specs/resource_snippet_spec.rb +10 -0
- data/specs/resource_template_spec.rb +5 -0
- data/specs/resource_timezone_spec.rb +5 -0
- data/specs/resource_volume_group_spec.rb +23 -0
- data/specs/scripts/kssetup.sh +24 -0
- data/specs/scripts/ksvalidate.sh +21 -0
- data/specs/server_spec.rb +84 -0
- data/specs/spec_helper.rb +33 -0
- data/specs/stork/authorized_keys +1 -0
- data/specs/stork/bundles/chefs/default.rb +9 -0
- data/specs/stork/bundles/distros/centos.rb +5 -0
- data/specs/stork/bundles/hosts/example.org.rb +66 -0
- data/specs/stork/bundles/layouts/home.rb +33 -0
- data/specs/stork/bundles/networks/local.rb +6 -0
- data/specs/stork/bundles/networks/org.rb +7 -0
- data/specs/stork/bundles/snippets/authorized-keys.erb +10 -0
- data/specs/stork/bundles/snippets/chef-bootstrap.erb +104 -0
- data/specs/stork/bundles/snippets/chef-reconfigure.erb +22 -0
- data/specs/stork/bundles/snippets/etc-hosts.erb +6 -0
- data/specs/stork/bundles/snippets/network-config.erb +7 -0
- data/specs/stork/bundles/snippets/noop.erb +1 -0
- data/specs/stork/bundles/snippets/notify.erb +2 -0
- data/specs/stork/bundles/snippets/ntp.erb +2 -0
- data/specs/stork/bundles/snippets/resolv-conf.erb +6 -0
- data/specs/stork/bundles/snippets/setup.erb +1 -0
- data/specs/stork/bundles/templates/default.ks.erb +25 -0
- data/specs/stork/config.rb +11 -0
- data/stork.gemspec +35 -0
- metadata +329 -0
@@ -0,0 +1,323 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Stork::Resource::Host" do
|
4
|
+
it "must create a host" do
|
5
|
+
Stork::Resource::Host.new.must_be_instance_of Stork::Resource::Host
|
6
|
+
end
|
7
|
+
|
8
|
+
it "must respond to the name method" do
|
9
|
+
Stork::Resource::Host.new.must_respond_to :name
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must respond to the layout accessors" do
|
13
|
+
Stork::Resource::Host.new.must_respond_to :layout
|
14
|
+
Stork::Resource::Host.new.must_respond_to :layout=
|
15
|
+
end
|
16
|
+
|
17
|
+
it "must respond to the template accessors" do
|
18
|
+
Stork::Resource::Host.new.must_respond_to :template
|
19
|
+
Stork::Resource::Host.new.must_respond_to :template=
|
20
|
+
end
|
21
|
+
|
22
|
+
it "must respond to the chef accessors" do
|
23
|
+
Stork::Resource::Host.new.must_respond_to :chef
|
24
|
+
Stork::Resource::Host.new.must_respond_to :chef=
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must respond to the pxemac accessors" do
|
28
|
+
Stork::Resource::Host.new.must_respond_to :pxemac
|
29
|
+
Stork::Resource::Host.new.must_respond_to :pxemac=
|
30
|
+
end
|
31
|
+
|
32
|
+
it "must respond to the pre_snippets accessors" do
|
33
|
+
Stork::Resource::Host.new.must_respond_to :pre_snippets
|
34
|
+
Stork::Resource::Host.new.must_respond_to :pre_snippets=
|
35
|
+
end
|
36
|
+
|
37
|
+
it "must respond to the post_snippets accessors" do
|
38
|
+
Stork::Resource::Host.new.must_respond_to :post_snippets
|
39
|
+
Stork::Resource::Host.new.must_respond_to :post_snippets=
|
40
|
+
end
|
41
|
+
|
42
|
+
it "must respond to the interfaces accessors" do
|
43
|
+
Stork::Resource::Host.new.must_respond_to :interfaces
|
44
|
+
Stork::Resource::Host.new.must_respond_to :interfaces=
|
45
|
+
end
|
46
|
+
|
47
|
+
it "must respond to the distro accessors" do
|
48
|
+
Stork::Resource::Host.new.must_respond_to :distro
|
49
|
+
Stork::Resource::Host.new.must_respond_to :distro=
|
50
|
+
end
|
51
|
+
|
52
|
+
it "must respond to the run_list accessors" do
|
53
|
+
Stork::Resource::Host.new.must_respond_to :run_list
|
54
|
+
Stork::Resource::Host.new.must_respond_to :run_list=
|
55
|
+
end
|
56
|
+
|
57
|
+
it "must respond to the repos accessors" do
|
58
|
+
Stork::Resource::Host.new.must_respond_to :repos
|
59
|
+
Stork::Resource::Host.new.must_respond_to :repos=
|
60
|
+
end
|
61
|
+
|
62
|
+
# it "must raise an error if the template is not found" do
|
63
|
+
# proc {
|
64
|
+
# host = Stork::Resource::Host.build configuration, collection, "example.org" do
|
65
|
+
# template "invalid"
|
66
|
+
# end
|
67
|
+
# }.must_raise(SyntaxError)
|
68
|
+
# end
|
69
|
+
|
70
|
+
# it "must raise an error if the snippet is not found for pre" do
|
71
|
+
# proc {
|
72
|
+
# host = Stork::Resource::Host.build configuration, collection, "example.org" do
|
73
|
+
# pre_snippet "invalid"
|
74
|
+
# end
|
75
|
+
# }.must_raise(SyntaxError)
|
76
|
+
# end
|
77
|
+
|
78
|
+
# it "must raise an error if the snippet is not found for post" do
|
79
|
+
# proc {
|
80
|
+
# host = Stork::Resource::Host.build configuration, collection, "example.org" do
|
81
|
+
# post_snippet "invalid"
|
82
|
+
# end
|
83
|
+
# }.must_raise(SyntaxError)
|
84
|
+
# end
|
85
|
+
|
86
|
+
# it "must raise an error if a block is not passed to firewall" do
|
87
|
+
# proc {
|
88
|
+
# host = Stork::Resource::Host.build configuration, collection, "example.org" do
|
89
|
+
# firewall
|
90
|
+
# end
|
91
|
+
# }.must_raise(SyntaxError)
|
92
|
+
# end
|
93
|
+
|
94
|
+
# it "must raise an error if a block is not passed to password" do
|
95
|
+
# proc {
|
96
|
+
# host = Stork::Resource::Host.build configuration, collection, "example.org" do
|
97
|
+
# password
|
98
|
+
# end
|
99
|
+
# }.must_raise(SyntaxError)
|
100
|
+
# end
|
101
|
+
|
102
|
+
# it "must build inline" do
|
103
|
+
# ckey = "./specs/keys/snakeoil-root.pem"
|
104
|
+
# vkey = "./specs/keys/snakeoil-validation.pem"
|
105
|
+
|
106
|
+
# host = Stork::Resource::Host.build configuration, collection, "example.org" do
|
107
|
+
# template "default"
|
108
|
+
# pxemac "00:11:22:33:44:55"
|
109
|
+
|
110
|
+
# repo 'foo', baseurl: 'http://foo.com'
|
111
|
+
|
112
|
+
# distro "centos" do
|
113
|
+
# kernel "vmlinuz"
|
114
|
+
# image "initrd.img"
|
115
|
+
# url "http://mirror.example.com/centos"
|
116
|
+
# end
|
117
|
+
|
118
|
+
# layout "default" do
|
119
|
+
# clearpart
|
120
|
+
# zerombr
|
121
|
+
# part "/boot" do
|
122
|
+
# size 100
|
123
|
+
# type "ext4"
|
124
|
+
# primary
|
125
|
+
# end
|
126
|
+
|
127
|
+
# part "swap" do
|
128
|
+
# type "swap"
|
129
|
+
# primary
|
130
|
+
# recommended
|
131
|
+
# end
|
132
|
+
|
133
|
+
# part "/" do
|
134
|
+
# size 4096
|
135
|
+
# type "ext4"
|
136
|
+
# end
|
137
|
+
|
138
|
+
# part "/home" do
|
139
|
+
# size 1
|
140
|
+
# type "ext4"
|
141
|
+
# grow
|
142
|
+
# end
|
143
|
+
# end
|
144
|
+
|
145
|
+
# chef "default" do
|
146
|
+
# url "https://chef.example.org"
|
147
|
+
# version "11.6.0"
|
148
|
+
# client_name "root"
|
149
|
+
# client_key ckey
|
150
|
+
# validator_name "chef-validator"
|
151
|
+
# validation_key vkey
|
152
|
+
# encrypted_data_bag_secret "secretkey"
|
153
|
+
# end
|
154
|
+
|
155
|
+
# interface "eth0" do
|
156
|
+
# bootproto :static
|
157
|
+
# ip "192.168.1.10"
|
158
|
+
# netmask "255.255.255.0"
|
159
|
+
# gateway "192.168.1.1"
|
160
|
+
# nameserver "192.168.1.253"
|
161
|
+
# nameserver "192.168.1.252"
|
162
|
+
# end
|
163
|
+
# end
|
164
|
+
|
165
|
+
# host.name.must_equal "example.org"
|
166
|
+
# host.pxemac.must_equal "00:11:22:33:44:55"
|
167
|
+
# host.distro.name.must_equal "centos"
|
168
|
+
# host.distro.kernel.must_equal "vmlinuz"
|
169
|
+
# host.distro.image.must_equal "initrd.img"
|
170
|
+
# host.distro.url.must_equal "http://mirror.example.com/centos"
|
171
|
+
# host.layout.clearpart.must_equal true
|
172
|
+
# host.layout.zerombr.must_equal true
|
173
|
+
# parts = host.layout.partitions
|
174
|
+
# parts[0].path.must_equal '/boot'
|
175
|
+
# parts[0].size.must_equal 100
|
176
|
+
# parts[0].type.must_equal "ext4"
|
177
|
+
# parts[0].primary.must_equal true
|
178
|
+
# parts[1].path.must_equal 'swap'
|
179
|
+
# parts[1].type.must_equal "swap"
|
180
|
+
# parts[1].recommended.must_equal true
|
181
|
+
# parts[2].path.must_equal "/"
|
182
|
+
# parts[2].size.must_equal 4096
|
183
|
+
# parts[3].path.must_equal "/home"
|
184
|
+
# parts[3].type.must_equal "ext4"
|
185
|
+
# parts[3].grow.must_equal true
|
186
|
+
# host.chef.url.must_equal "https://chef.example.org"
|
187
|
+
# host.chef.version.must_equal "11.6.0"
|
188
|
+
# host.chef.client_name.must_equal "root"
|
189
|
+
# host.chef.client_key.must_equal File.read(ckey)
|
190
|
+
# host.chef.validator_name.must_equal "chef-validator"
|
191
|
+
# host.chef.validation_key.must_equal File.read(vkey)
|
192
|
+
# host.chef.encrypted_data_bag_secret.must_equal "secretkey"
|
193
|
+
# interface = host.interfaces.first
|
194
|
+
# interface.device.must_equal "eth0"
|
195
|
+
# interface.bootproto.must_equal :static
|
196
|
+
# interface.ip.must_equal "192.168.1.10"
|
197
|
+
# interface.netmask.must_equal "255.255.255.0"
|
198
|
+
# interface.gateway.must_equal "192.168.1.1"
|
199
|
+
# interface.nameservers.must_equal ["192.168.1.253", "192.168.1.252"]
|
200
|
+
# end
|
201
|
+
|
202
|
+
# it "must build with collections" do
|
203
|
+
# ckey = "./specs/files/configs/keys/snakeoil-root.pem"
|
204
|
+
# vkey = "./specs/files/configs/keys/snakeoil-validation.pem"
|
205
|
+
# collection = Midwife::Collection.new
|
206
|
+
#
|
207
|
+
# distro = Stork::Resource::Distro.build("centos") do
|
208
|
+
# kernel "vmlinuz"
|
209
|
+
# image "initrd.img"
|
210
|
+
# url "http://mirror.example.com/centos"
|
211
|
+
# end
|
212
|
+
#
|
213
|
+
# layout = Stork::Resource::Layout.build("default") do
|
214
|
+
# clearpart
|
215
|
+
# zerombr
|
216
|
+
# part "/boot" do
|
217
|
+
# size 100
|
218
|
+
# type "ext4"
|
219
|
+
# primary
|
220
|
+
# end
|
221
|
+
#
|
222
|
+
# part "swap" do
|
223
|
+
# type "swap"
|
224
|
+
# primary
|
225
|
+
# recommended
|
226
|
+
# end
|
227
|
+
#
|
228
|
+
# part "/" do
|
229
|
+
# size 4096
|
230
|
+
# type "ext4"
|
231
|
+
# end
|
232
|
+
#
|
233
|
+
# part "/home" do
|
234
|
+
# size 1
|
235
|
+
# type "ext4"
|
236
|
+
# grow
|
237
|
+
# end
|
238
|
+
# end
|
239
|
+
#
|
240
|
+
# chef = Stork::Resource::Chef.build("default") do
|
241
|
+
# url "https://chef.example.org"
|
242
|
+
# version "11.6.0"
|
243
|
+
# client_name "root"
|
244
|
+
# client_key ckey
|
245
|
+
# validator_name "chef-validator"
|
246
|
+
# validation_key vkey
|
247
|
+
# encrypted_data_bag_secret "secretkey"
|
248
|
+
# end
|
249
|
+
#
|
250
|
+
# net = Stork::Resource::Network.build("local") do
|
251
|
+
# netmask "255.255.255.0"
|
252
|
+
# gateway "192.168.1.1"
|
253
|
+
# nameserver "192.168.1.253"
|
254
|
+
# nameserver "192.168.1.252"
|
255
|
+
# end
|
256
|
+
#
|
257
|
+
# snip = Stork::Resource::Snippet.new(File.dirname(__FILE__) + '/files/configs/snippets/noop.erb')
|
258
|
+
#
|
259
|
+
# collection.distros.add(distro)
|
260
|
+
# collection.layouts.add(layout)
|
261
|
+
# collection.chefs.add(chef)
|
262
|
+
# collection.networks.add(net)
|
263
|
+
# collection.snippets.add(snip)
|
264
|
+
#
|
265
|
+
# host = Stork::Resource::Host.build(collection, "example.org") do
|
266
|
+
# template "default"
|
267
|
+
# pxemac "00:11:22:33:44:55"
|
268
|
+
#
|
269
|
+
# distro "centos"
|
270
|
+
# layout "default"
|
271
|
+
# chef "default"
|
272
|
+
#
|
273
|
+
# pre_snippet "noop"
|
274
|
+
# post_snippet "noop"
|
275
|
+
#
|
276
|
+
# interface "eth0" do
|
277
|
+
# bootproto :static
|
278
|
+
# ip "192.168.1.10"
|
279
|
+
# network "local"
|
280
|
+
# end
|
281
|
+
# end
|
282
|
+
#
|
283
|
+
# host.name.must_equal "example.org"
|
284
|
+
# host.pxemac.must_equal "00:11:22:33:44:55"
|
285
|
+
# host.distro.name.must_equal "centos"
|
286
|
+
# host.distro.kernel.must_equal "vmlinuz"
|
287
|
+
# host.distro.image.must_equal "initrd.img"
|
288
|
+
# host.distro.url.must_equal "http://mirror.example.com/centos"
|
289
|
+
# host.layout.clearpart.must_equal true
|
290
|
+
# host.layout.zerombr.must_equal true
|
291
|
+
# parts = host.layout.partitions
|
292
|
+
# parts[0].path.must_equal '/boot'
|
293
|
+
# parts[0].size.must_equal 100
|
294
|
+
# parts[0].type.must_equal "ext4"
|
295
|
+
# parts[0].primary.must_equal true
|
296
|
+
# parts[1].path.must_equal 'swap'
|
297
|
+
# parts[1].type.must_equal "swap"
|
298
|
+
# parts[1].recommended.must_equal true
|
299
|
+
# parts[2].path.must_equal "/"
|
300
|
+
# parts[2].size.must_equal 4096
|
301
|
+
# parts[3].path.must_equal "/home"
|
302
|
+
# parts[3].type.must_equal "ext4"
|
303
|
+
# parts[3].grow.must_equal true
|
304
|
+
# host.chef.url.must_equal "https://chef.example.org"
|
305
|
+
# host.chef.version.must_equal "11.6.0"
|
306
|
+
# host.chef.client_name.must_equal "root"
|
307
|
+
# host.chef.client_key.must_equal File.read(ckey)
|
308
|
+
# host.chef.validator_name.must_equal "chef-validator"
|
309
|
+
# host.chef.validation_key.must_equal File.read(vkey)
|
310
|
+
# host.chef.encrypted_data_bag_secret.must_equal "secretkey"
|
311
|
+
# interface = host.interfaces.first
|
312
|
+
# interface.device.must_equal "eth0"
|
313
|
+
# interface.bootproto.must_equal "static"
|
314
|
+
# interface.ip.must_equal "192.168.1.10"
|
315
|
+
# interface.netmask.must_equal "255.255.255.0"
|
316
|
+
# interface.gateway.must_equal "192.168.1.1"
|
317
|
+
# interface.nameservers.must_equal ["192.168.1.253", "192.168.1.252"]
|
318
|
+
# host.post_snippets[0].name.must_equal "noop"
|
319
|
+
# host.post_snippets[0].content.must_equal "# Default Snippet\n"
|
320
|
+
# host.pre_snippets[0].name.must_equal "noop"
|
321
|
+
# host.pre_snippets[0].content.must_equal "# Default Snippet\n"
|
322
|
+
# end
|
323
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Stork::Resource::Interface" do
|
4
|
+
it "must create an interface" do
|
5
|
+
Stork::Resource::Interface.new('eth0').must_be_instance_of Stork::Resource::Interface
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should respond to the device method" do
|
9
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :device
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should respond to the ethtool accessors" do
|
13
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :ethtool
|
14
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :ethtool=
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should respond to the ip accessors" do
|
18
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :ip
|
19
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :ip=
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should respond to the bootproto accessors" do
|
23
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :bootproto
|
24
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :bootproto=
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should respond to the onboot accessors" do
|
28
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :onboot
|
29
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :onboot=
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should respond to the noipv4 accessors" do
|
33
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :ipv4
|
34
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :ipv4=
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should respond to the noipv6 accessors" do
|
38
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :ipv6
|
39
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :ipv6=
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should respond to the nodns accessors" do
|
43
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :dns
|
44
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :dns=
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should respond to the nodefroute accessors" do
|
48
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :defroute
|
49
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :defroute=
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should respond to the mtu accessors" do
|
53
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :mtu
|
54
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :mtu=
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should respond to the netmask accessors" do
|
58
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :netmask
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should respond to the gateway accessors" do
|
62
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :gateway
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should respond to the nameservers accessors" do
|
66
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :nameservers
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should respond to the search_paths accessors" do
|
70
|
+
Stork::Resource::Interface.new('eth0').must_respond_to :search_paths
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should raise a syntax error if the network is not found" do
|
74
|
+
collection = Stork::Collections.new
|
75
|
+
proc {
|
76
|
+
iface = Stork::Resource::Interface.build "eth0", collection: collection do
|
77
|
+
network 'invalid'
|
78
|
+
end
|
79
|
+
}.must_raise(SyntaxError)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should have dhcp as the default for bootproto" do
|
83
|
+
Stork::Resource::Interface.new('eth0').bootproto.must_equal :dhcp
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should build without a network definition" do
|
87
|
+
collection = Stork::Collections.new
|
88
|
+
iface = Stork::Resource::Interface.build "eth0", collection: collection do
|
89
|
+
ethtool "ethtool args"
|
90
|
+
ip "192.168.1.10"
|
91
|
+
bootproto :static
|
92
|
+
onboot
|
93
|
+
noipv4
|
94
|
+
noipv6
|
95
|
+
nodns
|
96
|
+
nodefroute
|
97
|
+
mtu 4000
|
98
|
+
netmask "255.255.0.0"
|
99
|
+
gateway "192.168.1.1"
|
100
|
+
nameserver "192.168.1.253"
|
101
|
+
nameserver "192.168.1.252"
|
102
|
+
search_path "example.org"
|
103
|
+
end
|
104
|
+
iface.device.must_equal "eth0"
|
105
|
+
iface.ethtool.must_equal "ethtool args"
|
106
|
+
iface.ip.must_equal "192.168.1.10"
|
107
|
+
iface.bootproto.must_equal :static
|
108
|
+
iface.onboot.must_equal true
|
109
|
+
iface.noipv4.must_equal true
|
110
|
+
iface.noipv6.must_equal true
|
111
|
+
iface.nodns.must_equal true
|
112
|
+
iface.nodefroute.must_equal true
|
113
|
+
iface.mtu.must_equal 4000
|
114
|
+
iface.netmask.must_equal "255.255.0.0"
|
115
|
+
iface.gateway.must_equal "192.168.1.1"
|
116
|
+
iface.nameservers.must_equal ["192.168.1.253", "192.168.1.252"]
|
117
|
+
iface.search_paths.must_equal ["example.org"]
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should build with a network definition" do
|
121
|
+
collection = Stork::Collections.new
|
122
|
+
net = Stork::Resource::Network.build("local") do
|
123
|
+
netmask "255.255.0.0"
|
124
|
+
gateway "192.168.1.1"
|
125
|
+
nameserver "192.168.1.253"
|
126
|
+
nameserver "192.168.1.252"
|
127
|
+
search_path "example.org"
|
128
|
+
end
|
129
|
+
collection.networks.add(net)
|
130
|
+
|
131
|
+
iface = Stork::Resource::Interface.build "eth0", collection: collection do
|
132
|
+
ethtool "ethtool args"
|
133
|
+
ip "192.168.1.10"
|
134
|
+
bootproto :static
|
135
|
+
onboot
|
136
|
+
noipv4
|
137
|
+
noipv6
|
138
|
+
nodns
|
139
|
+
nodefroute
|
140
|
+
mtu 4000
|
141
|
+
network "local"
|
142
|
+
end
|
143
|
+
iface.device.must_equal "eth0"
|
144
|
+
iface.ethtool.must_equal "ethtool args"
|
145
|
+
iface.ip.must_equal "192.168.1.10"
|
146
|
+
iface.bootproto.must_equal :static
|
147
|
+
iface.onboot.must_equal true
|
148
|
+
iface.noipv4.must_equal true
|
149
|
+
iface.noipv6.must_equal true
|
150
|
+
iface.nodns.must_equal true
|
151
|
+
iface.nodefroute.must_equal true
|
152
|
+
iface.mtu.must_equal 4000
|
153
|
+
iface.netmask.must_equal "255.255.0.0"
|
154
|
+
iface.gateway.must_equal "192.168.1.1"
|
155
|
+
iface.nameservers.must_equal ["192.168.1.253", "192.168.1.252"]
|
156
|
+
iface.search_paths.must_equal ["example.org"]
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Stork::Resource::Layout" do
|
4
|
+
it "should be created" do
|
5
|
+
Stork::Resource::Layout.new('test').must_be_instance_of Stork::Resource::Layout
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should respond to the name method" do
|
9
|
+
Stork::Resource::Layout.new('test').must_respond_to :name
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should respond to the zerombr accessors" do
|
13
|
+
Stork::Resource::Layout.new('test').must_respond_to :zerombr
|
14
|
+
Stork::Resource::Layout.new('test').must_respond_to :zerombr=
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should respond to the clearpart accessors" do
|
18
|
+
Stork::Resource::Layout.new('test').must_respond_to :clearpart
|
19
|
+
Stork::Resource::Layout.new('test').must_respond_to :clearpart=
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should respond to the partitions accessors" do
|
23
|
+
Stork::Resource::Layout.new('test').must_respond_to :partitions
|
24
|
+
Stork::Resource::Layout.new('test').must_respond_to :partitions=
|
25
|
+
end
|
26
|
+
|
27
|
+
it "requires a block for partition during build" do
|
28
|
+
proc {
|
29
|
+
layout = Stork::Resource::Layout.build('test') do
|
30
|
+
zerombr
|
31
|
+
clearpart
|
32
|
+
part '/'
|
33
|
+
end
|
34
|
+
}.must_raise(SyntaxError)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "requires a block for volume_group during build" do
|
38
|
+
proc {
|
39
|
+
layout = Stork::Resource::Layout.build('test') do
|
40
|
+
zerombr
|
41
|
+
clearpart
|
42
|
+
volgroup 'hello'
|
43
|
+
end
|
44
|
+
}.must_raise(SyntaxError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "must build with inline partitions" do
|
48
|
+
layout = Stork::Resource::Layout.build('test') do
|
49
|
+
zerombr
|
50
|
+
clearpart
|
51
|
+
part '/' do
|
52
|
+
size 100
|
53
|
+
type "ext4"
|
54
|
+
primary
|
55
|
+
grow
|
56
|
+
recommended
|
57
|
+
end
|
58
|
+
end
|
59
|
+
layout.zerombr.must_equal true
|
60
|
+
layout.clearpart.must_equal true
|
61
|
+
layout.partitions.size.must_equal 1
|
62
|
+
part = layout.partitions.first
|
63
|
+
part.size.must_equal 100
|
64
|
+
part.type.must_equal "ext4"
|
65
|
+
part.primary.must_equal true
|
66
|
+
part.grow.must_equal true
|
67
|
+
part.recommended.must_equal true
|
68
|
+
end
|
69
|
+
|
70
|
+
it "must error if part blocks are not given" do
|
71
|
+
proc {
|
72
|
+
layout = Stork::Resource::Layout.build('test') do
|
73
|
+
zerombr
|
74
|
+
clearpart
|
75
|
+
end
|
76
|
+
}.must_raise(SyntaxError)
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Stork::Resource::LogicalVolume" do
|
4
|
+
it "should be created" do
|
5
|
+
Stork::Resource::LogicalVolume.new('/').must_be_instance_of Stork::Resource::LogicalVolume
|
6
|
+
end
|
7
|
+
|
8
|
+
it "must respond to path" do
|
9
|
+
Stork::Resource::LogicalVolume.new('/').must_respond_to :path
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must respond to the size accessors" do
|
13
|
+
Stork::Resource::LogicalVolume.new('/').must_respond_to :size
|
14
|
+
Stork::Resource::LogicalVolume.new('/').must_respond_to :size=
|
15
|
+
end
|
16
|
+
|
17
|
+
it "must respond to the type accessors" do
|
18
|
+
Stork::Resource::LogicalVolume.new('/').must_respond_to :type
|
19
|
+
Stork::Resource::LogicalVolume.new('/').must_respond_to :type=
|
20
|
+
end
|
21
|
+
|
22
|
+
it "must respond to the grow accessors" do
|
23
|
+
Stork::Resource::LogicalVolume.new('/').must_respond_to :grow
|
24
|
+
Stork::Resource::LogicalVolume.new('/').must_respond_to :grow=
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must respond to the recommended accessors" do
|
28
|
+
Stork::Resource::LogicalVolume.new('/').must_respond_to :recommended
|
29
|
+
Stork::Resource::LogicalVolume.new('/').must_respond_to :recommended=
|
30
|
+
end
|
31
|
+
|
32
|
+
it "must build" do
|
33
|
+
lv = Stork::Resource::LogicalVolume.build('/') do
|
34
|
+
size 100
|
35
|
+
type "ext4"
|
36
|
+
grow
|
37
|
+
recommended
|
38
|
+
end
|
39
|
+
lv.size.must_equal 100
|
40
|
+
lv.type.must_equal "ext4"
|
41
|
+
lv.grow.must_equal true
|
42
|
+
lv.recommended.must_equal true
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Stork::Resource::Network" do
|
4
|
+
it "must create a network" do
|
5
|
+
Stork::Resource::Network.new("local").must_be_instance_of Stork::Resource::Network
|
6
|
+
end
|
7
|
+
|
8
|
+
it "must respond to the name method" do
|
9
|
+
Stork::Resource::Network.new("local").must_respond_to :name
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must respond to the netmask accessors" do
|
13
|
+
Stork::Resource::Network.new("local").must_respond_to :netmask
|
14
|
+
Stork::Resource::Network.new("local").must_respond_to :netmask=
|
15
|
+
end
|
16
|
+
|
17
|
+
it "must respond to the gateway accessors" do
|
18
|
+
Stork::Resource::Network.new("local").must_respond_to :gateway
|
19
|
+
Stork::Resource::Network.new("local").must_respond_to :gateway=
|
20
|
+
end
|
21
|
+
|
22
|
+
it "must respond to the nameservers accessors" do
|
23
|
+
Stork::Resource::Network.new("local").must_respond_to :nameservers
|
24
|
+
Stork::Resource::Network.new("local").must_respond_to :nameservers=
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must respond to the search_paths accessors" do
|
28
|
+
Stork::Resource::Network.new("local").must_respond_to :search_paths
|
29
|
+
Stork::Resource::Network.new("local").must_respond_to :search_paths=
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should build" do
|
33
|
+
net = Stork::Resource::Network.build("local") do
|
34
|
+
netmask "255.255.255.0"
|
35
|
+
gateway "192.168.1.1"
|
36
|
+
nameserver "8.8.8.8"
|
37
|
+
nameserver "8.8.8.9"
|
38
|
+
search_path "example.org"
|
39
|
+
end
|
40
|
+
net.netmask.must_equal "255.255.255.0"
|
41
|
+
net.gateway.must_equal "192.168.1.1"
|
42
|
+
net.nameservers.must_equal ["8.8.8.8", "8.8.8.9"]
|
43
|
+
net.search_paths.must_equal ["example.org"]
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "Stork::Resource::Partition" do
|
4
|
+
it "should be created" do
|
5
|
+
Stork::Resource::Partition.new('/').must_be_instance_of Stork::Resource::Partition
|
6
|
+
end
|
7
|
+
|
8
|
+
it "must respond to path" do
|
9
|
+
Stork::Resource::Partition.new('/').must_respond_to :path
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must respond to the size accessors" do
|
13
|
+
Stork::Resource::Partition.new('/').must_respond_to :size
|
14
|
+
Stork::Resource::Partition.new('/').must_respond_to :size=
|
15
|
+
end
|
16
|
+
|
17
|
+
it "must respond to the type accessors" do
|
18
|
+
Stork::Resource::Partition.new('/').must_respond_to :type
|
19
|
+
Stork::Resource::Partition.new('/').must_respond_to :type=
|
20
|
+
end
|
21
|
+
|
22
|
+
it "must respond to the primary accessors" do
|
23
|
+
Stork::Resource::Partition.new('/').must_respond_to :primary
|
24
|
+
Stork::Resource::Partition.new('/').must_respond_to :primary=
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must respond to the grow accessors" do
|
28
|
+
Stork::Resource::Partition.new('/').must_respond_to :grow
|
29
|
+
Stork::Resource::Partition.new('/').must_respond_to :grow=
|
30
|
+
end
|
31
|
+
|
32
|
+
it "must respond to the recommended accessors" do
|
33
|
+
Stork::Resource::Partition.new('/').must_respond_to :recommended
|
34
|
+
Stork::Resource::Partition.new('/').must_respond_to :recommended=
|
35
|
+
end
|
36
|
+
|
37
|
+
it "must build" do
|
38
|
+
part = Stork::Resource::Partition.build('/') do
|
39
|
+
size 100
|
40
|
+
type "ext4"
|
41
|
+
primary
|
42
|
+
grow
|
43
|
+
recommended
|
44
|
+
end
|
45
|
+
part.size.must_equal 100
|
46
|
+
part.type.must_equal "ext4"
|
47
|
+
part.primary.must_equal true
|
48
|
+
part.grow.must_equal true
|
49
|
+
part.recommended.must_equal true
|
50
|
+
end
|
51
|
+
end
|