continuent-tools-core 0.10.6 → 0.10.7

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/providers/awsec2.rb +43 -35
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98ee92f1a8d4f2e609211c326b0fe054e9a048ad
4
- data.tar.gz: 1a99ad83f75681fca485e740677e876d56fc519f
3
+ metadata.gz: 61c0fd7050e745e23b953ed0a2deee4423eaff82
4
+ data.tar.gz: 4d1ad1829623ec32ea08a68408a7d1c41cb067a7
5
5
  SHA512:
6
- metadata.gz: e97a7d38b5089aa673929764ccac1fa0331921359143e241148d3e693288163c01051a5f13150e80a81996a592ffc167b662fa46d48b870fbe13c4488374295e
7
- data.tar.gz: 9da41564c3b4534072dac80f4680fa207b95d6841e7921c5006d034103282d2c859c641b612ae995b7ccd33d0465aec668879dc73a1f065ab20a9834aad0e6ff
6
+ metadata.gz: 676a3ede37740ce80ad7eb803ef4a4cd11fee3b7bba4b23bedd5d142c662341d8ceaf42a7d60ecd5c719bb2576aa7503d894b3967d75c8738419c8d257f382e2
7
+ data.tar.gz: 8026fb1fe97b0b7fda0aadf846a064b487adec01cab01397c139144721f10e7ba6b518027da6389976c9ffe02ecb4a5c2c960f1fbd36eaaa1b44b24af65a4529
data/providers/awsec2.rb CHANGED
@@ -75,55 +75,63 @@ class AWSEC2TungstenDirectoryProvider < TungstenDirectoryProvider
75
75
 
76
76
  begin
77
77
  region_ec2 = AWS::EC2.new(:region => region)
78
- instances = region_ec2.instances().filter('instance-state-name', "running")
78
+ instances = nil
79
+
80
+ AWS.start_memoizing
81
+ AWS.memoize do
82
+ instances = region_ec2.instances().filter('instance-state-name', "running")
79
83
 
80
- if aws_info.has_key?("tag_key")
81
- if aws_info.has_key?("tag_value")
82
- instances = instances.with_tag(aws_info["tag_key"], aws_info["tag_value"])
84
+ if aws_info.has_key?("tag_key")
85
+ if aws_info.has_key?("tag_value")
86
+ instances = instances.with_tag(aws_info["tag_key"], aws_info["tag_value"])
87
+ else
88
+ instances = instances.tagged(aws_info["tag_key"])
89
+ end
83
90
  else
84
- instances = instances.tagged(aws_info["tag_key"])
91
+ instances = instances.tagged('tungsten-ServerType')
85
92
  end
86
- else
87
- instances = instances.tagged('tungsten-ServerType')
88
- end
89
- instances.each{
90
- |ins|
91
- tags = ins.tags.to_h()
93
+ instances.each{
94
+ |ins|
95
+ tags = ins.tags.to_h()
92
96
 
93
- name = tags.to_h()[hostname_tag]
97
+ name = tags.to_h()[hostname_tag]
94
98
 
95
- if name.to_s() == "" && require_hostname_tag == false
96
- # Allow the DEFAULT_HOSTNAME_TAG to be used as a backup
97
- name = tags.to_h()[DEFAULT_HOSTNAME_TAG]
98
- end
99
+ if name.to_s() == "" && require_hostname_tag == false
100
+ # Allow the DEFAULT_HOSTNAME_TAG to be used as a backup
101
+ name = tags.to_h()[DEFAULT_HOSTNAME_TAG]
102
+ end
99
103
 
100
- if name.to_s() == ""
101
- TU.error("Unable to identify the hostname for #{ins.id} in #{region}")
102
- end
104
+ if name.to_s() == ""
105
+ TU.error("Unable to identify the hostname for #{ins.id} in #{region}")
106
+ end
103
107
 
104
108
 
105
- if ins.vpc_id != nil
106
- location = ins.availability_zone + "." + ins.vpc_id
107
- else
108
- location = ins.availability_zone
109
- end
109
+ if ins.vpc_id != nil
110
+ location = ins.availability_zone + "." + ins.vpc_id
111
+ else
112
+ location = ins.availability_zone
113
+ end
110
114
 
111
- TU.debug("Found #{ins.id}")
112
- region_results[index][name] = {
113
- 'id' => ins.id.to_s(),
114
- 'hostname' => name,
115
- 'location' => location,
116
- 'public-address' => ins.public_ip_address,
117
- 'private-address' => ins.private_ip_address,
118
- 'tags' => tags.to_h(),
119
- 'provider' => "aws.ec2",
120
- 'autodetect-key' => @key
115
+ TU.debug("Found #{ins.id}")
116
+ region_results[index][name] = {
117
+ 'id' => ins.id.to_s(),
118
+ 'hostname' => name,
119
+ 'location' => location,
120
+ 'public-address' => ins.public_ip_address,
121
+ 'private-address' => ins.private_ip_address,
122
+ 'tags' => tags.to_h(),
123
+ 'provider' => "aws.ec2",
124
+ 'autodetect-key' => @key
125
+ }
121
126
  }
122
- }
127
+ end
128
+ AWS.stop_memoizing
123
129
  rescue AWS::EC2::Errors::AuthFailure => af
124
130
  TU.debug("Unable to find instances in #{region}: #{af.message}. Operation will continue.")
131
+ AWS.stop_memoizing
125
132
  rescue => e
126
133
  TU.debug("Error finding instances in #{region}: #{e.message}")
134
+ AWS.stop_memoizing
127
135
  raise e
128
136
  end
129
137
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: continuent-tools-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.6
4
+ version: 0.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Continuent
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-01 00:00:00.000000000 Z
11
+ date: 2015-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_pure