kitchen-gce 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +15 -0
- data/Gemfile +3 -0
- data/README.md +26 -10
- data/kitchen-gce.gemspec +7 -3
- data/lib/kitchen/driver/gce.rb +46 -8
- metadata +62 -7
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
### Bug fixes
|
2
|
+
|
3
|
+
* In GCE, instance names must be unique; derive by default from
|
4
|
+
`<suite>-<platform>` and a UUID.
|
5
|
+
* README formatting and clarity fixes.
|
6
|
+
|
7
|
+
### Improvements
|
8
|
+
|
9
|
+
* Add concept of an "area" (us, europe, any) to automatically select
|
10
|
+
an availability zone from those that are up within the requested
|
11
|
+
area for each instance.
|
12
|
+
|
13
|
+
## 0.0.1 / 2013-10-20
|
14
|
+
|
15
|
+
### Initial release
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -18,12 +18,14 @@ which to run your test-kitchen instances, create one, noting the
|
|
18
18
|
Console](https://code.google.com/apis/console/), create a "service
|
19
19
|
account" for the project under the "API Access" tab. Save the key
|
20
20
|
file, and note the email address associated with the service account
|
21
|
-
(e.g.
|
22
|
-
email address).
|
21
|
+
(e.g. 123456789012@developer.gserviceaccount.com - not the project
|
22
|
+
owner's email address).
|
23
23
|
|
24
24
|
If you have not [set up SSH keys for your GCE
|
25
25
|
environment](https://developers.google.com/compute/docs/instances#sshkeys),
|
26
|
-
you must also do that prior to using kitchen-gce.
|
26
|
+
you must also do that prior to using kitchen-gce. Also, you will
|
27
|
+
likely want to add your GCE SSH keys to ssh-agent prior to converging
|
28
|
+
any instances.
|
27
29
|
|
28
30
|
## Installation
|
29
31
|
|
@@ -45,6 +47,16 @@ Then, execute `bundle install`.
|
|
45
47
|
|
46
48
|
## Configuration
|
47
49
|
|
50
|
+
### area
|
51
|
+
|
52
|
+
Area in which to launch instances. For the purposes of this driver,
|
53
|
+
"area" is defined as the part prior to the first hyphen in an
|
54
|
+
availability zone's name; e.g. in "us-central1-b", the area is "us".
|
55
|
+
Specifying area but not "zone_name" allows kitchen-gce to avoid
|
56
|
+
launching instances into a zone that is down for maintenance. If
|
57
|
+
"any" is specified, kitchen-gce will select a zone from all areas.
|
58
|
+
Default: `us` (lowest cost area); valid values: `any`, `europe`, `us`
|
59
|
+
|
48
60
|
### google_client_email
|
49
61
|
|
50
62
|
**Required** Email address associated with your GCE service account.
|
@@ -69,11 +81,13 @@ instances will be launched.
|
|
69
81
|
|
70
82
|
GCE instance type (size) to launch; default: `n1-standard-1`
|
71
83
|
|
72
|
-
###
|
84
|
+
### inst_name
|
73
85
|
|
74
86
|
Name to give to instance; unlike EC2's "Name" tag, this is used as an
|
75
|
-
instance identifier and must be unique.
|
76
|
-
|
87
|
+
instance identifier and must be unique. If none is specified, a unique
|
88
|
+
name will be auto-generated; note that auto-generated names must be
|
89
|
+
used if there is more than one test suite. Default:
|
90
|
+
`<suite>-<platform>-<UUID>`
|
77
91
|
|
78
92
|
### username
|
79
93
|
|
@@ -82,7 +96,8 @@ to the appropriate SSH keys. Default: `ENV['USER']`
|
|
82
96
|
|
83
97
|
### zone_name
|
84
98
|
|
85
|
-
Location into which instances will be launched.
|
99
|
+
Location into which instances will be launched. If not specified, a
|
100
|
+
zone is chosen from available zones within the "area" (see above).
|
86
101
|
|
87
102
|
## Example
|
88
103
|
|
@@ -93,6 +108,7 @@ like this:
|
|
93
108
|
---
|
94
109
|
driver_plugin: gce
|
95
110
|
driver_config:
|
111
|
+
area: any
|
96
112
|
google_client_email: "123456789012@developer.gserviceaccount.com"
|
97
113
|
google_key_location: "<%= ENV['HOME']%>/gce/1234567890abcdef1234567890abcdef12345678-privatekey.p12"
|
98
114
|
google_project: "alpha-bravo-123"
|
@@ -126,11 +142,11 @@ Source is hosted on [GitHub](https://github.com/anl/kitchen-gce).
|
|
126
142
|
Created and maintained by [Andrew Leonard](http://andyleonard.com)
|
127
143
|
([andy@hurricane-ridge.com](mailto:andy@hurricane-ridge.com)).
|
128
144
|
|
129
|
-
The initial
|
145
|
+
The initial release drew heavily on the
|
130
146
|
[kitchen-ec2](https://github.com/opscode/kitchen-ec2/) gem for both
|
131
147
|
inspiration and implementation details. Any bugs, however, are solely
|
132
|
-
the author's own
|
148
|
+
the author's own doing.
|
133
149
|
|
134
150
|
## License
|
135
151
|
|
136
|
-
Apache 2.0.
|
152
|
+
Licensed under Apache 2.0.
|
data/kitchen-gce.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'kitchen-gce'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.4'
|
4
4
|
s.date = '2013-10-20'
|
5
5
|
s.summary = 'Kitchen::Driver::Gce'
|
6
6
|
s.description = 'A Test-Kitchen driver for Google Compute Engine'
|
@@ -10,7 +10,11 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = 'https://github.com/anl/kitchen-gce'
|
11
11
|
s.license = 'Apache 2.0'
|
12
12
|
|
13
|
-
s.add_dependency 'test-kitchen'
|
14
|
-
s.add_dependency 'fog', '>= 1.
|
13
|
+
s.add_dependency 'test-kitchen'
|
14
|
+
s.add_dependency 'fog', '>= 1.19.0'
|
15
15
|
s.add_dependency 'google-api-client'
|
16
|
+
|
17
|
+
s.add_development_dependency 'bundler'
|
18
|
+
s.add_development_dependency 'rspec'
|
19
|
+
s.add_development_dependency 'tailor'
|
16
20
|
end
|
data/lib/kitchen/driver/gce.rb
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require 'fog'
|
18
|
+
require 'securerandom'
|
18
19
|
|
19
20
|
require 'kitchen'
|
20
21
|
|
@@ -22,10 +23,11 @@ module Kitchen
|
|
22
23
|
module Driver
|
23
24
|
class Gce < Kitchen::Driver::SSHBase
|
24
25
|
|
25
|
-
default_config :
|
26
|
-
default_config :
|
27
|
-
default_config :
|
28
|
-
default_config :
|
26
|
+
default_config :area, 'us'
|
27
|
+
default_config :machine_type, 'n1-standard-1'
|
28
|
+
default_config :inst_name, nil
|
29
|
+
default_config :username, ENV['USER']
|
30
|
+
default_config :zone_name, nil
|
29
31
|
|
30
32
|
required_config :google_client_email
|
31
33
|
required_config :google_key_location
|
@@ -33,7 +35,10 @@ module Kitchen
|
|
33
35
|
required_config :image_name
|
34
36
|
|
35
37
|
def create(state)
|
36
|
-
|
38
|
+
return if state[:server_id]
|
39
|
+
|
40
|
+
config[:inst_name] ||= generate_name
|
41
|
+
server = create_instance
|
37
42
|
state[:server_id] = server.identity
|
38
43
|
|
39
44
|
info("GCE instance <#{state[:server_id]}> created.")
|
@@ -56,7 +61,7 @@ module Kitchen
|
|
56
61
|
end
|
57
62
|
|
58
63
|
private
|
59
|
-
|
64
|
+
|
60
65
|
def connection
|
61
66
|
Fog::Compute.new({
|
62
67
|
:provider => 'google',
|
@@ -68,13 +73,46 @@ module Kitchen
|
|
68
73
|
|
69
74
|
def create_instance
|
70
75
|
connection.servers.create({
|
71
|
-
:name => config[:
|
76
|
+
:name => config[:inst_name],
|
72
77
|
:image_name => config[:image_name],
|
73
78
|
:machine_type => config[:machine_type],
|
74
|
-
:zone_name =>
|
79
|
+
:zone_name => get_zone,
|
75
80
|
})
|
76
81
|
end
|
77
82
|
|
83
|
+
def get_zone
|
84
|
+
if config[:zone_name].nil?
|
85
|
+
zones = []
|
86
|
+
connection.zones.each do |z|
|
87
|
+
case config[:area]
|
88
|
+
when 'us'
|
89
|
+
if z.name.match(/^us/) and z.status == 'UP'
|
90
|
+
zones.push(z)
|
91
|
+
end
|
92
|
+
when 'europe'
|
93
|
+
if z.name.match(/^europe/) and z.status == 'UP'
|
94
|
+
zones.push(z)
|
95
|
+
end
|
96
|
+
when 'any'
|
97
|
+
if z.status == 'UP'
|
98
|
+
zones.push(z)
|
99
|
+
end
|
100
|
+
else
|
101
|
+
raise ArgumentError, 'Unknown area'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
return zones.sample.name
|
105
|
+
else
|
106
|
+
return config[:zone_name]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def generate_name
|
111
|
+
# Inspired by generate_name from kitchen-rackspace
|
112
|
+
base_name = instance.name[0..26] # UUID is 36 chars, max name length 63
|
113
|
+
"#{base_name}-#{SecureRandom.uuid}"
|
114
|
+
end
|
115
|
+
|
78
116
|
end
|
79
117
|
end
|
80
118
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-gce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -16,17 +16,17 @@ dependencies:
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: fog
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.
|
37
|
+
version: 1.19.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.
|
45
|
+
version: 1.19.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: google-api-client
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +59,54 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: bundler
|
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: rspec
|
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: tailor
|
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'
|
62
110
|
description: A Test-Kitchen driver for Google Compute Engine
|
63
111
|
email: andy@hurricane-ridge.com
|
64
112
|
executables: []
|
@@ -66,6 +114,7 @@ extensions: []
|
|
66
114
|
extra_rdoc_files: []
|
67
115
|
files:
|
68
116
|
- .gitignore
|
117
|
+
- CHANGELOG.md
|
69
118
|
- Gemfile
|
70
119
|
- LICENSE
|
71
120
|
- README.md
|
@@ -84,12 +133,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
133
|
- - ! '>='
|
85
134
|
- !ruby/object:Gem::Version
|
86
135
|
version: '0'
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
hash: -3638187786435759861
|
87
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
140
|
none: false
|
89
141
|
requirements:
|
90
142
|
- - ! '>='
|
91
143
|
- !ruby/object:Gem::Version
|
92
144
|
version: '0'
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
hash: -3638187786435759861
|
93
148
|
requirements: []
|
94
149
|
rubyforge_project:
|
95
150
|
rubygems_version: 1.8.23
|