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.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "jamie-lxc"
3
- gem.version = "0.0.1.alpha6"
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.alpha19")
12
+ gem.add_dependency("jamie", ">= 0.1.0.beta1")
13
13
 
14
14
  gem.add_development_dependency("rake")
15
15
 
@@ -7,22 +7,22 @@ module Jamie
7
7
 
8
8
  class Lxc < Jamie::Driver::SSHBase
9
9
 
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"
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["container_id"] = instance.name + "-" + ::SecureRandom.hex(3)
17
+ state[:container_id] = instance.name + "-" + ::SecureRandom.hex(3)
18
18
  clone_container(state)
19
19
  start_container(state)
20
- state["hostname"] = container_ip(state)
21
- wait_for_sshd(state["hostname"])
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["container_id"]
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["base_container"]} -n #{state["container_id"]}")
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["container_id"]} -d")
38
- run_command("lxc-wait -n #{state["container_id"]} -s RUNNING")
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["container_id"]} -f")
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["dhcp_lease_file"])
46
+ if ::File.exists?(config[:dhcp_lease_file])
47
47
  30.times do
48
- leases = ::File.readlines(config["dhcp_lease_file"]).map{ |line| line.split(" ") }
48
+ leases = ::File.readlines(config[:dhcp_lease_file]).map{ |line| line.split(" ") }
49
49
  leases.each do |lease|
50
- if lease.include?(state["container_id"])
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["dhcp_lease_file"]}'"
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["container_id"]}'"
59
+ raise ActionFailed, "Could not determine IP address for LXC container '#{state[:container_id]}'"
60
60
  end
61
61
 
62
62
  end
@@ -9,24 +9,24 @@ describe Jamie::Driver::Lxc do
9
9
  before do
10
10
  @logger_output = StringIO.new
11
11
  driver_options = {
12
- "jamie_root" => File.dirname(__FILE__),
13
- "base_container" => "ubuntu-1204"
12
+ :jamie_root => File.dirname(__FILE__),
13
+ :base_container => "ubuntu-1204"
14
14
  }
15
15
  instance_options = {
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")
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(/creation of <test-ubuntu-1204> complete/i)
27
+ @logger_output.string.must_match(/Finished creating <test-ubuntu-1204> complete/i)
28
28
  @instance.destroy
29
- @logger_output.string.must_match(/destruction of <test-ubuntu-1204> complete/i)
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.alpha6
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-04 00:00:00.000000000 Z
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.alpha19
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.alpha19
28
+ version: 0.1.0.beta1
29
29
  name: jamie
30
30
  - !ruby/object:Gem::Dependency
31
31
  type: :development