cloudster 2.19.1 → 2.19.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/VERSION +1 -1
- data/cloudster.gemspec +2 -2
- data/lib/cloudster/ec2.rb +12 -0
- data/lib/cloudster/s3.rb +8 -9
- data/spec/chef_client_spec.rb +15 -0
- data/spec/cloud_spec.rb +39 -11
- data/spec/ec2_spec.rb +56 -2
- data/spec/elastic_ip_spec.rb +15 -0
- metadata +3 -3
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.19.
|
1
|
+
2.19.2
|
data/cloudster.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "cloudster"
|
8
|
-
s.version = "2.19.
|
8
|
+
s.version = "2.19.2"
|
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 = "2013-01-
|
12
|
+
s.date = "2013-01-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 = [
|
data/lib/cloudster/ec2.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Cloudster
|
2
2
|
#==Ec2 resource
|
3
|
+
#Output values : availability_zone, private_dns_name, public_dns_name, private_ip, public_ip
|
3
4
|
class Ec2
|
5
|
+
extend Cloudster::Output
|
4
6
|
|
5
7
|
attr_accessor :template, :name
|
6
8
|
# Initialize an Ec2 instance
|
@@ -88,6 +90,16 @@ module Cloudster
|
|
88
90
|
}
|
89
91
|
}
|
90
92
|
}
|
93
|
+
outputs = {
|
94
|
+
options[:name] => {
|
95
|
+
'availablity_zone' => {'Fn::GetAtt' => [options[:name], 'AvailabilityZone']},
|
96
|
+
'private_dns_name' => {'Fn::GetAtt' => [options[:name], 'PrivateDnsName']},
|
97
|
+
'public_dns_name' => {'Fn::GetAtt' => [options[:name], 'PublicDnsName']},
|
98
|
+
'private_ip' => {'Fn::GetAtt' => [options[:name], 'PrivateIp']},
|
99
|
+
'public_ip' => {'Fn::GetAtt' => [options[:name], 'PublicIp']}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
template['Outputs'] = output_template(outputs)
|
91
103
|
return template
|
92
104
|
end
|
93
105
|
|
data/lib/cloudster/s3.rb
CHANGED
@@ -43,8 +43,7 @@ module Cloudster
|
|
43
43
|
@template ||= S3.template({
|
44
44
|
:name => @name,
|
45
45
|
:access_control => @access_control,
|
46
|
-
:website_configuration => @website_configuration
|
47
|
-
:outputs => @outputs
|
46
|
+
:website_configuration => @website_configuration
|
48
47
|
})
|
49
48
|
end
|
50
49
|
|
@@ -70,13 +69,6 @@ module Cloudster
|
|
70
69
|
unless options[:website_configuration].nil?
|
71
70
|
properties.merge!({"WebsiteConfiguration" => {"IndexDocument" => options[:website_configuration]["index_document"], "ErrorDocument" => options[:website_configuration]["error_document"]}})
|
72
71
|
end
|
73
|
-
outputs = {
|
74
|
-
options[:name] => {
|
75
|
-
'bucket_name' => { 'Ref' => options[:name] },
|
76
|
-
'dns_name' => {'Fn::GetAtt' => [options[:name], 'DomainName']},
|
77
|
-
'website_url' => {'Fn::GetAtt' => [options[:name], 'WebsiteURL']}
|
78
|
-
}
|
79
|
-
}
|
80
72
|
template = {
|
81
73
|
'Resources' => {
|
82
74
|
options[:name] => {
|
@@ -85,6 +77,13 @@ module Cloudster
|
|
85
77
|
}
|
86
78
|
}
|
87
79
|
}
|
80
|
+
outputs = {
|
81
|
+
options[:name] => {
|
82
|
+
'bucket_name' => { 'Ref' => options[:name] },
|
83
|
+
'dns_name' => {'Fn::GetAtt' => [options[:name], 'DomainName']},
|
84
|
+
'website_url' => {'Fn::GetAtt' => [options[:name], 'WebsiteURL']}
|
85
|
+
}
|
86
|
+
}
|
88
87
|
template['Outputs'] = output_template(outputs)
|
89
88
|
return template
|
90
89
|
end
|
data/spec/chef_client_spec.rb
CHANGED
@@ -80,6 +80,21 @@ describe Cloudster::ChefClient do
|
|
80
80
|
}
|
81
81
|
}
|
82
82
|
}
|
83
|
+
},
|
84
|
+
"Outputs" => {
|
85
|
+
"AppServer"=>{
|
86
|
+
"Value"=>{
|
87
|
+
"Fn::Join"=>[",",
|
88
|
+
[
|
89
|
+
{"Fn::Join"=>["|", ["availablity_zone", {"Fn::GetAtt"=>["AppServer", "AvailabilityZone"]}]]},
|
90
|
+
{"Fn::Join"=>["|", ["private_dns_name", {"Fn::GetAtt"=>["AppServer", "PrivateDnsName"]}]]},
|
91
|
+
{"Fn::Join"=>["|", ["public_dns_name", {"Fn::GetAtt"=>["AppServer", "PublicDnsName"]}]]},
|
92
|
+
{"Fn::Join"=>["|", ["private_ip", {"Fn::GetAtt"=>["AppServer", "PrivateIp"]}]]},
|
93
|
+
{"Fn::Join"=>["|", ["public_ip", {"Fn::GetAtt"=>["AppServer", "PublicIp"]}]]}
|
94
|
+
]
|
95
|
+
]
|
96
|
+
}
|
97
|
+
}
|
83
98
|
}
|
84
99
|
}
|
85
100
|
end
|
data/spec/cloud_spec.rb
CHANGED
@@ -11,21 +11,21 @@ describe Cloudster::Cloud do
|
|
11
11
|
end
|
12
12
|
describe '#template' do
|
13
13
|
it "should return a ruby hash for the stack cloudformation template" do
|
14
|
-
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => '
|
15
|
-
ec2_1 = Cloudster::Ec2.new(:key_name => 'testkey1', :image_id => 'image_id1', :name => '
|
14
|
+
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => 'Ec2Instance1')
|
15
|
+
ec2_1 = Cloudster::Ec2.new(:key_name => 'testkey1', :image_id => 'image_id1', :name => 'Ec2Instance2')
|
16
16
|
rds = Cloudster::Rds.new(:name => 'MySqlDB', :storage_size => '10')
|
17
|
-
elb = Cloudster::Elb.new(:name => 'ELB', :instance_names => ['
|
17
|
+
elb = Cloudster::Elb.new(:name => 'ELB', :instance_names => ['Ec2Instance1','Ec2Instance2'])
|
18
18
|
cloud = Cloudster::Cloud.new(:access_key_id => 'test', :secret_access_key => 'test')
|
19
19
|
cloud.template(:resources => [ec2, ec2_1, rds, elb], :description => 'test template').should == {"AWSTemplateFormatVersion"=>"2010-09-09",
|
20
20
|
"Description"=>"test template",
|
21
21
|
"Resources"=>{
|
22
|
-
"
|
22
|
+
"Ec2Instance1"=>{
|
23
23
|
"Type"=>"AWS::EC2::Instance",
|
24
24
|
"Properties"=>{
|
25
25
|
"KeyName"=>"testkey",
|
26
26
|
"ImageId"=>"image_id"}
|
27
27
|
},
|
28
|
-
"
|
28
|
+
"Ec2Instance2"=>{
|
29
29
|
"Type"=>"AWS::EC2::Instance",
|
30
30
|
"Properties"=>{
|
31
31
|
"KeyName"=>"testkey1",
|
@@ -62,7 +62,35 @@ describe Cloudster::Cloud do
|
|
62
62
|
"UnhealthyThreshold" => "5",
|
63
63
|
"Interval" => "30", "Timeout" => "5"
|
64
64
|
},
|
65
|
-
"Instances" => [{ "Ref" => "
|
65
|
+
"Instances" => [{ "Ref" => "Ec2Instance1"}, {"Ref" => "Ec2Instance2"}]}
|
66
|
+
}
|
67
|
+
},
|
68
|
+
"Outputs" => {
|
69
|
+
"Ec2Instance1"=> {
|
70
|
+
"Value" => {
|
71
|
+
"Fn::Join" => ["," ,
|
72
|
+
[
|
73
|
+
{"Fn::Join" => ["|", ["availablity_zone", {'Fn::GetAtt' => ['Ec2Instance1', 'AvailabilityZone']}]]},
|
74
|
+
{"Fn::Join" => ["|", ["private_dns_name", {'Fn::GetAtt' => ['Ec2Instance1', 'PrivateDnsName']}]]},
|
75
|
+
{"Fn::Join" => ["|", ["public_dns_name", {'Fn::GetAtt' => ['Ec2Instance1', 'PublicDnsName']}]]},
|
76
|
+
{"Fn::Join" => ["|", ["private_ip", {'Fn::GetAtt' => ['Ec2Instance1', 'PrivateIp']}]]},
|
77
|
+
{"Fn::Join" => ["|", ["public_ip", {'Fn::GetAtt' => ['Ec2Instance1', 'PublicIp']}]]}
|
78
|
+
]
|
79
|
+
]
|
80
|
+
}
|
81
|
+
},
|
82
|
+
"Ec2Instance2"=> {
|
83
|
+
"Value" => {
|
84
|
+
"Fn::Join" => ["," ,
|
85
|
+
[
|
86
|
+
{"Fn::Join" => ["|", ["availablity_zone", {'Fn::GetAtt' => ['Ec2Instance2', 'AvailabilityZone']}]]},
|
87
|
+
{"Fn::Join" => ["|", ["private_dns_name", {'Fn::GetAtt' => ['Ec2Instance2', 'PrivateDnsName']}]]},
|
88
|
+
{"Fn::Join" => ["|", ["public_dns_name", {'Fn::GetAtt' => ['Ec2Instance2', 'PublicDnsName']}]]},
|
89
|
+
{"Fn::Join" => ["|", ["private_ip", {'Fn::GetAtt' => ['Ec2Instance2', 'PrivateIp']}]]},
|
90
|
+
{"Fn::Join" => ["|", ["public_ip", {'Fn::GetAtt' => ['Ec2Instance2', 'PublicIp']}]]}
|
91
|
+
]
|
92
|
+
]
|
93
|
+
}
|
66
94
|
}
|
67
95
|
}
|
68
96
|
}.to_json
|
@@ -71,15 +99,15 @@ describe Cloudster::Cloud do
|
|
71
99
|
|
72
100
|
describe '#provision' do
|
73
101
|
it "should raise argument error if resources not provided" do
|
74
|
-
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => '
|
102
|
+
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => 'Ec2Instance1')
|
75
103
|
cloud = Cloudster::Cloud.new(:access_key_id => 'test', :secret_access_key => 'test')
|
76
104
|
expect { cloud.provision(:description => 'test') }.to raise_error(ArgumentError, 'Missing required argument: resources,stack_name' )
|
77
105
|
end
|
78
106
|
it "should trigger stack creation" do
|
79
107
|
cloud_formation = double('CloudFormation')
|
80
108
|
Fog::AWS::CloudFormation.should_receive(:new).with(:aws_access_key_id => 'test', :aws_secret_access_key => 'test', :region => nil).and_return cloud_formation
|
81
|
-
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => '
|
82
|
-
elb = Cloudster::Elb.new(:name => 'ELB', :instance_names => ['
|
109
|
+
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => 'Ec2Instance1')
|
110
|
+
elb = Cloudster::Elb.new(:name => 'ELB', :instance_names => ['Ec2Instance1','Ec2Instance2'])
|
83
111
|
rds = Cloudster::Rds.new(:name => 'MySqlDB', :storage_size => '10')
|
84
112
|
cloud = Cloudster::Cloud.new(:access_key_id => 'test', :secret_access_key => 'test')
|
85
113
|
cloud_formation.should_receive('create_stack').with('stack_name', 'TemplateBody' => cloud.template(:resources => [ec2, elb, rds], :description => 'testDescription'))
|
@@ -89,14 +117,14 @@ describe Cloudster::Cloud do
|
|
89
117
|
|
90
118
|
describe '#update' do
|
91
119
|
it "should raise argument error if resources not provided" do
|
92
|
-
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => '
|
120
|
+
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => 'Ec2Instance1')
|
93
121
|
cloud = Cloudster::Cloud.new(:access_key_id => 'test', :secret_access_key => 'test')
|
94
122
|
expect { cloud.update(:description => 'test') }.to raise_error(ArgumentError, 'Missing required argument: resources,stack_name' )
|
95
123
|
end
|
96
124
|
it "should trigger stack update" do
|
97
125
|
cloud_formation = double('CloudFormation')
|
98
126
|
Fog::AWS::CloudFormation.should_receive(:new).with(:aws_access_key_id => 'test', :aws_secret_access_key => 'test', :region => nil).and_return cloud_formation
|
99
|
-
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => '
|
127
|
+
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', :name => 'Ec2Instance1')
|
100
128
|
cloud = Cloudster::Cloud.new(:access_key_id => 'test', :secret_access_key => 'test')
|
101
129
|
cloud_formation.should_receive('update_stack').with('stack_name', 'TemplateBody' => cloud.template(:resources => [ec2], :description => 'testDescription'))
|
102
130
|
cloud.update(:resources => [ec2], :stack_name => 'stack_name', :description => 'testDescription')
|
data/spec/ec2_spec.rb
CHANGED
@@ -15,7 +15,34 @@ describe Cloudster::Ec2 do
|
|
15
15
|
describe '#template' 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
|
-
ec2.template.should == {
|
18
|
+
ec2.template.should == {
|
19
|
+
'Resources' => {
|
20
|
+
'name' => {
|
21
|
+
'Type' => 'AWS::EC2::Instance',
|
22
|
+
'Properties' => {
|
23
|
+
"KeyName" => 'testkey',
|
24
|
+
"ImageId" => 'image_id',
|
25
|
+
"InstanceType" => 't1.micro',
|
26
|
+
"SecurityGroups" => ["testSecurityGroup1", "testSecurityGroup2"]
|
27
|
+
}
|
28
|
+
}
|
29
|
+
},
|
30
|
+
"Outputs" => {
|
31
|
+
"name"=>{
|
32
|
+
"Value"=>{
|
33
|
+
"Fn::Join"=>[",",
|
34
|
+
[
|
35
|
+
{"Fn::Join"=>["|", ["availablity_zone", {"Fn::GetAtt"=>["name", "AvailabilityZone"]}]]},
|
36
|
+
{"Fn::Join"=>["|", ["private_dns_name", {"Fn::GetAtt"=>["name", "PrivateDnsName"]}]]},
|
37
|
+
{"Fn::Join"=>["|", ["public_dns_name", {"Fn::GetAtt"=>["name", "PublicDnsName"]}]]},
|
38
|
+
{"Fn::Join"=>["|", ["private_ip", {"Fn::GetAtt"=>["name", "PrivateIp"]}]]},
|
39
|
+
{"Fn::Join"=>["|", ["public_ip", {"Fn::GetAtt"=>["name", "PublicIp"]}]]}
|
40
|
+
]
|
41
|
+
]
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
19
46
|
end
|
20
47
|
end
|
21
48
|
describe '.template' do
|
@@ -24,7 +51,34 @@ describe Cloudster::Ec2 do
|
|
24
51
|
end
|
25
52
|
it "should return a ruby hash for the resource cloudformation template" do
|
26
53
|
hash = Cloudster::Ec2.template(:key_name => 'testkey', :image_id => 'image_id', :name => 'name', :instance_type => 't1.micro', :security_groups => ["testSecurityGroup1"])
|
27
|
-
hash.should == {
|
54
|
+
hash.should == {
|
55
|
+
'Resources' => {
|
56
|
+
'name' => {
|
57
|
+
'Type' => 'AWS::EC2::Instance',
|
58
|
+
'Properties' => {
|
59
|
+
"KeyName" => 'testkey',
|
60
|
+
"ImageId" => 'image_id',
|
61
|
+
"InstanceType" => 't1.micro',
|
62
|
+
"SecurityGroups" => ["testSecurityGroup1"]
|
63
|
+
}
|
64
|
+
}
|
65
|
+
},
|
66
|
+
"Outputs" => {
|
67
|
+
"name"=>{
|
68
|
+
"Value"=>{
|
69
|
+
"Fn::Join"=>[",",
|
70
|
+
[
|
71
|
+
{"Fn::Join"=>["|", ["availablity_zone", {"Fn::GetAtt"=>["name", "AvailabilityZone"]}]]},
|
72
|
+
{"Fn::Join"=>["|", ["private_dns_name", {"Fn::GetAtt"=>["name", "PrivateDnsName"]}]]},
|
73
|
+
{"Fn::Join"=>["|", ["public_dns_name", {"Fn::GetAtt"=>["name", "PublicDnsName"]}]]},
|
74
|
+
{"Fn::Join"=>["|", ["private_ip", {"Fn::GetAtt"=>["name", "PrivateIp"]}]]},
|
75
|
+
{"Fn::Join"=>["|", ["public_ip", {"Fn::GetAtt"=>["name", "PublicIp"]}]]}
|
76
|
+
]
|
77
|
+
]
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
28
82
|
end
|
29
83
|
end
|
30
84
|
end
|
data/spec/elastic_ip_spec.rb
CHANGED
@@ -33,6 +33,21 @@ describe Cloudster::ChefClient do
|
|
33
33
|
}
|
34
34
|
}
|
35
35
|
}
|
36
|
+
},
|
37
|
+
"Outputs" => {
|
38
|
+
"AppServer"=>{
|
39
|
+
"Value"=>{
|
40
|
+
"Fn::Join"=>[",",
|
41
|
+
[
|
42
|
+
{"Fn::Join"=>["|", ["availablity_zone", {"Fn::GetAtt"=>["AppServer", "AvailabilityZone"]}]]},
|
43
|
+
{"Fn::Join"=>["|", ["private_dns_name", {"Fn::GetAtt"=>["AppServer", "PrivateDnsName"]}]]},
|
44
|
+
{"Fn::Join"=>["|", ["public_dns_name", {"Fn::GetAtt"=>["AppServer", "PublicDnsName"]}]]},
|
45
|
+
{"Fn::Join"=>["|", ["private_ip", {"Fn::GetAtt"=>["AppServer", "PrivateIp"]}]]},
|
46
|
+
{"Fn::Join"=>["|", ["public_ip", {"Fn::GetAtt"=>["AppServer", "PublicIp"]}]]}
|
47
|
+
]
|
48
|
+
]
|
49
|
+
}
|
50
|
+
}
|
36
51
|
}
|
37
52
|
}
|
38
53
|
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.19.
|
4
|
+
version: 2.19.2
|
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: 2013-01-
|
12
|
+
date: 2013-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -169,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
169
169
|
version: '0'
|
170
170
|
segments:
|
171
171
|
- 0
|
172
|
-
hash:
|
172
|
+
hash: 773599183
|
173
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
174
|
none: false
|
175
175
|
requirements:
|