jackal-cfn 0.2.0 → 0.2.2
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/CHANGELOG.md +4 -0
- data/lib/jackal-cfn/resource/ami_manager.rb +14 -9
- data/lib/jackal-cfn/utils/fog.rb +3 -3
- data/lib/jackal-cfn/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82ce644625dd07609c7f577d4aac80ad289ce94b
|
4
|
+
data.tar.gz: 3052efa5fbc0b06279e2adb15a5e829cf36c41df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb1df43542af6ed17f680cbc28482fd4270f00b27a9487e20097f714131b61a009db69a94d1e65aa2c6bb096db5e32564919e30b9c247da9dec51f91c68a169c
|
7
|
+
data.tar.gz: 77b196a91a89cafb1c1ee1d1a7f2e7ca700d4d0ee813b87b5c4a195b66cf8a718e99cac5aa01d524f2f4d6124a2a683d576068e137962ac94730252a4c5f347c
|
data/CHANGELOG.md
CHANGED
@@ -33,6 +33,11 @@ module Jackal
|
|
33
33
|
|
34
34
|
PHYSICAL_ID_JOINER = '__-__'
|
35
35
|
|
36
|
+
# Ensure fog library is loaded
|
37
|
+
def setup(*_)
|
38
|
+
require 'fog'
|
39
|
+
end
|
40
|
+
|
36
41
|
# Process message, send value back to CFN
|
37
42
|
#
|
38
43
|
# @param message [Carnivore::Message]
|
@@ -42,7 +47,7 @@ module Jackal
|
|
42
47
|
properties = rekey_hash(cfn_resource[:resource_properties])
|
43
48
|
parameters = rekey_hash(properties[:parameters])
|
44
49
|
cfn_response = build_response(cfn_resource)
|
45
|
-
case cfn_resource[:request_type]
|
50
|
+
case cfn_resource[:request_type].to_sym
|
46
51
|
when :create
|
47
52
|
ami_response_update(cfn_response, parameters)
|
48
53
|
when :delete
|
@@ -50,8 +55,8 @@ module Jackal
|
|
50
55
|
when :update
|
51
56
|
else
|
52
57
|
error "Unknown request type received: #{cfn_resource[:request_type].inspect}"
|
53
|
-
|
54
|
-
|
58
|
+
cfn_response['Status'] = 'FAILED'
|
59
|
+
cfn_response['Reason'] = 'Unknown request type received'
|
55
60
|
end
|
56
61
|
respond_to_stack(cfn_response, cfn_resource[:response_url])
|
57
62
|
job_completed(:jackal_cfn, payload, message)
|
@@ -81,11 +86,11 @@ module Jackal
|
|
81
86
|
ami_id = payload[:physical_resource_id].split(PHYSICAL_ID_JOINER).last
|
82
87
|
begin
|
83
88
|
compute_api(parameters[:region]).deregister_image(ami_id)
|
84
|
-
rescue Fog::Compute::AWS::Error => e
|
85
|
-
warn "
|
86
|
-
response['Reason'] = e.
|
89
|
+
rescue ::Fog::Compute::AWS::Error => e
|
90
|
+
warn "Failed to remove AMI: #{e.class}: #{e}"
|
91
|
+
response['Reason'] = "Failed to remove AMI resource: #{e}. Ignoring."
|
87
92
|
rescue => e
|
88
|
-
error "
|
93
|
+
error "Unexpected error removing AMI: #{e.class}: #{e}"
|
89
94
|
response['Status'] = 'FAILED'
|
90
95
|
response['Reason'] = e.message
|
91
96
|
end
|
@@ -97,9 +102,9 @@ module Jackal
|
|
97
102
|
# @param region [String] AWS region ami exists
|
98
103
|
# @return [Fog::Compute]
|
99
104
|
def compute_api(region)
|
100
|
-
Fog::Compute.new(
|
105
|
+
::Fog::Compute.new(
|
101
106
|
{:provider => :aws}.merge(
|
102
|
-
config.
|
107
|
+
config.get(:ami, :credentials, :compute).merge(
|
103
108
|
:region => region
|
104
109
|
)
|
105
110
|
)
|
data/lib/jackal-cfn/utils/fog.rb
CHANGED
@@ -14,7 +14,7 @@ module Jackal
|
|
14
14
|
# @return [Fog::Service]
|
15
15
|
# @note extracts credentials from confg at :api -> [type | :default]
|
16
16
|
def api_for(type)
|
17
|
-
klass = Fog.constants.detect do |const|
|
17
|
+
klass = ::Fog.constants.detect do |const|
|
18
18
|
snakecase(const).to_s == type.to_s
|
19
19
|
end
|
20
20
|
if(klass)
|
@@ -27,7 +27,7 @@ module Jackal
|
|
27
27
|
key = credentials.to_a.flatten.push(klass).sort.hash
|
28
28
|
Thread.current[:cfn_apis] ||= Smash.new
|
29
29
|
unless(Thread.current[:cfn_apis][key])
|
30
|
-
Thread.current[:cfn_apis][key] = Fog.const_get(klass).new(credentials)
|
30
|
+
Thread.current[:cfn_apis][key] = ::Fog.const_get(klass).new(credentials)
|
31
31
|
end
|
32
32
|
Thread.current[:cfn_apis][key]
|
33
33
|
else
|
@@ -52,7 +52,7 @@ module Jackal
|
|
52
52
|
[var, api.instance_variable_get(var)]
|
53
53
|
end.flatten.compact.map(&:to_s).push(api.service_name).sort.hash
|
54
54
|
if(Thread.current[:cfn_assume_apis].get(key, :expires).to_i < Time.now.to_i + 5)
|
55
|
-
sts = Fog::AWS::STS.new(
|
55
|
+
sts = ::Fog::AWS::STS.new(
|
56
56
|
config.fetch(
|
57
57
|
:api, :sts, config.get(
|
58
58
|
:api, :default
|
data/lib/jackal-cfn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jackal-cfn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jackal
|