abiquo-chef-agent 1.0.7 → 1.0.8
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.
- data/Gemfile +6 -0
- data/lib/abiquo-chef-agent.rb +4 -4
- data/spec/data/bootstrap.xml +1 -0
- data/spec/data/bootstrap_empty_runlist.xml +1 -0
- data/spec/data/dhclient/dhclient.leases +182 -0
- data/spec/data/invalid_bootstrap.xml +2 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/unit/bootstrap_config_parser_spec.rb +80 -0
- data/spec/unit/config_spec.rb +35 -0
- data/spec/unit/util_spec.rb +47 -0
- metadata +65 -12
data/Gemfile
ADDED
data/lib/abiquo-chef-agent.rb
CHANGED
@@ -3,7 +3,7 @@ require 'xmlsimple'
|
|
3
3
|
module Abiquo
|
4
4
|
module Chef
|
5
5
|
|
6
|
-
VERSION="1.0.
|
6
|
+
VERSION="1.0.8"
|
7
7
|
|
8
8
|
class Config
|
9
9
|
def self.chef_config_dir
|
@@ -89,6 +89,7 @@ module Abiquo
|
|
89
89
|
leases = []
|
90
90
|
search_dirs.each do |d|
|
91
91
|
Dir["#{d}/*"].each do |f|
|
92
|
+
next if f !~ /leases$/
|
92
93
|
leases << f
|
93
94
|
end
|
94
95
|
end
|
@@ -107,8 +108,8 @@ module Abiquo
|
|
107
108
|
# :abiquo_api_token => token
|
108
109
|
# }
|
109
110
|
#
|
110
|
-
def self.parse_leases_file
|
111
|
-
files = find_leases_file
|
111
|
+
def self.parse_leases_file(search_dirs = ['/var/lib/dhcp3', '/var/lib/dhcp', '/var/lib/dhclient'])
|
112
|
+
files = find_leases_file(search_dirs)
|
112
113
|
files.each do |file|
|
113
114
|
f = File.open(file)
|
114
115
|
l = {}
|
@@ -133,7 +134,6 @@ module Abiquo
|
|
133
134
|
end
|
134
135
|
end
|
135
136
|
if l[:abiquo_api_token]
|
136
|
-
log "Default leases file '#{file}' found"
|
137
137
|
return l
|
138
138
|
end
|
139
139
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><bootstrap><node>ABQ-d4542f23-a755-4d9a-96f3-1e31c7a269d5</node><chef><chef-server-url>https://api.opscode.com/organizations/chef_integration</chef-server-url><validation-client-name>chef_integration-validator</validation-client-name><validation-cert>-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAlksjdfEAnUhY5w7ykVJE6uICX9d9wWLcAMB5e1UO0Zxagtmzjy6UHEyk
lgGJb2PeaCeyjnkhtwlRgeq9zgRqcGFFu+q/2VJUGeUUt4JqX0dfIiTT5nbK0kYW
wWkDBQvKtC+nepKs5Sck9y4h2DO95uAMhct6+R6W4qzXyMQKQST5r0FfdyWbUKFN
6mvpaxBoB3BF8YQcs8Z6cGZfCdEC2vI2jhgR9MALFE/w2G3+REmDpi7tpX4eB7al
NrJr8E6f44EEYDmrO9zQ0pnEV9et9rvULUYXIovuKIoIEXeY8vIUaEuGPYL5gcYS
HtROW0zCxlO2eg5HNJcTAUQUI4OnTd2o+9LdCwIDAQABAoIBAQCGoAZ4wDKgcOrM
oeemYa0iepwViKpzBrtIb6yJlA494ICmOHQocehRkAou3MvZZ5WUNkWuDl+ol98D
kj8+OhE801tpTswMx3SFWXH0p9E40zWIBrYzls8e4pj+4ktYf3O+MWNSsAoIJUHG
/L+7RhBca/J607dgAW1FlYCiojI0qIRKPRkvdotQ3M+kYitYIv+MxZtmOB5OqG5g
cUFT9BxMAFW0JrCf8Zgcd0qvtjnQkqHp1SAFlFOE9918JijeVj3cXXajy+IazNwy
3Qq945thQpZaEXtMnggpN86CeaVtt4m9dXLiyjVVd6OfF6aTdG8W9CoKnIIvyKIA
Uzu+IcwBAoGBAM29a/OeY74ezG6MwVRw4uLATllg6acnfSUNQhMtdfPKhQWSGanM
/jwpWx/b4vgTiR8ZPxf1tViEdSwFsZwbo1fzWZvxRicbyIHtMF23sFNPo2rDhdBX
efafa0FlV3solOFFrSuDPkbi8WDKJA6156NqJfv6RTjSzKWtpPpxYYpxAoGBAMO0
f4XnfOAOTzeJ75C0/bRnGxE8Fb4h9+CvBbTzcm+m9csAQcriY/cyqiidKulrDgeQ
UKlRGwtrgWHQEPRLmdj3e/bPNOt6o+CJy2/pLfbp/boG7xdQus0U4Kx7+rmPd7Lv
uXcSeNupODhC44uH3HE16LA5WQxTu3PI3k3JP8U7AoGAcqgMwDDV7z8kuLsyhsd+
edWoFEFhFWl5Yau41g0wvdNwPIGGUc3PJWH6yY92NsBUW4NrWQPys0jmL8lgiNoS
NtKEbtaQPP1LybSQjrnuxw8LyFT8fvYxHxMK59/9V8Ju7fgxoJ08mK6izEj6vUP8
suJOltWLvDYmHHLgDT4gmNECgYBzVcmdwaoPZX98DLd5waCPFACYrJ9nuR8bdCpZ
1OtJL81FQLaFedxOD7bGTrG+dFAFVyCiWGEm3smWOofzYSae/mM5Ni5K5LD1oF+b
aYGkNYxJeNKpG/Oq7zXlkP9XIlz5wFu9983wLoxxiYQk27u+UbJ/gUzvOjv43I1cX
4pXJhwKBgEjSju4IYF8KRKCiQ+s/95xIUqwITt9nEDssaI4ms0ZcRROq9cAhxX4H
lOn8Ruyy7mGJ0LEpyuFVsSvb7sHqRdy2eyyXO/amwSquOZ9+BjGOb2wjoVHDCYm+
1obXuj+YB36cHqDTbWOM8yCkBcdHCL0eczvComocAiKWfJX9ZNWM
-----END RSA PRIVATE KEY-----</validation-cert><runlist><element>role[web-server]</element><element>recipe[apache2]</element></runlist></chef></bootstrap>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><bootstrap><node>ABQ-d4542f23-a755-4d9a-96f3-1e31c7a269d5</node><chef><chef-server-url>https://api.opscode.com/organizations/chef_integration</chef-server-url><validation-client-name>chef_integration-validator</validation-client-name><validation-cert>-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAlksjdfEAnUhY5w7ykVJE6uICX9d9wWLcAMB5e1UO0Zxagtmzjy6UHEyk
lgGJb2PeaCeyjnkhtwlRgeq9zgRqcGFFu+q/2VJUGeUUt4JqX0dfIiTT5nbK0kYW
wWkDBQvKtC+nepKs5Sck9y4h2DO95uAMhct6+R6W4qzXyMQKQST5r0FfdyWbUKFN
6mvpaxBoB3BF8YQcs8Z6cGZfCdEC2vI2jhgR9MALFE/w2G3+REmDpi7tpX4eB7al
NrJr8E6f44EEYDmrO9zQ0pnEV9et9rvULUYXIovuKIoIEXeY8vIUaEuGPYL5gcYS
HtROW0zCxlO2eg5HNJcTAUQUI4OnTd2o+9LdCwIDAQABAoIBAQCGoAZ4wDKgcOrM
oeemYa0iepwViKpzBrtIb6yJlA494ICmOHQocehRkAou3MvZZ5WUNkWuDl+ol98D
kj8+OhE801tpTswMx3SFWXH0p9E40zWIBrYzls8e4pj+4ktYf3O+MWNSsAoIJUHG
/L+7RhBca/J607dgAW1FlYCiojI0qIRKPRkvdotQ3M+kYitYIv+MxZtmOB5OqG5g
cUFT9BxMAFW0JrCf8Zgcd0qvtjnQkqHp1SAFlFOE9918JijeVj3cXXajy+IazNwy
3Qq945thQpZaEXtMnggpN86CeaVtt4m9dXLiyjVVd6OfF6aTdG8W9CoKnIIvyKIA
Uzu+IcwBAoGBAM29a/OeY74ezG6MwVRw4uLATllg6acnfSUNQhMtdfPKhQWSGanM
/jwpWx/b4vgTiR8ZPxf1tViEdSwFsZwbo1fzWZvxRicbyIHtMF23sFNPo2rDhdBX
efafa0FlV3solOFFrSuDPkbi8WDKJA6156NqJfv6RTjSzKWtpPpxYYpxAoGBAMO0
f4XnfOAOTzeJ75C0/bRnGxE8Fb4h9+CvBbTzcm+m9csAQcriY/cyqiidKulrDgeQ
UKlRGwtrgWHQEPRLmdj3e/bPNOt6o+CJy2/pLfbp/boG7xdQus0U4Kx7+rmPd7Lv
uXcSeNupODhC44uH3HE16LA5WQxTu3PI3k3JP8U7AoGAcqgMwDDV7z8kuLsyhsd+
edWoFEFhFWl5Yau41g0wvdNwPIGGUc3PJWH6yY92NsBUW4NrWQPys0jmL8lgiNoS
NtKEbtaQPP1LybSQjrnuxw8LyFT8fvYxHxMK59/9V8Ju7fgxoJ08mK6izEj6vUP8
suJOltWLvDYmHHLgDT4gmNECgYBzVcmdwaoPZX98DLd5waCPFACYrJ9nuR8bdCpZ
1OtJL81FQLaFedxOD7bGTrG+dFAFVyCiWGEm3smWOofzYSae/mM5Ni5K5LD1oF+b
aYGkNYxJeNKpG/Oq7zXlkP9XIlz5wFu9983wLoxxiYQk27u+UbJ/gUzvOjv43I1cX
4pXJhwKBgEjSju4IYF8KRKCiQ+s/95xIUqwITt9nEDssaI4ms0ZcRROq9cAhxX4H
lOn8Ruyy7mGJ0LEpyuFVsSvb7sHqRdy2eyyXO/amwSquOZ9+BjGOb2wjoVHDCYm+
1obXuj+YB36cHqDTbWOM8yCkBcdHCL0eczvComocAiKWfJX9ZNWM
-----END RSA PRIVATE KEY-----</validation-cert><runlist/></chef></bootstrap>
|
@@ -0,0 +1,182 @@
|
|
1
|
+
lease {
|
2
|
+
interface "eth0";
|
3
|
+
fixed-address 192.168.0.3;
|
4
|
+
option subnet-mask 255.255.255.0;
|
5
|
+
option routers 192.168.0.1;
|
6
|
+
option dhcp-lease-time 60000;
|
7
|
+
option dhcp-message-type 5;
|
8
|
+
option domain-name-servers 8.8.8.8;
|
9
|
+
option dhcp-server-identifier 192.168.0.1;
|
10
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
11
|
+
renew 4 2011/11/17 22:59:41;
|
12
|
+
rebind 5 2011/11/18 06:41:48;
|
13
|
+
expire 5 2011/11/18 08:46:48;
|
14
|
+
}
|
15
|
+
lease {
|
16
|
+
interface "eth0";
|
17
|
+
fixed-address 192.168.0.3;
|
18
|
+
option subnet-mask 255.255.255.0;
|
19
|
+
option routers 192.168.0.1;
|
20
|
+
option dhcp-lease-time 60000;
|
21
|
+
option dhcp-message-type 5;
|
22
|
+
option domain-name-servers 8.8.8.8;
|
23
|
+
option dhcp-server-identifier 192.168.0.1;
|
24
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
25
|
+
renew 5 2011/11/18 05:48:45;
|
26
|
+
rebind 5 2011/11/18 13:34:41;
|
27
|
+
expire 5 2011/11/18 15:39:41;
|
28
|
+
}
|
29
|
+
lease {
|
30
|
+
interface "eth0";
|
31
|
+
fixed-address 192.168.0.3;
|
32
|
+
option subnet-mask 255.255.255.0;
|
33
|
+
option routers 192.168.0.1;
|
34
|
+
option dhcp-lease-time 60000;
|
35
|
+
option dhcp-message-type 5;
|
36
|
+
option domain-name-servers 8.8.8.8;
|
37
|
+
option dhcp-server-identifier 192.168.0.1;
|
38
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
39
|
+
renew 5 2011/11/18 13:07:55;
|
40
|
+
rebind 5 2011/11/18 20:23:45;
|
41
|
+
expire 5 2011/11/18 22:28:45;
|
42
|
+
}
|
43
|
+
lease {
|
44
|
+
interface "eth0";
|
45
|
+
fixed-address 192.168.0.3;
|
46
|
+
option subnet-mask 255.255.255.0;
|
47
|
+
option routers 192.168.0.1;
|
48
|
+
option dhcp-lease-time 60000;
|
49
|
+
option dhcp-message-type 5;
|
50
|
+
option domain-name-servers 8.8.8.8;
|
51
|
+
option dhcp-server-identifier 192.168.0.1;
|
52
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
53
|
+
renew 5 2011/11/18 19:28:24;
|
54
|
+
rebind 6 2011/11/19 03:42:55;
|
55
|
+
expire 6 2011/11/19 05:47:55;
|
56
|
+
}
|
57
|
+
lease {
|
58
|
+
interface "eth0";
|
59
|
+
fixed-address 192.168.0.3;
|
60
|
+
option subnet-mask 255.255.255.0;
|
61
|
+
option routers 192.168.0.1;
|
62
|
+
option dhcp-lease-time 60000;
|
63
|
+
option dhcp-message-type 5;
|
64
|
+
option domain-name-servers 8.8.8.8;
|
65
|
+
option dhcp-server-identifier 192.168.0.1;
|
66
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
67
|
+
renew 6 2011/11/19 02:52:16;
|
68
|
+
rebind 6 2011/11/19 10:03:24;
|
69
|
+
expire 6 2011/11/19 12:08:24;
|
70
|
+
}
|
71
|
+
lease {
|
72
|
+
interface "eth0";
|
73
|
+
fixed-address 192.168.0.3;
|
74
|
+
option subnet-mask 255.255.255.0;
|
75
|
+
option routers 192.168.0.1;
|
76
|
+
option dhcp-lease-time 60000;
|
77
|
+
option dhcp-message-type 5;
|
78
|
+
option domain-name-servers 8.8.8.8;
|
79
|
+
option dhcp-server-identifier 192.168.0.1;
|
80
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
81
|
+
renew 6 2011/11/19 10:49:20;
|
82
|
+
rebind 6 2011/11/19 17:27:16;
|
83
|
+
expire 6 2011/11/19 19:32:16;
|
84
|
+
}
|
85
|
+
lease {
|
86
|
+
interface "eth0";
|
87
|
+
fixed-address 192.168.0.3;
|
88
|
+
option subnet-mask 255.255.255.0;
|
89
|
+
option routers 192.168.0.1;
|
90
|
+
option dhcp-lease-time 60000;
|
91
|
+
option dhcp-message-type 5;
|
92
|
+
option domain-name-servers 8.8.8.8;
|
93
|
+
option dhcp-server-identifier 192.168.0.1;
|
94
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
95
|
+
renew 6 2011/11/19 18:18:01;
|
96
|
+
rebind 0 2011/11/20 01:24:20;
|
97
|
+
expire 0 2011/11/20 03:29:20;
|
98
|
+
}
|
99
|
+
lease {
|
100
|
+
interface "eth0";
|
101
|
+
fixed-address 192.168.0.3;
|
102
|
+
option subnet-mask 255.255.255.0;
|
103
|
+
option routers 192.168.0.1;
|
104
|
+
option dhcp-lease-time 60000;
|
105
|
+
option dhcp-message-type 5;
|
106
|
+
option domain-name-servers 8.8.8.8;
|
107
|
+
option dhcp-server-identifier 192.168.0.1;
|
108
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
109
|
+
renew 0 2011/11/20 01:22:01;
|
110
|
+
rebind 0 2011/11/20 08:53:01;
|
111
|
+
expire 0 2011/11/20 10:58:01;
|
112
|
+
}
|
113
|
+
lease {
|
114
|
+
interface "eth0";
|
115
|
+
fixed-address 192.168.0.3;
|
116
|
+
option subnet-mask 255.255.255.0;
|
117
|
+
option routers 192.168.0.1;
|
118
|
+
option dhcp-lease-time 60000;
|
119
|
+
option dhcp-message-type 5;
|
120
|
+
option domain-name-servers 8.8.8.8;
|
121
|
+
option dhcp-server-identifier 192.168.0.1;
|
122
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
123
|
+
renew 0 2011/11/20 08:56:59;
|
124
|
+
rebind 0 2011/11/20 15:57:01;
|
125
|
+
expire 0 2011/11/20 18:02:01;
|
126
|
+
}
|
127
|
+
lease {
|
128
|
+
interface "eth0";
|
129
|
+
fixed-address 192.168.0.3;
|
130
|
+
option subnet-mask 255.255.255.0;
|
131
|
+
option routers 192.168.0.1;
|
132
|
+
option dhcp-lease-time 60000;
|
133
|
+
option dhcp-message-type 5;
|
134
|
+
option domain-name-servers 8.8.8.8;
|
135
|
+
option dhcp-server-identifier 192.168.0.1;
|
136
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
137
|
+
renew 0 2011/11/20 16:03:25;
|
138
|
+
rebind 0 2011/11/20 23:32:03;
|
139
|
+
expire 1 2011/11/21 01:37:03;
|
140
|
+
}
|
141
|
+
lease {
|
142
|
+
interface "eth0";
|
143
|
+
fixed-address 192.168.0.3;
|
144
|
+
option subnet-mask 255.255.255.0;
|
145
|
+
option routers 192.168.0.1;
|
146
|
+
option dhcp-lease-time 60000;
|
147
|
+
option dhcp-message-type 5;
|
148
|
+
option domain-name-servers 8.8.8.8;
|
149
|
+
option dhcp-server-identifier 192.168.0.1;
|
150
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
151
|
+
renew 0 2011/11/20 22:57:38;
|
152
|
+
rebind 1 2011/11/21 06:38:25;
|
153
|
+
expire 1 2011/11/21 08:43:25;
|
154
|
+
}
|
155
|
+
lease {
|
156
|
+
interface "eth0";
|
157
|
+
fixed-address 192.168.0.3;
|
158
|
+
option subnet-mask 255.255.255.0;
|
159
|
+
option routers 192.168.0.1;
|
160
|
+
option dhcp-lease-time 60000;
|
161
|
+
option dhcp-message-type 5;
|
162
|
+
option domain-name-servers 8.8.8.8;
|
163
|
+
option dhcp-server-identifier 192.168.0.1;
|
164
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
165
|
+
renew 1 2011/11/21 06:46:17;
|
166
|
+
rebind 1 2011/11/21 13:32:38;
|
167
|
+
expire 1 2011/11/21 15:37:38;
|
168
|
+
}
|
169
|
+
lease {
|
170
|
+
interface "eth0";
|
171
|
+
fixed-address 192.168.0.3;
|
172
|
+
option subnet-mask 255.255.255.0;
|
173
|
+
option routers 192.168.0.1;
|
174
|
+
option dhcp-lease-time 60000;
|
175
|
+
option dhcp-message-type 5;
|
176
|
+
option domain-name-servers 8.8.8.8;
|
177
|
+
option dhcp-server-identifier 192.168.0.1;
|
178
|
+
option vendor-encapsulated-options "http://10.60.20.11/api/cloud/virtualdatacenters/4/virtualappliances/12/virtualmachines/10/config/bootstrap@@Ykozf/WP/hred8HWnFOwHA==";
|
179
|
+
renew 1 2011/11/21 14:39:27;
|
180
|
+
rebind 1 2011/11/21 21:21:17;
|
181
|
+
expire 1 2011/11/21 23:26:17;
|
182
|
+
}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec/autorun'
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start do
|
5
|
+
add_filter '/spec/'
|
6
|
+
end
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
9
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
10
|
+
require 'abiquo-chef-agent'
|
11
|
+
|
12
|
+
module TestHelpersMod
|
13
|
+
|
14
|
+
def data_dir
|
15
|
+
File.join(File.dirname(__FILE__),"data/")
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include Abiquo::Chef
|
3
|
+
|
4
|
+
describe "Bootstrap Config Parser" do
|
5
|
+
include TestHelpersMod
|
6
|
+
before do
|
7
|
+
@cp = BootstrapConfigParser.new(File.read(data_dir + "bootstrap.xml"))
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "parsing" do
|
11
|
+
it "should load a valid bootstrap file" do
|
12
|
+
lambda do
|
13
|
+
BootstrapConfigParser.new(File.read(data_dir + "bootstrap.xml"))
|
14
|
+
end.should_not raise_error
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should raise exception loading invalid bootstrap file" do
|
18
|
+
lambda do
|
19
|
+
BootstrapConfigParser.new(File.read(data_dir + "invalid_bootstrap.xml"))
|
20
|
+
end.should raise_error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "name" do
|
25
|
+
it "should be a string" do
|
26
|
+
@cp.node_name.should be_a(String)
|
27
|
+
end
|
28
|
+
it "should start with ABQ-" do
|
29
|
+
@cp.node_name.should match(/^ABQ-/)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "run_list" do
|
34
|
+
it "should be an Array" do
|
35
|
+
@cp.run_list.should be_a(Array)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should be an empty Array" do
|
39
|
+
cp = BootstrapConfigParser.new(File.read(data_dir + "bootstrap_empty_runlist.xml"))
|
40
|
+
cp.run_list.should be_empty
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should have a two items in the runlist" do
|
44
|
+
@cp.run_list.should have(2).items
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should be an array of strings" do
|
48
|
+
@cp.run_list.each do |i|
|
49
|
+
i.should be_a(String)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should have a recipe and a role" do
|
54
|
+
@cp.run_list.first.should match(/role\[/)
|
55
|
+
@cp.run_list.last.should match(/recipe\[/)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "chef-server-url" do
|
60
|
+
it "should be a URL" do
|
61
|
+
@cp.chef_server_url.should match(/^http(s)?:\/\//)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "validation-client-name" do
|
66
|
+
it "should be a String" do
|
67
|
+
@cp.validation_client_name.should be_a(String)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "validation_cert" do
|
72
|
+
it 'should start with -----BEGIN RSA PRIVATE KEY' do
|
73
|
+
@cp.validation_cert.should match(/^-----BEGIN RSA PRIVATE KEY/)
|
74
|
+
end
|
75
|
+
it 'should end with END RSA PRIVATE KEY-----' do
|
76
|
+
@cp.validation_cert.should match(/END RSA PRIVATE KEY-----$/)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Abiquo::Chef::Config do
|
4
|
+
before do
|
5
|
+
@config = Abiquo::Chef::Config
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "default options" do
|
9
|
+
|
10
|
+
it "should have a valid chef_config_dir" do
|
11
|
+
@config.chef_config_dir.should be_a(String)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a valid ntp_server" do
|
15
|
+
@config.ntp_server.should be_a(String)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have a valid log_file" do
|
19
|
+
@config.log_file.should be_a(String)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have a valid bootstrap_backup_file" do
|
23
|
+
@config.bootstrap_backup_file.should be_a(String)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have a valid validation_cert" do
|
27
|
+
@config.validation_cert.should be_a(String)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have a valid client_cert_file" do
|
31
|
+
@config.client_cert_file.should be_a(String)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include Abiquo::Chef
|
3
|
+
|
4
|
+
describe Util do
|
5
|
+
include TestHelpersMod
|
6
|
+
|
7
|
+
before do
|
8
|
+
@leases = Util.parse_leases_file([data_dir + "dhclient/"])
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'parse_leases_file' do
|
12
|
+
it 'parse leases file without error' do
|
13
|
+
@leases.should be_a(Hash)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should not be empty' do
|
17
|
+
@leases.should_not be_empty
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should find a valid ip address' do
|
21
|
+
@leases[:ip].should match(/([0-9]{1,3}\.){3}[0-9]{1,3}/)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have a valid API URL' do
|
25
|
+
@leases[:abiquo_api_url].should match(/http(s)?:\/\//)
|
26
|
+
end
|
27
|
+
it 'should have a valid token' do
|
28
|
+
@leases[:abiquo_api_token].should have_at_least(5).characters
|
29
|
+
end
|
30
|
+
#it 'should have a valid mac' do
|
31
|
+
# #@leases[:mac].should match(/([a-f]{2}:){3}[a-f]{2}/m)
|
32
|
+
#end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'find_leases_file' do
|
37
|
+
it 'should find a lease file' do
|
38
|
+
Util.find_leases_file([data_dir + "dhclient/"]).should have(1).item
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should return an empty list' do
|
42
|
+
Util.find_leases_file([]).should have(0).items
|
43
|
+
Util.find_leases_file(['/tmp']).should have(0).items
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abiquo-chef-agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,55 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &8789080 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *8789080
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bundler
|
27
|
+
requirement: &8787780 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *8787780
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jeweler
|
38
|
+
requirement: &8861900 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *8861900
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: simplecov
|
49
|
+
requirement: &8859440 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *8859440
|
14
58
|
- !ruby/object:Gem::Dependency
|
15
59
|
name: run-as-root
|
16
|
-
requirement: &
|
60
|
+
requirement: &8858860 !ruby/object:Gem::Requirement
|
17
61
|
none: false
|
18
62
|
requirements:
|
19
63
|
- - ! '>='
|
@@ -21,10 +65,10 @@ dependencies:
|
|
21
65
|
version: '0'
|
22
66
|
type: :runtime
|
23
67
|
prerelease: false
|
24
|
-
version_requirements: *
|
68
|
+
version_requirements: *8858860
|
25
69
|
- !ruby/object:Gem::Dependency
|
26
70
|
name: chef
|
27
|
-
requirement: &
|
71
|
+
requirement: &8858080 !ruby/object:Gem::Requirement
|
28
72
|
none: false
|
29
73
|
requirements:
|
30
74
|
- - ! '>='
|
@@ -32,10 +76,10 @@ dependencies:
|
|
32
76
|
version: '0'
|
33
77
|
type: :runtime
|
34
78
|
prerelease: false
|
35
|
-
version_requirements: *
|
79
|
+
version_requirements: *8858080
|
36
80
|
- !ruby/object:Gem::Dependency
|
37
81
|
name: daemons
|
38
|
-
requirement: &
|
82
|
+
requirement: &8857380 !ruby/object:Gem::Requirement
|
39
83
|
none: false
|
40
84
|
requirements:
|
41
85
|
- - ! '>='
|
@@ -43,10 +87,10 @@ dependencies:
|
|
43
87
|
version: '0'
|
44
88
|
type: :runtime
|
45
89
|
prerelease: false
|
46
|
-
version_requirements: *
|
90
|
+
version_requirements: *8857380
|
47
91
|
- !ruby/object:Gem::Dependency
|
48
92
|
name: rest-client
|
49
|
-
requirement: &
|
93
|
+
requirement: &9016680 !ruby/object:Gem::Requirement
|
50
94
|
none: false
|
51
95
|
requirements:
|
52
96
|
- - ! '>='
|
@@ -54,10 +98,10 @@ dependencies:
|
|
54
98
|
version: '0'
|
55
99
|
type: :runtime
|
56
100
|
prerelease: false
|
57
|
-
version_requirements: *
|
101
|
+
version_requirements: *9016680
|
58
102
|
- !ruby/object:Gem::Dependency
|
59
103
|
name: xml-simple
|
60
|
-
requirement: &
|
104
|
+
requirement: &9014900 !ruby/object:Gem::Requirement
|
61
105
|
none: false
|
62
106
|
requirements:
|
63
107
|
- - ! '>='
|
@@ -65,7 +109,7 @@ dependencies:
|
|
65
109
|
version: '0'
|
66
110
|
type: :runtime
|
67
111
|
prerelease: false
|
68
|
-
version_requirements: *
|
112
|
+
version_requirements: *9014900
|
69
113
|
description: Abiquo Chef Agent
|
70
114
|
email: srubio@abiquo.com
|
71
115
|
executables:
|
@@ -75,6 +119,7 @@ extra_rdoc_files:
|
|
75
119
|
- LICENSE.txt
|
76
120
|
- README.md
|
77
121
|
files:
|
122
|
+
- Gemfile
|
78
123
|
- LICENSE.txt
|
79
124
|
- README.md
|
80
125
|
- Rakefile
|
@@ -83,6 +128,14 @@ files:
|
|
83
128
|
- scripts/abiquo-chef-agent.init
|
84
129
|
- scripts/debian/abiquo-chef-agent.conf.upstart
|
85
130
|
- scripts/debian/chef-client.defaults
|
131
|
+
- spec/data/bootstrap.xml
|
132
|
+
- spec/data/bootstrap_empty_runlist.xml
|
133
|
+
- spec/data/dhclient/dhclient.leases
|
134
|
+
- spec/data/invalid_bootstrap.xml
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
- spec/unit/bootstrap_config_parser_spec.rb
|
137
|
+
- spec/unit/config_spec.rb
|
138
|
+
- spec/unit/util_spec.rb
|
86
139
|
homepage: http://github.com/abiquo/abiquo-chef-agent
|
87
140
|
licenses:
|
88
141
|
- MIT
|