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 CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -17,13 +17,23 @@ module Skeme
17
17
  module CloudProviders
18
18
  class Aws
19
19
  @@logger = nil
20
- @@fog_aws_compute = nil
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
- @@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'})
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 @@fog_aws_compute
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
- @@logger.info("Tagging AWS resource id (#{resource_id}) with (#{tag})")
51
- @@fog_aws_compute.create_tags(resource_id, {tag => nil})
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
- @@fog_aws_compute.delete_tags(resource_id, {tag => nil})
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{skeme}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan J. Geyer"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skeme
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan J. Geyer