cm 0.1.4 → 0.1.6

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/cm.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: cm 0.1.4 ruby lib
5
+ # stub: cm 0.1.6 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "cm"
9
- s.version = "0.1.4"
9
+ s.version = "0.1.6"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Adrian Webb"]
14
- s.date = "2015-12-11"
14
+ s.date = "2015-12-27"
15
15
  s.description = "\nPluggable cloud management framework that provides a simple foundation for\ndeploying and destroying enterprise ready cloud environments and components\nthat integrate; cloud provider components and services, cloud orchestration\nand configuration management tools, and continuous integration and delivery\npipelines.\n"
16
16
  s.email = "adrian.webb@gsa.gov"
17
17
  s.executables = ["cm"]
@@ -20,23 +20,25 @@ Gem::Specification.new do |s|
20
20
  ]
21
21
  s.files = [
22
22
  ".gitignore",
23
+ ".gitmodules",
23
24
  "Gemfile",
24
25
  "Gemfile.lock",
25
26
  "Rakefile",
26
27
  "VERSION",
27
28
  "bin/cm",
29
+ "bootstrap/lib/bash/LICENSE.txt",
28
30
  "cm.gemspec",
29
31
  "lib/CM/batch/celluloid.rb",
30
32
  "lib/CM/configuration/directory.rb",
31
33
  "lib/CM/configuration/file.rb",
32
34
  "lib/CM/function/generate_password.rb",
33
- "lib/CM/job/AWS.rb",
34
- "lib/CM/job/BOSH.rb",
35
- "lib/CM/job/MicroBOSH.rb",
36
- "lib/CM/job/concourse.rb",
37
- "lib/CM/job/keypair.rb",
38
- "lib/CM/job/variables.rb",
39
35
  "lib/CM/plan/default.rb",
36
+ "lib/CM/resource/AWS.rb",
37
+ "lib/CM/resource/BOSH.rb",
38
+ "lib/CM/resource/MicroBOSH.rb",
39
+ "lib/CM/resource/concourse.rb",
40
+ "lib/CM/resource/keypair.rb",
41
+ "lib/CM/resource/variables.rb",
40
42
  "lib/CM/sequence/default.rb",
41
43
  "lib/cm.rb",
42
44
  "lib/core/errors.rb",
@@ -44,19 +46,21 @@ Gem::Specification.new do |s|
44
46
  "lib/core/mixin/action/config.rb",
45
47
  "lib/core/mixin/action/registration.rb",
46
48
  "lib/core/overrides.rb",
49
+ "lib/core/plugin/auth_docker_resource.rb",
47
50
  "lib/core/plugin/batch.rb",
48
51
  "lib/core/plugin/cm_action.rb",
49
52
  "lib/core/plugin/configuration.rb",
50
53
  "lib/core/plugin/disk_configuration.rb",
51
- "lib/core/plugin/docker_job.rb",
54
+ "lib/core/plugin/docker_resource.rb",
52
55
  "lib/core/plugin/function.rb",
53
- "lib/core/plugin/job.rb",
54
56
  "lib/core/plugin/parallel_base.rb",
55
57
  "lib/core/plugin/plan.rb",
56
58
  "lib/core/plugin/plan_action.rb",
59
+ "lib/core/plugin/resource.rb",
57
60
  "lib/core/plugin/sequence.rb",
58
61
  "lib/nucleon/action/plan/deploy.rb",
59
62
  "lib/nucleon/action/plan/destroy.rb",
63
+ "lib/nucleon/action/resource/run.rb",
60
64
  "locales/en.yml",
61
65
  "spec/spec_helper.rb"
62
66
  ]
@@ -64,7 +68,7 @@ Gem::Specification.new do |s|
64
68
  s.licenses = ["Apache License, Version 2.0"]
65
69
  s.rdoc_options = ["--title", "CM (Cloud Manager)", "--main", "README.rdoc", "--line-numbers"]
66
70
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
67
- s.rubygems_version = "2.4.8"
71
+ s.rubygems_version = "2.4.5"
68
72
  s.summary = "Pluggable cloud management framework that provides a simple foundation for deploying and destroying enterprise ready cloud environments and components"
69
73
 
