cloudster 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,7 +15,8 @@ Create AWS resources :
15
15
  app_server = Cloudster::Ec2.new(:name => 'AppServer',
16
16
  :key_name => 'mykey',
17
17
  :image_id => 'ami_image_id',
18
- :instance_type => 't1.micro'
18
+ :instance_type => 't1.micro',
19
+ :security_groups => ["TopSecurityGroup"]
19
20
  )
20
21
 
21
22
  chef_client = Cloudster::ChefClient.new(
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.7.0
1
+ 2.8.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cloudster"
8
- s.version = "2.7.0"
8
+ s.version = "2.8.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-18"
12
+ s.date = "2012-11-21"
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 = [
@@ -13,7 +13,8 @@ module Cloudster
13
13
  # :name => 'AppServer',
14
14
  # :key_name => 'mykey',
15
15
  # :image_id => 'ami_image_id',
16
- # :instance_type => 't1.micro'
16
+ # :instance_type => 't1.micro',
17
+ # :security_groups => ["TopSecurityGroup"]
17
18
  # )
18
19
  #
19
20
  # ==== Parameters
@@ -22,12 +23,14 @@ module Cloudster
22
23
  # * :key_name: String containing the name of the keypair to be used for SSH
23
24
  # * :image_id: String containing the AMI image id to be used while creating the Ec2 resource
24
25
  # * :instance_type: String containing instance type ( Example : t1.micro )
26
+ # * :security_groups: Array containing names of existing SecurityGroups already defined using AWS console
25
27
  def initialize(options = {})
26
28
  require_options(options, [:name, :key_name, :image_id])
27
29
  @name = options[:name]
28
30
  @key_name = options[:key_name]
29
31
  @image_id = options[:image_id]
30
32
  @instance_type = options[:instance_type]
33
+ @security_groups = options[:security_groups]
31
34
  end
32
35
 
33
36
  # Returns a Ruby hash version of the Cloud Formation template for the resource instance
@@ -37,14 +40,15 @@ module Cloudster
37
40
  # :name => 'AppServer',
38
41
  # :key_name => 'mykey',
39
42
  # :image_id => 'ami_image_id',
40
- # :instance_type => 't1.micro'
43
+ # :instance_type => 't1.micro',
44
+ # :security_groups => ["SecurityGroup"]
41
45
  # )
42
46
  # ec2.template
43
47
  #
44
48
  # ==== Returns
45
49
  # * Ruby hash version of the Cloud Formation template for the resource instance
46
50
  def template
47
- @template ||= Ec2.template({:name =>@name, :key_name => @key_name, :image_id => @image_id, :instance_type => @instance_type})
51
+ @template ||= Ec2.template({:name =>@name, :key_name => @key_name, :image_id => @image_id, :instance_type => @instance_type, :security_groups => @security_groups})
48
52
  end
49
53
 
50
54
  # Class method that returns a Ruby hash version of the Cloud Formation template
@@ -64,6 +68,7 @@ module Cloudster
64
68
  # * :key_name: String containing the name of the keypair to be used for SSH
65
69
  # * :image_id: String containing the AMI image id to be used while creating the Ec2 resource
66
70
  # * :instance_type: String containing instance type ( Example : t1.micro )
71
+ # * :security_groups: Array containing names of existing SecurityGroups already defined using AWS console
67
72
  #
68
73
  # ==== Returns
69
74
  # * Ruby hash version of the Cloud Formation template
@@ -72,6 +77,10 @@ module Cloudster
72
77
  properties = {}
73
78
  properties.merge!({"KeyName" => options[:key_name], "ImageId" => options[:image_id]})
74
79
  properties.merge!({"InstanceType" => options[:instance_type]}) unless options[:instance_type].nil?
80
+ unless options[:security_groups].nil?
81
+ security_groups = options[:security_groups].to_a
82
+ properties.merge!({"SecurityGroups" => security_groups})
83
+ end
75
84
  template = {'Resources' => {
76
85
  options[:name] => {
77
86
  'Type' => 'AWS::EC2::Instance',
@@ -14,8 +14,9 @@ describe Cloudster::Ec2 do
14
14
  end
15
15
  describe '#template' do
16
16
  it "should return a ruby hash for the resource cloudformation template" do
17
- ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => 'name', :instance_type => 't1.micro' )
18
- ec2.template.should == {'Resources' => {'name' => {'Type' => 'AWS::EC2::Instance', 'Properties' => {"KeyName" => 'testkey', "ImageId" => 'image_id', "InstanceType" => 't1.micro'} }}}
17
+ ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => 'name', :instance_type => 't1.micro', :security_groups => ["testSecurityGroup1", "testSecurityGroup2"] )
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
19
20
  end
20
21
  end
21
22
  describe '.template' do
@@ -23,8 +24,8 @@ describe Cloudster::Ec2 do
23
24
  expect { Cloudster::Ec2.template() }.to raise_error(ArgumentError, 'Missing required argument: name,key_name,image_id')
24
25
  end
25
26
  it "should return a ruby hash for the resource cloudformation template" do
26
- hash = Cloudster::Ec2.template(:key_name => 'testkey', :image_id => 'image_id', :name => 'name', :instance_type => 't1.micro')
27
- hash.should == {'Resources' => {'name' => {'Type' => 'AWS::EC2::Instance', 'Properties' => {"KeyName" => 'testkey', "ImageId" => 'image_id', "InstanceType" => 't1.micro'} }}}
27
+ hash = Cloudster::Ec2.template(:key_name => 'testkey', :image_id => 'image_id', :name => 'name', :instance_type => 't1.micro', :security_groups => ["testSecurityGroup1"])
28
+ hash.should == {'Resources' => {'name' => {'Type' => 'AWS::EC2::Instance', 'Properties' => {"KeyName" => 'testkey', "ImageId" => 'image_id', "InstanceType" => 't1.micro', "SecurityGroups" => ["testSecurityGroup1"]} }}}
28
29
  end
29
30
  end
30
31
  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.7.0
4
+ version: 2.8.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-18 00:00:00.000000000 Z
12
+ date: 2012-11-21 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: 991965789
161
+ hash: -464146239
162
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  none: false
164
164
  requirements: