cloudster 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/VERSION +1 -1
- data/cloudster.gemspec +1 -1
- data/lib/cloudster/ec2.rb +15 -9
- data/spec/ec2_spec.rb +5 -5
- metadata +2 -2
data/README.md
CHANGED
@@ -16,7 +16,8 @@ Create AWS EC2 resources as shown here:
|
|
16
16
|
|
17
17
|
app_server = Cloudster::Ec2.new(:name => 'AppServer',
|
18
18
|
:key_name => 'mykey',
|
19
|
-
:image_id => 'ami_image_id'
|
19
|
+
:image_id => 'ami_image_id',
|
20
|
+
:instance_type => 't1.micro'
|
20
21
|
)
|
21
22
|
app_server_2 = Cloudster::Ec2.new(:name => 'AppServer',
|
22
23
|
:key_name => 'mykey',
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.1.0
|
data/cloudster.gemspec
CHANGED
data/lib/cloudster/ec2.rb
CHANGED
@@ -11,7 +11,8 @@ module Cloudster
|
|
11
11
|
# ec2 = Cloudster::Ec2.new(
|
12
12
|
# :name => 'AppServer',
|
13
13
|
# :key_name => 'mykey',
|
14
|
-
# :image_id => 'ami_image_id'
|
14
|
+
# :image_id => 'ami_image_id',
|
15
|
+
# :instance_type => 't1.micro'
|
15
16
|
# )
|
16
17
|
#
|
17
18
|
# ==== Parameters
|
@@ -19,11 +20,13 @@ module Cloudster
|
|
19
20
|
# * :name: String containing the name for the Ec2 resource
|
20
21
|
# * :key_name: String containing the name of the keypair to be used for SSH
|
21
22
|
# * :image_id: String containing the AMI image id to be used while creating the Ec2 resource
|
23
|
+
# * :instance_type: String containing instance type ( Example : t1.micro )
|
22
24
|
def initialize(options = {})
|
23
25
|
require_options(options, [:name, :key_name, :image_id])
|
24
26
|
@name = options[:name]
|
25
27
|
@key_name = options[:key_name]
|
26
28
|
@image_id = options[:image_id]
|
29
|
+
@instance_type = options[:instance_type]
|
27
30
|
end
|
28
31
|
|
29
32
|
# Returns a Ruby hash version of the Cloud Formation template for the resource instance
|
@@ -32,14 +35,15 @@ module Cloudster
|
|
32
35
|
# ec2 = Cloudster::Ec2.new(
|
33
36
|
# :name => 'AppServer',
|
34
37
|
# :key_name => 'mykey',
|
35
|
-
# :image_id => 'ami_image_id'
|
38
|
+
# :image_id => 'ami_image_id',
|
39
|
+
# :instance_type => 't1.micro'
|
36
40
|
# )
|
37
41
|
# ec2.template
|
38
42
|
#
|
39
43
|
# ==== Returns
|
40
44
|
# * Ruby hash version of the Cloud Formation template for the resource instance
|
41
45
|
def template
|
42
|
-
Ec2.template({:name =>@name, :key_name => @key_name, :image_id => @image_id})
|
46
|
+
Ec2.template({:name =>@name, :key_name => @key_name, :image_id => @image_id, :instance_type => @instance_type})
|
43
47
|
end
|
44
48
|
|
45
49
|
# Class method that returns a Ruby hash version of the Cloud Formation template
|
@@ -48,7 +52,8 @@ module Cloudster
|
|
48
52
|
# template = Cloudster::Ec2.template(
|
49
53
|
# :name => 'AppServer',
|
50
54
|
# :key_name => 'mykey',
|
51
|
-
# :image_id => 'ami_image_id'
|
55
|
+
# :image_id => 'ami_image_id',
|
56
|
+
# :instance_type => 't1.micro'
|
52
57
|
# )
|
53
58
|
#
|
54
59
|
# ==== Parameters
|
@@ -57,20 +62,21 @@ module Cloudster
|
|
57
62
|
# * :name: String containing the name for the Ec2 resource
|
58
63
|
# * :key_name: String containing the name of the keypair to be used for SSH
|
59
64
|
# * :image_id: String containing the AMI image id to be used while creating the Ec2 resource
|
65
|
+
# * :instance_type: String containing instance type ( Example : t1.micro )
|
60
66
|
#
|
61
67
|
# ==== Returns
|
62
68
|
# * Ruby hash version of the Cloud Formation template
|
63
69
|
def self.template(options = {})
|
64
70
|
require_options(options, [:name, :key_name, :image_id])
|
71
|
+
properties = {}
|
72
|
+
properties.merge!({"KeyName" => options[:key_name], "ImageId" => options[:image_id]})
|
73
|
+
properties.merge!({"InstanceType" => options[:instance_type]}) unless options[:instance_type].nil?
|
65
74
|
template = {'Resources' => {
|
66
75
|
options[:name] => {
|
67
76
|
'Type' => 'AWS::EC2::Instance',
|
68
|
-
'Properties' =>
|
69
|
-
"KeyName" => options[:key_name],
|
70
|
-
"ImageId" => options[:image_id]
|
71
|
-
}
|
72
|
-
}
|
77
|
+
'Properties' => properties
|
73
78
|
}
|
79
|
+
}
|
74
80
|
}
|
75
81
|
return template
|
76
82
|
end
|
data/spec/ec2_spec.rb
CHANGED
@@ -9,13 +9,13 @@ describe Cloudster::Ec2 do
|
|
9
9
|
expect { Cloudster::Ec2.new() }.to raise_error(ArgumentError, 'Missing required argument: name,key_name,image_id')
|
10
10
|
end
|
11
11
|
it "should not raise argument error if all arguments are provided" do
|
12
|
-
expect { Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', name
|
12
|
+
expect { Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => 'name', :instance_type => 't1.micro') }.to_not raise_error
|
13
13
|
end
|
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
|
18
|
-
ec2.template.should == {'Resources' => {'name' => {'Type' => 'AWS::EC2::Instance', 'Properties' => {"KeyName" => 'testkey', "ImageId" => 'image_id'} }}}
|
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'} }}}
|
19
19
|
end
|
20
20
|
end
|
21
21
|
describe '.template' do
|
@@ -23,8 +23,8 @@ describe Cloudster::Ec2 do
|
|
23
23
|
expect { Cloudster::Ec2.template() }.to raise_error(ArgumentError, 'Missing required argument: name,key_name,image_id')
|
24
24
|
end
|
25
25
|
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
|
27
|
-
hash.should == {'Resources' => {'name' => {'Type' => 'AWS::EC2::Instance', 'Properties' => {"KeyName" => 'testkey', "ImageId" => 'image_id'} }}}
|
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'} }}}
|
28
28
|
end
|
29
29
|
end
|
30
30
|
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.
|
4
|
+
version: 2.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -162,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
162
|
version: '0'
|
163
163
|
segments:
|
164
164
|
- 0
|
165
|
-
hash: -
|
165
|
+
hash: -644821325
|
166
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
167
|
none: false
|
168
168
|
requirements:
|