cloudster 2.8.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.8.0
1
+ 2.9.0
data/cloudster.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cloudster"
8
- s.version = "2.8.0"
8
+ s.version = "2.9.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"]
@@ -191,6 +191,35 @@ module Cloudster
191
191
  return endpoints
192
192
  end
193
193
 
194
+ # Returns all EC2 dns names 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_ec2_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 instance details where the key is the logical instance name and value is the instance detail
209
+ def get_ec2_details(options = {})
210
+ stack_resources = resources(options)
211
+ ec2_resource_ids = get_ec2_resource_ids(stack_resources)
212
+ ec2 = Fog::Compute::AWS.new(:aws_access_key_id => @access_key_id, :aws_secret_access_key => @secret_access_key)
213
+ ec2_details = {}
214
+ ec2_resource_ids.each do |key, value|
215
+ ec2_instance_details = ec2.describe_instances('instance-id' => value)
216
+ ec2_details[key] = ec2_instance_details.body["reservationSet"][0]["instancesSet"][0]
217
+ end
218
+ return ec2_details
219
+ rescue
220
+ return nil
221
+ end
222
+
194
223
  # Returns an array containing a list of Resources in a stack
195
224
  #
196
225
  # ==== Examples
@@ -270,5 +299,16 @@ module Cloudster
270
299
  return rds_physical_ids
271
300
  end
272
301
 
302
+ #Returns an array containing the physical ids of EC2 resources
303
+ def get_ec2_resource_ids(stack_resources)
304
+ ec2_resource_ids = {}
305
+ 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
309
+ end
310
+ return ec2_resource_ids
311
+ end
312
+
273
313
  end
274
314
  end
data/spec/ec2_spec.rb CHANGED
@@ -16,7 +16,6 @@ describe Cloudster::Ec2 do
16
16
  it "should return a ruby hash for the resource cloudformation template" do
17
17
  ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => 'name', :instance_type => 't1.micro', :security_groups => ["testSecurityGroup1", "testSecurityGroup2"] )
18
18
  ec2.template.should == {'Resources' => {'name' => {'Type' => 'AWS::EC2::Instance', 'Properties' => {"KeyName" => 'testkey', "ImageId" => 'image_id', "InstanceType" => 't1.micro', "SecurityGroups" => ["testSecurityGroup1", "testSecurityGroup2"]} }}}
19
- puts ec2.template.to_json
20
19
  end
21
20
  end
22
21
  describe '.template' do
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.8.0
4
+ version: 2.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -158,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  segments:
160
160
  - 0
161
- hash: -464146239
161
+ hash: -799207843
162
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  none: false
164
164
  requirements: