cucumber-chef 2.1.0.rc.2 → 2.1.0.rc.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/cc-knife +2 -3
- data/bin/cc-push +7 -15
- data/bin/cc-server +38 -7
- data/bin/cucumber-chef +179 -119
- data/cucumber-chef.gemspec +1 -1
- data/lib/cucumber/chef.rb +2 -2
- data/lib/cucumber/chef/config.rb +24 -16
- data/lib/cucumber/chef/helpers.rb +0 -2
- data/lib/cucumber/chef/helpers/chef_client.rb +20 -23
- data/lib/cucumber/chef/helpers/chef_server.rb +7 -7
- data/lib/cucumber/chef/helpers/command.rb +20 -33
- data/lib/cucumber/chef/helpers/container.rb +55 -22
- data/lib/cucumber/chef/helpers/server.rb +45 -31
- data/lib/cucumber/chef/helpers/test_lab.rb +8 -2
- data/lib/cucumber/chef/helpers/utility.rb +2 -23
- data/lib/cucumber/chef/provider.rb +24 -19
- data/lib/cucumber/chef/providers/aws.rb +90 -121
- data/lib/cucumber/chef/providers/vagrant.rb +92 -36
- data/lib/cucumber/chef/provisioner.rb +52 -94
- data/lib/cucumber/chef/server.rb +42 -36
- data/lib/cucumber/chef/steps/provision_steps.rb +7 -7
- data/lib/cucumber/chef/steps/ssh_steps.rb +9 -4
- data/lib/cucumber/chef/templates/bootstrap/ubuntu-precise-test-lab.erb +13 -7
- data/lib/cucumber/chef/templates/cucumber/cc-hooks.rb +1 -1
- data/lib/cucumber/chef/test_lab.rb +38 -9
- data/lib/cucumber/chef/utility.rb +55 -48
- data/lib/cucumber/chef/version.rb +1 -1
- data/spec/cucumber/chef/config_spec.rb +8 -8
- metadata +11 -12
- data/lib/cucumber/chef/bootstrap.rb +0 -95
data/lib/cucumber/chef/server.rb
CHANGED
@@ -37,10 +37,10 @@ module Cucumber
|
|
37
37
|
|
38
38
|
################################################################################
|
39
39
|
|
40
|
-
def up
|
40
|
+
def up(options={})
|
41
41
|
user = Cucumber::Chef.lab_user
|
42
42
|
home_dir = Cucumber::Chef.lab_user_home_dir
|
43
|
-
provider = Cucumber::Chef::Config
|
43
|
+
provider = Cucumber::Chef::Config.provider.to_s
|
44
44
|
@test_lab.ssh.exec("sudo mkdir -p #{File.join(home_dir, ".cucumber-chef", provider)}")
|
45
45
|
@test_lab.ssh.exec("sudo cp -f #{File.join(home_dir, ".chef", "knife.rb")} #{File.join(home_dir, ".cucumber-chef", provider, "knife.rb")}")
|
46
46
|
@test_lab.ssh.exec("sudo chown -R #{user}:#{user} #{File.join(home_dir, ".cucumber-chef")}")
|
@@ -49,32 +49,52 @@ module Cucumber
|
|
49
49
|
remote_file = File.join(home_dir, ".cucumber-chef", "config.rb")
|
50
50
|
@test_lab.ssh.upload(local_file, remote_file)
|
51
51
|
|
52
|
-
|
53
|
-
|
52
|
+
begin
|
53
|
+
self.ping
|
54
|
+
rescue
|
55
|
+
@background = ZTK::Background.new
|
56
|
+
@background.process do
|
57
|
+
self.down
|
54
58
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
environment = Array.new
|
60
|
+
%w(PURGE VERBOSE LOG_LEVEL).each do |env_var|
|
61
|
+
environment << "#{env_var}=#{ENV[env_var].inspect}" if (!ENV[env_var].nil? && !ENV[env_var].empty?)
|
62
|
+
end
|
63
|
+
environment = environment.join(" ")
|
64
|
+
external_ip = Cucumber::Chef.external_ip
|
65
|
+
|
66
|
+
command = %Q{nohup sudo #{environment} /usr/bin/env cc-server #{external_ip} &}
|
67
|
+
|
68
|
+
@test_lab.ssh.exec(command, options)
|
69
|
+
end
|
60
70
|
|
61
71
|
Kernel.at_exit do
|
62
|
-
|
72
|
+
self.at_exit
|
63
73
|
end
|
64
74
|
end
|
65
75
|
|
66
|
-
|
67
|
-
|
76
|
+
ZTK::RescueRetry.try(:tries => 30) do
|
77
|
+
self.ping
|
78
|
+
end
|
68
79
|
|
69
|
-
|
70
|
-
File.exists?(artifacts) && FileUtils.rm_rf(artifacts)
|
80
|
+
File.exists?(Cucumber::Chef.artifacts_dir) && FileUtils.rm_rf(Cucumber::Chef.artifacts_dir)
|
71
81
|
|
72
|
-
|
82
|
+
true
|
83
|
+
end
|
84
|
+
|
85
|
+
################################################################################
|
86
|
+
|
87
|
+
def ping
|
88
|
+
@drb and DRb.stop_service
|
89
|
+
@drb = DRbObject.new_with_uri("druby://#{@test_lab.ip}:8787")
|
90
|
+
@drb and DRb.start_service
|
91
|
+
@drb.ping
|
73
92
|
end
|
74
93
|
|
75
94
|
################################################################################
|
76
95
|
|
77
96
|
def down
|
97
|
+
(@test_lab.drb.shutdown rescue nil)
|
78
98
|
end
|
79
99
|
|
80
100
|
################################################################################
|
@@ -84,20 +104,7 @@ module Cucumber
|
|
84
104
|
# we use various aspects of the scenario to name our artifacts
|
85
105
|
$scenario = scenario
|
86
106
|
|
87
|
-
|
88
|
-
if ENV['DESTROY']
|
89
|
-
Cucumber::Chef.logger.info("'containers' are being destroyed")
|
90
|
-
@test_lab.drb.servers.each do |name, value|
|
91
|
-
@test_lab.drb.server_destroy(name)
|
92
|
-
end
|
93
|
-
File.exists?(Cucumber::Chef.servers_bin) && File.delete(Cucumber::Chef.servers_bin)
|
94
|
-
else
|
95
|
-
Cucumber::Chef.logger.info("'containers' are being persisted")
|
96
|
-
end
|
97
|
-
|
98
|
-
if File.exists?(Cucumber::Chef.servers_bin)
|
99
|
-
@test_lab.drb.servers = (Marshal.load(IO.read(Cucumber::Chef.servers_bin)) rescue Hash.new(nil))
|
100
|
-
end
|
107
|
+
@test_lab.drb.load_containers
|
101
108
|
|
102
109
|
@test_lab.drb.chef_set_client_config(:chef_server_url => "http://192.168.255.254:4000",
|
103
110
|
:validation_client_name => "chef-validator")
|
@@ -106,12 +113,10 @@ module Cucumber
|
|
106
113
|
################################################################################
|
107
114
|
|
108
115
|
def after(scenario)
|
109
|
-
|
110
|
-
f.puts(Marshal.dump(@test_lab.drb.servers))
|
111
|
-
end
|
116
|
+
@test_lab.drb.save_containers
|
112
117
|
|
113
|
-
# cleanup non-persistent lxc containers
|
114
|
-
@test_lab.drb.
|
118
|
+
# cleanup non-persistent lxc containers after tests
|
119
|
+
@test_lab.drb.containers.select{ |name, attributes| !attributes[:persist] }.each do |name, attributes|
|
115
120
|
@test_lab.drb.server_destroy(name)
|
116
121
|
end
|
117
122
|
end
|
@@ -119,8 +124,9 @@ module Cucumber
|
|
119
124
|
################################################################################
|
120
125
|
|
121
126
|
def at_exit
|
122
|
-
@
|
123
|
-
|
127
|
+
@logger.fatal { "Waiting for cc-server to shutdown." }
|
128
|
+
self.down
|
129
|
+
@background.wait
|
124
130
|
end
|
125
131
|
|
126
132
|
################################################################################
|
@@ -20,31 +20,31 @@
|
|
20
20
|
################################################################################
|
21
21
|
|
22
22
|
Given /^I have a server called "([^\"]*)"$/ do |name|
|
23
|
-
|
23
|
+
$test_lab.drb.server_init(name)
|
24
24
|
end
|
25
25
|
|
26
26
|
And /^"([^\"]*)" is running "([^\"]*)" "([^\"]*)"$/ do |name, distro, release|
|
27
|
-
|
27
|
+
$test_lab.drb.server_set_attributes(name, :distro => distro, :release => release)
|
28
28
|
end
|
29
29
|
|
30
30
|
And /^"([^\"]*)" has "([^\"]*)" architecture$/ do |name, arch|
|
31
|
-
|
31
|
+
$test_lab.drb.server_set_attributes(name, :arch => arch)
|
32
32
|
end
|
33
33
|
|
34
34
|
And /^"([^\"]*)" should( not)? be persist[ae]nt$/ do |name, boolean|
|
35
|
-
|
35
|
+
$test_lab.drb.server_set_attributes(name, :persist => (!boolean ? true : false))
|
36
36
|
end
|
37
37
|
|
38
38
|
And /^"([^\"]*)" has an IP address of "([^\"]*)"$/ do |name, ip|
|
39
|
-
|
39
|
+
$test_lab.drb.server_set_attributes(name, :ip => ip)
|
40
40
|
end
|
41
41
|
|
42
42
|
And /^"([^\"]*)" has a MAC address of "([^\"]*)"$/ do |name, mac|
|
43
|
-
|
43
|
+
$test_lab.drb.server_set_attributes(name, :mac => mac)
|
44
44
|
end
|
45
45
|
|
46
46
|
And /^"([^\"]*)" has been provisioned$/ do |name|
|
47
|
-
$test_lab.drb.server_create(name
|
47
|
+
$test_lab.drb.server_create(name)
|
48
48
|
end
|
49
49
|
|
50
50
|
And /^the "([^\"]*)" role has been added to the "([^\"]*)" run list$/ do |role, name|
|
@@ -29,8 +29,8 @@ When /^I ssh to "([^\"]*)" with the following credentials:$/ do |hostname, table
|
|
29
29
|
session = table.hashes.first
|
30
30
|
lambda {
|
31
31
|
|
32
|
-
@connection and
|
33
|
-
@connection = ZTK::SSH.new
|
32
|
+
@connection and @connection.ssh.shutdown!
|
33
|
+
@connection = ZTK::SSH.new(:timeout => 120, :ignore_exit_status => true)
|
34
34
|
|
35
35
|
@connection.config.proxy_host_name = $test_lab.ip
|
36
36
|
@connection.config.proxy_port = $test_lab.port
|
@@ -60,8 +60,9 @@ When /^I ssh to "([^\"]*)" with the following credentials:$/ do |hostname, table
|
|
60
60
|
end
|
61
61
|
|
62
62
|
And /^I run "([^\"]*)"$/ do |command|
|
63
|
-
@
|
64
|
-
|
63
|
+
@result = @connection.exec(command, :silence => true)
|
64
|
+
@output = @result.output
|
65
|
+
@exit_code = @result.exit_code
|
65
66
|
end
|
66
67
|
|
67
68
|
Then /^I should( not)? see "([^\"]*)" in the output$/ do |boolean, string|
|
@@ -80,6 +81,10 @@ Then /^I should( not)? see the "([^\"]*)" of "([^\"]*)" in the output$/ do |bool
|
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
84
|
+
Then /^the exit code should be "([^\"]*)"$/ do |exit_code|
|
85
|
+
@exit_code.to_i.should == exit_code.to_i
|
86
|
+
end
|
87
|
+
|
83
88
|
Then /^(path|directory|file|symlink) "([^\"]*)" should exist$/ do |type, path|
|
84
89
|
parent = File.dirname path
|
85
90
|
child = File.basename path
|
@@ -1,12 +1,19 @@
|
|
1
|
-
bash
|
1
|
+
#!/bin/env bash
|
2
|
+
#
|
3
|
+
# Cucumber-Chef Bootstrap Script
|
4
|
+
#
|
5
|
+
# Generated <%= Time.now.utc %>
|
6
|
+
#
|
7
|
+
set -x
|
8
|
+
|
2
9
|
CUCUMBER_CHEF_BOOTSTRAP_DONE="/.cucumber-chef-bootstrap-finished"
|
3
10
|
[ -f ${CUCUMBER_CHEF_BOOTSTRAP_DONE} ] && echo "Already bootstrapped!" && exit
|
4
11
|
|
5
12
|
export DEBIAN_FRONTEND=noninteractive
|
6
13
|
|
7
|
-
echo "127.0.0.1 <%= @
|
8
|
-
echo "<%= @
|
9
|
-
hostname <%= @
|
14
|
+
echo "127.0.0.1 <%= @hostname_full %> <%= @hostname_short %>" | tee -a /etc/hosts
|
15
|
+
echo "<%= @hostname_full %>" | tee /etc/hostname
|
16
|
+
hostname <%= @hostname_full %>
|
10
17
|
|
11
18
|
echo "deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main" | tee /etc/apt/sources.list.d/opscode.list
|
12
19
|
mkdir -p /etc/apt/trusted.gpg.d
|
@@ -19,7 +26,7 @@ chown -R ${SUDO_USER}:${SUDO_USER} ${HOME}/.gnupg
|
|
19
26
|
apt-get -q -y upgrade
|
20
27
|
|
21
28
|
cat <<EOF | debconf-set-selections
|
22
|
-
chef chef/chef_server_url string http://<%= @
|
29
|
+
chef chef/chef_server_url string http://<%= @hostname_short %>:4000
|
23
30
|
chef-solr chef-solr/amqp_password password <%= @amqp_password %>
|
24
31
|
chef-server-webui chef-server-webui/admin_password password <%= @admin_password %>
|
25
32
|
EOF
|
@@ -93,8 +100,7 @@ if [ ! -f /etc/chef/client.pem ]; then
|
|
93
100
|
fi
|
94
101
|
|
95
102
|
cat <<EOF > /etc/chef/first-boot.json
|
96
|
-
<%= @
|
103
|
+
<%= @chef_client_attributes.to_json %>
|
97
104
|
EOF
|
98
105
|
|
99
106
|
touch ${CUCUMBER_CHEF_BOOTSTRAP_DONE}
|
100
|
-
'
|
@@ -22,7 +22,7 @@ tag = Cucumber::Chef.tag("cucumber-chef")
|
|
22
22
|
puts(" * #{tag}")
|
23
23
|
Cucumber::Chef.boot(tag)
|
24
24
|
|
25
|
-
if ($test_lab = Cucumber::Chef::TestLab.new) &&
|
25
|
+
if (($test_lab = Cucumber::Chef::TestLab.new) && $test_lab.alive?)
|
26
26
|
$cc_server = Cucumber::Chef::Server.new($test_lab)
|
27
27
|
$cc_server.up
|
28
28
|
else
|
@@ -36,11 +36,29 @@ module Cucumber
|
|
36
36
|
@provider = Cucumber::Chef::Provider.new(@stdout, @stderr, @stdin, @logger)
|
37
37
|
end
|
38
38
|
|
39
|
+
################################################################################
|
40
|
+
|
41
|
+
def bootstrap_ssh
|
42
|
+
dead? and raise TestLabError, "The test lab must be running in order to start a bootstrap SSH session!"
|
43
|
+
|
44
|
+
if (!defined?(@ssh) || @ssh.nil?)
|
45
|
+
@ssh ||= ZTK::SSH.new(:stdout => @stdout, :stderr => @stderr, :stdin => @stdin, :timeout => Cucumber::Chef::Config.command_timeout)
|
46
|
+
|
47
|
+
@ssh.config.host_name = self.ip
|
48
|
+
@ssh.config.port = self.port
|
49
|
+
@ssh.config.user = Cucumber::Chef.bootstrap_user
|
50
|
+
@ssh.config.keys = Cucumber::Chef.bootstrap_identity
|
51
|
+
end
|
52
|
+
@ssh
|
53
|
+
end
|
54
|
+
|
39
55
|
################################################################################
|
40
56
|
|
41
57
|
def ssh
|
58
|
+
dead? and raise TestLabError, "The test lab must be running in order to start an SSH session!"
|
59
|
+
|
42
60
|
if (!defined?(@ssh) || @ssh.nil?)
|
43
|
-
@ssh ||= ZTK::SSH.new
|
61
|
+
@ssh ||= ZTK::SSH.new(:stdout => @stdout, :stderr => @stderr, :stdin => @stdin, :timeout => Cucumber::Chef::Config.command_timeout)
|
44
62
|
|
45
63
|
@ssh.config.host_name = self.ip
|
46
64
|
@ssh.config.port = self.port
|
@@ -53,10 +71,12 @@ module Cucumber
|
|
53
71
|
################################################################################
|
54
72
|
|
55
73
|
def proxy_ssh(container)
|
74
|
+
dead? and raise TestLabError, "The test lab must be running in order to start a proxy SSH session!"
|
75
|
+
|
56
76
|
container = container.to_sym
|
57
77
|
@proxy_ssh ||= Hash.new
|
58
78
|
if (!defined?(@proxy_ssh[container]) || @proxy_ssh[container].nil?)
|
59
|
-
@proxy_ssh[container] ||= ZTK::SSH.new
|
79
|
+
@proxy_ssh[container] ||= ZTK::SSH.new(:stdout => @stdout, :stderr => @stderr, :stdin => @stdin, :timeout => Cucumber::Chef::Config.command_timeout)
|
60
80
|
|
61
81
|
@proxy_ssh[container].config.proxy_host_name = self.ip
|
62
82
|
@proxy_ssh[container].config.proxy_port = self.port
|
@@ -73,20 +93,29 @@ module Cucumber
|
|
73
93
|
################################################################################
|
74
94
|
|
75
95
|
def drb
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
96
|
+
dead? and raise TestLabError, "The test lab must be running in order to start a Drb session!"
|
97
|
+
|
98
|
+
# @drb and DRb.stop_service
|
99
|
+
@drb ||= DRbObject.new_with_uri("druby://#{self.ip}:8787")
|
100
|
+
@drb and DRb.start_service
|
81
101
|
@drb
|
82
102
|
end
|
83
103
|
|
104
|
+
################################################################################
|
105
|
+
|
106
|
+
def cc_server
|
107
|
+
@cc_server ||= Cucumber::Chef::Server.new(self, @stdout, @stderr, @stdin, @logger)
|
108
|
+
@cc_server
|
109
|
+
end
|
110
|
+
|
84
111
|
################################################################################
|
85
112
|
|
86
113
|
def method_missing(method_name, *method_args)
|
87
114
|
if Cucumber::Chef::Provider::PROXY_METHODS.include?(method_name.to_s)
|
88
|
-
|
89
|
-
|
115
|
+
result = @provider.send(method_name.to_sym, *method_args)
|
116
|
+
splat = [method_name, *method_args].flatten.compact
|
117
|
+
Cucumber::Chef.logger.debug { "test_lab: #{splat.inspect} -> #{result.inspect}" }
|
118
|
+
result
|
90
119
|
else
|
91
120
|
super(method_name, *method_args)
|
92
121
|
end
|
@@ -66,26 +66,6 @@ module Cucumber
|
|
66
66
|
File.expand_path(File.join(parent[0..(parent.length - 2)]))
|
67
67
|
end
|
68
68
|
|
69
|
-
################################################################################
|
70
|
-
|
71
|
-
def spinner(stdout=STDOUT, stderr=STDERR, stdin=STDIN)
|
72
|
-
spinning_chars = %w[| / - \\]
|
73
|
-
count = 0
|
74
|
-
spinner = Thread.new do
|
75
|
-
while count do
|
76
|
-
stdout.print spinning_chars[(count+=1) % spinning_chars.length]
|
77
|
-
stdout.flush if stdout.respond_to?(:flush)
|
78
|
-
sleep(0.25)
|
79
|
-
stdout.print "\b"
|
80
|
-
stdout.flush if stdout.respond_to?(:flush)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
yield.tap do
|
84
|
-
count = false
|
85
|
-
spinner.join
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
69
|
################################################################################
|
90
70
|
|
91
71
|
def generate_do_not_edit_warning(message=nil)
|
@@ -130,6 +110,14 @@ module Cucumber
|
|
130
110
|
home_dir
|
131
111
|
end
|
132
112
|
|
113
|
+
################################################################################
|
114
|
+
|
115
|
+
def artifacts_dir
|
116
|
+
artifacts_dir = File.join(Cucumber::Chef.home_dir, Cucumber::Chef::Config.provider.to_s, "artifacts")
|
117
|
+
FileUtils.mkdir_p(File.dirname(artifacts_dir))
|
118
|
+
artifacts_dir
|
119
|
+
end
|
120
|
+
|
133
121
|
################################################################################
|
134
122
|
|
135
123
|
def log_file
|
@@ -149,17 +137,17 @@ module Cucumber
|
|
149
137
|
################################################################################
|
150
138
|
|
151
139
|
def knife_rb
|
152
|
-
knife_rb = File.join(Cucumber::Chef.home_dir, Cucumber::Chef::Config
|
140
|
+
knife_rb = File.join(Cucumber::Chef.home_dir, Cucumber::Chef::Config.provider.to_s, "knife.rb")
|
153
141
|
FileUtils.mkdir_p(File.dirname(knife_rb))
|
154
142
|
knife_rb
|
155
143
|
end
|
156
144
|
|
157
145
|
################################################################################
|
158
146
|
|
159
|
-
def
|
160
|
-
|
161
|
-
FileUtils.mkdir_p(File.dirname(
|
162
|
-
|
147
|
+
def containers_bin
|
148
|
+
containers_bin = File.join(Cucumber::Chef.home_dir, "containers.bin")
|
149
|
+
FileUtils.mkdir_p(File.dirname(containers_bin))
|
150
|
+
containers_bin
|
163
151
|
end
|
164
152
|
|
165
153
|
################################################################################
|
@@ -167,11 +155,11 @@ module Cucumber
|
|
167
155
|
################################################################################
|
168
156
|
|
169
157
|
def bootstrap_user
|
170
|
-
Cucumber::Chef::Config[Cucumber::Chef::Config
|
158
|
+
Cucumber::Chef::Config[Cucumber::Chef::Config.provider][:lab_user]
|
171
159
|
end
|
172
160
|
|
173
161
|
def bootstrap_identity
|
174
|
-
bootstrap_identity = Cucumber::Chef::Config[Cucumber::Chef::Config
|
162
|
+
bootstrap_identity = Cucumber::Chef::Config[Cucumber::Chef::Config.provider][:identity_file]
|
175
163
|
File.exists?(bootstrap_identity) && File.chmod(0400, bootstrap_identity)
|
176
164
|
bootstrap_identity
|
177
165
|
end
|
@@ -181,35 +169,43 @@ module Cucumber
|
|
181
169
|
################################################################################
|
182
170
|
|
183
171
|
def lab_user
|
184
|
-
Cucumber::Chef::Config[Cucumber::Chef::Config
|
172
|
+
Cucumber::Chef::Config[Cucumber::Chef::Config.provider][:lab_user]
|
185
173
|
end
|
186
174
|
|
187
175
|
def lab_user_home_dir
|
188
|
-
user = Cucumber::Chef::Config[Cucumber::Chef::Config
|
176
|
+
user = Cucumber::Chef::Config[Cucumber::Chef::Config.provider][:lab_user]
|
189
177
|
((user == "root") ? "/root" : "/home/#{user}")
|
190
178
|
end
|
191
179
|
|
192
180
|
def lab_identity
|
193
|
-
lab_identity = File.join(Cucumber::Chef.home_dir, Cucumber::Chef::Config
|
181
|
+
lab_identity = File.join(Cucumber::Chef.home_dir, Cucumber::Chef::Config.provider.to_s, "id_rsa-#{lab_user}")
|
194
182
|
File.exists?(lab_identity) && File.chmod(0400, lab_identity)
|
195
183
|
lab_identity
|
196
184
|
end
|
197
185
|
|
186
|
+
def lab_hostname_short
|
187
|
+
Cucumber::Chef::Config.test_lab[:hostname]
|
188
|
+
end
|
189
|
+
|
190
|
+
def lab_hostname_full
|
191
|
+
"#{lab_hostname_short}.#{Cucumber::Chef::Config.test_lab[:tld]}"
|
192
|
+
end
|
193
|
+
|
198
194
|
################################################################################
|
199
195
|
# Container SSH Helpers
|
200
196
|
################################################################################
|
201
197
|
|
202
198
|
def lxc_user
|
203
|
-
Cucumber::Chef::Config[Cucumber::Chef::Config
|
199
|
+
Cucumber::Chef::Config[Cucumber::Chef::Config.provider][:lxc_user]
|
204
200
|
end
|
205
201
|
|
206
202
|
def lxc_user_home_dir
|
207
|
-
user = Cucumber::Chef::Config[Cucumber::Chef::Config
|
203
|
+
user = Cucumber::Chef::Config[Cucumber::Chef::Config.provider][:lxc_user]
|
208
204
|
((user == "root") ? "/root" : "/home/#{user}")
|
209
205
|
end
|
210
206
|
|
211
207
|
def lxc_identity
|
212
|
-
lxc_identity = File.join(Cucumber::Chef.home_dir, Cucumber::Chef::Config
|
208
|
+
lxc_identity = File.join(Cucumber::Chef.home_dir, Cucumber::Chef::Config.provider.to_s, "id_rsa-#{lab_user}")
|
213
209
|
File.exists?(lxc_identity) && File.chmod(0400, lxc_identity)
|
214
210
|
lxc_identity
|
215
211
|
end
|
@@ -241,8 +237,7 @@ module Cucumber
|
|
241
237
|
################################################################################
|
242
238
|
|
243
239
|
def load_chef_config
|
244
|
-
test_lab = (Cucumber::Chef::TestLab.new rescue nil)
|
245
|
-
if (test_lab && ((test_lab.labs_running.count rescue 0) > 0))
|
240
|
+
if (test_lab = (Cucumber::Chef::TestLab.new rescue nil)) && test_lab.alive?
|
246
241
|
if File.exists?(Cucumber::Chef.knife_rb)
|
247
242
|
logger.info { "load_chef_config(#{Cucumber::Chef.knife_rb})" }
|
248
243
|
::Chef::Config.from_file(Cucumber::Chef.knife_rb)
|
@@ -266,31 +261,43 @@ module Cucumber
|
|
266
261
|
$logger = ZTK::Logger.new(Cucumber::Chef.log_file)
|
267
262
|
Cucumber::Chef.is_rc? and ($logger.level = ZTK::Logger::DEBUG)
|
268
263
|
|
269
|
-
|
270
|
-
"program" => $0.to_s.inspect,
|
264
|
+
dependencies = {
|
271
265
|
"cucumber_chef_version" => Cucumber::Chef::VERSION.inspect,
|
272
|
-
"uname" => %x(uname -a).chomp.strip.inspect,
|
273
|
-
"chef_repo" => chef_repo.inspect,
|
274
266
|
"chef_version" => ::Chef::VERSION.inspect,
|
275
267
|
"vagrant_version" => ::Vagrant::VERSION.inspect,
|
276
268
|
"fog_version" => ::Fog::VERSION.inspect,
|
277
|
-
"log_file" => log_file.inspect,
|
278
|
-
# "config_rb" => config_rb,
|
279
|
-
# "knife_rb" => knife_rb,
|
280
|
-
"servers_bin" => servers_bin.inspect,
|
281
269
|
"ruby_version" => RUBY_VERSION.inspect,
|
282
270
|
"ruby_patchlevel" => RUBY_PATCHLEVEL.inspect,
|
283
|
-
"ruby_platform" => RUBY_PLATFORM.inspect
|
271
|
+
"ruby_platform" => RUBY_PLATFORM.inspect,
|
272
|
+
"ztk_version" => ::ZTK::VERSION.inspect
|
273
|
+
# "cucumber_version" => ::Cucumber::VERSION.inspect
|
284
274
|
}
|
285
275
|
if RUBY_VERSION >= "1.9"
|
286
|
-
|
276
|
+
dependencies.merge!("ruby_engine" => RUBY_ENGINE.inspect)
|
287
277
|
end
|
288
|
-
|
278
|
+
|
279
|
+
details = {
|
280
|
+
"program" => $0.to_s.inspect,
|
281
|
+
"uname" => %x(uname -a).chomp.strip.inspect,
|
282
|
+
"chef_repo" => chef_repo.inspect,
|
283
|
+
"log_file" => log_file.inspect,
|
284
|
+
"config_rb" => config_rb.inspect,
|
285
|
+
"knife_rb" => knife_rb.inspect,
|
286
|
+
"containers_bin" => containers_bin.inspect
|
287
|
+
}
|
288
|
+
|
289
|
+
max_key_length = [dependencies.keys.collect{ |key| key.to_s.length }.max, details.keys.collect{ |key| key.to_s.length }.max].max + 2
|
289
290
|
|
290
291
|
$logger.info { ("=" * 80) }
|
291
|
-
|
292
|
-
$logger.info { "
|
292
|
+
details.sort.each do |key, value|
|
293
|
+
$logger.info { " %s%s: %s" % [ key.upcase, '.' * (max_key_length - key.length), value.to_s ] }
|
294
|
+
end
|
295
|
+
$logger.info { ("-" * (max_key_length * 2)) }
|
296
|
+
dependencies.sort.each do |key, value|
|
297
|
+
$logger.info { " %s%s: %s" % [ key.upcase, '.' * (max_key_length - key.length), value.to_s ] }
|
293
298
|
end
|
299
|
+
$logger.info { ("-" * (max_key_length * 2)) }
|
300
|
+
|
294
301
|
end
|
295
302
|
|
296
303
|
$logger
|