cloudster 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +62 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/cloudster.gemspec +73 -0
- data/lib/cloudster.rb +8 -0
- data/lib/cloudster/cloud.rb +81 -0
- data/lib/cloudster/ec2.rb +80 -0
- data/lib/cloudster/options_manager.rb +9 -0
- data/spec/cloud_spec.rb +36 -0
- data/spec/ec2_spec.rb +30 -0
- data/spec/spec_helper.rb +12 -0
- metadata +178 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
gem "fog"
|
9
|
+
gem "json"
|
10
|
+
group :development do
|
11
|
+
gem "rspec", "~> 2.8.0"
|
12
|
+
gem "rdoc", "~> 3.12"
|
13
|
+
gem "bundler"
|
14
|
+
gem "jeweler", "~> 1.8.4"
|
15
|
+
gem "debugger"
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
builder (3.1.4)
|
5
|
+
columnize (0.3.6)
|
6
|
+
debugger (1.2.0)
|
7
|
+
columnize (>= 0.3.1)
|
8
|
+
debugger-linecache (~> 1.1.1)
|
9
|
+
debugger-ruby_core_source (~> 1.1.3)
|
10
|
+
debugger-linecache (1.1.2)
|
11
|
+
debugger-ruby_core_source (>= 1.1.1)
|
12
|
+
debugger-ruby_core_source (1.1.3)
|
13
|
+
diff-lcs (1.1.3)
|
14
|
+
excon (0.14.2)
|
15
|
+
fog (1.4.0)
|
16
|
+
builder
|
17
|
+
excon (~> 0.14.0)
|
18
|
+
formatador (~> 0.2.0)
|
19
|
+
mime-types
|
20
|
+
multi_json (~> 1.0)
|
21
|
+
net-scp (~> 1.0.4)
|
22
|
+
net-ssh (>= 2.1.3)
|
23
|
+
nokogiri (~> 1.5.0)
|
24
|
+
ruby-hmac
|
25
|
+
formatador (0.2.3)
|
26
|
+
git (1.2.5)
|
27
|
+
jeweler (1.8.4)
|
28
|
+
bundler (~> 1.0)
|
29
|
+
git (>= 1.2.5)
|
30
|
+
rake
|
31
|
+
rdoc
|
32
|
+
json (1.7.5)
|
33
|
+
mime-types (1.19)
|
34
|
+
multi_json (1.3.6)
|
35
|
+
net-scp (1.0.4)
|
36
|
+
net-ssh (>= 1.99.1)
|
37
|
+
net-ssh (2.6.1)
|
38
|
+
nokogiri (1.5.5)
|
39
|
+
rake (0.9.2.2)
|
40
|
+
rdoc (3.12)
|
41
|
+
json (~> 1.4)
|
42
|
+
rspec (2.8.0)
|
43
|
+
rspec-core (~> 2.8.0)
|
44
|
+
rspec-expectations (~> 2.8.0)
|
45
|
+
rspec-mocks (~> 2.8.0)
|
46
|
+
rspec-core (2.8.0)
|
47
|
+
rspec-expectations (2.8.0)
|
48
|
+
diff-lcs (~> 1.1.2)
|
49
|
+
rspec-mocks (2.8.0)
|
50
|
+
ruby-hmac (0.4.0)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
bundler
|
57
|
+
debugger
|
58
|
+
fog
|
59
|
+
jeweler (~> 1.8.4)
|
60
|
+
json
|
61
|
+
rdoc (~> 3.12)
|
62
|
+
rspec (~> 2.8.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Emil S
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= cloudster
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to cloudster
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Emil S. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "cloudster"
|
18
|
+
gem.homepage = "http://github.com/emilsoman/cloudster"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Cloudster exposes simple helper methods to provision your AWS cloud.}
|
21
|
+
gem.description = %Q{Cloudster uses the AWS APIs to provision stacks on Amazon Cloud.}
|
22
|
+
gem.email = "emil.soman@gmail.com"
|
23
|
+
gem.authors = ["Emil Soman"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "cloudster #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/cloudster.gemspec
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "cloudster"
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Emil Soman"]
|
12
|
+
s.date = "2012-10-28"
|
13
|
+
s.description = "Cloudster uses the AWS APIs to provision stacks on Amazon Cloud."
|
14
|
+
s.email = "emil.soman@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"cloudster.gemspec",
|
29
|
+
"lib/cloudster.rb",
|
30
|
+
"lib/cloudster/cloud.rb",
|
31
|
+
"lib/cloudster/ec2.rb",
|
32
|
+
"lib/cloudster/options_manager.rb",
|
33
|
+
"spec/cloud_spec.rb",
|
34
|
+
"spec/ec2_spec.rb",
|
35
|
+
"spec/spec_helper.rb"
|
36
|
+
]
|
37
|
+
s.homepage = "http://github.com/emilsoman/cloudster"
|
38
|
+
s.licenses = ["MIT"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = "1.8.24"
|
41
|
+
s.summary = "Cloudster exposes simple helper methods to provision your AWS cloud."
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
s.specification_version = 3
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_runtime_dependency(%q<fog>, [">= 0"])
|
48
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
50
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
51
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
53
|
+
s.add_development_dependency(%q<debugger>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<fog>, [">= 0"])
|
56
|
+
s.add_dependency(%q<json>, [">= 0"])
|
57
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
58
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
59
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
61
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<fog>, [">= 0"])
|
65
|
+
s.add_dependency(%q<json>, [">= 0"])
|
66
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
67
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
68
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
69
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
70
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
data/lib/cloudster.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
module Cloudster
|
2
|
+
#Cloud objects have many resources. This class can generate the cloudformation template and provision the stack.
|
3
|
+
class Cloud
|
4
|
+
|
5
|
+
# Initialize a Cloud instance
|
6
|
+
#
|
7
|
+
# ==== Notes
|
8
|
+
# options parameter must include values for :resources
|
9
|
+
#
|
10
|
+
# ==== Examples
|
11
|
+
# cloud = Cloudster::Cloud.new(
|
12
|
+
# :resources => [
|
13
|
+
# #Cloudster resource instances ..
|
14
|
+
# ]
|
15
|
+
# )
|
16
|
+
#
|
17
|
+
# ==== Parameters
|
18
|
+
# * options<~Hash> - :resources : An array of Cloudster resource instances. Defaults to {}.
|
19
|
+
def initialize(options = {})
|
20
|
+
require_options(options, [:resources])
|
21
|
+
@resources = options[:resources]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Generates CloudFormation Template for the stack
|
25
|
+
#
|
26
|
+
# ==== Examples
|
27
|
+
# cloud = Cloudster::Cloud.new(
|
28
|
+
# :resources => [
|
29
|
+
# #Cloudster resource instances ..
|
30
|
+
# ]
|
31
|
+
# )
|
32
|
+
# cloud.template(:description => 'This is the description for the stack template')
|
33
|
+
#
|
34
|
+
# ==== Parameters
|
35
|
+
# * options<~Hash> - :description : A string which will be used as the Description of the CloudFormation template.
|
36
|
+
#
|
37
|
+
# ==== Returns
|
38
|
+
# * JSON cloud formation template
|
39
|
+
def template(options = {})
|
40
|
+
description = options[:description] || 'This stack is created by Cloudster'
|
41
|
+
resource_template = { 'Resources' => {}}
|
42
|
+
@resources.each do |resource|
|
43
|
+
resource_template['Resources'].merge!(resource.template['Resources'])
|
44
|
+
end
|
45
|
+
|
46
|
+
cloud_template = {'AWSTemplateFormatVersion' => '2010-09-09',
|
47
|
+
'Description' => description,
|
48
|
+
'Resources' => resource_template
|
49
|
+
}
|
50
|
+
return cloud_template.to_json
|
51
|
+
end
|
52
|
+
|
53
|
+
# Triggers the stack creation
|
54
|
+
#
|
55
|
+
# ==== Examples
|
56
|
+
# cloud = Cloudster::Cloud.new(
|
57
|
+
# :resources => [
|
58
|
+
# #Cloudster resource instances ..
|
59
|
+
# ]
|
60
|
+
# )
|
61
|
+
# cloud.template(:description => 'This is the description for the stack template')
|
62
|
+
#
|
63
|
+
# ==== Notes
|
64
|
+
# options parameter must include values for :stack_name for naming the stack , :access_key_id and
|
65
|
+
# :secret_access_key in order to create a connection
|
66
|
+
#
|
67
|
+
# ==== Parameters
|
68
|
+
# * options<~Hash> - :description : A string which will be used as the Description of the CloudFormation template.
|
69
|
+
#
|
70
|
+
# ==== Returns
|
71
|
+
# * response<~Excon::Response>:
|
72
|
+
# * body<~Hash>:
|
73
|
+
# * 'StackId'<~String> - Id of the new stack
|
74
|
+
def provision(options = {})
|
75
|
+
require_options(options, [:stack_name, :access_key_id, :secret_access_key])
|
76
|
+
cloud_formation = Fog::AWS::CloudFormation.new(:aws_access_key_id => options[:access_key_id], :aws_secret_access_key => options[:secret_access_key])
|
77
|
+
return cloud_formation.create_stack(options[:stack_name], 'TemplateBody' => template)
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Cloudster
|
2
|
+
#==Ec2 resource
|
3
|
+
class Ec2
|
4
|
+
|
5
|
+
# Initialize an Ec2 instance
|
6
|
+
#
|
7
|
+
# ==== Notes
|
8
|
+
# options parameter must include values for :name, :key_name and :image_id
|
9
|
+
#
|
10
|
+
# ==== Examples
|
11
|
+
# ec2 = Cloudster::Ec2.new(
|
12
|
+
# :name => 'AppServer',
|
13
|
+
# :key_name => 'mykey',
|
14
|
+
# :image_id => 'ami_image_id'
|
15
|
+
# )
|
16
|
+
#
|
17
|
+
# ==== Parameters
|
18
|
+
# * options<~Hash> -
|
19
|
+
# *Keys:
|
20
|
+
# * :name: String containing the name for the Ec2 resource
|
21
|
+
# * :key_name: String containing the name of the keypair to be used for SSH
|
22
|
+
# * :image_id: String containing the AMI image id to be used while creating the Ec2 resource
|
23
|
+
def initialize(options = {})
|
24
|
+
require_options(options, [:name, :key_name, :image_id])
|
25
|
+
@name = options[:name]
|
26
|
+
@key_name = options[:key_name]
|
27
|
+
@image_id = options[:image_id]
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns a Ruby hash version of the Cloud Formation template for the resource instance
|
31
|
+
#
|
32
|
+
# ==== Examples
|
33
|
+
# ec2 = Cloudster::Ec2.new(
|
34
|
+
# :name => 'AppServer',
|
35
|
+
# :key_name => 'mykey',
|
36
|
+
# :image_id => 'ami_image_id'
|
37
|
+
# )
|
38
|
+
# ec2.template
|
39
|
+
#
|
40
|
+
# ==== Returns
|
41
|
+
# * Ruby hash version of the Cloud Formation template for the resource instance
|
42
|
+
def template
|
43
|
+
Ec2.template({:name =>@name, :key_name => @key_name, :image_id => @image_id})
|
44
|
+
end
|
45
|
+
|
46
|
+
# Class method that returns a Ruby hash version of the Cloud Formation template
|
47
|
+
#
|
48
|
+
# ==== Examples
|
49
|
+
# template = Cloudster::Ec2.template(
|
50
|
+
# :name => 'AppServer',
|
51
|
+
# :key_name => 'mykey',
|
52
|
+
# :image_id => 'ami_image_id'
|
53
|
+
# )
|
54
|
+
#
|
55
|
+
# ==== Parameters
|
56
|
+
# * options<~Hash> -
|
57
|
+
# *Keys:
|
58
|
+
# * :name: String containing the name for the Ec2 resource
|
59
|
+
# * :key_name: String containing the name of the keypair to be used for SSH
|
60
|
+
# * :image_id: String containing the AMI image id to be used while creating the Ec2 resource
|
61
|
+
#
|
62
|
+
# ==== Returns
|
63
|
+
# * Ruby hash version of the Cloud Formation template
|
64
|
+
def self.template(options = {})
|
65
|
+
require_options(options, [:name, :key_name, :image_id])
|
66
|
+
template = {'Resources' => {
|
67
|
+
options[:name] => {
|
68
|
+
'Type' => 'AWS::EC2::Instance',
|
69
|
+
'Properties' => {
|
70
|
+
"KeyName" => options[:key_name],
|
71
|
+
"ImageId" => options[:image_id]
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
return template
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module OptionsManager
|
2
|
+
def require_options(options = {}, required_params)
|
3
|
+
missing_args = []
|
4
|
+
required_params.each do |param|
|
5
|
+
missing_args << param.to_s if options[param].nil?
|
6
|
+
end
|
7
|
+
raise ArgumentError, "Missing required argument: #{missing_args.join(',')}" unless missing_args.empty?
|
8
|
+
end
|
9
|
+
end
|
data/spec/cloud_spec.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cloudster::Cloud do
|
4
|
+
describe 'initialize' do
|
5
|
+
it "should raise argument error if resources not provided" do
|
6
|
+
expect { Cloudster::Cloud.new() }.to raise_error(ArgumentError, 'Missing required argument: resources')
|
7
|
+
end
|
8
|
+
it "should not raise argument error if all arguments are provided" do
|
9
|
+
expect { Cloudster::Cloud.new(:resources => []) }.to_not raise_error(ArgumentError, 'Missing required argument: name')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
describe '#template' do
|
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: 'name')
|
15
|
+
ec2_1 = Cloudster::Ec2.new(:key_name => 'testkey1', :image_id => 'image_id1', name: 'name1')
|
16
|
+
cloud = Cloudster::Cloud.new(:resources => [ec2, ec2_1])
|
17
|
+
cloud.template(:description => 'test template').should == {"AWSTemplateFormatVersion"=>"2010-09-09", "Description"=>"test template", "Resources"=>{"Resources"=>{"name"=>{"Type"=>"AWS::EC2::Instance", "Properties"=>{"KeyName"=>"testkey", "ImageId"=>"image_id"}}, "name1"=>{"Type"=>"AWS::EC2::Instance", "Properties"=>{"KeyName"=>"testkey1", "ImageId"=>"image_id1"}}}}}.to_json
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#provision' do
|
22
|
+
it "should raise argument error if resources not provided" do
|
23
|
+
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', name: 'name')
|
24
|
+
cloud = Cloudster::Cloud.new(:resources => [ec2])
|
25
|
+
expect { cloud.provision() }.to raise_error(ArgumentError, 'Missing required argument: stack_name,access_key_id,secret_access_key' )
|
26
|
+
end
|
27
|
+
it "should create an instance of cloud formation and trigger stack creation" do
|
28
|
+
ec2 = Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id', name: 'name')
|
29
|
+
cloud = Cloudster::Cloud.new(:resources => [ec2])
|
30
|
+
cloud_formation = double('CloudFormation')
|
31
|
+
cloud_formation.should_receive('create_stack').with('stack_name', 'TemplateBody' => cloud.template)
|
32
|
+
Fog::AWS::CloudFormation.should_receive(:new).with(:aws_access_key_id => 'access_key_id', :aws_secret_access_key => 'secret_access_key').and_return cloud_formation
|
33
|
+
cloud.provision(:stack_name => 'stack_name', :access_key_id => 'access_key_id', :secret_access_key => 'secret_access_key')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/ec2_spec.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cloudster::Ec2 do
|
4
|
+
describe 'initialize' do
|
5
|
+
it "should raise argument error if name is not provided" do
|
6
|
+
expect { Cloudster::Ec2.new(:key_name => 'testkey', :image_id => 'image_id') }.to raise_error(ArgumentError, 'Missing required argument: name')
|
7
|
+
end
|
8
|
+
it "should raise argument error if no argument is not provided" do
|
9
|
+
expect { Cloudster::Ec2.new() }.to raise_error(ArgumentError, 'Missing required argument: name,key_name,image_id')
|
10
|
+
end
|
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: 'name') }.to_not raise_error
|
13
|
+
end
|
14
|
+
end
|
15
|
+
describe '#template' do
|
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')
|
18
|
+
ec2.template.should == {'Resources' => {'name' => {'Type' => 'AWS::EC2::Instance', 'Properties' => {"KeyName" => 'testkey', "ImageId" => 'image_id'} }}}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
describe '.template' do
|
22
|
+
it "should raise argument error if no argument is not provided" do
|
23
|
+
expect { Cloudster::Ec2.template() }.to raise_error(ArgumentError, 'Missing required argument: name,key_name,image_id')
|
24
|
+
end
|
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: 'name')
|
27
|
+
hash.should == {'Resources' => {'name' => {'Type' => 'AWS::EC2::Instance', 'Properties' => {"KeyName" => 'testkey', "ImageId" => 'image_id'} }}}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'cloudster'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cloudster
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Emil Soman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fog
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.8.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.8.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rdoc
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.12'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.12'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: bundler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: jeweler
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.8.4
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.8.4
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: debugger
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: Cloudster uses the AWS APIs to provision stacks on Amazon Cloud.
|
127
|
+
email: emil.soman@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files:
|
131
|
+
- LICENSE.txt
|
132
|
+
- README.rdoc
|
133
|
+
files:
|
134
|
+
- .document
|
135
|
+
- .rspec
|
136
|
+
- Gemfile
|
137
|
+
- Gemfile.lock
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.rdoc
|
140
|
+
- Rakefile
|
141
|
+
- VERSION
|
142
|
+
- cloudster.gemspec
|
143
|
+
- lib/cloudster.rb
|
144
|
+
- lib/cloudster/cloud.rb
|
145
|
+
- lib/cloudster/ec2.rb
|
146
|
+
- lib/cloudster/options_manager.rb
|
147
|
+
- spec/cloud_spec.rb
|
148
|
+
- spec/ec2_spec.rb
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
homepage: http://github.com/emilsoman/cloudster
|
151
|
+
licenses:
|
152
|
+
- MIT
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
none: false
|
159
|
+
requirements:
|
160
|
+
- - ! '>='
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
segments:
|
164
|
+
- 0
|
165
|
+
hash: 319557629
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
168
|
+
requirements:
|
169
|
+
- - ! '>='
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
requirements: []
|
173
|
+
rubyforge_project:
|
174
|
+
rubygems_version: 1.8.24
|
175
|
+
signing_key:
|
176
|
+
specification_version: 3
|
177
|
+
summary: Cloudster exposes simple helper methods to provision your AWS cloud.
|
178
|
+
test_files: []
|