skeme 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/cloud_providers/aws.rb +36 -6
- data/skeme.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/cloud_providers/aws.rb
CHANGED
@@ -17,13 +17,23 @@ module Skeme
|
|
17
17
|
module CloudProviders
|
18
18
|
class Aws
|
19
19
|
@@logger = nil
|
20
|
-
@@
|
20
|
+
@@fog_aws_computes = {}
|
21
21
|
|
22
22
|
def initialize(options={})
|
23
23
|
@@logger = options[:logger]
|
24
24
|
if options[:aws_access_key_id] && options[:aws_secret_access_key]
|
25
25
|
@@logger.info("AWS credentials supplied. EC2 Tagging Enabled.")
|
26
|
-
|
26
|
+
fog_aws_compute = Fog::Compute.new({:aws_access_key_id => options[:aws_access_key_id], :aws_secret_access_key => options[:aws_secret_access_key], :provider => 'AWS'})
|
27
|
+
fog_aws_compute.describe_regions.body['regionInfo'].each do |region|
|
28
|
+
@@fog_aws_computes.store(region['regionName'],
|
29
|
+
Fog::Compute.new({
|
30
|
+
:aws_access_key_id => options[:aws_access_key_id],
|
31
|
+
:aws_secret_access_key => options[:aws_secret_access_key],
|
32
|
+
:provider => 'AWS',
|
33
|
+
:host => region['regionEndpoint']
|
34
|
+
})
|
35
|
+
)
|
36
|
+
end
|
27
37
|
end
|
28
38
|
end
|
29
39
|
|
@@ -38,7 +48,7 @@ module Skeme
|
|
38
48
|
private
|
39
49
|
|
40
50
|
def tag(params={})
|
41
|
-
if @@
|
51
|
+
if @@fog_aws_computes
|
42
52
|
tag = params[:ec2_tag] || params[:tag]
|
43
53
|
setting = params[:action] == "set"
|
44
54
|
|
@@ -47,11 +57,31 @@ module Skeme
|
|
47
57
|
supplied_id_type.each do |resource_id_key|
|
48
58
|
resource_id = params[resource_id_key]
|
49
59
|
if setting
|
50
|
-
|
51
|
-
@@
|
60
|
+
not_found_exceptions = []
|
61
|
+
@@fog_aws_computes.each do |key,val|
|
62
|
+
begin
|
63
|
+
val.create_tags(resource_id, {tag => nil})
|
64
|
+
@@logger.info("Tagging AWS resource id (#{resource_id}) with (#{tag}) in AWS cloud (#{key})")
|
65
|
+
rescue Fog::Service::NotFound => e
|
66
|
+
not_found_exceptions << e
|
67
|
+
end
|
68
|
+
end
|
69
|
+
if not_found_exceptions.count == @@fog_aws_computes.count
|
70
|
+
raise not_found_exceptions.first
|
71
|
+
end
|
52
72
|
else
|
53
73
|
@@logger.info("Removing tag (#{tag}) from AWS resource id (#{resource_id})")
|
54
|
-
|
74
|
+
not_found_exceptions = []
|
75
|
+
@@fog_aws_computes.each do |key,val|
|
76
|
+
begin
|
77
|
+
val.delete_tags(resource_id, {tag => nil})
|
78
|
+
rescue Fog::Service::NotFound => e
|
79
|
+
not_found_exceptions << e
|
80
|
+
end
|
81
|
+
end
|
82
|
+
if not_found_exceptions.count == @@fog_aws_computes.count
|
83
|
+
raise not_found_exceptions.first
|
84
|
+
end
|
55
85
|
end
|
56
86
|
|
57
87
|
end
|
data/skeme.gemspec
CHANGED
metadata
CHANGED