logical-construct 0.0.5 → 0.1.0
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/bin/flight-deck +3 -0
- data/doc/DESIGN +48 -0
- data/doc/EC2-baking-notes +70 -0
- data/doc/ExampleStartupRakefile +152 -0
- data/doc/ExampleTargetRakefile +4 -0
- data/doc/TODO +148 -0
- data/doc/Vb-EC2-translation-notes +96 -0
- data/doc/hating-chef +32 -0
- data/lib/logical-construct/archive-tasks.rb +307 -0
- data/lib/logical-construct/ground-control.rb +4 -1
- data/lib/logical-construct/ground-control/build-plan.rb +95 -0
- data/lib/logical-construct/ground-control/core.rb +1 -1
- data/lib/logical-construct/ground-control/generate-manifest.rb +67 -0
- data/lib/logical-construct/ground-control/provision.rb +73 -168
- data/lib/logical-construct/ground-control/run-on-target.rb +1 -1
- data/lib/logical-construct/ground-control/setup.rb +1 -4
- data/lib/logical-construct/ground-control/setup/copy-files.rb +2 -2
- data/lib/logical-construct/ground-control/tools.rb +66 -0
- data/lib/logical-construct/node-client.rb +112 -0
- data/lib/logical-construct/plan.rb +2 -0
- data/lib/logical-construct/plan/core.rb +45 -0
- data/lib/logical-construct/plan/standalone-bundle.rb +80 -0
- data/lib/logical-construct/port-open-check.rb +41 -0
- data/lib/logical-construct/protocol.rb +2 -0
- data/lib/logical-construct/protocol/plan-validation.rb +46 -0
- data/lib/logical-construct/protocol/ssh-tunnel.rb +127 -0
- data/lib/logical-construct/protocol/vocabulary.rb +8 -0
- data/lib/logical-construct/target/Implement.rake +8 -0
- data/lib/logical-construct/target/command-line.rb +90 -0
- data/lib/logical-construct/target/flight-deck.rb +341 -0
- data/lib/logical-construct/target/implementation.rb +33 -0
- data/lib/logical-construct/target/plan-records.rb +317 -0
- data/lib/logical-construct/target/resolution-server.rb +153 -0
- data/lib/logical-construct/target/{unpack-cookbook.rb → unpack-plan.rb} +8 -4
- data/lib/logical-construct/template-file.rb +41 -0
- data/lib/templates/Rakefile.erb +8 -0
- data/spec/ground-control/smoke-test.rb +8 -7
- data/spec/node_resolution.rb +62 -0
- data/spec/target/plan-records.rb +142 -0
- data/spec/target/provisioning.rb +21 -0
- data/spec_help/file-sandbox.rb +12 -6
- data/spec_help/fixtures/Manifest +1 -0
- data/spec_help/fixtures/source/one.tbz +1 -0
- data/spec_help/fixtures/source/three.tbz +1 -0
- data/spec_help/fixtures/source/two.tbz +1 -0
- data/spec_help/spec_helper.rb +5 -7
- metadata +165 -72
- data/lib/logical-construct/ground-control/setup/build-files.rb +0 -93
- data/lib/logical-construct/ground-control/setup/create-construct-directory.rb +0 -22
- data/lib/logical-construct/ground-control/setup/install-init.rb +0 -32
- data/lib/logical-construct/resolving-task.rb +0 -141
- data/lib/logical-construct/satisfiable-task.rb +0 -87
- data/lib/logical-construct/target.rb +0 -4
- data/lib/logical-construct/target/chef-solo.rb +0 -37
- data/lib/logical-construct/target/platforms.rb +0 -51
- data/lib/logical-construct/target/platforms/aws.rb +0 -8
- data/lib/logical-construct/target/platforms/default/chef-config.rb +0 -134
- data/lib/logical-construct/target/platforms/default/resolve-configuration.rb +0 -44
- data/lib/logical-construct/target/platforms/default/volume.rb +0 -11
- data/lib/logical-construct/target/platforms/virtualbox.rb +0 -8
- data/lib/logical-construct/target/platforms/virtualbox/volume.rb +0 -15
- data/lib/logical-construct/target/provision.rb +0 -36
- data/lib/logical-construct/target/sinatra-resolver.rb +0 -99
- data/lib/logical-construct/testing/resolve-configuration.rb +0 -32
- data/lib/logical-construct/testing/resolving-task.rb +0 -15
- data/lib/templates/chef.rb.erb +0 -9
- data/lib/templates/construct.init.d.erb +0 -18
- data/lib/templates/resolver/finished.html.erb +0 -1
- data/lib/templates/resolver/index.html.erb +0 -17
- data/lib/templates/resolver/task-file-form.html.erb +0 -6
- data/lib/templates/resolver/task-form.html.erb +0 -6
- data/spec/resolution.rb +0 -147
- data/spec/target/chef-config.rb +0 -67
- data/spec/target/chef-solo.rb +0 -55
- data/spec/target/platforms.rb +0 -36
- data/spec/target/smoke-test.rb +0 -45
- data/spec_help/ungemmer.rb +0 -36
@@ -1,17 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head profile="http://lrdesign/document-profiles/logical-construct/resolution">
|
4
|
-
<meta charset="UTF-8" />
|
5
|
-
<title>Logical Construct Provisioning Data Resolution</title>
|
6
|
-
</head>
|
7
|
-
<body>
|
8
|
-
<p>The following conditions must be satisfied in order to provision this machine:</p>
|
9
|
-
<ul>
|
10
|
-
<% unsatisfied.each do |task| %>
|
11
|
-
<li>
|
12
|
-
<a rel="requirement" href="<%= web_path(task.name)%>"><%= task.name %></a>
|
13
|
-
</li>
|
14
|
-
<% end %>
|
15
|
-
</ul>
|
16
|
-
</body>
|
17
|
-
</html>
|
data/spec/resolution.rb
DELETED
@@ -1,147 +0,0 @@
|
|
1
|
-
require 'mattock/testing/rake-example-group'
|
2
|
-
require 'mattock/template-host'
|
3
|
-
require 'timeout'
|
4
|
-
|
5
|
-
require 'logical-construct/target/sinatra-resolver'
|
6
|
-
require 'logical-construct/ground-control/provision'
|
7
|
-
require 'logical-construct/satisfiable-task'
|
8
|
-
|
9
|
-
describe LogicalConstruct::SinatraResolver, :slow => true do
|
10
|
-
include Mattock::RakeExampleGroup
|
11
|
-
|
12
|
-
let :file_target_path do
|
13
|
-
"target-file"
|
14
|
-
end
|
15
|
-
|
16
|
-
let :string_target_path do
|
17
|
-
"target-string"
|
18
|
-
end
|
19
|
-
|
20
|
-
let :resolver_pipe do
|
21
|
-
IO.pipe
|
22
|
-
end
|
23
|
-
|
24
|
-
let! :resolver_write do
|
25
|
-
resolver_pipe[1]
|
26
|
-
end
|
27
|
-
|
28
|
-
let :resolver_read do
|
29
|
-
resolver_pipe[0]
|
30
|
-
end
|
31
|
-
|
32
|
-
let :resolver_buffer do
|
33
|
-
""
|
34
|
-
end
|
35
|
-
|
36
|
-
let :resolver_process do
|
37
|
-
Process.fork do
|
38
|
-
extend Mattock::ValiseManager
|
39
|
-
file = LogicalConstruct::SatisfiableFileTask.new(:file_target) do |task|
|
40
|
-
task.target_path = file_target_path
|
41
|
-
end
|
42
|
-
|
43
|
-
string = LogicalConstruct::SatisfiableFileTask.new(:string_target) do |task|
|
44
|
-
task.target_path = string_target_path
|
45
|
-
end
|
46
|
-
|
47
|
-
LogicalConstruct::SinatraResolver.new(file, string, :resolver) do |task|
|
48
|
-
task.valise = default_valise(File::expand_path("../../lib", __FILE__))
|
49
|
-
task.bind = "127.0.0.1"
|
50
|
-
end
|
51
|
-
|
52
|
-
$stdout.reopen(resolver_write)
|
53
|
-
$stderr.reopen(resolver_write)
|
54
|
-
|
55
|
-
rake[:file_target].invoke
|
56
|
-
rake[:string_target].invoke
|
57
|
-
end.tap do |pid|
|
58
|
-
at_exit do
|
59
|
-
kill("KILL", pid) rescue nil
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
before :each do
|
66
|
-
resolver_process
|
67
|
-
|
68
|
-
begin
|
69
|
-
resolver_buffer << resolver_read.read_nonblock(4096)
|
70
|
-
rescue IO::WaitReadable => err
|
71
|
-
sleep 0.1
|
72
|
-
retry
|
73
|
-
end until /Listening on/ =~ resolver_buffer
|
74
|
-
end
|
75
|
-
|
76
|
-
after do
|
77
|
-
begin
|
78
|
-
Process.kill("INT", resolver_process)
|
79
|
-
Process.wait(resolver_process)
|
80
|
-
rescue => ex
|
81
|
-
warn ex
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should block when unresolved" do
|
86
|
-
expect do
|
87
|
-
Process.wait(resolver_process, Process::WNOHANG)
|
88
|
-
end.not_to raise_error
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should not have a file already" do
|
92
|
-
File::file?(file_target_path).should be_false
|
93
|
-
end
|
94
|
-
|
95
|
-
describe LogicalConstruct::GroundControl::Provision::WebConfigure do
|
96
|
-
let :file_content do
|
97
|
-
"Some test file content"
|
98
|
-
end
|
99
|
-
|
100
|
-
let :string_content do
|
101
|
-
"Some string content"
|
102
|
-
end
|
103
|
-
|
104
|
-
let :file do
|
105
|
-
require 'stringio'
|
106
|
-
StringIO.new(file_content).tap do |str|
|
107
|
-
def str.path
|
108
|
-
"fake_file.txt"
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
let! :web_configure do
|
114
|
-
LogicalConstruct::GroundControl::Provision::WebConfigure.new(:web_configure) do |task|
|
115
|
-
task.target_address = "127.0.0.1"
|
116
|
-
task.resolutions["file_target"] = proc{ file }
|
117
|
-
task.resolutions["string_target"] = string_content
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
before :each do
|
122
|
-
rake[:web_configure].invoke
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should complete resolver thread" do
|
126
|
-
expect do
|
127
|
-
begin
|
128
|
-
Timeout::timeout(10) do
|
129
|
-
Process.wait(resolver_process)
|
130
|
-
end
|
131
|
-
rescue Object => ex
|
132
|
-
resolver_buffer << resolver.read_nonblock(10000) rescue ""
|
133
|
-
p resolver_buffer
|
134
|
-
raise
|
135
|
-
end
|
136
|
-
end.not_to raise_error
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should produce the file" do
|
140
|
-
File::read(file_target_path).should == file_content
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should produce the string" do
|
144
|
-
File::read(string_target_path).should == string_content
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
data/spec/target/chef-config.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'logical-construct/target/platforms'
|
2
|
-
require 'mattock/testing/rake-example-group'
|
3
|
-
require 'mattock/testing/mock-command-line'
|
4
|
-
|
5
|
-
describe LogicalConstruct::VirtualBox::ChefConfig do
|
6
|
-
include Mattock::RakeExampleGroup
|
7
|
-
include Mattock::CommandLineExampleGroup
|
8
|
-
include FileSandbox
|
9
|
-
|
10
|
-
before :each do
|
11
|
-
sandbox.new :directory => "construct-dir"
|
12
|
-
sandbox.new :directory => "chef-dir"
|
13
|
-
end
|
14
|
-
|
15
|
-
let :provision do
|
16
|
-
require 'logical-construct/target/provision'
|
17
|
-
LogicalConstruct::Provision.new do |prov|
|
18
|
-
prov.construct_dir = "construct-dir"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
let :resolution do
|
23
|
-
require 'logical-construct/testing/resolve-configuration'
|
24
|
-
LogicalConstruct::Testing::ResolveConfiguration.new(provision) do |resolve|
|
25
|
-
resolve.resolutions = {
|
26
|
-
'chef_config:cookbook_tarball' => "",
|
27
|
-
'chef_config:json_attribs' => "",
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
let! :chef_config do
|
33
|
-
LogicalConstruct::VirtualBox::ChefConfig.new(provision, resolution) do |cc|
|
34
|
-
cc.file_cache_path = "chef-dir"
|
35
|
-
cc.solo_rb = "chef-solo.rb"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should make an absolute path for solo.rb" do
|
40
|
-
chef_config.solo_rb.should =~ /\A\//
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "invoked" do
|
44
|
-
before :each do
|
45
|
-
expect_command /tar/, 0
|
46
|
-
expect_command /tar/, 0
|
47
|
-
expect_command /tar/, 0
|
48
|
-
rake[File::join(sandbox["chef-dir"].path, "chef-solo.rb")].invoke
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should generate the chef-solo.rb file" do
|
52
|
-
sandbox["chef-dir/chef-solo.rb"].should be_exist
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "resulting config file" do
|
56
|
-
subject do
|
57
|
-
sandbox["chef-dir/chef-solo.rb"].contents
|
58
|
-
end
|
59
|
-
|
60
|
-
it{ should =~ %r{file_cache_path\s*(["']).*\1} }
|
61
|
-
it{ should =~ %r{cookbook_path\s*(["']).*/cookbooks\1} }
|
62
|
-
it{ should =~ %r{json_attribs\s*(["']).*/node.json\1} }
|
63
|
-
it{ should_not =~ /role_path/ }
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
data/spec/target/chef-solo.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'logical-construct/target/chef-solo'
|
2
|
-
require 'logical-construct/target/platforms'
|
3
|
-
require 'mattock/testing/rake-example-group'
|
4
|
-
require 'mattock/testing/mock-command-line'
|
5
|
-
|
6
|
-
describe LogicalConstruct::ChefSolo do
|
7
|
-
include Mattock::RakeExampleGroup
|
8
|
-
include FileSandbox
|
9
|
-
|
10
|
-
let :provision do
|
11
|
-
require 'logical-construct/target/provision'
|
12
|
-
LogicalConstruct::Provision.new
|
13
|
-
end
|
14
|
-
|
15
|
-
let :resolver do
|
16
|
-
require 'logical-construct/testing/resolve-configuration'
|
17
|
-
LogicalConstruct::Testing::ResolveConfiguration.new(provision) do |resolve|
|
18
|
-
resolve.resolutions = {
|
19
|
-
'chef_config:cookbook_tarball' => '',
|
20
|
-
'chef_config:json_attribs' => '',
|
21
|
-
}
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
let! :chef_config do
|
26
|
-
LogicalConstruct::VirtualBox::ChefConfig.new(provision, resolver) do |cc|
|
27
|
-
cc.file_cache_path = "chef-dir"
|
28
|
-
cc.solo_rb = "chef-solo.rb"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
let! :chef_solo do
|
33
|
-
LogicalConstruct::ChefSolo.new(chef_config)
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "invoked" do
|
37
|
-
include Mattock::CommandLineExampleGroup
|
38
|
-
|
39
|
-
it "should have the bundle path in the PATH" do
|
40
|
-
expect_some_commands
|
41
|
-
rake["chef_solo:run"].invoke
|
42
|
-
ENV['PATH'].should =~ %r{/var/logical-construct/bin}
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should run chef-solo" do
|
46
|
-
Rake.verbose(true)
|
47
|
-
expect_command /tar/, 0
|
48
|
-
expect_command /tar/, 0
|
49
|
-
expect_command /tar/, 0
|
50
|
-
expect_command /chef-solo/, 0
|
51
|
-
|
52
|
-
rake["chef_solo:run"].invoke
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/spec/target/platforms.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'logical-construct/target/platforms'
|
2
|
-
|
3
|
-
describe LogicalConstruct do
|
4
|
-
after :each do
|
5
|
-
ENV['LOGCON_DEPLOYMENT_PLATFORM'] = nil
|
6
|
-
$DEPLOYMENT_PLATFORM = nil
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "Platform()" do
|
10
|
-
it "should fail for unset plaform" do
|
11
|
-
expect do
|
12
|
-
LogicalConstruct::Platform()
|
13
|
-
end.to raise_error(KeyError)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should succeed for ENV VirtualBox" do
|
17
|
-
ENV['LOGCON_DEPLOYMENT_PLATFORM'] = 'VirtualBox'
|
18
|
-
LogicalConstruct::Platform().should == LogicalConstruct::VirtualBox
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should succeed for global VirtualBox" do
|
22
|
-
$DEPLOYMENT_PLATFORM = 'VirtualBox'
|
23
|
-
LogicalConstruct::Platform().should == LogicalConstruct::VirtualBox
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "including VirtualBox" do
|
28
|
-
before :each do
|
29
|
-
ENV['LOGCON_DEPLOYMENT_PLATFORM'] = 'VirtualBox'
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should make ChefConfig available" do
|
33
|
-
LogicalConstruct::Platform()::ChefConfig.should == ::LogicalConstruct::VirtualBox::ChefConfig
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/spec/target/smoke-test.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'logical-construct/target'
|
2
|
-
|
3
|
-
|
4
|
-
module TestAWS
|
5
|
-
include LogicalConstruct
|
6
|
-
include LogicalConstruct::Platform("AWS")
|
7
|
-
|
8
|
-
describe "VirtualBox platform" do
|
9
|
-
before :each do
|
10
|
-
provision = Provision.new
|
11
|
-
|
12
|
-
provision.in_namespace do
|
13
|
-
resolution = ResolveConfiguration.new(provision)
|
14
|
-
chef_config = ChefConfig.new(provision, resolution)
|
15
|
-
chef_solo = ChefSolo.new(chef_config)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should not crash" do
|
20
|
-
true.should be_true
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
module TestVirtualBox
|
26
|
-
include LogicalConstruct
|
27
|
-
include LogicalConstruct::Platform("VirtualBox")
|
28
|
-
|
29
|
-
describe "VirtualBox platform" do
|
30
|
-
before :each do
|
31
|
-
provision = Provision.new
|
32
|
-
|
33
|
-
provision.in_namespace do
|
34
|
-
resolution = ResolveConfiguration.new(provision)
|
35
|
-
chef_config = ChefConfig.new(provision, resolution)
|
36
|
-
chef_solo = ChefSolo.new(chef_config)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should not crash" do
|
41
|
-
true.should be_true
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
data/spec_help/ungemmer.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
class Ungemmer
|
2
|
-
def self.ungem(*names)
|
3
|
-
deps = names.map do |name|
|
4
|
-
Gem::Dependency.new(name, nil)
|
5
|
-
end
|
6
|
-
|
7
|
-
deps.each do |dep|
|
8
|
-
Gem.source_index.search(dep).each do |gemspec|
|
9
|
-
puts " ** Ungemming #{gemspec.full_name} **"
|
10
|
-
Gem.source_index.remove_spec(gemspec.full_name)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
Gem.instance_eval do
|
15
|
-
if defined? Gem::MUTEX
|
16
|
-
Gem::MUTEX.synchronize do
|
17
|
-
@searcher = nil
|
18
|
-
end
|
19
|
-
else
|
20
|
-
@searcher = nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.ungem_gemspec
|
26
|
-
Dir[File::expand_path(__FILE__ + "../../../*.gemspec")].each do |gemspec_path|
|
27
|
-
puts "Ungemming based on #{gemspec_path}"
|
28
|
-
begin
|
29
|
-
spec = Gem::Specification::load(gemspec_path)
|
30
|
-
Ungemmer::ungem(spec)
|
31
|
-
rescue LoadError
|
32
|
-
puts "Couldn't load #{gemspec_path}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|