stackmate 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +12 -0
- data/bin/stackmate.rb +10 -2
- data/lib/stackmate/logging.rb +15 -0
- data/lib/stackmate/participants/cloudstack.rb +2 -2
- data/lib/stackmate/participants/common.rb +9 -0
- data/lib/stackmate/stack_executor.rb +11 -5
- data/lib/stackmate/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG.txt
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
|
2
2
|
= stackmate - CHANGELOG.txt
|
3
3
|
|
4
|
+
== stackmate - 0.1.1
|
5
|
+
- Timeout and notification support
|
6
|
+
- Rollback notification.
|
7
|
+
- No API changes
|
8
|
+
- Added templates in CloudStack:: namespace
|
9
|
+
|
4
10
|
|
5
11
|
== stackmate - 0.1.0
|
6
12
|
|
7
13
|
- replace cloudstack_ruby_client with a simple built-in client
|
14
|
+
- support for CloudStack:: namespace in json template.
|
15
|
+
- tests
|
16
|
+
- rake tasks to simplify generation of code for CS virtual resources and template docs
|
17
|
+
- extensibility support by adding your own plugin classes to interface with other services
|
18
|
+
- added CS sample template
|
19
|
+
|
data/bin/stackmate.rb
CHANGED
@@ -4,6 +4,7 @@ require 'optparse'
|
|
4
4
|
require 'stackmate'
|
5
5
|
require 'stackmate/classmap'
|
6
6
|
require 'stackmate/waitcondition_server'
|
7
|
+
require 'stackmate/logging'
|
7
8
|
|
8
9
|
|
9
10
|
options = {}
|
@@ -34,6 +35,13 @@ opt_parser = OptionParser.new do |opts|
|
|
34
35
|
opts.on("--plugins DIRS",String, "Comman separated plugins directory") do |plugins|
|
35
36
|
options[:plugins] = plugins
|
36
37
|
end
|
38
|
+
options[:timeout] = "600"
|
39
|
+
opts.on("--timeout SECONDS",String, "Timeout for stack creation in seconds, defaults to 600 seconds") do |t|
|
40
|
+
options[:timeout] = t
|
41
|
+
end
|
42
|
+
opts.on("-d", "--debug", "Debug level logging") do
|
43
|
+
StackMate.set_log_level("debug")
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
47
|
begin
|
@@ -65,7 +73,7 @@ if options[:file] && stack_name != ''
|
|
65
73
|
StackMate.configure('NOOP') if options[:dry_run]
|
66
74
|
opts = {}
|
67
75
|
api_opts = {:APIKEY => "#{ENV['APIKEY']}", :SECKEY => "#{ENV['SECKEY']}", :URL => "#{ENV['URL']}" }
|
68
|
-
p = StackMate::StackExecutor.new(options[:file], stack_name, options[:params], engine, options[:wait_conditions], api_opts, options[:plugins])
|
76
|
+
p = StackMate::StackExecutor.new(options[:file], stack_name, options[:params], engine, options[:wait_conditions], api_opts, options[:timeout], options[:plugins])
|
69
77
|
p.launch()
|
70
78
|
nil
|
71
79
|
end
|
@@ -75,4 +83,4 @@ if options[:file] && stack_name != ''
|
|
75
83
|
print "Sorry, I don't know how to create resources of type: ", unknown, "\n" if unknown
|
76
84
|
else
|
77
85
|
puts opt_parser.help()
|
78
|
-
end
|
86
|
+
end
|
data/lib/stackmate/logging.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
require 'logger'
|
2
2
|
|
3
3
|
module StackMate
|
4
|
+
@log_lvl = Logger::INFO
|
5
|
+
def StackMate.set_log_level(lvl)
|
6
|
+
case lvl
|
7
|
+
when 'info'
|
8
|
+
@log_lvl = Logger::INFO
|
9
|
+
when 'debug'
|
10
|
+
@log_lvl = Logger::DEBUG
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def StackMate.log_level
|
15
|
+
@log_lvl
|
16
|
+
end
|
17
|
+
|
4
18
|
module Logging
|
5
19
|
def logger
|
6
20
|
@logger ||= Logging.logger_for(self.class.name)
|
@@ -16,6 +30,7 @@ module StackMate
|
|
16
30
|
|
17
31
|
def configure_logger_for(classname)
|
18
32
|
logger = Logger.new(STDOUT)
|
33
|
+
logger.level = StackMate.log_level
|
19
34
|
logger.progname = classname
|
20
35
|
logger.datetime_format= '%F %T'
|
21
36
|
logger.formatter = proc do |severity, datetime, progname, msg|
|
@@ -304,7 +304,7 @@ module StackMate
|
|
304
304
|
v = val['Value']
|
305
305
|
constructed_value = intrinsic(v, workitem)
|
306
306
|
val['Value'] = constructed_value
|
307
|
-
workitem['Outputs'][key] = constructed_value
|
307
|
+
#workitem['Outputs'][key] = constructed_value
|
308
308
|
logger.debug "Output: key = #{key}, value = #{constructed_value} descr = #{val['Description']}"
|
309
309
|
end
|
310
310
|
|
@@ -315,4 +315,4 @@ module StackMate
|
|
315
315
|
end
|
316
316
|
|
317
317
|
|
318
|
-
end
|
318
|
+
end
|
@@ -153,6 +153,15 @@ module StackMate
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
+
class StackNotifier < Ruote::Participant
|
157
|
+
include Logging
|
158
|
+
|
159
|
+
def on_workitem
|
160
|
+
logger.error("\n\nINITIATING STACK ROLLBACK\n\n")
|
161
|
+
reply
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
156
165
|
class StackNest < Ruote::Participant
|
157
166
|
include Logging
|
158
167
|
include Intrinsic
|
@@ -17,12 +17,13 @@ module StackMate
|
|
17
17
|
class StackExecutor < StackMate::Stacker
|
18
18
|
include Logging
|
19
19
|
|
20
|
-
def initialize(templatefile, stackname, params, engine, create_wait_conditions, api_opts, plugins=nil)
|
20
|
+
def initialize(templatefile, stackname, params, engine, create_wait_conditions, api_opts, timeout, plugins=nil)
|
21
21
|
stackstr = File.read(templatefile)
|
22
22
|
super(stackstr, stackname, resolve_param_refs(params, stackname))
|
23
23
|
@engine = engine
|
24
24
|
@create_wait_conditions = create_wait_conditions
|
25
25
|
@api_opts = api_opts
|
26
|
+
@timeout = timeout
|
26
27
|
load_plugins(plugins)
|
27
28
|
end
|
28
29
|
|
@@ -82,6 +83,8 @@ module StackMate
|
|
82
83
|
resolved_params['AWS::Region'] = 'us-east-1' #TODO handle this better
|
83
84
|
resolved_params['AWS::StackName'] = stackname
|
84
85
|
resolved_params['AWS::StackId'] = stackname
|
86
|
+
resolved_params['CloudStack::StackName'] = stackname
|
87
|
+
resolved_params['CloudStack::StackId'] = stackname
|
85
88
|
resolved_params
|
86
89
|
end
|
87
90
|
|
@@ -104,14 +107,16 @@ module StackMate
|
|
104
107
|
throw :unknown, t if !StackMate.class_for(t)
|
105
108
|
@engine.register_participant p, StackMate.class_for(t), @api_opts
|
106
109
|
end
|
107
|
-
|
110
|
+
timeout = @timeout + "s"
|
108
111
|
@engine.register_participant 'Output', StackMate.class_for('Outputs')
|
112
|
+
@engine.register_participant 'Notify', StackMate.class_for('StackMate::StackNotifier')
|
109
113
|
@pdef = Ruote.define @stackname.to_s() do
|
110
|
-
cursor :timeout =>
|
114
|
+
cursor :timeout => timeout, :on_error => 'rollback', :on_timeout => 'rollback' do
|
111
115
|
participants.collect{ |name| __send__(name, :operation => :create) }
|
112
116
|
__send__('Output')
|
113
117
|
end
|
114
|
-
define 'rollback', :timeout =>
|
118
|
+
define 'rollback', :timeout => timeout do
|
119
|
+
__send__('Notify')
|
115
120
|
participants.reverse_each.collect {|name| __send__(name, :operation => :rollback) }
|
116
121
|
end
|
117
122
|
end
|
@@ -119,7 +124,8 @@ module StackMate
|
|
119
124
|
|
120
125
|
def launch
|
121
126
|
wfid = @engine.launch( pdef, @templ)
|
122
|
-
@
|
127
|
+
timeout = @timeout.to_i * 2
|
128
|
+
@engine.wait_for(wfid, :timeout => timeout)
|
123
129
|
logger.error { "engine error : #{@engine.errors.first.message}"} if @engine.errors.first
|
124
130
|
end
|
125
131
|
end
|
data/lib/stackmate/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackmate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|