cm 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/cm +1 -1
- data/cm.gemspec +21 -3
- data/lib/CM/batch/celluloid.rb +38 -0
- data/lib/CM/configuration/directory.rb +70 -0
- data/lib/CM/configuration/file.rb +56 -0
- data/lib/CM/job/AWS.rb +32 -0
- data/lib/CM/job/BOSH.rb +32 -0
- data/lib/CM/job/concourse.rb +32 -0
- data/lib/CM/job/keypair.rb +32 -0
- data/lib/CM/job/variables.rb +32 -0
- data/lib/CM/plan/default.rb +28 -0
- data/lib/CM/sequence/default.rb +48 -0
- data/lib/cm.rb +17 -1
- data/lib/core/facade.rb +60 -0
- data/lib/core/mixin/action/config.rb +63 -0
- data/lib/core/mixin/action/registration.rb +131 -0
- data/lib/core/plugin/batch.rb +95 -0
- data/lib/core/plugin/cm_action.rb +4 -6
- data/lib/core/plugin/configuration.rb +88 -0
- data/lib/core/plugin/disk_configuration.rb +86 -0
- data/lib/core/plugin/job.rb +46 -0
- data/lib/core/plugin/parallel_base.rb +34 -0
- data/lib/core/plugin/plan.rb +193 -0
- data/lib/core/plugin/plan_action.rb +44 -4
- data/lib/core/plugin/sequence.rb +107 -0
- data/lib/nucleon/action/plan/deploy.rb +6 -3
- data/lib/nucleon/action/plan/destroy.rb +6 -3
- data/locales/en.yml +46 -0
- metadata +20 -2
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
module CM
|
3
|
+
module Sequence
|
4
|
+
class Default < Nucleon.plugin_class(:CM, :sequence)
|
5
|
+
|
6
|
+
#-----------------------------------------------------------------------------
|
7
|
+
# Plugin interface
|
8
|
+
|
9
|
+
def normalize(reload)
|
10
|
+
super
|
11
|
+
yield if block_given?
|
12
|
+
end
|
13
|
+
|
14
|
+
#-----------------------------------------------------------------------------
|
15
|
+
# Checks
|
16
|
+
|
17
|
+
#-----------------------------------------------------------------------------
|
18
|
+
# Property accessors / modifiers
|
19
|
+
|
20
|
+
#-----------------------------------------------------------------------------
|
21
|
+
# Operations
|
22
|
+
|
23
|
+
def forward(options)
|
24
|
+
super do |config, success|
|
25
|
+
jobs.each do |job|
|
26
|
+
success = false unless job.execute(settings)
|
27
|
+
end
|
28
|
+
success
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
#---
|
33
|
+
|
34
|
+
def reverse(options)
|
35
|
+
super do |config, success|
|
36
|
+
jobs.reverse.each do |job|
|
37
|
+
success = false unless job.execute(settings)
|
38
|
+
end
|
39
|
+
success
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
#-----------------------------------------------------------------------------
|
44
|
+
# Utilities
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/cm.rb
CHANGED
@@ -72,6 +72,13 @@ nucleon_require(core_dir, :errors)
|
|
72
72
|
# Include facade
|
73
73
|
nucleon_require(core_dir, :facade)
|
74
74
|
|
75
|
+
#
|
76
|
+
# CM::Facade extends CM
|
77
|
+
#
|
78
|
+
module CM
|
79
|
+
extend Facade
|
80
|
+
end
|
81
|
+
|
75
82
|
# Include CM core plugins
|
76
83
|
nucleon_require(core_dir, :plugin)
|
77
84
|
|
@@ -96,7 +103,11 @@ module CM
|
|
96
103
|
Nucleon.reload(true, :cm) do |op, manager|
|
97
104
|
if op == :define
|
98
105
|
manager.define_types :CM, {
|
99
|
-
|
106
|
+
:plan => :default, # Execution plan
|
107
|
+
:configuration => :file, # Component and manifest storage
|
108
|
+
:sequence => :default, # Event sequence
|
109
|
+
:batch => :celluloid,# Batch processor
|
110
|
+
:job => :variables # Individual job
|
100
111
|
}
|
101
112
|
end
|
102
113
|
end
|
@@ -106,3 +117,8 @@ end
|
|
106
117
|
# Load CM action overrides
|
107
118
|
|
108
119
|
nucleon_require(core_dir, :overrides)
|
120
|
+
|
121
|
+
#
|
122
|
+
# Temporarily set dump_enabled by default during initial development
|
123
|
+
#
|
124
|
+
Nucleon.dump_enabled=true
|
data/lib/core/facade.rb
CHANGED
@@ -2,5 +2,65 @@
|
|
2
2
|
module CM
|
3
3
|
module Facade
|
4
4
|
|
5
|
+
#-----------------------------------------------------------------------------
|
6
|
+
# Configuration settings
|
7
|
+
|
8
|
+
def config_path
|
9
|
+
ENV['CM_CONFIG_PATH'] || '/etc/cm'
|
10
|
+
end
|
11
|
+
|
12
|
+
#-----------------------------------------------------------------------------
|
13
|
+
# Core plugin type facade
|
14
|
+
|
15
|
+
def plan(name, options = {}, provider = nil)
|
16
|
+
Nucleon.plugin(:CM, :plan, provider, Nucleon::Config.ensure(options).import({ :name => name }))
|
17
|
+
end
|
18
|
+
|
19
|
+
def plans(data, build_hash = false, keep_array = false)
|
20
|
+
Nucleon.plugins(:CM, :plan, data, build_hash, keep_array)
|
21
|
+
end
|
22
|
+
|
23
|
+
#---
|
24
|
+
|
25
|
+
def configuration(options, provider = nil)
|
26
|
+
Nucleon.plugin(:CM, :configuration, provider, options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def configurations(data, build_hash = false, keep_array = false)
|
30
|
+
Nucleon.plugins(:CM, :configuration, data, build_hash, keep_array)
|
31
|
+
end
|
32
|
+
|
33
|
+
#-----------------------------------------------------------------------------
|
34
|
+
# Processor plugin type facade
|
35
|
+
|
36
|
+
#---
|
37
|
+
|
38
|
+
def sequence(options = {}, provider = nil)
|
39
|
+
Nucleon.plugin(:CM, :sequence, provider, options)
|
40
|
+
end
|
41
|
+
|
42
|
+
def sequences(data, build_hash = false, keep_array = false)
|
43
|
+
Nucleon.plugins(:CM, :sequence, data, build_hash, keep_array)
|
44
|
+
end
|
45
|
+
|
46
|
+
#---
|
47
|
+
|
48
|
+
def batch(options, provider = nil)
|
49
|
+
Nucleon.plugin(:CM, :batch, provider, options)
|
50
|
+
end
|
51
|
+
|
52
|
+
def batches(data, build_hash = false, keep_array = false)
|
53
|
+
Nucleon.plugins(:CM, :batch, data, build_hash, keep_array)
|
54
|
+
end
|
55
|
+
|
56
|
+
#---
|
57
|
+
|
58
|
+
def job(options, provider = nil)
|
59
|
+
Nucleon.plugin(:CM, :job, provider, options)
|
60
|
+
end
|
61
|
+
|
62
|
+
def jobs(data, build_hash = false, keep_array = false)
|
63
|
+
Nucleon.plugins(:CM, :job, data, build_hash, keep_array)
|
64
|
+
end
|
5
65
|
end
|
6
66
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
|
2
|
+
module Nucleon
|
3
|
+
module Mixin
|
4
|
+
module Action
|
5
|
+
module Config
|
6
|
+
|
7
|
+
#-----------------------------------------------------------------------------
|
8
|
+
# Settings
|
9
|
+
|
10
|
+
def config_config
|
11
|
+
register_str :settings_path, CM.config_path, 'nucleon.mixin.action.config.options.settings_path' do |value|
|
12
|
+
success = true
|
13
|
+
|
14
|
+
if value
|
15
|
+
path = File.expand_path(value)
|
16
|
+
|
17
|
+
if File.exist?(path)
|
18
|
+
success = false unless import_system_config(path)
|
19
|
+
else
|
20
|
+
warn('nucleon.mixin.action.config.errors.settings_path', { :path => path })
|
21
|
+
success = false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
success
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#---
|
29
|
+
|
30
|
+
def config_ignore
|
31
|
+
[ :settings_path ]
|
32
|
+
end
|
33
|
+
|
34
|
+
#-----------------------------------------------------------------------------
|
35
|
+
# Properties
|
36
|
+
|
37
|
+
#-----------------------------------------------------------------------------
|
38
|
+
# Utilities
|
39
|
+
|
40
|
+
def import_system_config(path)
|
41
|
+
config_provider = (File.directory?(path) ? :directory : :file)
|
42
|
+
system_config = CM.configuration(extended_config(:system_config, {
|
43
|
+
:path => path,
|
44
|
+
:translator_error => 'nucleon.mixin.action.config.errors.translator',
|
45
|
+
:config_error => 'nucleon.mixin.action.config.errors.config_file'
|
46
|
+
}), config_provider).export
|
47
|
+
|
48
|
+
unless system_config.nil?
|
49
|
+
# Values are already set from parameters and validation is just starting
|
50
|
+
system_config.each do |key, value|
|
51
|
+
# TODO: Some error handling here if config key doesn't exist
|
52
|
+
# For instance, if extra properties in config file
|
53
|
+
if !config.has_key?(key) || settings[key] == config[key].default
|
54
|
+
settings[key] = value
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
system_config.nil? ? false : true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
|
2
|
+
module Nucleon
|
3
|
+
module Mixin
|
4
|
+
module Action
|
5
|
+
module Registration
|
6
|
+
|
7
|
+
#-----------------------------------------------------------------------------
|
8
|
+
# Registration definitions
|
9
|
+
|
10
|
+
def register_plan_provider(name, default = nil, locale = nil, &code)
|
11
|
+
register_plugin_provider(:CM, :plan, name.to_sym, default, locale, &code)
|
12
|
+
end
|
13
|
+
|
14
|
+
#---
|
15
|
+
|
16
|
+
def register_plan_providers(name, default = nil, locale = nil, &code)
|
17
|
+
register_plugin_providers(:CM, :plan, name.to_sym, default, locale, &code)
|
18
|
+
end
|
19
|
+
|
20
|
+
#---
|
21
|
+
|
22
|
+
def register_plan(name, default = nil, locale = nil, &code)
|
23
|
+
register_plugin(:CM, :plan, name.to_sym, default, locale, &code)
|
24
|
+
end
|
25
|
+
|
26
|
+
#---
|
27
|
+
|
28
|
+
def register_plans(name, default = nil, locale = nil, &code)
|
29
|
+
register_plugins(:CM, :plan, name.to_sym, default, locale, &code)
|
30
|
+
end
|
31
|
+
|
32
|
+
#---
|
33
|
+
|
34
|
+
def register_configuration_provider(name, default = nil, locale = nil, &code)
|
35
|
+
register_plugin_provider(:CM, :configuration, name.to_sym, default, locale, &code)
|
36
|
+
end
|
37
|
+
|
38
|
+
#---
|
39
|
+
|
40
|
+
def register_configuration_providers(name, default = nil, locale = nil, &code)
|
41
|
+
register_plugin_providers(:CM, :configuration, name.to_sym, default, locale, &code)
|
42
|
+
end
|
43
|
+
|
44
|
+
#---
|
45
|
+
|
46
|
+
def register_configuration(name, default = nil, locale = nil, &code)
|
47
|
+
register_plugin(:CM, :configuration, name.to_sym, default, locale, &code)
|
48
|
+
end
|
49
|
+
|
50
|
+
#---
|
51
|
+
|
52
|
+
def register_configurations(name, default = nil, locale = nil, &code)
|
53
|
+
register_plugins(:CM, :configuration, name.to_sym, default, locale, &code)
|
54
|
+
end
|
55
|
+
|
56
|
+
#---
|
57
|
+
|
58
|
+
def register_sequence_provider(name, default = nil, locale = nil, &code)
|
59
|
+
register_plugin_provider(:CM, :sequence, name.to_sym, default, locale, &code)
|
60
|
+
end
|
61
|
+
|
62
|
+
#---
|
63
|
+
|
64
|
+
def register_sequence_providers(name, default = nil, locale = nil, &code)
|
65
|
+
register_plugin_providers(:CM, :sequence, name.to_sym, default, locale, &code)
|
66
|
+
end
|
67
|
+
|
68
|
+
#---
|
69
|
+
|
70
|
+
def register_sequence(name, default = nil, locale = nil, &code)
|
71
|
+
register_plugin(:CM, :sequence, name.to_sym, default, locale, &code)
|
72
|
+
end
|
73
|
+
|
74
|
+
#---
|
75
|
+
|
76
|
+
def register_sequences(name, default = nil, locale = nil, &code)
|
77
|
+
register_plugins(:CM, :sequence, name.to_sym, default, locale, &code)
|
78
|
+
end
|
79
|
+
|
80
|
+
#---
|
81
|
+
|
82
|
+
def register_batch_provider(name, default = nil, locale = nil, &code)
|
83
|
+
register_plugin_provider(:CM, :batch, name.to_sym, default, locale, &code)
|
84
|
+
end
|
85
|
+
|
86
|
+
#---
|
87
|
+
|
88
|
+
def register_batch_providers(name, default = nil, locale = nil, &code)
|
89
|
+
register_plugin_providers(:CM, :batch, name.to_sym, default, locale, &code)
|
90
|
+
end
|
91
|
+
|
92
|
+
#---
|
93
|
+
|
94
|
+
def register_batch(name, default = nil, locale = nil, &code)
|
95
|
+
register_plugin(:CM, :batch, name.to_sym, default, locale, &code)
|
96
|
+
end
|
97
|
+
|
98
|
+
#---
|
99
|
+
|
100
|
+
def register_batches(name, default = nil, locale = nil, &code)
|
101
|
+
register_plugins(:CM, :batch, name.to_sym, default, locale, &code)
|
102
|
+
end
|
103
|
+
|
104
|
+
#---
|
105
|
+
|
106
|
+
def register_job_provider(name, default = nil, locale = nil, &code)
|
107
|
+
register_plugin_provider(:CM, :jobch, name.to_sym, default, locale, &code)
|
108
|
+
end
|
109
|
+
|
110
|
+
#---
|
111
|
+
|
112
|
+
def register_job_providers(name, default = nil, locale = nil, &code)
|
113
|
+
register_plugin_providers(:CM, :job, name.to_sym, default, locale, &code)
|
114
|
+
end
|
115
|
+
|
116
|
+
#---
|
117
|
+
|
118
|
+
def register_job(name, default = nil, locale = nil, &code)
|
119
|
+
register_plugin(:CM, :job, name.to_sym, default, locale, &code)
|
120
|
+
end
|
121
|
+
|
122
|
+
#---
|
123
|
+
|
124
|
+
def register_jobs(name, default = nil, locale = nil, &code)
|
125
|
+
register_plugins(:CM, :job, name.to_sym, default, locale, &code)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
|
2
|
+
nucleon_require(File.dirname(__FILE__), :parallel_base)
|
3
|
+
|
4
|
+
#---
|
5
|
+
|
6
|
+
module CM
|
7
|
+
module Plugin
|
8
|
+
class Batch < Nucleon.plugin_class(:nucleon, :parallel_base)
|
9
|
+
|
10
|
+
#-----------------------------------------------------------------------------
|
11
|
+
# Plugin interface
|
12
|
+
|
13
|
+
def normalize(reload)
|
14
|
+
super
|
15
|
+
|
16
|
+
@sequence = delete(:sequence, nil)
|
17
|
+
|
18
|
+
init_jobs
|
19
|
+
yield if block_given?
|
20
|
+
end
|
21
|
+
|
22
|
+
#---
|
23
|
+
|
24
|
+
def init_jobs
|
25
|
+
@jobs = []
|
26
|
+
get_array(:jobs).each do |job_config|
|
27
|
+
if job_config.has_key?(:sequence) # Array
|
28
|
+
@jobs << sequence.create_sequence(job_config[:sequence])
|
29
|
+
else # Atomic
|
30
|
+
@jobs << sequence.create_job(job_config)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
@jobs
|
34
|
+
end
|
35
|
+
|
36
|
+
#-----------------------------------------------------------------------------
|
37
|
+
# Checks
|
38
|
+
|
39
|
+
def initialized?(options = {})
|
40
|
+
true
|
41
|
+
end
|
42
|
+
|
43
|
+
#-----------------------------------------------------------------------------
|
44
|
+
# Property accessors / modifiers
|
45
|
+
|
46
|
+
def sequence
|
47
|
+
@sequence
|
48
|
+
end
|
49
|
+
|
50
|
+
#---
|
51
|
+
|
52
|
+
def jobs
|
53
|
+
@jobs
|
54
|
+
end
|
55
|
+
|
56
|
+
def jobs=jobs
|
57
|
+
set(:jobs, array(jobs))
|
58
|
+
init_jobs
|
59
|
+
end
|
60
|
+
|
61
|
+
#-----------------------------------------------------------------------------
|
62
|
+
# Operations
|
63
|
+
|
64
|
+
def execute(settings, parallel = true)
|
65
|
+
if initialized?
|
66
|
+
if Nucleon.parallel? && parallel
|
67
|
+
success = execute_parallel
|
68
|
+
else
|
69
|
+
success = execute_sequence
|
70
|
+
end
|
71
|
+
else
|
72
|
+
success = false
|
73
|
+
end
|
74
|
+
success
|
75
|
+
end
|
76
|
+
|
77
|
+
#-----------------------------------------------------------------------------
|
78
|
+
# Utilities
|
79
|
+
|
80
|
+
def execute_parallel
|
81
|
+
false # Override me!!
|
82
|
+
end
|
83
|
+
|
84
|
+
#---
|
85
|
+
|
86
|
+
def execute_sequence
|
87
|
+
success = true
|
88
|
+
jobs.each do |job|
|
89
|
+
success = false unless job.execute(sequence.settings)
|
90
|
+
end
|
91
|
+
success
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -3,6 +3,9 @@ module Nucleon
|
|
3
3
|
module Plugin
|
4
4
|
class CmAction < Nucleon.plugin_class(:nucleon, :action)
|
5
5
|
|
6
|
+
include Parallel
|
7
|
+
include Mixin::Action::Config
|
8
|
+
|
6
9
|
#-----------------------------------------------------------------------------
|
7
10
|
# Constuctor / Destructor
|
8
11
|
|
@@ -23,6 +26,7 @@ class CmAction < Nucleon.plugin_class(:nucleon, :action)
|
|
23
26
|
|
24
27
|
def configure
|
25
28
|
super do
|
29
|
+
config_config
|
26
30
|
yield if block_given?
|
27
31
|
end
|
28
32
|
end
|
@@ -33,12 +37,6 @@ class CmAction < Nucleon.plugin_class(:nucleon, :action)
|
|
33
37
|
#-----------------------------------------------------------------------------
|
34
38
|
# Operations
|
35
39
|
|
36
|
-
def validate(node = nil, network = nil)
|
37
|
-
super(node, network)
|
38
|
-
end
|
39
|
-
|
40
|
-
#---
|
41
|
-
|
42
40
|
def execute(&block)
|
43
41
|
super(false, false) do
|
44
42
|
block.call
|