kitchen-rackspace 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
18
+ .kitchen
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+
3
+ gemfile:
4
+ - Gemfile
5
+
6
+ rvm:
7
+ - 1.8.7
8
+ - 1.9.2
9
+ - 1.9.3
10
+ - 2.0.0
11
+
12
+ # vim: ai et ts=2 sts=2 sw=2 ft=yaml
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kitchen-rackspace.gemspec
4
+ gemspec
5
+
6
+ # vim: ai et ts=2 sts=2 sw=2 ft=ruby
data/LICENSE.txt ADDED
@@ -0,0 +1,15 @@
1
+ Author:: Jonathan Hartman (<j@p4nt5.com>)
2
+
3
+ Copyright (c) 2013 Jonathan Hartman
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.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # Kitchen::Rackspace
2
+
3
+ A Rackspace Cloud Servers driver for Test Kitchen 1.0!
4
+
5
+ Shamelessly copied from [Fletcher Nichol](https://github.com/fnichol)'s
6
+ awesome work on an [EC2 driver](https://github.com/opscode/kitchen-ec2).
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'kitchen-rackspace'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install kitchen-rackspace
21
+
22
+ ## Usage
23
+
24
+ Provide, at a minimum, the required driver options in your `.kitchen.yml` file:
25
+
26
+ driver_plugin: rackspace
27
+ driver_config:
28
+ rackspace_username: [YOUR RACKSPACE CLOUD USERNAME]
29
+ rackspace_api_key: [YOUR RACKSPACE CLOUD API KEY]
30
+ require_chef_omnibus: latest (if you'll be using Chef)
31
+
32
+ By default, the driver will spawn a 512MB Ubuntu 12.10 instance.
33
+ Additional, optional settings can be provided:
34
+
35
+ image_id: [SERVER IMAGE ID]
36
+ flavor_id: [SERVER FLAVOR ID]
37
+ name: [A UNIQUE SERVER NAME]
38
+ public_key_path: [PATH TO YOUR PUBLIC SSH KEY]
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'tailor/rake_task'
3
+ require 'cane/rake_task'
4
+
5
+ desc 'Run Cane to check quality metrics'
6
+ Cane::RakeTask.new
7
+
8
+ desc 'Run Tailor to lint check code'
9
+ Tailor::RakeTask.new
10
+
11
+ desc 'Display LOC stats'
12
+ task :loc do
13
+ puts "\n## LOC Stats"
14
+ sh 'countloc -r lib/kitchen'
15
+ end
16
+
17
+ task :default => [ :cane, :tailor, :loc ]
18
+
19
+ # vim: ai et ts=2 sts=2 sw=2 ft=ruby fdm=marker
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kitchen/driver/rackspace_version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'kitchen-rackspace'
8
+ spec.version = Kitchen::Driver::RACKSPACE_VERSION
9
+ spec.authors = ['Jonathan Hartman']
10
+ spec.email = ['j@p4nt5.com']
11
+ spec.description = %q{A Test Kitchen Rackspace driver}
12
+ spec.summary = spec.description
13
+ spec.homepage = 'https://github.com/RoboticCheese/kitchen-rackspace'
14
+ spec.license = 'Apache'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'test-kitchen', '~> 1.0.0.alpha'
22
+ spec.add_dependency 'fog'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.3'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'tailor'
27
+ spec.add_development_dependency 'cane'
28
+ spec.add_development_dependency 'countloc'
29
+ end
30
+
31
+ # vim: ai et ts=2 sts=2 sw=2 ft=ruby
@@ -0,0 +1,88 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Jonathan Hartman (<j@p4nt5.com>)
4
+ #
5
+ # Copyright (C) 2013, Jonathan Hartman
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
+ require 'kitchen'
22
+ require 'etc'
23
+ require 'socket'
24
+
25
+ module Kitchen
26
+ module Driver
27
+ # Rackspace driver for Kitchen.
28
+ #
29
+ # @author Jonathan Hartman <j@p4nt5.com>
30
+ class Rackspace < Kitchen::Driver::SSHBase
31
+ default_config :version, 'v2'
32
+ default_config :image_id, '8a3a9f96-b997-46fd-b7a8-a9e740796ffd'
33
+ default_config :flavor_id, '2'
34
+ default_config :name, nil
35
+ default_config :public_key_path, File.expand_path('~/.ssh/id_dsa.pub')
36
+ default_config :username, 'root'
37
+ default_config :port, '22'
38
+
39
+ def create(state)
40
+ if not config[:name]
41
+ # Generate what should be a unique server name
42
+ config[:name] = "#{instance.name}-#{Etc.getlogin}-" +
43
+ "#{Socket.gethostname}-#{Array.new(8){rand(36).to_s(36)}.join}"
44
+ end
45
+ server = create_server
46
+ state[:server_id] = server.id
47
+ info("Rackspace instance <#{state[:server_id]}> created.")
48
+ server.wait_for { ready? } ; puts "(server ready)"
49
+ state[:hostname] = server.public_ip_address
50
+ wait_for_sshd(state[:hostname]) ; puts "(ssh ready)"
51
+ rescue Fog::Errors::Error, Excon::Errors::Error => ex
52
+ raise ActionFailed, ex.message
53
+ end
54
+
55
+ def destroy(state)
56
+ return if state[:server_id].nil?
57
+
58
+ server = compute.servers.get(state[:server_id])
59
+ server.destroy unless server.nil?
60
+ info("Rackspace instance <#{state[:server_id]}> destroyed.")
61
+ state.delete(:server_id)
62
+ state.delete(:hostname)
63
+ end
64
+
65
+ private
66
+
67
+ def compute
68
+ Fog::Compute.new(
69
+ :provider => "Rackspace",
70
+ :version => config[:version],
71
+ :rackspace_username => config[:rackspace_username],
72
+ :rackspace_api_key => config[:rackspace_api_key]
73
+ )
74
+ end
75
+
76
+ def create_server
77
+ compute.servers.bootstrap(
78
+ :name => config[:name],
79
+ :image_id => config[:image_id],
80
+ :flavor_id => config[:flavor_id],
81
+ :public_key_path => config[:public_key_path]
82
+ )
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ # vim: ai et ts=2 sts=2 sw=2 ft=ruby
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Jonathan Hartman (<j@p4nt5.com>)
4
+ #
5
+ # Copyright (C) 2013, Jonathan Hartman
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
+ module Driver
21
+ # Version string for Rackspace Kitchen driver
22
+ RACKSPACE_VERSION = '0.1.0'
23
+ end
24
+ end
25
+
26
+ # vim: ai et ts=2 sts=2 sw=2 ft=ruby
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitchen-rackspace
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jonathan Hartman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-12 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
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
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: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
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: '1.3'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
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: tailor
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: cane
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
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: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: countloc
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: A Test Kitchen Rackspace driver
127
+ email:
128
+ - j@p4nt5.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - .travis.yml
135
+ - Gemfile
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - kitchen-rackspace.gemspec
140
+ - lib/kitchen/driver/rackspace.rb
141
+ - lib/kitchen/driver/rackspace_version.rb
142
+ homepage: https://github.com/RoboticCheese/kitchen-rackspace
143
+ licenses:
144
+ - Apache
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ requirements: []
162
+ rubyforge_project:
163
+ rubygems_version: 1.8.23
164
+ signing_key:
165
+ specification_version: 3
166
+ summary: A Test Kitchen Rackspace driver
167
+ test_files: []
168
+ has_rdoc: