kitchen-ec2 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kitchen-ec2.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'rake'
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ Author:: Fletcher Nichol (<fnichol@nichol.ca>)
2
+
3
+ Copyright (C) 2012, Fletcher Nichol
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
@@ -0,0 +1,29 @@
1
+ # Kitchen::Driver::Ec2
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'kitchen-ec2'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install kitchen-ec2
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,16 @@
1
+ require "bundler/gem_tasks"
2
+ require 'cane/rake_task'
3
+ require 'tailor/rake_task'
4
+
5
+ desc "Run cane to check quality metrics"
6
+ Cane::RakeTask.new
7
+
8
+ Tailor::RakeTask.new
9
+
10
+ desc "Display LOC stats"
11
+ task :stats do
12
+ puts "\n## Production Code Stats"
13
+ sh "countloc -r lib/kitchen"
14
+ end
15
+
16
+ task :default => [ :cane, :tailor, :stats ]
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kitchen/driver/ec2_version.rb'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "kitchen-ec2"
8
+ gem.version = Kitchen::Driver::EC2_VERSION
9
+ gem.authors = ["Fletcher Nichol"]
10
+ gem.email = ["fnichol@nichol.ca"]
11
+ gem.description = "Kitchen::Driver::Ec2 - A Test Kitchen Driver for Ec2"
12
+ gem.summary = gem.description
13
+ gem.homepage = "https://github.com/opscode/kitchen-ec2/"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = []
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'test-kitchen', '~> 1.0.0.alpha.0'
21
+ gem.add_dependency 'fog'
22
+
23
+ gem.add_development_dependency 'cane'
24
+ gem.add_development_dependency 'tailor'
25
+ gem.add_development_dependency 'countloc'
26
+ end
@@ -0,0 +1,84 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
+ #
5
+ # Copyright (C) 2012, Fletcher Nichol
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require 'benchmark'
20
+ require 'fog'
21
+
22
+ require 'kitchen'
23
+
24
+ module Kitchen
25
+
26
+ module Driver
27
+
28
+ # Amazon EC2 driver for Test Kitchen.
29
+ #
30
+ # @author Fletcher Nichol <fnichol@nichol.ca>
31
+ class Ec2 < Kitchen::Driver::SSHBase
32
+
33
+ default_config :region, 'us-east-1'
34
+ default_config :availability_zone, 'us-east-1b'
35
+ default_config :flavor_id, 'm1.small'
36
+ default_config :groups, [ 'default' ]
37
+ default_config :username, 'root'
38
+ default_config :port, '22'
39
+
40
+ def create(state)
41
+ server = create_server
42
+ state[:server_id] = server.id
43
+
44
+ info("EC2 instance <#{state[:server_id]}> created.")
45
+ server.wait_for { print "."; ready? } ; print "(server ready)"
46
+ state[:hostname] = server.public_ip_address
47
+ wait_for_sshd(state[:hostname]) ; print "(ssh ready)\n"
48
+ rescue Fog::Errors::Error, Excon::Errors::Error => ex
49
+ raise ActionFailed, ex.message
50
+ end
51
+
52
+ def destroy(state)
53
+ return if state[:server_id].nil?
54
+
55
+ server = connection.servers.get(state[:server_id])
56
+ server.destroy unless server.nil?
57
+ info("EC2 instance <#{state[:server_id]}> destroyed.")
58
+ state.delete(:server_id)
59
+ state.delete(:hostname)
60
+ end
61
+
62
+ private
63
+
64
+ def connection
65
+ Fog::Compute.new(
66
+ :provider => :aws,
67
+ :aws_access_key_id => config[:aws_access_key_id],
68
+ :aws_secret_access_key => config[:aws_secret_access_key],
69
+ :region => config[:region],
70
+ )
71
+ end
72
+
73
+ def create_server
74
+ connection.servers.create(
75
+ :availability_zone => config[:availability_zone],
76
+ :groups => config[:groups],
77
+ :flavor_id => config[:flavor_id],
78
+ :image_id => config[:image_id],
79
+ :key_name => config[:aws_ssh_key_id],
80
+ )
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
+ #
5
+ # Copyright (C) 2012, Fletcher Nichol
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ module Kitchen
20
+
21
+ module Driver
22
+
23
+ # Version string for EC2 Test Kitchen driver
24
+ EC2_VERSION = "0.4.0"
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitchen-ec2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Fletcher Nichol
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: test-kitchen
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0.alpha.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: 1.0.0.alpha.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: fog
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: cane
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '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: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: tailor
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
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: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: countloc
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
+ description: Kitchen::Driver::Ec2 - A Test Kitchen Driver for Ec2
95
+ email:
96
+ - fnichol@nichol.ca
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - .travis.yml
103
+ - Gemfile
104
+ - LICENSE
105
+ - README.md
106
+ - Rakefile
107
+ - kitchen-ec2.gemspec
108
+ - lib/kitchen/driver/ec2.rb
109
+ - lib/kitchen/driver/ec2_version.rb
110
+ homepage: https://github.com/opscode/kitchen-ec2/
111
+ licenses: []
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ segments:
123
+ - 0
124
+ hash: 4246554264751038241
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ segments:
132
+ - 0
133
+ hash: 4246554264751038241
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 1.8.24
137
+ signing_key:
138
+ specification_version: 3
139
+ summary: Kitchen::Driver::Ec2 - A Test Kitchen Driver for Ec2
140
+ test_files: []