70
74
  if s.respond_to? :specification_version then
@@ -72,12 +76,14 @@ Gem::Specification.new do |s|
72
76
 
73
77
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
74
78
  s.add_runtime_dependency(%q<nucleon>, ["~> 0.2"])
79
+ s.add_runtime_dependency(%q<docker-api>, ["~> 1.24"])
75
80
  s.add_development_dependency(%q<bundler>, ["~> 1.10"])
76
81
  s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
77
82
  s.add_development_dependency(%q<rspec>, ["~> 3.4"])
78
83
  s.add_development_dependency(%q<rdoc>, ["~> 4.2"])
79
84
  else
80
85
  s.add_dependency(%q<nucleon>, ["~> 0.2"])
86
+ s.add_dependency(%q<docker-api>, ["~> 1.24"])
81
87
  s.add_dependency(%q<bundler>, ["~> 1.10"])
82
88
  s.add_dependency(%q<jeweler>, ["~> 2.0"])
83
89
  s.add_dependency(%q<rspec>, ["~> 3.4"])
@@ -85,6 +91,7 @@ Gem::Specification.new do |s|
85
91
  end
86
92
  else
87
93
  s.add_dependency(%q<nucleon>, ["~> 0.2"])
94
+ s.add_dependency(%q<docker-api>, ["~> 1.24"])
88
95
  s.add_dependency(%q<bundler>, ["~> 1.10"])
89
96
  s.add_dependency(%q<jeweler>, ["~> 2.0"])
90
97
  s.add_dependency(%q<rspec>, ["~> 3.4"])
@@ -23,11 +23,11 @@ class Celluloid < Nucleon.plugin_class(:CM, :batch)
23
23
  #-----------------------------------------------------------------------------
24
24
  # Utilities
25
25
 
26
- def execute_parallel
26
+ def execute_parallel(operation)
27
27
  values = []
28
- jobs.each do |job|
29
- values << Celluloid::Future.new(job) do
30
- job.execute
28
+ resources.each do |resource|
29
+ values << ::Celluloid::Future.new(resource) do
30
+ resource.execute(operation)
31
31
  end
32
32
  end
33
33
  values = values.map { |future| future.value }
@@ -14,10 +14,6 @@ class File < Nucleon.plugin_class(:CM, :disk_configuration)
14
14
  #-----------------------------------------------------------------------------
15
15
  # Checks
16
16
 
17
- def initialized?(options = {})
18
- path && ::File.exist?(path)
19
- end
20
-
21
17
  #-----------------------------------------------------------------------------
22
18
  # Property accessors / modifiers
23
19
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CM
3
- module Job
4
- class AWS < Nucleon.plugin_class(:CM, :job)
3
+ module Resource
4
+ class AWS < Nucleon.plugin_class(:CM, :docker_resource)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Plugin interface
@@ -24,7 +24,15 @@ class AWS < Nucleon.plugin_class(:CM, :job)
24
24
  #-----------------------------------------------------------------------------
25
25
  # Operations
26
26
 
27
- def execute
27
+ def operation_deploy
28
+ super do
29
+ success = true
30
+ end
31
+ end
32
+
33
+ #---
34
+
35
+ def operation_destroy
28
36
  super do
29
37
  success = true
30
38
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CM
3
- module Job
4
- class BOSH < Nucleon.plugin_class(:CM, :job)
3
+ module Resource
4
+ class BOSH < Nucleon.plugin_class(:CM, :docker_resource)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Plugin interface
@@ -24,7 +24,15 @@ class BOSH < Nucleon.plugin_class(:CM, :job)
24
24
  #-----------------------------------------------------------------------------
25
25
  # Operations
26
26
 
27
- def execute
27
+ def operation_deploy
28
+ super do
29
+ success = true
30
+ end
31
+ end
32
+
33
+ #---
34
+
35
+ def operation_destroy
28
36
  super do
29
37
  success = true
30
38
  end
