cloudster 2.10.0 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ GEM
3
3
  specs:
4
4
  builder (3.1.4)
5
5
  diff-lcs (1.1.3)
6
- excon (0.16.8)
6
+ excon (0.16.10)
7
7
  fog (1.7.0)
8
8
  builder
9
9
  excon (~> 0.14)
@@ -26,9 +26,9 @@ GEM
26
26
  multi_json (1.3.7)
27
27
  net-scp (1.0.4)
28
28
  net-ssh (>= 1.99.1)
29
- net-ssh (2.6.1)
29
+ net-ssh (2.6.2)
30
30
  nokogiri (1.5.5)
31
- rake (10.0.1)
31
+ rake (10.0.2)
32
32
  rdoc (3.12)
33
33
  json (~> 1.4)
34
34
  rspec (2.12.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.10.0
1
+ 2.11.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cloudster"
8
- s.version = "2.10.0"
8
+ s.version = "2.11.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Emil Soman"]
12
- s.date = "2012-11-22"
12
+ s.date = "2012-11-23"
13
13
  s.description = "Cloudster is a Ruby gem that was born to cut the learning curve involved \n in writing your own CloudFormation templates. If you don't know what a CloudFormation template is, \n but know about the AWS Cloud offerings, you can still use cloudster to provision your stack. \n Still in infancy , cloudster can create a very basic stack like a breeze. All kinds of contribution welcome !"
14
14
  s.email = "emil.soman@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -180,7 +180,7 @@ module Cloudster
180
180
  # ==== Returns
181
181
  # * Array of hashes, example: [{:address => 'simcoprod01.cu7u2t4uz396.us-east-1.rds.amazonaws.com', :port => '3306'}]
182
182
  def get_database_endpoints(options = {})
183
- rds_physical_ids = get_rds_resource_ids(resources(options))
183
+ rds_physical_ids = get_resource_ids(resources(options), "AWS::RDS::DBInstance").values
184
184
  return [] if rds_physical_ids.empty?
185
185
  rds = Fog::AWS::RDS.new(:aws_access_key_id => @access_key_id, :aws_secret_access_key => @secret_access_key)
186
186
  endpoints = []
@@ -191,7 +191,34 @@ module Cloudster
191
191
  return endpoints
192
192
  end
193
193
 
194
- # Returns all EC2 dns names in a stack
194
+ # Get details of all RDS resources in a stack
195
+ #
196
+ # ==== Examples
197
+ # cloud = Cloudster::Cloud.new(
198
+ # :access_key_id => 'aws_access_key_id'
199
+ # :secret_access_key => 'aws_secret_access_key',
200
+ # )
201
+ # cloud.get_rds_details(:stack_name => 'ShittyStack')
202
+ #
203
+ # ==== Parameters
204
+ # * options<~Hash>
205
+ # * :stack_name : A string which will contain the name of the stack
206
+ #
207
+ # ==== Returns
208
+ # * A hash of RDS details where the key is the logical name and value is the RDS detail
209
+ def get_rds_details(options = {})
210
+ stack_resources = resources(options)
211
+ rds_resource_ids = get_resource_ids(stack_resources, "AWS::RDS::DBInstance")
212
+ rds = Fog::AWS::RDS.new(:aws_access_key_id => @access_key_id, :aws_secret_access_key => @secret_access_key)
213
+ rds_details = {}
214
+ rds_resource_ids.each do |key, value|
215
+ rds_instance_details = rds.describe_db_instances(value)
216
+ rds_details[key] = rds_instance_details.body["DescribeDBInstancesResult"]["DBInstances"][0] rescue nil
217
+ end
218
+ return rds_details
219
+ end
220
+
221
+ # Get details of all EC2 instances in a stack
195
222
  #
196
223
  # ==== Examples
197
224
  # cloud = Cloudster::Cloud.new(
@@ -208,16 +235,41 @@ module Cloudster
208
235
  # * A hash of instance details where the key is the logical instance name and value is the instance detail
209
236
  def get_ec2_details(options = {})
210
237
  stack_resources = resources(options)
