CfnTools 0.0.13 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mstacks.rb +78 -0
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5f6c53dd5c5ea082905af92f85778545b2cff90
4
- data.tar.gz: 98458e407b17e3d427da4d921903eab689940e33
3
+ metadata.gz: 532cc47793044bcb049432832a7439e568578ad1
4
+ data.tar.gz: 00aee917d254b5796ed43dc811db6f5f70a143f2
5
5
  SHA512:
6
- metadata.gz: 7770aab053591b2adfe016f4241998225bcfce3f2805b3f73937c0dbe77a0e69df12264b46e8c8afe229c4025265ae6f52b973af10f719c5a6c91db735bfea9d
7
- data.tar.gz: 631bb232b2fc190b1ea6bd7c02208c1565c378fc1e12e9993bfeea323fd48d2fe30f00827c315bc934df110820a3cbc966fdce7665231194bf8d5dd0de62e225
6
+ metadata.gz: 2f848b980e5914f2ab391c590a1b236a3402a847bc21bd252bff448631b6b763690fc3767457bed9afc2c29d6b653516fbbe34ef08c2f40e71e7e9f70ce1cc57
7
+ data.tar.gz: a0aeaaa7be9fa0f2f16a371d2ced4b7352b0651f169aeb0fc1c7df3028d1048140d12bd7fff7900f53538d9bc111fe1b5158b516e9255a2bc218606b1e46564b
data/lib/mstacks.rb ADDED
@@ -0,0 +1,78 @@
1
+ require 'aws-sdk'
2
+ require 'set'
3
+
4
+ class Mstacks
5
+ def active_mstacks()
6
+ a = []
7
+ get_active_stack_summaries.each do |summary|
8
+ stack_identity = parse_stack_identity(summary[:stack_name])
9
+ if stack_identity
10
+ stack_info = stack_identity.merge(summary)
11
+ a.push(stack_info)
12
+ end
13
+ end
14
+ return a
15
+ end
16
+
17
+ def autoupdate_stack_configs(environment_type)
18
+ yr = Ploy::YamlReader.new
19
+ conf = yr.from_http("http://stack-hub/api/configured-stacks?EnvironmentType=#{environment_type}")
20
+
21
+ configs = []
22
+ conf.each do |name, conf|
23
+ if conf['stack_autoupdate']
24
+ configs.push(conf)
25
+ end
26
+ end
27
+ return configs
28
+ end
29
+
30
+ def stack_hub_url(stack_info)
31
+ stack_name = stack_info.has_key?(:stack_name) ? stack_info[:stack_name] : stack_info['StackName']
32
+ return "http://stack-hub/api/#{stack_name}"
33
+ end
34
+
35
+ def parse_stack_identity(name)
36
+ p = name.split("--")
37
+ if not p.length == 3
38
+ return nil
39
+ end
40
+ return {
41
+ :stack_name => name,
42
+ :stack_type => p[0],
43
+ :env_name => p[1],
44
+ :env_type => p[2]
45
+ }
46
+ end
47
+
48
+ def get_active_stack_summaries()
49
+ cfn = AWS::CloudFormation.new
50
+ return cfn.stack_summaries.with_status(statuses.to_a)
51
+ end
52
+
53
+ def statuses()
54
+ return Set.new [
55
+ :create_in_progress,
56
+ :create_complete,
57
+ :rollback_in_progress,
58
+ :rollback_failed,
59
+ :rollback_complete,
60
+ :delete_failed,
61
+ :update_in_progress,
62
+ :update_complete_cleanup_in_progress,
63
+ :update_complete,
64
+ :update_rollback_in_progress,
65
+ :update_rollback_failed,
66
+ :update_rollback_complete_cleanup_in_progress,
67
+ :update_rollback_complete
68
+ ]
69
+ end
70
+
71
+ def obsolete_statuses()
72
+ return Set.new [
73
+ :delete_in_progress,
74
+ :delete_complete,
75
+ :create_failed
76
+ ]
77
+ end
78
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CfnTools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Schrock
@@ -17,6 +17,7 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/CfnTools.rb
20
+ - lib/mstacks.rb
20
21
  homepage: http://github.com/mantacode/CfnTools
21
22
  licenses:
22
23
  - MIT