kitchen-lxc 0.0.1.beta2 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 418715ee25b2e76bc05bdb529246672c285a4a03
4
+ data.tar.gz: b6e88dd94c7188b5c42dd26b43bf5f918ffa9aaf
5
+ SHA512:
6
+ metadata.gz: 4a257a729d514716151fc6f81ea5efb460dcf640daf59624828d2afafa9009dc5aac6fbe34c91df51c5c32a10cd3eaf005ed8426d3b568a32a17bc7a637871c0
7
+ data.tar.gz: 0733d4006ea2409a31a359899349f4f932c54f86da727b45e6cc234aeaf2fd6caec644a77c4a36fdfe4a4a95e3c8eff267945bcdf81c143373fed2d7f9f1b836
data/Gemfile CHANGED
@@ -1,6 +1,3 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # Specify your gem"s dependencies in kitchen-lxc.gemspec
4
3
  gemspec
5
-
6
- gem "test-kitchen", :git => "git://github.com/opscode/test-kitchen.git", :branch => "1.0"
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # Kitchen LXC
2
2
 
3
3
  The LXC driver for the Chef convergence integration test harness,
4
- [Test Kitchen](https://github.com/opscode/test-kitchen/tree/1.0).
4
+ [Test Kitchen](https://github.com/test-kitchen).
5
5
 
6
- Kitchen LXC creates a clone of a "base" LXC container to run a test
7
- suite.
6
+ Kitchen LXC creates an ephemeral clone of a "base" LXC container to
7
+ run a test suite.
8
+
9
+ You may want to use the
10
+ [Docker driver](https://github.com/portertech/kitchen-docker).
8
11
 
9
12
  ## Installation
10
13
 
@@ -33,28 +36,11 @@ The password used to login to the container.
33
36
 
34
37
  Defaults to "root".
35
38
 
36
- #### dhcp_lease_file
37
- The DHCP lease file used to determine the container IP address.
38
-
39
- Defaults to the first match for "/var/lib/misc/dnsmasq*leases".
40
-
41
- #### ipaddress
42
- You may specify an IP address for the container, within the
43
- 10.0.3.0/24 subnet, instead of using DHCP.
44
-
45
39
  #### port
46
40
  The SSH port used to login to the container.
47
41
 
48
42
  Defaults to 22.
49
43
 
50
- #### overlay
51
- The directory to use for the rootfs overlay.
52
-
53
- Defaults to "/tmp".
54
-
55
- #### device
56
- The size (MB) of the block device for the rootfs overlay.
57
-
58
44
  ### Example
59
45
 
60
46
  `.kitchen.local.yml`
@@ -72,38 +58,19 @@ platforms:
72
58
  ```
73
59
 
74
60
  ```
75
- $ bundle exec kitchen create
76
- -----> Starting Kitchen
77
- -----> Creating <default-ubuntu>
78
- [kitchen::driver::lxc command] BEGIN (lxc-awesome-ephemeral -d -o tk-ubuntu-1204 -n default-ubuntu-a0c75e)
79
- Setting up ephemeral container...
80
- Starting up the container...
81
- default-ubuntu-a0c75e is running
82
- You connect with the command:
83
- sudo lxc-console -n default-ubuntu-a0c75e
84
- [kitchen::driver::lxc command] END (0m1.92s)
85
- Finished creating <default-ubuntu> (0m4.98s).
86
- -----> Creating <stack-ubuntu>
87
- [kitchen::driver::lxc command] BEGIN (lxc-awesome-ephemeral -d -o tk-ubuntu-1204 -n stack-ubuntu-cb87c2)
88
- Setting up ephemeral container...
89
- Starting up the container...
90
- stack-ubuntu-cb87c2 is running
91
- You connect with the command:
92
- sudo lxc-console -n stack-ubuntu-cb87c2
93
- [kitchen::driver::lxc command] END (0m1.91s)
94
- Finished creating <stack-ubuntu> (0m4.99s).
95
- -----> Kitchen is finished. (0m9.99s)
96
- $ bundle exec kitchen destroy
97
- -----> Starting Kitchen
98
- -----> Destroying <default-ubuntu>
99
- [kitchen::driver::lxc command] BEGIN (lxc-awesome-ephemeral -c -o tk-ubuntu-1204 -n default-ubuntu-a0c75e)
100
- [kitchen::driver::lxc command] END (0m3.41s)
101
- Finished destroying <default-ubuntu> (0m3.48s).
102
- -----> Destroying <stack-ubuntu>
103
- [kitchen::driver::lxc command] BEGIN (lxc-awesome-ephemeral -c -o tk-ubuntu-1204 -n stack-ubuntu-cb87c2)
104
- [kitchen::driver::lxc command] END (0m3.44s)
105
- Finished destroying <stack-ubuntu> (0m3.52s).
106
- -----> Kitchen is finished. (0m7.03s)
61
+ $ sudo kitchen create default
62
+ -----> Starting Kitchen (v1.0.0.beta.4)
63
+ -----> Creating <default-ubuntu_1204>
64
+ Finished creating <default-ubuntu_1204> (0m4.50s).
65
+ -----> Kitchen is finished. (0m4.54s)
66
+ $ sudo kitchen destroy default
67
+ -----> Starting Kitchen (v1.0.0.beta.4)
68
+ -----> Destroying <default-ubuntu_1204>
69
+ Finished destroying <default-ubuntu_1204> (0m0.32s).
70
+ -----> Kitchen is finished. (0m0.35s)
71
+ $ sudo kitchen list
72
+ Instance Driver Provisioner Last Action
73
+ default-ubuntu_1204 Lxc Chef Solo <Not Created>
107
74
  ```
108
75
 
109
76
  ## Contributing
@@ -114,10 +81,4 @@ $ bundle exec kitchen destroy
114
81
  4. Push to the branch (`git push origin my-new-feature`)
115
82
  5. Create new Pull Request
116
83
 
117
- ## Authors
118
-
119
- Author:: Sean Porter (<portertech@gmail.com>)
120
-
121
- Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
122
-
123
84
  See LICENSE.txt for licensing details
data/kitchen-lxc.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "kitchen-lxc"
3
- gem.version = "0.0.1.beta2"
3
+ gem.version = "0.0.1"
4
4
  gem.authors = ["Sean Porter"]
5
5
  gem.email = ["portertech@gmail.com"]
6
6
  gem.description = "LXC driver for Test Kitchen"
@@ -9,8 +9,8 @@ Gem::Specification.new do |gem|
9
9
  gem.license = "MIT"
10
10
  gem.has_rdoc = false
11
11
 
12
- gem.add_dependency("test-kitchen", ">= 1.0.0.alpha.6")
13
- gem.add_dependency("lxc-awesome-ephemeral", ">= 0.0.1.beta1")
12
+ gem.add_dependency("test-kitchen", ">= 1.0.0.beta.4")
13
+ gem.add_dependency("elecksee", ">= 1.0.14")
14
14
 
15
15
  gem.add_development_dependency("rake")
16
16
 
@@ -1,5 +1,7 @@
1
- require "securerandom"
2
1
  require "kitchen"
2
+ require "elecksee/ephemeral"
3
+
4
+ ::Lxc.use_sudo = true
3
5
 
4
6
  module Kitchen
5
7
 
@@ -7,66 +9,36 @@ module Kitchen
7
9
 
8
10
  class Lxc < Kitchen::Driver::SSHBase
9
11
 
10
- no_parallel_for :create
11
-
12
- default_config :use_sudo, false
13
- default_config :dhcp_lease_file, Dir["/var/lib/misc/dnsmasq*leases"][0]
14
- default_config :port, "22"
15
- default_config :username, "root" # most LXC templates use this
16
- default_config :password, "root" # most LXC templates use this
12
+ default_config :use_sudo, true
13
+ default_config :username, "root" # most LXC templates use this
14
+ default_config :password, "root" # most LXC templates use this
17
15
 
18
- def create(state)
19
- state[:container_id] = instance.name + "-" + ::SecureRandom.hex(3)
20
- state[:overlay] = config[:overlay] if config[:overlay]
21
- start_container(state)
22
- state[:hostname] = container_ip(state)
23
- wait_for_sshd(state[:hostname])
16
+ default_config :original do |driver|
17
+ driver[:base_container]
24
18
  end
25
19
 
26
- def destroy(state)
27
- destroy_container(state) if state[:container_id]
28
- end
20
+ no_parallel_for :create
29
21
 
30
- protected
22
+ def create(state)
23
+ container = ::Lxc::Ephemeral.new(config.to_hash)
24
+ container.create!
31
25
 
32
- def start_container(state)
33
- cmd = "lxc-awesome-ephemeral -d -o #{config[:base_container]} -n #{state[:container_id]}"
34
- [:device, :ipaddress, :netmask, :gateway, :key].each do |opt|
35
- unless config[opt].nil?
36
- cmd << " --#{opt} #{config[opt]}"
37
- end
38
- end
39
- cmd << " -z #{state[:overlay]}" if state[:overlay]
40
- run_command(cmd)
41
- end
26
+ state[:container_name] = container.name
42
27
 
43
- def destroy_container(state)
44
- cmd = "lxc-awesome-ephemeral -c -o #{config[:base_container]} -n #{state[:container_id]}"
45
- cmd << " -z #{state[:overlay]}" if state[:overlay]
46
- run_command(cmd)
47
- end
28
+ lxc = ::Lxc.new(state[:container_name])
29
+ lxc.start
48
30
 
49
- def dhcp_lease_file
50
- unless ::File.exists?(config[:dhcp_lease_file])
51
- raise ActionFailed, "LXC DHCP lease file does not exist '#{config[:dhcp_lease_file]}'"
52
- end
53
- config[:dhcp_lease_file]
31
+ state[:hostname] = lxc.container_ip(10, true)
32
+ wait_for_sshd(state[:hostname])
54
33
  end
55
34
 
56
- def container_ip(state)
57
- if config[:ipaddress]
58
- return config[:ipaddress]
59
- else
60
- 30.times do
61
- leases = ::File.readlines(dhcp_lease_file).map { |line| line.split(" ") }
62
- leases.each do |lease|
63
- return lease[2] if lease.include?(state[:container_id])
64
- end
65
- sleep 3
66
- end
35
+ def destroy(state)
36
+ if state[:container_name]
37
+ lxc = ::Lxc.new(state[:container_name])
38
+ lxc.destroy
67
39
  end
68
- raise ActionFailed, "Could not determine IP address for LXC container '#{state[:container_id]}'"
69
40
  end
41
+
70
42
  end
71
43
 
72
44
  class LXC < Lxc; end
metadata CHANGED
@@ -1,64 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-lxc
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 0.0.1.beta2
4
+ version: 0.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sean Porter
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-13 00:00:00.000000000 Z
11
+ date: 2013-11-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- type: :runtime
14
+ name: test-kitchen
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: 1.0.0.alpha.6
19
+ version: 1.0.0.beta.4
20
+ type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
- none: false
25
23
  requirements:
26
- - - ! '>='
24
+ - - '>='
27
25
  - !ruby/object:Gem::Version
28
- version: 1.0.0.alpha.6
29
- name: test-kitchen
26
+ version: 1.0.0.beta.4
30
27
  - !ruby/object:Gem::Dependency
31
- type: :runtime
28
+ name: elecksee
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
- version: 0.0.1.beta1
33
+ version: 1.0.14
34
+ type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
- none: false
41
37
  requirements:
42
- - - ! '>='
38
+ - - '>='
43
39
  - !ruby/object:Gem::Version
44
- version: 0.0.1.beta1
45
- name: lxc-awesome-ephemeral
40
+ version: 1.0.14
46
41
  - !ruby/object:Gem::Dependency
47
- type: :development
42
+ name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
48
+ type: :development
54
49
  prerelease: false
55
50
  version_requirements: !ruby/object:Gem::Requirement
56
- none: false
57
51
  requirements:
58
- - - ! '>='
52
+ - - '>='
59
53
  - !ruby/object:Gem::Version
60
54
  version: '0'
61
- name: rake
62
55
  description: LXC driver for Test Kitchen
63
56
  email:
64
57
  - portertech@gmail.com
@@ -77,27 +70,27 @@ files:
77
70
  homepage: https://github.com/portertech/kitchen-lxc
78
71
  licenses:
79
72
  - MIT
73
+ metadata: {}
80
74
  post_install_message:
81
75
  rdoc_options: []
82
76
  require_paths:
83
77
  - lib
84
78
  required_ruby_version: !ruby/object:Gem::Requirement
85
- none: false
86
79
  requirements:
87
- - - ! '>='
80
+ - - '>='
88
81
  - !ruby/object:Gem::Version
89
82
  version: '0'
90
83
  required_rubygems_version: !ruby/object:Gem::Requirement
91
- none: false
92
84
  requirements:
93
- - - ! '>'
85
+ - - '>='
94
86
  - !ruby/object:Gem::Version
95
- version: 1.3.1
87
+ version: '0'
96
88
  requirements: []
97
89
  rubyforge_project:
98
- rubygems_version: 1.8.24
90
+ rubygems_version: 2.0.6
99
91
  signing_key:
100
- specification_version: 3
92
+ specification_version: 4
101
93
  summary: LXC driver for Test Kitchen
102
94
  test_files:
103
95
  - test/lxc_driver_tests.rb
96
+ has_rdoc: false