211
- ec2_resource_ids = get_ec2_resource_ids(stack_resources)
238
+ ec2_resource_ids = get_resource_ids(stack_resources, "AWS::EC2::Instance")
212
239
  ec2 = Fog::Compute::AWS.new(:aws_access_key_id => @access_key_id, :aws_secret_access_key => @secret_access_key)
213
240
  ec2_details = {}
214
241
  ec2_resource_ids.each do |key, value|
215
242
  ec2_instance_details = ec2.describe_instances('instance-id' => value)
216
- ec2_details[key] = ec2_instance_details.body["reservationSet"][0]["instancesSet"][0]
243
+ ec2_details[key] = ec2_instance_details.body["reservationSet"][0]["instancesSet"][0] rescue nil
217
244
  end
218
245
  return ec2_details
219
- rescue
220
- return nil
246
+ end
247
+
248
+ # Get details of all Elastic Load Balancers in the stack
249
+ #
250
+ # ==== Examples
251
+ # cloud = Cloudster::Cloud.new(
252
+ # :access_key_id => 'aws_access_key_id'
253
+ # :secret_access_key => 'aws_secret_access_key',
254
+ # )
255
+ # cloud.get_elb_details(:stack_name => 'ShittyStack')
256
+ #
257
+ # ==== Parameters
258
+ # * options<~Hash>
259
+ # * :stack_name : A string which will contain the name of the stack
260
+ #
261
+ # ==== Returns
262
+ # * A hash containing elb details where the key is the logical name and value contains the details
263
+ def get_elb_details(options = {})
264
+ stack_resources = resources(options)
265
+ elb_resource_ids = get_resource_ids(stack_resources, "AWS::ElasticLoadBalancing::LoadBalancer")
266
+ elb = Fog::AWS::ELB.new(:aws_access_key_id => @access_key_id, :aws_secret_access_key => @secret_access_key)
267
+ elb_details = {}
268
+ elb_resource_ids.each do |key, value|
269
+ elb_instance_details = elb.describe_load_balancers("LoadBalancerNames" => [value])
270
+ elb_details[key] = elb_instance_details.body["DescribeLoadBalancersResult"]["LoadBalancerDescriptions"][0] rescue nil
271
+ end
272
+ return elb_details
221
273
  end
222
274
 
223
275
  # Returns an array containing a list of Resources in a stack
@@ -290,24 +342,18 @@ module Cloudster
290
342
  end
291
343
 
292
344
  private
293
- #Returns an array containing the Physical Resource Id's of RDS resources
294
- def get_rds_resource_ids(resources)
295
- rds_physical_ids = []
296
- resources.each do |resource|
297
- rds_physical_ids << resource["PhysicalResourceId"] if resource["ResourceType"] == "AWS::RDS::DBInstance"
298
- end
299
- return rds_physical_ids
300
- end
301
345
 
302
- #Returns an array containing the physical ids of EC2 resources
303
- def get_ec2_resource_ids(stack_resources)
304
- ec2_resource_ids = {}
346
+ #Returns a hash {<logical_resource_id> => <physical_resource_id>}
347
+ def get_resource_ids(stack_resources, resource_type)
348
+ resource_ids = {}
305
349
  stack_resources.each do |resource|
306
- key = resource["LogicalResourceId"] if resource["ResourceType"] == "AWS::EC2::Instance"
307
- value = resource["PhysicalResourceId"] if resource["ResourceType"] == "AWS::EC2::Instance"
308
- ec2_resource_ids[key] = value
350
+ if resource["ResourceType"] == resource_type
351
+ key = resource["LogicalResourceId"]
352
+ value = resource["PhysicalResourceId"]
353
+ resource_ids[key] = value
354
+ end
309
355
  end
310
- return ec2_resource_ids
356
+ return resource_ids
311
357
  end
312
358
 
313
359
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudster
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.11.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-22 00:00:00.000000000 Z
12
+ date: 2012-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -158,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  segments:
160
160
  - 0
161
- hash: 929236787
161
+ hash: 198939057
162
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  none: false
164
164
  requirements: