cloudster 2.6.1 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -22,7 +22,6 @@ Create AWS resources :
22
22
  :validation_key => 'asd3e33880889098asdnmnnasd8900890a8sdmasdjna9s880808asdnmnasd90-a',
23
23
  :server_url => 'http://10.50.60.70:4000',
24
24
  :node_name => 'project.environment.appserver_1',
25
- :environment => 'production',
26
25
  :interval => 1800
27
26
  )
28
27
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.6.1
1
+ 2.7.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cloudster"
8
- s.version = "2.6.1"
8
+ s.version = "2.7.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-16"
12
+ s.date = "2012-11-18"
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 = [
@@ -20,9 +20,9 @@ module Cloudster
20
20
  # )
21
21
  def initialize(options = {})
22
22
  require_options(options, [:access_key_id, :secret_access_key])
23
- access_key_id = options[:access_key_id]
24
- secret_access_key = options[:secret_access_key]
25
- @cloud_formation = Fog::AWS::CloudFormation.new(:aws_access_key_id => access_key_id, :aws_secret_access_key => secret_access_key)
23
+ @access_key_id = options[:access_key_id]
24
+ @secret_access_key = options[:secret_access_key]
25
+ @cloud_formation = Fog::AWS::CloudFormation.new(:aws_access_key_id => @access_key_id, :aws_secret_access_key => @secret_access_key)
26
26
  end
27
27
 
28
28
  # Generates CloudFormation Template for the stack
@@ -164,5 +164,111 @@ module Cloudster
164
164
  return @cloud_formation.delete_stack(options[:stack_name])
165
165
  end
166
166
 
167
+ # Returns all RDS(database) endpoints in a stack
168
+ #
169
+ # ==== Examples
170
+ # cloud = Cloudster::Cloud.new(
171
+ # :access_key_id => 'aws_access_key_id'
172
+ # :secret_access_key => 'aws_secret_access_key',
173
+ # )
174
+ # cloud.get_database_endpoints(:stack_name => 'ShittyStack')
175
+ #
176
+ # ==== Parameters
177
+ # * options<~Hash>
178
+ # * :stack_name : A string which will contain the name of the stack
179
+ #
180
+ # ==== Returns
181
+ # * Array of hashes, example: [{:address => 'simcoprod01.cu7u2t4uz396.us-east-1.rds.amazonaws.com', :port => '3306'}]
182
+ def get_database_endpoints(options = {})
183
+ rds_physical_ids = get_rds_resource_ids(resources(options))
184
+ return [] if rds_physical_ids.empty?
185
+ rds = Fog::AWS::RDS.new(:aws_access_key_id => @access_key_id, :aws_secret_access_key => @secret_access_key)
186
+ endpoints = []
187
+ rds_physical_ids.each do |rds_physical_id|
188
+ endpoint = rds.describe_db_instances(rds_physical_id).body["DescribeDBInstancesResult"]["DBInstances"][0]["Endpoint"] rescue nil
189
+ endpoints << {:address => endpoint["Address"], :port => endpoint["Port"]} unless endpoint.nil?
190
+ end
191
+ return endpoints
192
+ end
193
+
194
+ # Returns an array containing a list of 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.resources(:stack_name => 'RDSStack')
202
+ #
203
+ # ==== Parameters
204
+ # * options<~Hash>
205
+ # * :stack_name : A string which will contain the name of the stack
206
+ #
207
+ # ==== Returns
208
+ # * Array of hashes, example: [{"Timestamp"=>2012-11-16 14:31:55 UTC, "ResourceStatus"=>"CREATE_COMPLETE", "StackId"=>"arn:aws::asd", "LogicalResourceId"=>"TestDB", "StackName"=>"RDSStack", "PhysicalResourceId"=>"rtad", "ResourceType"=>"AWS::RDS::DBInstance"}]
209
+ def resources(options = {})
210
+ require_options(options, [:stack_name])
211
+ return @cloud_formation.describe_stack_resources('StackName' => options[:stack_name]).body["StackResources"] rescue []
212
+ end
213
+
214
+ # Describes the attributes of a Stack
215
+ #
216
+ # ==== Examples
217
+ # cloud = Cloudster::Cloud.new(
218
+ # :access_key_id => 'aws_access_key_id'
219
+ # :secret_access_key => 'aws_secret_access_key',
220
+ # )
221
+ # cloud.describe(:stack_name => 'RDSStack')
222
+ #
223
+ # ==== Parameters
224
+ # * options<~Hash>
225
+ # * :stack_name : A string which will contain the name of the stack
226
+ #
227
+ # ==== Returns
228
+ # * Hash containing description of the stack
229
+ def describe(options = {})
230
+ require_options(options, [:stack_name])
231
+ return @cloud_formation.describe_stacks('StackName' => options[:stack_name]).body["Stacks"][0] rescue nil
232
+ end
233
+
234
+ # Returns the status of the stack
235
+ #
236
+ # ==== Examples
237
+ # cloud = Cloudster::Cloud.new(
238
+ # :access_key_id => 'aws_access_key_id'
239
+ # :secret_access_key => 'aws_secret_access_key',
240
+ # )
241
+ # cloud.status(:stack_name => 'RDSStack')
242
+ #
243
+ # ==== Parameters
244
+ # * options<~Hash>
245
+ # * :stack_name : A string which will contain the name of the stack
246
+ #
247
+ # ==== Returns
248
+ # * One of these strings :
249
+ # * CREATE_IN_PROGRESS
250
+ # * CREATE_FAILED
251
+ # * CREATE_COMPLETE
252
+ # * ROLLBACK_IN_PROGRESS
253
+ # * ROLLBACK_FAILED
254
+ # * ROLLBACK_COMPLETE
255
+ # * DELETE_IN_PROGRESS
256
+ # * DELETE_FAILED
257
+ def status(options = {})
258
+ require_options(options, [:stack_name])
259
+ description = describe(options)
260
+ return description["StackStatus"] rescue nil
261
+ end
262
+
263
+ private
264
+ #Returns an array containing the Physical Resource Id's of RDS resources
265
+ def get_rds_resource_ids(resources)
266
+ rds_physical_ids = []
267
+ resources.each do |resource|
268
+ rds_physical_ids << resource["PhysicalResourceId"] if resource["ResourceType"] == "AWS::RDS::DBInstance"
269
+ end
270
+ return rds_physical_ids
271
+ end
272
+
167
273
  end
168
274
  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.6.1
4
+ version: 2.7.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-16 00:00:00.000000000 Z
12
+ date: 2012-11-18 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: -610566703
161
+ hash: 991965789
162
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  none: false
164
164
  requirements: