leibniz 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/leibniz.gemspec +3 -0
- data/lib/leibniz/version.rb +1 -1
- data/lib/leibniz.rb +105 -1
- metadata +34 -2
data/leibniz.gemspec
CHANGED
@@ -18,6 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "test-kitchen", "~> 1.0.0.alpha"
|
22
|
+
spec.add_dependency "kitchen-vagrant"
|
23
|
+
|
21
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
25
|
spec.add_development_dependency "rake"
|
23
26
|
end
|
data/lib/leibniz/version.rb
CHANGED
data/lib/leibniz.rb
CHANGED
@@ -1,5 +1,109 @@
|
|
1
1
|
require "leibniz/version"
|
2
2
|
|
3
|
+
require 'kitchen'
|
4
|
+
require 'forwardable'
|
5
|
+
|
6
|
+
module Kitchen
|
7
|
+
class Config
|
8
|
+
def new_instance_logger(index)
|
9
|
+
level = Util.to_logger_level(self.log_level)
|
10
|
+
|
11
|
+
lambda do |name|
|
12
|
+
logfile = File.join(log_root, "#{name}.log")
|
13
|
+
|
14
|
+
Logger.new(:logdev => logfile,
|
15
|
+
:level => level, :progname => name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
3
21
|
module Leibniz
|
4
|
-
|
22
|
+
|
23
|
+
def self.build(specification)
|
24
|
+
loader = KitchenLoader.new(specification)
|
25
|
+
config = Kitchen::Config.new(:loader => loader)
|
26
|
+
Infrastructure.new(config.instances)
|
27
|
+
end
|
28
|
+
|
29
|
+
class Infrastructure
|
30
|
+
|
31
|
+
def initialize(instances)
|
32
|
+
@nodes = Hash.new
|
33
|
+
instances.each do |instance|
|
34
|
+
@nodes[instance.name.sub(/^leibniz-/, '')] = Node.new(instance)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def [](name)
|
39
|
+
@nodes[name]
|
40
|
+
end
|
41
|
+
|
42
|
+
def converge
|
43
|
+
@nodes.each_pair { |name, node| node.converge }
|
44
|
+
end
|
45
|
+
|
46
|
+
def destroy
|
47
|
+
@nodes.each_pair { |name, node| node.destroy }
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
class Node
|
53
|
+
|
54
|
+
extend Forwardable
|
55
|
+
|
56
|
+
def_delegators :@instance, :create, :converge, :setup, :verify, :destroy, :test
|
57
|
+
|
58
|
+
def initialize(instance)
|
59
|
+
@instance = instance
|
60
|
+
end
|
61
|
+
|
62
|
+
def ip
|
63
|
+
instance.driver[:ipaddress]
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
attr_reader :instance
|
69
|
+
end
|
70
|
+
|
71
|
+
class KitchenLoader
|
72
|
+
|
73
|
+
def initialize(specification)
|
74
|
+
@last_octet = 11
|
75
|
+
@platforms = specification.hashes.map do |spec|
|
76
|
+
create_platform(spec)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def read
|
81
|
+
{
|
82
|
+
:driver_plugin => "vagrant",
|
83
|
+
:platforms => platforms,
|
84
|
+
:suites => [ { :name => "leibniz", :run_list => [] } ]
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
attr_reader :platforms
|
91
|
+
|
92
|
+
def create_platform(spec)
|
93
|
+
distro = "#{spec['Operating System']}-#{spec['Version']}"
|
94
|
+
ipaddress = "10.2.3.#{@last_octet}"
|
95
|
+
@last_octet += 1
|
96
|
+
platform = Hash.new
|
97
|
+
platform[:name] = spec["Server Name"]
|
98
|
+
platform[:driver_config] = Hash.new
|
99
|
+
platform[:driver_config][:box] = "opscode-#{distro}"
|
100
|
+
platform[:driver_config][:box_url] = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_#{distro}_provisionerless.box"
|
101
|
+
platform[:driver_config][:network] = [["private_network", {:ip => ipaddress}]]
|
102
|
+
platform[:driver_config][:require_chef_omnibus] = spec["Chef Version"] || true
|
103
|
+
platform[:driver_config][:ipaddress] = ipaddress
|
104
|
+
platform[:run_list] = Array(spec["Run List"])
|
105
|
+
platform
|
106
|
+
end
|
107
|
+
end
|
5
108
|
end
|
109
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leibniz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: test-kitchen
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0.alpha
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0.alpha
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: kitchen-vagrant
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
14
46
|
- !ruby/object:Gem::Dependency
|
15
47
|
name: bundler
|
16
48
|
requirement: !ruby/object:Gem::Requirement
|