corl 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitmodules +4 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +123 -0
- data/LICENSE.txt +674 -0
- data/README.rdoc +27 -0
- data/Rakefile +78 -0
- data/VERSION +1 -0
- data/bin/corl +55 -0
- data/corl.gemspec +228 -0
- data/lib/corl/action/add.rb +69 -0
- data/lib/corl/action/bootstrap.rb +83 -0
- data/lib/corl/action/clone.rb +40 -0
- data/lib/corl/action/create.rb +55 -0
- data/lib/corl/action/exec.rb +41 -0
- data/lib/corl/action/extract.rb +49 -0
- data/lib/corl/action/image.rb +30 -0
- data/lib/corl/action/images.rb +55 -0
- data/lib/corl/action/lookup.rb +35 -0
- data/lib/corl/action/machines.rb +51 -0
- data/lib/corl/action/provision.rb +37 -0
- data/lib/corl/action/remove.rb +51 -0
- data/lib/corl/action/save.rb +53 -0
- data/lib/corl/action/seed.rb +115 -0
- data/lib/corl/action/spawn.rb +75 -0
- data/lib/corl/action/start.rb +37 -0
- data/lib/corl/action/stop.rb +30 -0
- data/lib/corl/action/update.rb +37 -0
- data/lib/corl/command/shell.rb +164 -0
- data/lib/corl/configuration/file.rb +386 -0
- data/lib/corl/event/puppet.rb +90 -0
- data/lib/corl/event/regex.rb +52 -0
- data/lib/corl/extension/puppetloader.rb +24 -0
- data/lib/corl/machine/fog.rb +310 -0
- data/lib/corl/machine/physical.rb +161 -0
- data/lib/corl/network/default.rb +26 -0
- data/lib/corl/node/aws.rb +90 -0
- data/lib/corl/node/fog.rb +198 -0
- data/lib/corl/node/google.rb +115 -0
- data/lib/corl/node/local.rb +26 -0
- data/lib/corl/node/rackspace.rb +89 -0
- data/lib/corl/project/git.rb +465 -0
- data/lib/corl/project/github.rb +108 -0
- data/lib/corl/provisioner/puppetnode/resource.rb +245 -0
- data/lib/corl/provisioner/puppetnode/resource_group.rb +205 -0
- data/lib/corl/provisioner/puppetnode.rb +407 -0
- data/lib/corl/template/environment.rb +73 -0
- data/lib/corl/template/json.rb +16 -0
- data/lib/corl/template/wrapper.rb +16 -0
- data/lib/corl/template/yaml.rb +16 -0
- data/lib/corl/translator/json.rb +27 -0
- data/lib/corl/translator/yaml.rb +27 -0
- data/lib/corl.rb +173 -0
- data/lib/corl_core/codes.rb +107 -0
- data/lib/corl_core/config/collection.rb +57 -0
- data/lib/corl_core/config/options.rb +70 -0
- data/lib/corl_core/config.rb +337 -0
- data/lib/corl_core/core.rb +59 -0
- data/lib/corl_core/corl.rb +254 -0
- data/lib/corl_core/errors.rb +84 -0
- data/lib/corl_core/facade.rb +126 -0
- data/lib/corl_core/gems.rb +72 -0
- data/lib/corl_core/manager.rb +425 -0
- data/lib/corl_core/mixin/action/commit.rb +58 -0
- data/lib/corl_core/mixin/action/keypair.rb +105 -0
- data/lib/corl_core/mixin/action/node.rb +129 -0
- data/lib/corl_core/mixin/action/project.rb +53 -0
- data/lib/corl_core/mixin/action/push.rb +52 -0
- data/lib/corl_core/mixin/config/collection.rb +53 -0
- data/lib/corl_core/mixin/config/ops.rb +53 -0
- data/lib/corl_core/mixin/config/options.rb +39 -0
- data/lib/corl_core/mixin/lookup.rb +196 -0
- data/lib/corl_core/mixin/macro/object_interface.rb +361 -0
- data/lib/corl_core/mixin/macro/plugin_interface.rb +380 -0
- data/lib/corl_core/mixin/settings.rb +46 -0
- data/lib/corl_core/mixin/sub_config.rb +148 -0
- data/lib/corl_core/mod/hash.rb +29 -0
- data/lib/corl_core/mod/hiera_backend.rb +63 -0
- data/lib/corl_core/plugin/action.rb +381 -0
- data/lib/corl_core/plugin/base.rb +374 -0
- data/lib/corl_core/plugin/command.rb +98 -0
- data/lib/corl_core/plugin/configuration.rb +177 -0
- data/lib/corl_core/plugin/event.rb +53 -0
- data/lib/corl_core/plugin/extension.rb +12 -0
- data/lib/corl_core/plugin/machine.rb +266 -0
- data/lib/corl_core/plugin/network.rb +359 -0
- data/lib/corl_core/plugin/node.rb +904 -0
- data/lib/corl_core/plugin/project.rb +927 -0
- data/lib/corl_core/plugin/provisioner.rb +51 -0
- data/lib/corl_core/plugin/template.rb +80 -0
- data/lib/corl_core/plugin/translator.rb +38 -0
- data/lib/corl_core/util/cli.rb +352 -0
- data/lib/corl_core/util/data.rb +404 -0
- data/lib/corl_core/util/disk.rb +114 -0
- data/lib/corl_core/util/git.rb +47 -0
- data/lib/corl_core/util/interface.rb +319 -0
- data/lib/corl_core/util/liquid.rb +17 -0
- data/lib/corl_core/util/package.rb +93 -0
- data/lib/corl_core/util/shell.rb +239 -0
- data/lib/corl_core/util/ssh.rb +286 -0
- data/lib/facter/corl_config_ready.rb +13 -0
- data/lib/facter/corl_exists.rb +15 -0
- data/lib/facter/corl_network.rb +17 -0
- data/lib/hiera/corl_logger.rb +18 -0
- data/lib/puppet/indirector/corl.rb +27 -0
- data/lib/puppet/indirector/data_binding/corl.rb +6 -0
- data/lib/puppet/parser/functions/config_initialized.rb +26 -0
- data/lib/puppet/parser/functions/corl_include.rb +44 -0
- data/lib/puppet/parser/functions/corl_resources.rb +58 -0
- data/lib/puppet/parser/functions/deep_merge.rb +21 -0
- data/lib/puppet/parser/functions/ensure.rb +29 -0
- data/lib/puppet/parser/functions/file_exists.rb +19 -0
- data/lib/puppet/parser/functions/global_array.rb +35 -0
- data/lib/puppet/parser/functions/global_hash.rb +35 -0
- data/lib/puppet/parser/functions/global_options.rb +23 -0
- data/lib/puppet/parser/functions/global_param.rb +43 -0
- data/lib/puppet/parser/functions/interpolate.rb +26 -0
- data/lib/puppet/parser/functions/is_false.rb +21 -0
- data/lib/puppet/parser/functions/is_true.rb +21 -0
- data/lib/puppet/parser/functions/module_array.rb +38 -0
- data/lib/puppet/parser/functions/module_hash.rb +38 -0
- data/lib/puppet/parser/functions/module_options.rb +23 -0
- data/lib/puppet/parser/functions/module_param.rb +48 -0
- data/lib/puppet/parser/functions/name.rb +21 -0
- data/lib/puppet/parser/functions/render.rb +33 -0
- data/lib/puppet/parser/functions/value.rb +21 -0
- data/locales/en.yml +232 -0
- data/spec/corl_core/interface_spec.rb +489 -0
- data/spec/corl_mock_input.rb +29 -0
- data/spec/corl_test_kernel.rb +22 -0
- data/spec/spec_helper.rb +15 -0
- metadata +406 -0
@@ -0,0 +1,198 @@
|
|
1
|
+
|
2
|
+
module CORL
|
3
|
+
module Node
|
4
|
+
class Fog < Plugin::Node
|
5
|
+
|
6
|
+
#-----------------------------------------------------------------------------
|
7
|
+
# Node plugin interface
|
8
|
+
|
9
|
+
def normalize
|
10
|
+
super
|
11
|
+
myself.region = region
|
12
|
+
|
13
|
+
yield if block_given?
|
14
|
+
myself.machine = create_machine(:machine, :fog, machine_config)
|
15
|
+
end
|
16
|
+
|
17
|
+
#-----------------------------------------------------------------------------
|
18
|
+
# Checks
|
19
|
+
|
20
|
+
#-----------------------------------------------------------------------------
|
21
|
+
# Property accessors / modifiers
|
22
|
+
|
23
|
+
def api_user=api_user
|
24
|
+
myself[:api_user] = api_user
|
25
|
+
end
|
26
|
+
|
27
|
+
def api_user
|
28
|
+
myself[:api_user]
|
29
|
+
end
|
30
|
+
|
31
|
+
#---
|
32
|
+
|
33
|
+
def api_key=api_key
|
34
|
+
myself[:api_key] = api_key
|
35
|
+
end
|
36
|
+
|
37
|
+
def api_key
|
38
|
+
myself[:api_key]
|
39
|
+
end
|
40
|
+
|
41
|
+
#---
|
42
|
+
|
43
|
+
def auth_url=auth_url
|
44
|
+
myself[:auth_url] = auth_url
|
45
|
+
end
|
46
|
+
|
47
|
+
def auth_url
|
48
|
+
myself[:auth_url]
|
49
|
+
end
|
50
|
+
|
51
|
+
#---
|
52
|
+
|
53
|
+
def connection_options=options
|
54
|
+
myself[:connection_options] = options
|
55
|
+
end
|
56
|
+
|
57
|
+
def connection_options
|
58
|
+
myself[:connection_options]
|
59
|
+
end
|
60
|
+
|
61
|
+
#---
|
62
|
+
|
63
|
+
def regions
|
64
|
+
[]
|
65
|
+
end
|
66
|
+
|
67
|
+
def region=region
|
68
|
+
myself[:region] = region
|
69
|
+
end
|
70
|
+
|
71
|
+
def region
|
72
|
+
if region = myself[:region]
|
73
|
+
region
|
74
|
+
else
|
75
|
+
first_region = regions.first
|
76
|
+
myself.region = first_region
|
77
|
+
first_region
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
#-----------------------------------------------------------------------------
|
82
|
+
# Settings groups
|
83
|
+
|
84
|
+
def machine_config
|
85
|
+
super do |config|
|
86
|
+
config[:connection_options] = connection_options if connection_options
|
87
|
+
yield(config) if block_given?
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
#---
|
92
|
+
|
93
|
+
def exec_options(name, options = {})
|
94
|
+
extended_config(name, options).export
|
95
|
+
end
|
96
|
+
|
97
|
+
#-----------------------------------------------------------------------------
|
98
|
+
# Node operations
|
99
|
+
|
100
|
+
def create(options = {})
|
101
|
+
super do |op, config|
|
102
|
+
if op == :config
|
103
|
+
config.import(exec_options(:create))
|
104
|
+
end
|
105
|
+
yield(op, config) if block_given?
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
#---
|
110
|
+
|
111
|
+
def download(remote_path, local_path, options = {})
|
112
|
+
super do |op, config|
|
113
|
+
if op == :config
|
114
|
+
config.import(exec_options(:download))
|
115
|
+
end
|
116
|
+
yield(op, config) if block_given?
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
#---
|
121
|
+
|
122
|
+
def upload(local_path, remote_path, options = {})
|
123
|
+
super do |op, config|
|
124
|
+
if op == :config
|
125
|
+
config.import(exec_options(:upload))
|
126
|
+
end
|
127
|
+
yield(op, config) if block_given?
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
#---
|
132
|
+
|
133
|
+
def exec(options = {})
|
134
|
+
super do |op, config|
|
135
|
+
if op == :config
|
136
|
+
config.import(exec_options(:exec))
|
137
|
+
end
|
138
|
+
yield(op, config) if block_given?
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
#---
|
143
|
+
|
144
|
+
def start(options = {})
|
145
|
+
super do |op, config|
|
146
|
+
if op == :config
|
147
|
+
config.import(exec_options(:start))
|
148
|
+
end
|
149
|
+
yield(op, config) if block_given?
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
#---
|
154
|
+
|
155
|
+
def reload(options = {})
|
156
|
+
super do |op, config|
|
157
|
+
if op == :config
|
158
|
+
config.import(exec_options(:reload))
|
159
|
+
end
|
160
|
+
yield(op, config) if block_given?
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
#---
|
165
|
+
|
166
|
+
def create_image(options = {})
|
167
|
+
super do |op, config|
|
168
|
+
if op == :config
|
169
|
+
config.import(exec_options(:image))
|
170
|
+
end
|
171
|
+
yield(op, config) if block_given?
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
#---
|
176
|
+
|
177
|
+
def stop(options = {})
|
178
|
+
super do |op, config|
|
179
|
+
if op == :config
|
180
|
+
config.import(exec_options(:stop))
|
181
|
+
end
|
182
|
+
yield(op, config) if block_given?
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
#---
|
187
|
+
|
188
|
+
def destroy(options = {})
|
189
|
+
super do |op, config|
|
190
|
+
if op == :config
|
191
|
+
config.import(exec_options(:destroy))
|
192
|
+
end
|
193
|
+
yield(op, config) if block_given?
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
|
2
|
+
corl_require(File.dirname(__FILE__), :fog)
|
3
|
+
|
4
|
+
#---
|
5
|
+
|
6
|
+
module CORL
|
7
|
+
module Node
|
8
|
+
class Google < Node::Fog
|
9
|
+
|
10
|
+
#-----------------------------------------------------------------------------
|
11
|
+
# Node plugin interface
|
12
|
+
|
13
|
+
#-----------------------------------------------------------------------------
|
14
|
+
# Checks
|
15
|
+
|
16
|
+
def usable_image?(image)
|
17
|
+
image.status == 'READY' && ! image.description.match(/DEPRECATED/i)
|
18
|
+
end
|
19
|
+
|
20
|
+
#-----------------------------------------------------------------------------
|
21
|
+
# Property accessors / modifiers
|
22
|
+
|
23
|
+
def project_name=project_name
|
24
|
+
myself[:project_name] = project_name
|
25
|
+
end
|
26
|
+
|
27
|
+
def project_name
|
28
|
+
myself[:project_name]
|
29
|
+
end
|
30
|
+
|
31
|
+
#---
|
32
|
+
|
33
|
+
def regions
|
34
|
+
[
|
35
|
+
'us-central1-a',
|
36
|
+
'us-central1-b',
|
37
|
+
'europe-west1-a',
|
38
|
+
'europe-west1-b'
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
#-----------------------------------------------------------------------------
|
43
|
+
# Settings groups
|
44
|
+
|
45
|
+
def machine_config
|
46
|
+
super do |config|
|
47
|
+
config.import({
|
48
|
+
:provider => 'google'
|
49
|
+
})
|
50
|
+
|
51
|
+
config[:google_project] = project_name if project_name
|
52
|
+
config[:google_client_email] = api_user if api_user
|
53
|
+
config[:google_key_location] = api_key if api_key
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
#-----------------------------------------------------------------------------
|
58
|
+
# Node operations
|
59
|
+
|
60
|
+
def create(options = {})
|
61
|
+
super do |op, config|
|
62
|
+
if op == :config
|
63
|
+
config[:private_key_path] = private_key if private_key
|
64
|
+
config[:public_key_path] = public_key if public_key
|
65
|
+
|
66
|
+
config.defaults({
|
67
|
+
:name => hostname,
|
68
|
+
:machine_type => machine_type,
|
69
|
+
:image_name => image
|
70
|
+
})
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
#-----------------------------------------------------------------------------
|
76
|
+
# Utilities
|
77
|
+
|
78
|
+
def machine_type_id(machine_type)
|
79
|
+
machine_type.name
|
80
|
+
end
|
81
|
+
|
82
|
+
#---
|
83
|
+
|
84
|
+
def render_machine_type(machine_type)
|
85
|
+
sprintf("[ %20s ][ VCPUS: %2i ] %-55s ( RAM: %6iMB | DISK: %3iGB ) ( MAX DISKS: %2i | MAX STORAGE: %6iGB )",
|
86
|
+
machine_type_id(machine_type),
|
87
|
+
machine_type.guest_cpus,
|
88
|
+
machine_type.description,
|
89
|
+
machine_type.memory_mb,
|
90
|
+
machine_type.image_space_gb,
|
91
|
+
machine_type.maximum_persistent_disks,
|
92
|
+
machine_type.maximum_persistent_disks_size
|
93
|
+
)
|
94
|
+
end
|
95
|
+
|
96
|
+
#---
|
97
|
+
|
98
|
+
def image_id(image)
|
99
|
+
image.name
|
100
|
+
end
|
101
|
+
|
102
|
+
#---
|
103
|
+
|
104
|
+
def render_image(image)
|
105
|
+
sprintf("[ %40s ][ %10s ] %s - %s", image_id(image), image.status, image.description, image.project)
|
106
|
+
end
|
107
|
+
|
108
|
+
#---
|
109
|
+
|
110
|
+
def image_search_text(image)
|
111
|
+
sprintf("%s %s %s %s", image.name, image.description, image.status, image.project)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
module CORL
|
3
|
+
module Node
|
4
|
+
class Local < Plugin::Node
|
5
|
+
|
6
|
+
#-----------------------------------------------------------------------------
|
7
|
+
# Node plugin interface
|
8
|
+
|
9
|
+
def normalize
|
10
|
+
super
|
11
|
+
myself.machine = create_machine(:machine, :physical, machine_config)
|
12
|
+
end
|
13
|
+
|
14
|
+
#-----------------------------------------------------------------------------
|
15
|
+
# Checks
|
16
|
+
|
17
|
+
def local?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
#-----------------------------------------------------------------------------
|
22
|
+
# Property accessors / modifiers
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
|
2
|
+
corl_require(File.dirname(__FILE__), :fog)
|
3
|
+
|
4
|
+
#---
|
5
|
+
|
6
|
+
module CORL
|
7
|
+
module Node
|
8
|
+
class Rackspace < Node::Fog
|
9
|
+
|
10
|
+
#-----------------------------------------------------------------------------
|
11
|
+
# Node plugin interface
|
12
|
+
|
13
|
+
#-----------------------------------------------------------------------------
|
14
|
+
# Checks
|
15
|
+
|
16
|
+
def usable_image?(image)
|
17
|
+
image.state != 'DELETED'
|
18
|
+
end
|
19
|
+
|
20
|
+
#-----------------------------------------------------------------------------
|
21
|
+
# Property accessors / modifiers
|
22
|
+
|
23
|
+
def regions
|
24
|
+
[
|
25
|
+
:dfw, # Dallas
|
26
|
+
:ord, # Chicago
|
27
|
+
:lon # London (for UK accounts)
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
#-----------------------------------------------------------------------------
|
32
|
+
# Settings groups
|
33
|
+
|
34
|
+
def machine_config
|
35
|
+
super do |config|
|
36
|
+
config.import({
|
37
|
+
:provider => 'rackspace',
|
38
|
+
:version => :v2,
|
39
|
+
:rackspace_region => region
|
40
|
+
})
|
41
|
+
|
42
|
+
config[:rackspace_username] = api_user if api_user
|
43
|
+
config[:rackspace_api_key] = api_key if api_key
|
44
|
+
config[:rackspace_auth_url] = auth_url if auth_url
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
#-----------------------------------------------------------------------------
|
49
|
+
# Node operations
|
50
|
+
|
51
|
+
def create(options = {})
|
52
|
+
super do |op, config|
|
53
|
+
if op == :config
|
54
|
+
config.defaults({
|
55
|
+
:name => hostname,
|
56
|
+
:flavor_id => machine_type,
|
57
|
+
:image_id => image
|
58
|
+
})
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
#-----------------------------------------------------------------------------
|
64
|
+
# Utilities
|
65
|
+
|
66
|
+
def render_machine_type(machine_type)
|
67
|
+
sprintf("[ %20s ][ VCPUS: %2i ] %-30s ( RAM: %6iMB | DISK: %4iGB )",
|
68
|
+
machine_type_id(machine_type),
|
69
|
+
machine_type.vcpus,
|
70
|
+
machine_type.name,
|
71
|
+
machine_type.ram,
|
72
|
+
machine_type.disk
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
#---
|
77
|
+
|
78
|
+
def render_image(image)
|
79
|
+
sprintf("[ %40s ][ %10s ] %s", image_id(image), image.state, image.name)
|
80
|
+
end
|
81
|
+
|
82
|
+
#---
|
83
|
+
|
84
|
+
def image_search_text(image)
|
85
|
+
sprintf("%s %s %s", image_id(image), image.name, image.state)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|