@@ -0,0 +1,46 @@
1
+
2
+ module CM
3
+ module Resource
4
+ class MicroBOSH < Nucleon.plugin_class(:CM, :docker_resource)
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
+ def initialized?(options = {})
18
+ true
19
+ end
20
+
21
+ #-----------------------------------------------------------------------------
22
+ # Property accessors / modifiers
23
+
24
+ #-----------------------------------------------------------------------------
25
+ # Operations
26
+
27
+ def operation_deploy
28
+ super do
29
+ success = true
30
+ end
31
+ end
32
+
33
+ #---
34
+
35
+ def operation_destroy
36
+ super do
37
+ success = true
38
+ end
39
+ end
40
+
41
+ #-----------------------------------------------------------------------------
42
+ # Utilities
43
+
44
+ end
45
+ end
46
+ end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CM
3
- module Job
4
- class Concourse < Nucleon.plugin_class(:CM, :job)
3
+ module Resource
4
+ class Concourse < Nucleon.plugin_class(:CM, :docker_resource)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Plugin interface
@@ -24,7 +24,15 @@ class Concourse < Nucleon.plugin_class(:CM, :job)
24
24
  #-----------------------------------------------------------------------------
25
25
  # Operations
26
26
 
27
- def execute
27
+ def operation_deploy
28
+ super do
29
+ success = true
30
+ end
31
+ end
32
+
33
+ #---
34
+
35
+ def operation_destroy
28
36
  super do
29
37
  success = true
30
38
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CM
3
- module Job
4
- class Keypair < Nucleon.plugin_class(:CM, :job)
3
+ module Resource
4
+ class Keypair < Nucleon.plugin_class(:CM, :docker_resource)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Plugin interface
@@ -24,7 +24,15 @@ class Keypair < Nucleon.plugin_class(:CM, :job)
24
24
  #-----------------------------------------------------------------------------
25
25
  # Operations
26
26
 
27
- def execute
27
+ def operation_deploy
28
+ super do
29
+ success = true
30
+ end
31
+ end
32
+
33
+ #---
34
+
35
+ def operation_destroy
28
36
  super do
29
37
  success = true
30
38
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module CM
3
- module Job
4
- class MicroBOSH < Nucleon.plugin_class(:CM, :job)
3
+ module Resource
4
+ class Variables < Nucleon.plugin_class(:CM, :resource)
5
5
 
6
6
  #-----------------------------------------------------------------------------
7
7
  # Plugin interface
@@ -14,17 +14,21 @@ class MicroBOSH < Nucleon.plugin_class(:CM, :job)
14
14
  #-----------------------------------------------------------------------------
15
15
  # Checks
16
16
 
17
- def initialized?(options = {})
18
- true
19
- end
20
-
21
17
  #-----------------------------------------------------------------------------
22
18
  # Property accessors / modifiers
23
19
 
24
20
  #-----------------------------------------------------------------------------
25
21
  # Operations
26
22
 
27
- def execute
23
+ def operation_deploy
24
+ super do
25
+ success = true
26
+ end
27
+ end
28
+
29
+ #---
30
+
31
+ def operation_destroy
28
32
  super do
29
33
  success = true
30
34
  end
@@ -20,11 +20,11 @@ class Default < Nucleon.plugin_class(:CM, :sequence)
20
20
  #-----------------------------------------------------------------------------
21
21
  # Operations
22
22
 
23
- def forward(options)
24
- super do |config, success|
25
- jobs.each do |job|
26
- success = false unless job.execute
27
- break if trap && step
23
+ def forward(operation)
24
+ super do |success|
25
+ resources.each do |resource|
26
+ success = false unless resource.execute(operation)
27
+ break if plan.trap && plan.step
28
28
  end
29
29
  success
30
30
  end
@@ -32,11 +32,11 @@ class Default < Nucleon.plugin_class(:CM, :sequence)
32
32
 
33
33
  #---
34
34
 
35
- def reverse(options)
36
- super do |config, success|
37
- jobs.reverse.each do |job|
38
- success = false unless job.execute
39
- break if trap && step
35
+ def reverse(operation)
36
+ super do |success|
37
+ resources.reverse.each do |resource|
38
+ success = false unless resource.execute(operation)
39
+ break if plan.trap && plan.step
40
40
  end
41
41
  success
42
42
  end
data/lib/cm.rb CHANGED
@@ -107,7 +107,7 @@ module CM
107
107
  :configuration => :file, # Component and manifest storage
108
108
  :sequence => :default, # Event sequence
