cloudster 2.14.1 → 2.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/cloudster.gemspec +4 -2
- data/lib/cloudster.rb +1 -0
- data/lib/cloudster/elasticache.rb +93 -0
- data/lib/cloudster/s3.rb +41 -40
- data/spec/elasticache_spec.rb +50 -0
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.15.0
|
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.
|
8
|
+
s.version = "2.15.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-12-
|
12
|
+
s.date = "2012-12-30"
|
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 = [
|
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/cloudster/cloud.rb",
|
33
33
|
"lib/cloudster/deep_merge.rb",
|
34
34
|
"lib/cloudster/ec2.rb",
|
35
|
+
"lib/cloudster/elasticache.rb",
|
35
36
|
"lib/cloudster/elb.rb",
|
36
37
|
"lib/cloudster/options_manager.rb",
|
37
38
|
"lib/cloudster/rds.rb",
|
@@ -39,6 +40,7 @@ Gem::Specification.new do |s|
|
|
39
40
|
"spec/chef_client_spec.rb",
|
40
41
|
"spec/cloud_spec.rb",
|
41
42
|
"spec/ec2_spec.rb",
|
43
|
+
"spec/elasticache_spec.rb",
|
42
44
|
"spec/elb_spec.rb",
|
43
45
|
"spec/rds_spec.rb",
|
44
46
|
"spec/s3_spec.rb",
|
data/lib/cloudster.rb
CHANGED
@@ -0,0 +1,93 @@
|
|
1
|
+
module Cloudster
|
2
|
+
#ElastiCache Resource
|
3
|
+
class ElastiCache
|
4
|
+
|
5
|
+
attr_accessor :name, :template
|
6
|
+
# Initializes an ElastiCache resource
|
7
|
+
#
|
8
|
+
# ==== Notes
|
9
|
+
# options parameter must include values for :node_type, :cache_security_group_names, :engine, :node_count
|
10
|
+
#
|
11
|
+
# ==== Parameters
|
12
|
+
# * options<~Hash>
|
13
|
+
# * :name : String representing the name for the ElastiCache resource (Required)
|
14
|
+
# * :node_type : String representing the compute and memory capacity of nodes in a Cache Cluster. One of : cache.t1.micro | cache.m1.small | cache.m1.medium | cache.m1.large | cache.m1.xlarge | cache.m3.xlarge | cache.m3.2xlarge | cache.m2.xlarge | cache.m2.2xlarge | cache.m2.4xlarge | cache.c1.xlarge (Required)
|
15
|
+
# * :cache_security_group_names : Array of cache security group names (Required)
|
16
|
+
# * :engine : String containing the name of the cache engine to be used for this cache cluster. Only 'memcached' is supported now.(Required)
|
17
|
+
# * :node_count : Integer indicating number of cache nodes the cache cluster should have.(Required)
|
18
|
+
# ==== Examples
|
19
|
+
# cache = Cloudster::ElastiCache.new(
|
20
|
+
# :name => 'ElastiCacheResource',
|
21
|
+
# :node_type => 'cache.t1.micro',
|
22
|
+
# :cache_security_group_names => ['default'],
|
23
|
+
# :engine => 'memcached',
|
24
|
+
# :node_count => 3"
|
25
|
+
# )
|
26
|
+
|
27
|
+
def initialize(options = {})
|
28
|
+
require_options(options, [:name, :node_type, :cache_security_group_names, :engine, :node_count])
|
29
|
+
@name = options[:name]
|
30
|
+
@node_type = options[:node_type]
|
31
|
+
@cache_security_group_names = options[:cache_security_group_names]
|
32
|
+
@engine = options[:engine]
|
33
|
+
@node_count = options[:node_count]
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns a Ruby hash version of the Cloud Formation template for the ElastiCache resource
|
37
|
+
#
|
38
|
+
# ==== Examples
|
39
|
+
# elasticache = Cloudster::ElastiCache.new(
|
40
|
+
# :name => 'ElastiCacheResource',
|
41
|
+
# :node_type => 'cache.t1.micro',
|
42
|
+
# :cache_security_group_names => ['default'],
|
43
|
+
# :engine => 'memcached',
|
44
|
+
# :node_count => 3"
|
45
|
+
# )
|
46
|
+
# elasticache.template
|
47
|
+
#
|
48
|
+
# ==== Returns
|
49
|
+
# * Ruby hash version of the Cloud Formation template for the elasticache resource
|
50
|
+
def template
|
51
|
+
@template ||= ElastiCache.template({:name => @name, :node_type => @node_type, :cache_security_group_names => @cache_security_group_names, :engine => @engine, :node_count => @node_count})
|
52
|
+
end
|
53
|
+
|
54
|
+
# Class method that returns a Ruby hash version of the Cloud Formation template
|
55
|
+
#
|
56
|
+
# ==== Examples
|
57
|
+
# template = Cloudster::ElastiCache.template(
|
58
|
+
# :name => 'ElastiCacheResource',
|
59
|
+
# :node_type => 'cache.t1.micro',
|
60
|
+
# :cache_security_group_names => ['default'],
|
61
|
+
# :engine => 'memcached',
|
62
|
+
# :node_count => 3"
|
63
|
+
# )
|
64
|
+
#
|
65
|
+
# ==== Parameters
|
66
|
+
# * options<~Hash>
|
67
|
+
# * :name : String representing the name for the ElastiCache resource (Required)
|
68
|
+
# * :node_type : String representing the compute and memory capacity of nodes in a Cache Cluster. One of : cache.t1.micro | cache.m1.small | cache.m1.medium | cache.m1.large | cache.m1.xlarge | cache.m3.xlarge | cache.m3.2xlarge | cache.m2.xlarge | cache.m2.2xlarge | cache.m2.4xlarge | cache.c1.xlarge (Required)
|
69
|
+
# * :cache_security_group_names : Array of cache security group names (Required)
|
70
|
+
# * :engine : String containing the name of the cache engine to be used for this cache cluster. Only 'memcached' is supported now.(Required)
|
71
|
+
# * :node_count : Integer indicating number of cache nodes the cache cluster should have.(Required)
|
72
|
+
# ==== Returns
|
73
|
+
# * Ruby hash version of the Cloud Formation template for ElastiCache
|
74
|
+
def self.template(options = {})
|
75
|
+
require_options(options, [:name, :node_type, :cache_security_group_names, :engine, :node_count])
|
76
|
+
properties = {}
|
77
|
+
properties.merge!({
|
78
|
+
"CacheNodeType" => options[:node_type],
|
79
|
+
"CacheSecurityGroupNames" => options[:cache_security_group_names],
|
80
|
+
"Engine" => options[:engine],
|
81
|
+
"NumCacheNodes" => options[:node_count].to_s
|
82
|
+
})
|
83
|
+
template = {'Resources' => {
|
84
|
+
options[:name] => {
|
85
|
+
'Type' => 'AWS::ElastiCache::CacheCluster',
|
86
|
+
'Properties' => properties
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
return template
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/lib/cloudster/s3.rb
CHANGED
@@ -1,41 +1,42 @@
|
|
1
1
|
module Cloudster
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
attr_accessor :name, :template
|
6
|
-
# Initialize a s3 bucket
|
7
|
-
#
|
8
|
-
# ==== Notes
|
9
|
-
# options parameter must include values for the :name
|
10
|
-
#
|
11
|
-
# ==== Parameters
|
12
|
-
# * options<~Hash>
|
13
|
-
# * :name : String representing the bucket name (Required)
|
14
|
-
# * :access_control : String consisting of one of the predefined permission value. ( Example: PublicRead )
|
15
|
-
# * :website_configuration : A hash containing the name of the index document and name of the error document. ( Example: {"index_document" => "index.html", "error_document" => "error.html"} )
|
16
|
-
#
|
17
|
-
# ==== Examples
|
18
|
-
# bucket = Cloudster::S3.new(
|
19
|
-
# :name => 'unique_bucket_name'
|
20
|
-
# )
|
21
|
-
|
22
|
-
def initialize(options = {})
|
23
|
-
require_options(options, [:name])
|
24
|
-
@name = options[:name]
|
25
|
-
@access_control = options[:access_control]
|
26
|
-
@website_configuration = options[:website_configuration]
|
27
|
-
end
|
2
|
+
#S3 Resource
|
3
|
+
class S3
|
28
4
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
5
|
+
attr_accessor :name, :template
|
6
|
+
# Initialize a s3 bucket
|
7
|
+
#
|
8
|
+
# ==== Notes
|
9
|
+
# options parameter must include values for the :name
|
10
|
+
#
|
11
|
+
# ==== Parameters
|
12
|
+
# * options<~Hash>
|
13
|
+
# * :name : String representing the resource name (Required)
|
14
|
+
# * :access_control : String consisting of one of the predefined permission values: Private | PublicRead | PublicReadWrite | AuthenticatedRead | BucketOwnerRead | BucketOwnerFullControl
|
15
|
+
# * :website_configuration : A hash containing the name of the index document and name of the error document. ( Example: {"index_document" => "index.html", "error_document" => "error.html"} )
|
16
|
+
#
|
17
|
+
# ==== Examples
|
18
|
+
# bucket = Cloudster::S3.new(
|
19
|
+
# :name => 'ResourceName',
|
20
|
+
# :access_control => 'PublicRead'
|
21
|
+
# )
|
22
|
+
|
23
|
+
def initialize(options = {})
|
24
|
+
require_options(options, [:name])
|
25
|
+
@name = options[:name]
|
26
|
+
@access_control = options[:access_control]
|
27
|
+
@website_configuration = options[:website_configuration]
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns a Ruby hash version of the Cloud Formation template for the s3 resource
|
31
|
+
#
|
32
|
+
# ==== Examples
|
33
|
+
# s3 = Cloudster::S3.new(
|
34
|
+
# :name => 'S3Resource'
|
35
|
+
# )
|
36
|
+
# s3.template
|
37
|
+
#
|
38
|
+
# ==== Returns
|
39
|
+
# * Ruby hash version of the Cloud Formation template for the s3 resource
|
39
40
|
def template
|
40
41
|
@template ||= S3.template({:name => @name, :access_control => @access_control, :website_configuration => @website_configuration})
|
41
42
|
end
|
@@ -44,15 +45,15 @@ module Cloudster
|
|
44
45
|
#
|
45
46
|
# ==== Examples
|
46
47
|
# template = Cloudster::S3.template(
|
47
|
-
#
|
48
|
+
# :name => 'S3Resource'
|
48
49
|
# )
|
49
50
|
#
|
50
51
|
# ==== Parameters
|
51
52
|
# * options<~Hash>
|
52
|
-
# * :name : String representing the
|
53
|
+
# * :name : String representing the resource name (Required)
|
53
54
|
# * :access_control : String consisting of one of the predefined permission value. ( Example: PublicRead )
|
54
55
|
# * :website_configuration : A hash containing the name of the index document and name of the error document. ( Example: {"index_document" => "index.html", "error_document" => "error.html"} )
|
55
|
-
#
|
56
|
+
#
|
56
57
|
# ==== Returns
|
57
58
|
# * Ruby hash version of the Cloud Formation template for S3
|
58
59
|
def self.template(options = {})
|
@@ -71,5 +72,5 @@ module Cloudster
|
|
71
72
|
}
|
72
73
|
return template
|
73
74
|
end
|
74
|
-
|
75
|
+
end
|
75
76
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cloudster::ElastiCache do
|
4
|
+
describe 'initialize' do
|
5
|
+
it "should raise argument error if no argument is provided" do
|
6
|
+
expect { Cloudster::ElastiCache.new() }.to raise_error(ArgumentError, 'Missing required argument: name,node_type,cache_security_group_names,engine,node_count')
|
7
|
+
end
|
8
|
+
it "should not raise argument error if all arguments are provided" do
|
9
|
+
expect do
|
10
|
+
Cloudster::ElastiCache.new(
|
11
|
+
:name => 'ElastiCache',
|
12
|
+
:node_type => 'test',
|
13
|
+
:cache_security_group_names => ['default'],
|
14
|
+
:engine => 'memcached',
|
15
|
+
:node_count => 3
|
16
|
+
)
|
17
|
+
end.to_not raise_error
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#template' do
|
22
|
+
it "should return a ruby hash for the resource cloudformation template with only mandatory fields" do
|
23
|
+
elasticache = Cloudster::ElastiCache.new(
|
24
|
+
:name => 'ElastiCache',
|
25
|
+
:node_type => 'test',
|
26
|
+
:cache_security_group_names => ['default'],
|
27
|
+
:engine => 'memcached',
|
28
|
+
:node_count => 3
|
29
|
+
)
|
30
|
+
elasticache.template.should == {'Resources' => {"ElastiCache"=>{"Type"=>"AWS::ElastiCache::CacheCluster", "Properties"=>{"CacheNodeType"=>"test", "CacheSecurityGroupNames"=>["default"], "Engine"=>"memcached", "NumCacheNodes"=>"3"}}}}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.template' do
|
35
|
+
it "should raise argument error if no argument is provided" do
|
36
|
+
expect { Cloudster::ElastiCache.template() }.to raise_error(ArgumentError, 'Missing required argument: name,node_type,cache_security_group_names,engine,node_count')
|
37
|
+
end
|
38
|
+
it "should return a ruby hash for the resource cloudformation template" do
|
39
|
+
hash = Cloudster::ElastiCache.template(
|
40
|
+
:name => 'ElastiCache',
|
41
|
+
:node_type => 'test',
|
42
|
+
:cache_security_group_names => ['default'],
|
43
|
+
:engine => 'memcached',
|
44
|
+
:node_count => 3
|
45
|
+
)
|
46
|
+
hash.should == {'Resources' => {"ElastiCache"=>{"Type"=>"AWS::ElastiCache::CacheCluster", "Properties"=>{"CacheNodeType"=>"test", "CacheSecurityGroupNames"=>["default"], "Engine"=>"memcached", "NumCacheNodes"=>"3"}}}}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
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.15.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-12-
|
12
|
+
date: 2012-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/cloudster/cloud.rb
|
135
135
|
- lib/cloudster/deep_merge.rb
|
136
136
|
- lib/cloudster/ec2.rb
|
137
|
+
- lib/cloudster/elasticache.rb
|
137
138
|
- lib/cloudster/elb.rb
|
138
139
|
- lib/cloudster/options_manager.rb
|
139
140
|
- lib/cloudster/rds.rb
|
@@ -141,6 +142,7 @@ files:
|
|
141
142
|
- spec/chef_client_spec.rb
|
142
143
|
- spec/cloud_spec.rb
|
143
144
|
- spec/ec2_spec.rb
|
145
|
+
- spec/elasticache_spec.rb
|
144
146
|
- spec/elb_spec.rb
|
145
147
|
- spec/rds_spec.rb
|
146
148
|
- spec/s3_spec.rb
|
@@ -160,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
162
|
version: '0'
|
161
163
|
segments:
|
162
164
|
- 0
|
163
|
-
hash:
|
165
|
+
hash: 761406417
|
164
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
167
|
none: false
|
166
168
|
requirements:
|