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
@@ -5,14 +5,16 @@ nucleon_require(File.dirname(__FILE__), :cm_action)
|
|
5
5
|
|
6
6
|
module Nucleon
|
7
7
|
module Plugin
|
8
|
-
class PlanAction <
|
8
|
+
class PlanAction < Nucleon.plugin_class(:nucleon, :cm_action)
|
9
|
+
|
10
|
+
include Mixin::Action::Project
|
9
11
|
|
10
12
|
#-----------------------------------------------------------------------------
|
11
13
|
# Constuctor / Destructor
|
12
14
|
|
13
15
|
def normalize(reload)
|
14
16
|
super do
|
15
|
-
|
17
|
+
yield if block_given?
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
@@ -21,25 +23,63 @@ class PlanAction < Plugin::CmAction
|
|
21
23
|
|
22
24
|
def configure
|
23
25
|
super do
|
26
|
+
register_plan_provider :plan_provider, Nucleon.type_default(:CM, :plan), [
|
27
|
+
'cm.action.plan.base.options.plan',
|
28
|
+
'cm.action.plan.base.errors.plan'
|
29
|
+
]
|
30
|
+
register_str :plan_path, Dir.pwd, [
|
31
|
+
'cm.action.plan.base.options.plan_path',
|
32
|
+
'cm.action.plan.base.errors.plan_path'
|
33
|
+
]
|
34
|
+
register_str :manifest, 'plan.yml', [
|
35
|
+
'cm.action.plan.base.options.manifest',
|
36
|
+
'cm.action.plan.base.errors.manifest'
|
37
|
+
]
|
38
|
+
register_directory :config_path, Dir.pwd, [
|
39
|
+
'cm.action.plan.base.options.config_path',
|
40
|
+
'cm.action.plan.base.errors.config_path'
|
41
|
+
]
|
42
|
+
register_directory :key_path, Dir.pwd, [
|
43
|
+
'cm.action.plan.base.options.key_path',
|
44
|
+
'cm.action.plan.base.errors.key_path'
|
45
|
+
]
|
46
|
+
|
47
|
+
project_config
|
48
|
+
|
24
49
|
yield if block_given?
|
25
50
|
end
|
26
51
|
end
|
27
52
|
|
28
53
|
#-----------------------------------------------------------------------------
|
29
|
-
#
|
54
|
+
# Properties
|
55
|
+
|
56
|
+
def plan
|
57
|
+
@plan
|
58
|
+
end
|
30
59
|
|
31
60
|
#-----------------------------------------------------------------------------
|
32
61
|
# Operations
|
33
62
|
|
34
63
|
def execute(&block)
|
35
64
|
super do
|
36
|
-
block.call
|
65
|
+
block.call if initialize_plan
|
37
66
|
end
|
38
67
|
end
|
39
68
|
|
40
69
|
#-----------------------------------------------------------------------------
|
41
70
|
# Utilities
|
42
71
|
|
72
|
+
def initialize_plan
|
73
|
+
@plan = CM.plan(plugin_name, extended_config(:plan, {
|
74
|
+
:path => settings[:plan_path],
|
75
|
+
:config_directory => settings[:config_path],
|
76
|
+
:key_directory => settings[:key_path],
|
77
|
+
:manifest_file => settings[:manifest],
|
78
|
+
:project_provider => settings[:project_provider],
|
79
|
+
:url => settings[:project_reference],
|
80
|
+
:revision => settings[:project_revision]
|
81
|
+
}), settings[:plan_provider])
|
82
|
+
end
|
43
83
|
end
|
44
84
|
end
|
45
85
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
|
2
|
+
nucleon_require(File.dirname(__FILE__), :parallel_base)
|
3
|
+
|
4
|
+
#---
|
5
|
+
|
6
|
+
module CM
|
7
|
+
module Plugin
|
8
|
+
class Sequence < Nucleon.plugin_class(:nucleon, :parallel_base)
|
9
|
+
|
10
|
+
#-----------------------------------------------------------------------------
|
11
|
+
# Plugin interface
|
12
|
+
|
13
|
+
def normalize(reload)
|
14
|
+
super
|
15
|
+
|
16
|
+
init_jobs
|
17
|
+
yield if block_given?
|
18
|
+
end
|
19
|
+
|
20
|
+
#-----------------------------------------------------------------------------
|
21
|
+
# Checks
|
22
|
+
|
23
|
+
def initialized?(options = {})
|
24
|
+
!@jobs.empty?
|
25
|
+
end
|
26
|
+
|
27
|
+
#-----------------------------------------------------------------------------
|
28
|
+
# Property accessors / modifiers
|
29
|
+
|
30
|
+
def settings
|
31
|
+
get_hash(:settings)
|
32
|
+
end
|
33
|
+
|
34
|
+
#---
|
35
|
+
|
36
|
+
def init_jobs
|
37
|
+
@jobs = []
|
38
|
+
get_array(:jobs).each do |job_config|
|
39
|
+
if job_config.has_key?(:aggregate) # Array
|
40
|
+
@jobs << create_batch(job_config[:aggregate])
|
41
|
+
else # Atomic
|
42
|
+
@jobs << create_job(job_config)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
@jobs
|
46
|
+
end
|
47
|
+
|
48
|
+
def jobs
|
49
|
+
@jobs
|
50
|
+
end
|
51
|
+
|
52
|
+
def jobs=jobs
|
53
|
+
set(:jobs, Nucleon::Util::Data.array(jobs))
|
54
|
+
init_jobs
|
55
|
+
end
|
56
|
+
|
57
|
+
#-----------------------------------------------------------------------------
|
58
|
+
# Operations
|
59
|
+
|
60
|
+
def forward(options)
|
61
|
+
config = Nucleon::Config.ensure(options)
|
62
|
+
|
63
|
+
if initialized?
|
64
|
+
success = true
|
65
|
+
success = yield(config, success) if block_given?
|
66
|
+
else
|
67
|
+
success = false
|
68
|
+
end
|
69
|
+
success
|
70
|
+
end
|
71
|
+
|
72
|
+
#---
|
73
|
+
|
74
|
+
def reverse(options)
|
75
|
+
config = Nucleon::Config.ensure(options)
|
76
|
+
|
77
|
+
if initialized?
|
78
|
+
success = true
|
79
|
+
success = yield(config, success) if block_given?
|
80
|
+
else
|
81
|
+
success = false
|
82
|
+
end
|
83
|
+
success
|
84
|
+
end
|
85
|
+
|
86
|
+
#-----------------------------------------------------------------------------
|
87
|
+
# Utilities
|
88
|
+
|
89
|
+
def create_sequence(jobs)
|
90
|
+
CM.sequence({ :settings => settings, :jobs => jobs }, get(:sequence_provider, :default))
|
91
|
+
end
|
92
|
+
|
93
|
+
#---
|
94
|
+
|
95
|
+
def create_batch(jobs)
|
96
|
+
CM.batch({ :sequence => myself, :jobs => jobs }, get(:batch_provider, :celluloid))
|
97
|
+
end
|
98
|
+
|
99
|
+
#---
|
100
|
+
|
101
|
+
def create_job(settings)
|
102
|
+
settings[:type] ||= get(:default_job_provider, :variables)
|
103
|
+
CM.job({ :settings => settings }, settings[:type])
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
module Nucleon
|
3
3
|
module Action
|
4
4
|
module Plan
|
5
|
-
class Deploy <
|
5
|
+
class Deploy < Nucleon.plugin_class(:nucleon, :plan_action)
|
6
6
|
|
7
7
|
#-----------------------------------------------------------------------------
|
8
8
|
# Info
|
@@ -16,14 +16,14 @@ class Deploy < Plugin::PlanAction
|
|
16
16
|
|
17
17
|
def configure
|
18
18
|
super do
|
19
|
-
|
19
|
+
codes :deploy_failed
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
#---
|
24
24
|
|
25
25
|
def arguments
|
26
|
-
[]
|
26
|
+
[:manifest]
|
27
27
|
end
|
28
28
|
|
29
29
|
#-----------------------------------------------------------------------------
|
@@ -32,6 +32,9 @@ class Deploy < Plugin::PlanAction
|
|
32
32
|
def execute
|
33
33
|
super do
|
34
34
|
info('start')
|
35
|
+
unless plan.execute(:deploy)
|
36
|
+
myself.status = code.deploy_failed
|
37
|
+
end
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
module Nucleon
|
3
3
|
module Action
|
4
4
|
module Plan
|
5
|
-
class Destroy <
|
5
|
+
class Destroy < Nucleon.plugin_class(:nucleon, :plan_action)
|
6
6
|
|
7
7
|
#-----------------------------------------------------------------------------
|
8
8
|
# Info
|
@@ -16,14 +16,14 @@ class Destroy < Plugin::PlanAction
|
|
16
16
|
|
17
17
|
def configure
|
18
18
|
super do
|
19
|
-
|
19
|
+
codes :destroy_failed
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
#---
|
24
24
|
|
25
25
|
def arguments
|
26
|
-
[]
|
26
|
+
[:manifest]
|
27
27
|
end
|
28
28
|
|
29
29
|
#-----------------------------------------------------------------------------
|
@@ -32,6 +32,9 @@ class Destroy < Plugin::PlanAction
|
|
32
32
|
def execute
|
33
33
|
super do
|
34
34
|
info('start')
|
35
|
+
unless plan.execute(:destroy)
|
36
|
+
myself.status = code.destroy_failed
|
37
|
+
end
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
data/locales/en.yml
CHANGED
@@ -1,7 +1,53 @@
|
|
1
1
|
en:
|
2
|
+
nucleon:
|
3
|
+
mixin:
|
4
|
+
action:
|
5
|
+
config:
|
6
|
+
options:
|
7
|
+
settings_path: |-
|
8
|
+
Configuration path for loading system settings (default %{default_value})
|
9
|
+
errors:
|
10
|
+
translator: |-
|
11
|
+
No translator provider available for: %{provider}
|
12
|
+
settings_path: |-
|
13
|
+
System settings path does not exist: %{path}
|
14
|
+
config_file: |-
|
15
|
+
Configuration file can not be parsed: %{file}
|
16
|
+
plan:
|
17
|
+
default:
|
18
|
+
error:
|
19
|
+
manifest_file: |-
|
20
|
+
Execution plan manifest %{file} does not exist
|
21
|
+
translator: |-
|
22
|
+
No translator provider available for: %{provider}
|
23
|
+
config_file: |-
|
24
|
+
Failed to parse the execution plan manifest %{file}
|
2
25
|
cm:
|
3
26
|
action:
|
4
27
|
plan:
|
28
|
+
base:
|
29
|
+
options:
|
30
|
+
plan: |-
|
31
|
+
Execution plan plugin type
|
32
|
+
plan_path: |-
|
33
|
+
File path to the root directory of the plan project
|
34
|
+
config_path: |-
|
35
|
+
File path of the private configuration directory
|
36
|
+
key_path: |-
|
37
|
+
File path of the SSH private key directory
|
38
|
+
manifest: |-
|
39
|
+
File path of the execution plan manifest file
|
40
|
+
errors:
|
41
|
+
plan: |-
|
42
|
+
Execution plan must be one of the following options: %{choices}
|
43
|
+
plan_path: |-
|
44
|
+
Plan top level directory (%{directory}) does not exist or is not readable
|
45
|
+
config_path: |-
|
46
|
+
Plan configuration directory (%{directory}) does not exist or is not readable
|
47
|
+
key_path: |-
|
48
|
+
Private SSH key top level directory (%{directory}) does not exist or is not readable
|
49
|
+
manifest: |-
|
50
|
+
Execution plan manifest file (%{file}) does not exist or is not readable
|
5
51
|
deploy:
|
6
52
|
description: |-
|
7
53
|
Create or update a cloud definition
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Webb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
type: :runtime
|
@@ -102,13 +102,31 @@ files:
|
|
102
102
|
- VERSION
|
103
103
|
- bin/cm
|
104
104
|
- cm.gemspec
|
105
|
+
- lib/CM/batch/celluloid.rb
|
106
|
+
- lib/CM/configuration/directory.rb
|
107
|
+
- lib/CM/configuration/file.rb
|
108
|
+
- lib/CM/job/AWS.rb
|
109
|
+
- lib/CM/job/BOSH.rb
|
110
|
+
- lib/CM/job/concourse.rb
|
111
|
+
- lib/CM/job/keypair.rb
|
112
|
+
- lib/CM/job/variables.rb
|
113
|
+
- lib/CM/plan/default.rb
|
114
|
+
- lib/CM/sequence/default.rb
|
105
115
|
- lib/cm.rb
|
106
116
|
- lib/core/errors.rb
|
107
117
|
- lib/core/facade.rb
|
108
118
|
- lib/core/mixin/action/config.rb
|
119
|
+
- lib/core/mixin/action/registration.rb
|
109
120
|
- lib/core/overrides.rb
|
121
|
+
- lib/core/plugin/batch.rb
|
110
122
|
- lib/core/plugin/cm_action.rb
|
123
|
+
- lib/core/plugin/configuration.rb
|
124
|
+
- lib/core/plugin/disk_configuration.rb
|
125
|
+
- lib/core/plugin/job.rb
|
126
|
+
- lib/core/plugin/parallel_base.rb
|
127
|
+
- lib/core/plugin/plan.rb
|
111
128
|
- lib/core/plugin/plan_action.rb
|
129
|
+
- lib/core/plugin/sequence.rb
|
112
130
|
- lib/nucleon/action/plan/deploy.rb
|
113
131
|
- lib/nucleon/action/plan/destroy.rb
|
114
132
|
- locales/en.yml
|