109
109
  :batch => :celluloid,# Batch processor
110
- :job => :variables,# Individual job
110
+ :resource => :variables,# Individual resource
111
111
  :function => nil # Configuration processing function
112
112
  }
113
113
  end
@@ -55,12 +55,12 @@ module Facade
55
55
 
56
56
  #---
57
57
 
58
- def job(options, provider = nil)
59
- Nucleon.plugin(:CM, :job, provider, options)
58
+ def resource(options, provider = nil)
59
+ Nucleon.plugin(:CM, :resource, provider, options)
60
60
  end
61
61
 
62
- def jobs(data, build_hash = false, keep_array = false)
63
- Nucleon.plugins(:CM, :job, data, build_hash, keep_array)
62
+ def resources(data, build_hash = false, keep_array = false)
63
+ Nucleon.plugins(:CM, :resource, data, build_hash, keep_array)
64
64
  end
65
65
 
66
66
  #---
@@ -103,26 +103,26 @@ module Registration
103
103
 
104
104
  #---
105
105
 
106
- def register_job_provider(name, default = nil, locale = nil, &code)
107
- register_plugin_provider(:CM, :job, name.to_sym, default, locale, &code)
106
+ def register_resource_provider(name, default = nil, locale = nil, &code)
107
+ register_plugin_provider(:CM, :resource, name.to_sym, default, locale, &code)
108
108
  end
109
109
 
110
110
  #---
111
111
 
112
- def register_job_providers(name, default = nil, locale = nil, &code)
113
- register_plugin_providers(:CM, :job, name.to_sym, default, locale, &code)
112
+ def register_resource_providers(name, default = nil, locale = nil, &code)
113
+ register_plugin_providers(:CM, :resource, name.to_sym, default, locale, &code)
114
114
  end
115
115
 
116
116
  #---
117
117
 
118
- def register_job(name, default = nil, locale = nil, &code)
119
- register_plugin(:CM, :job, name.to_sym, default, locale, &code)
118
+ def register_resource(name, default = nil, locale = nil, &code)
119
+ register_plugin(:CM, :resource, name.to_sym, default, locale, &code)
120
120
  end
121
121
 
122
122
  #---
123
123
 
124
- def register_jobs(name, default = nil, locale = nil, &code)
125
- register_plugins(:CM, :job, name.to_sym, default, locale, &code)
124
+ def register_resources(name, default = nil, locale = nil, &code)
125
+ register_plugins(:CM, :resource, name.to_sym, default, locale, &code)
126
126
  end
127
127
 
128
128
  #---
@@ -0,0 +1,52 @@
1
+
2
+ nucleon_require(File.dirname(__FILE__), :docker_resource)
3
+
4
+ #---
5
+
6
+ module CM
7
+ module Plugin
8
+ class AuthDockerResource < Nucleon.plugin_class(:CM, :docker_resource)
9
+
10
+ #-----------------------------------------------------------------------------
11
+ # Plugin interface
12
+
13
+ def normalize(reload)
14
+ super
15
+
16
+ if settings[:docker_username] && settings[:docker_password] && settings[:docker_email]
17
+ begin
18
+ Docker.authenticate!({
19
+ 'username' => settings[:docker_username],
20
+ 'password' => settings[:docker_password],
21
+ 'email' => settings[:docker_email]
22
+ })
23
+ rescue Docker::Error::AuthenticationError => error
24
+ error('authentication_failed', { :error => error.message })
25
+ raise error
26
+ end
27
+ else
28
+ raise render_message('cm.resource.docker.info.no_credentials', {
29
+ :username_option => 'docker_username',
30
+ :password_option => 'docker_password',
31
+ :email_option => 'docker_email'
32
+ })
33
+ end
34
+
35
+ yield if block_given?
36
+ end
37
+
38
+ #-----------------------------------------------------------------------------
39
+ # Checks
40
+
41
+ #-----------------------------------------------------------------------------
42
+ # Property accessors / modifiers
43
+
44
+ #-----------------------------------------------------------------------------
45
+ # Operations
46
+
47
+ #-----------------------------------------------------------------------------
48
+ # Utilities
49
+
50
+ end
51
+ end
52
+ end