jamie-lxc 0.0.1.alpha6 → 0.0.1.beta1
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/jamie-lxc.gemspec +2 -2
- data/lib/jamie/driver/lxc.rb +18 -18
- data/test/lxc_driver_tests.rb +9 -9
- metadata +4 -4
data/jamie-lxc.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "jamie-lxc"
|
3
|
-
gem.version = "0.0.1.
|
3
|
+
gem.version = "0.0.1.beta1"
|
4
4
|
gem.authors = ["Sean Porter"]
|
5
5
|
gem.email = ["portertech@gmail.com"]
|
6
6
|
gem.description = "LXC driver for Jamie"
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.license = "MIT"
|
10
10
|
gem.has_rdoc = false
|
11
11
|
|
12
|
-
gem.add_dependency("jamie", ">= 0.1.0.
|
12
|
+
gem.add_dependency("jamie", ">= 0.1.0.beta1")
|
13
13
|
|
14
14
|
gem.add_development_dependency("rake")
|
15
15
|
|
data/lib/jamie/driver/lxc.rb
CHANGED
@@ -7,22 +7,22 @@ module Jamie
|
|
7
7
|
|
8
8
|
class Lxc < Jamie::Driver::SSHBase
|
9
9
|
|
10
|
-
default_config
|
11
|
-
default_config
|
12
|
-
default_config
|
13
|
-
default_config
|
14
|
-
default_config
|
10
|
+
default_config :use_sudo, true
|
11
|
+
default_config :dhcp_lease_file, "/var/lib/misc/dnsmasq.leases"
|
12
|
+
default_config :port, "22"
|
13
|
+
default_config :username, "jamie"
|
14
|
+
default_config :password, "jamie"
|
15
15
|
|
16
16
|
def create(state)
|
17
|
-
state[
|
17
|
+
state[:container_id] = instance.name + "-" + ::SecureRandom.hex(3)
|
18
18
|
clone_container(state)
|
19
19
|
start_container(state)
|
20
|
-
state[
|
21
|
-
wait_for_sshd(state[
|
20
|
+
state[:hostname] = container_ip(state)
|
21
|
+
wait_for_sshd(state[:hostname])
|
22
22
|
end
|
23
23
|
|
24
24
|
def destroy(state)
|
25
|
-
if state[
|
25
|
+
if state[:container_id]
|
26
26
|
destroy_container(state)
|
27
27
|
end
|
28
28
|
end
|
@@ -30,33 +30,33 @@ module Jamie
|
|
30
30
|
protected
|
31
31
|
|
32
32
|
def clone_container(state)
|
33
|
-
run_command("lxc-clone -o #{config[
|
33
|
+
run_command("lxc-clone -o #{config[:base_container]} -n #{state[:container_id]}")
|
34
34
|
end
|
35
35
|
|
36
36
|
def start_container(state)
|
37
|
-
run_command("lxc-start -n #{state[
|
38
|
-
run_command("lxc-wait -n #{state[
|
37
|
+
run_command("lxc-start -n #{state[:container_id]} -d")
|
38
|
+
run_command("lxc-wait -n #{state[:container_id]} -s RUNNING")
|
39
39
|
end
|
40
40
|
|
41
41
|
def destroy_container(state)
|
42
|
-
run_command("lxc-destroy -n #{state[
|
42
|
+
run_command("lxc-destroy -n #{state[:container_id]} -f")
|
43
43
|
end
|
44
44
|
|
45
45
|
def container_ip(state)
|
46
|
-
if ::File.exists?(config[
|
46
|
+
if ::File.exists?(config[:dhcp_lease_file])
|
47
47
|
30.times do
|
48
|
-
leases = ::File.readlines(config[
|
48
|
+
leases = ::File.readlines(config[:dhcp_lease_file]).map{ |line| line.split(" ") }
|
49
49
|
leases.each do |lease|
|
50
|
-
if lease.include?(state[
|
50
|
+
if lease.include?(state[:container_id])
|
51
51
|
return lease[2]
|
52
52
|
end
|
53
53
|
end
|
54
54
|
sleep 3
|
55
55
|
end
|
56
56
|
else
|
57
|
-
raise ActionFailed, "LXC DHCP lease file does not exist '#{config[
|
57
|
+
raise ActionFailed, "LXC DHCP lease file does not exist '#{config[:dhcp_lease_file]}'"
|
58
58
|
end
|
59
|
-
raise ActionFailed, "Could not determine IP address for LXC container '#{state[
|
59
|
+
raise ActionFailed, "Could not determine IP address for LXC container '#{state[:container_id]}'"
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
data/test/lxc_driver_tests.rb
CHANGED
@@ -9,24 +9,24 @@ describe Jamie::Driver::Lxc do
|
|
9
9
|
before do
|
10
10
|
@logger_output = StringIO.new
|
11
11
|
driver_options = {
|
12
|
-
|
13
|
-
|
12
|
+
:jamie_root => File.dirname(__FILE__),
|
13
|
+
:base_container => "ubuntu-1204"
|
14
14
|
}
|
15
15
|
instance_options = {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
:logger => Jamie::Logger.new(:stdout => @logger_output),
|
17
|
+
:suite => Jamie::Suite.new(:name => "test", :run_list => Array.new),
|
18
|
+
:platform => Jamie::Platform.new(:name => "ubuntu-1204"),
|
19
|
+
:driver => Jamie::Driver::Lxc.new(driver_options),
|
20
|
+
:jr => Jamie::Jr.new("test")
|
21
21
|
}
|
22
22
|
@instance = Jamie::Instance.new(instance_options)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "can clone a base lxc container" do
|
26
26
|
@instance.create
|
27
|
-
@logger_output.string.must_match(/
|
27
|
+
@logger_output.string.must_match(/Finished creating <test-ubuntu-1204> complete/i)
|
28
28
|
@instance.destroy
|
29
|
-
@logger_output.string.must_match(/
|
29
|
+
@logger_output.string.must_match(/Finished destroying of <test-ubuntu-1204> complete/i)
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: jamie-lxc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 0.0.1.
|
5
|
+
version: 0.0.1.beta1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sean Porter
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
type: :runtime
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.1.0.
|
21
|
+
version: 0.1.0.beta1
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
26
|
- - ! '>='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.1.0.
|
28
|
+
version: 0.1.0.beta1
|
29
29
|
name: jamie
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
type: :development
|