vagrant-google 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/._CHANGELOG.md +0 -0
- data/._README.md +0 -0
- data/CHANGELOG.md +7 -0
- data/README.md +6 -5
- data/lib/vagrant-google/._action.rb +0 -0
- data/lib/vagrant-google/action.rb +9 -6
- data/lib/vagrant-google/action/._sync_folders.rb +0 -0
- data/lib/vagrant-google/action/run_instance.rb +49 -20
- data/lib/vagrant-google/action/start_instance.rb +1 -1
- data/lib/vagrant-google/action/stop_instance.rb +1 -1
- data/lib/vagrant-google/action/sync_folders.rb +1 -1
- data/lib/vagrant-google/action/terminate_instance.rb +1 -1
- data/lib/vagrant-google/action/warn_ssh_keys.rb +33 -0
- data/lib/vagrant-google/config.rb +7 -3
- data/lib/vagrant-google/plugin.rb +1 -1
- data/lib/vagrant-google/version.rb +1 -1
- data/locales/en.yml +8 -7
- data/tasks/._acceptance.rake +0 -0
- data/tasks/acceptance.rake +26 -6
- data/test/acceptance/provider/halt_spec.rb +34 -0
- data/test/acceptance/provider/multi_instance_spec.rb +1 -1
- data/test/acceptance/provider/preemptible_spec.rb +1 -1
- data/test/acceptance/provider/reload_spec.rb +29 -0
- data/test/acceptance/provider/scopes_spec.rb +1 -1
- data/test/acceptance/skeletons/._.DS_Store +0 -0
- data/test/acceptance/skeletons/generic/Vagrantfile +16 -0
- data/vagrantfile_examples/Vagrantfile.multiple_machines +1 -1
- metadata +49 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc34cd087ca2be06cd2f4c4ebf0299397e2ead9b
|
4
|
+
data.tar.gz: 80878f7ea508eeeadbc61b122ca2e68f86729dcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c5bfaab84c111b6619d163d566b329786520d4e7010444e75c6455e69a9256c3fc8abb7f150853df2d2eb88a853e2937d318aa4982bbd4a254d1a5002028b32
|
7
|
+
data.tar.gz: fd31180ce6ce43321b4005406d6ea34d967dcfad11cbea9db1c8406b889e8b2bb86d22793d36bfc1c7683b5323165e27606632ce19df64843f2e64a3a8ac3c6d
|
data/._CHANGELOG.md
ADDED
Binary file
|
data/._README.md
ADDED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.2.2 (October 2015)
|
2
|
+
|
3
|
+
* Cleanup instance and disks on backend failures [p0deje]
|
4
|
+
* Refactoring ssh warnings into separate action [temikus]
|
5
|
+
* Refactoring disk type detection logic [temikus]
|
6
|
+
* Miscellaneous doc updates and minor fixes [mbrukman, temikus]
|
7
|
+
|
1
8
|
# 0.2.1 (July 2015)
|
2
9
|
|
3
10
|
* Temporarily reverted the old SyncedFolders behaviour. (See #94)
|
data/README.md
CHANGED
@@ -172,7 +172,8 @@ This provider exposes quite a few provider-specific configuration options:
|
|
172
172
|
* `disk_size` - The disk size in GB. The default is 10.
|
173
173
|
* `disk_name` - The disk name to use. If the disk exists, it will be reused, otherwise created.
|
174
174
|
* `metadata` - Custom key/value pairs of metadata to add to the instance.
|
175
|
-
* `name` - The name of your instance. The default is "i-
|
175
|
+
* `name` - The name of your instance. The default is "i-yyyymmddhh-randomsd",
|
176
|
+
e.g. 10/08/2015 13:15:15 is "i-2015081013-15637fda".
|
176
177
|
* `network` - The name of the network to use for the instance. Default is
|
177
178
|
"default".
|
178
179
|
* `tags` - An array of tags to apply to this instance.
|
@@ -180,8 +181,8 @@ This provider exposes quite a few provider-specific configuration options:
|
|
180
181
|
* `can_ip_forward` - Boolean whether to enable IP Forwarding.
|
181
182
|
* `external_ip` - The external IP address to use (supports names).
|
182
183
|
* `preemptible` - Boolean whether to enable preemptibility. Default is false.
|
183
|
-
* `auto_restart` - Boolean whether to enable auto_restart. Default is true.
|
184
|
-
* `on_host_maintenance` - What to do on host maintenance. Default is "MIGRATE".
|
184
|
+
* `auto_restart` - Boolean whether to enable auto_restart. Default is true.
|
185
|
+
* `on_host_maintenance` - What to do on host maintenance. Default is "MIGRATE".
|
185
186
|
* `service_accounts` or `scopes` - An array of OAuth2 account scopes for
|
186
187
|
services that the instance will have access to. Those can be both full API
|
187
188
|
scopes, just endpoint aliases (the part after `...auth/`), and `gcloud`
|
@@ -297,10 +298,10 @@ export GOOGLE_SSH_USER="testuser"
|
|
297
298
|
export GOOGLE_SSH_KEY_LOCATION="/home/testuser/.ssh/id_rsa"
|
298
299
|
```
|
299
300
|
|
300
|
-
After, you can run acceptance tests by running the `
|
301
|
+
After, you can run acceptance tests by running the `full` task in `acceptance`
|
301
302
|
namespace:
|
302
303
|
```sh
|
303
|
-
$ bundle exec rake acceptance:
|
304
|
+
$ bundle exec rake acceptance:full
|
304
305
|
```
|
305
306
|
|
306
307
|
**IMPORTANT NOTES**:
|
Binary file
|
@@ -24,7 +24,7 @@ module VagrantPlugins
|
|
24
24
|
Vagrant::Action::Builder.new.tap do |b|
|
25
25
|
b.use ConfigValidate
|
26
26
|
b.use Call, IsCreated do |env, b2|
|
27
|
-
|
27
|
+
unless env[:result]
|
28
28
|
b2.use MessageNotCreated
|
29
29
|
next
|
30
30
|
end
|
@@ -41,7 +41,7 @@ module VagrantPlugins
|
|
41
41
|
if env[:result]
|
42
42
|
b2.use ConfigValidate
|
43
43
|
b2.use Call, IsCreated do |env2, b3|
|
44
|
-
|
44
|
+
unless env2[:result]
|
45
45
|
b3.use MessageNotCreated
|
46
46
|
next
|
47
47
|
end
|
@@ -60,7 +60,7 @@ module VagrantPlugins
|
|
60
60
|
Vagrant::Action::Builder.new.tap do |b|
|
61
61
|
b.use ConfigValidate
|
62
62
|
b.use Call, IsCreated do |env, b2|
|
63
|
-
|
63
|
+
unless env[:result]
|
64
64
|
b2.use MessageNotCreated
|
65
65
|
next
|
66
66
|
end
|
@@ -98,7 +98,7 @@ module VagrantPlugins
|
|
98
98
|
Vagrant::Action::Builder.new.tap do |b|
|
99
99
|
b.use ConfigValidate
|
100
100
|
b.use Call, IsCreated do |env, b2|
|
101
|
-
|
101
|
+
unless env[:result]
|
102
102
|
b2.use MessageNotCreated
|
103
103
|
next
|
104
104
|
end
|
@@ -112,7 +112,7 @@ module VagrantPlugins
|
|
112
112
|
Vagrant::Action::Builder.new.tap do |b|
|
113
113
|
b.use ConfigValidate
|
114
114
|
b.use Call, IsCreated do |env, b2|
|
115
|
-
|
115
|
+
unless env[:result]
|
116
116
|
b2.use MessageNotCreated
|
117
117
|
next
|
118
118
|
end
|
@@ -136,6 +136,7 @@ module VagrantPlugins
|
|
136
136
|
b2.use Provision
|
137
137
|
b2.use SyncFolders
|
138
138
|
b2.use WarnNetworks
|
139
|
+
b2.use WarnSshKeys
|
139
140
|
b2.use StartInstance
|
140
141
|
else
|
141
142
|
# TODO: Impement better messages for different states
|
@@ -146,6 +147,7 @@ module VagrantPlugins
|
|
146
147
|
b1.use Provision
|
147
148
|
b1.use SyncFolders
|
148
149
|
b1.use WarnNetworks
|
150
|
+
b1.use WarnSshKeys
|
149
151
|
b1.use RunInstance
|
150
152
|
end
|
151
153
|
end
|
@@ -157,7 +159,7 @@ module VagrantPlugins
|
|
157
159
|
b.use ConfigValidate
|
158
160
|
b.use ConnectGoogle
|
159
161
|
b.use Call, IsCreated do |env1, b1|
|
160
|
-
|
162
|
+
unless env1[:result]
|
161
163
|
b1.use MessageNotCreated
|
162
164
|
next
|
163
165
|
end
|
@@ -186,6 +188,7 @@ module VagrantPlugins
|
|
186
188
|
autoload :TerminateInstance, action_root.join("terminate_instance")
|
187
189
|
autoload :TimedProvision, action_root.join("timed_provision")
|
188
190
|
autoload :WarnNetworks, action_root.join("warn_networks")
|
191
|
+
autoload :WarnSshKeys, action_root.join("warn_ssh_keys")
|
189
192
|
end
|
190
193
|
end
|
191
194
|
end
|
Binary file
|
@@ -22,6 +22,12 @@ module VagrantPlugins
|
|
22
22
|
class RunInstance
|
23
23
|
include Vagrant::Util::Retryable
|
24
24
|
|
25
|
+
FOG_ERRORS = [
|
26
|
+
Fog::Compute::Google::NotFound,
|
27
|
+
Fog::Compute::Google::Error,
|
28
|
+
Fog::Errors::Error
|
29
|
+
]
|
30
|
+
|
25
31
|
def initialize(app, env)
|
26
32
|
@app = app
|
27
33
|
@logger = Log4r::Logger.new("vagrant_google::action::run_instance")
|
@@ -73,24 +79,14 @@ module VagrantPlugins
|
|
73
79
|
env[:ui].info(" -- Autodelete Disk: #{autodelete_disk}")
|
74
80
|
env[:ui].info(" -- Scopes: #{service_accounts}")
|
75
81
|
begin
|
76
|
-
request_start_time = Time.now
|
77
|
-
|
78
|
-
if env[:machine].config.ssh.username.nil?
|
79
|
-
env[:ui].warn(I18n.t("vagrant_google.warn_ssh_vagrant_user"))
|
80
|
-
end
|
82
|
+
request_start_time = Time.now.to_i
|
83
|
+
|
81
84
|
# Check if specified external ip is available
|
82
85
|
external_ip = get_external_ip(env, external_ip) if external_ip
|
83
|
-
# Check if disk type is available in the zone
|
84
|
-
|
85
|
-
disk_type_obj = env[:google_compute].list_disk_types(zone).body['items'].select { |dt| dt['name'] == disk_type } || []
|
86
|
-
if !disk_type_obj.empty?
|
87
|
-
disk_type = disk_type_obj[0]["selfLink"]
|
88
|
-
else
|
89
|
-
raise Errors::DiskTypeError,
|
90
|
-
:disktype => disk_type
|
91
|
-
end
|
92
|
-
end
|
86
|
+
# Check if disk type is available in the zone and set the proper resource link
|
87
|
+
disk_type = get_disk_type(env, disk_type, zone)
|
93
88
|
|
89
|
+
disk_created_by_vagrant = false
|
94
90
|
if disk_name.nil?
|
95
91
|
# no disk_name... disk_name defaults to instance name
|
96
92
|
disk = env[:google_compute].disks.create(
|
@@ -100,6 +96,7 @@ module VagrantPlugins
|
|
100
96
|
zone_name: zone,
|
101
97
|
source_image: image
|
102
98
|
)
|
99
|
+
disk_created_by_vagrant = true
|
103
100
|
disk.wait_for { disk.ready? }
|
104
101
|
else
|
105
102
|
disk = env[:google_compute].disks.get(disk_name, zone)
|
@@ -112,6 +109,7 @@ module VagrantPlugins
|
|
112
109
|
zone_name: zone,
|
113
110
|
source_image: image
|
114
111
|
)
|
112
|
+
disk_created_by_vagrant = true
|
115
113
|
disk.wait_for { disk.ready? }
|
116
114
|
end
|
117
115
|
end
|
@@ -136,9 +134,13 @@ module VagrantPlugins
|
|
136
134
|
}
|
137
135
|
server = env[:google_compute].servers.create(defaults)
|
138
136
|
@logger.info("Machine '#{zone}:#{name}' created.")
|
139
|
-
rescue
|
140
|
-
|
141
|
-
|
137
|
+
rescue *FOG_ERRORS => e
|
138
|
+
# there is a chance Google responded with error but actually created
|
139
|
+
# instance, so we need to remove it
|
140
|
+
cleanup_instance(env)
|
141
|
+
# there is a chance Google has failed to create instance, so we need
|
142
|
+
# to remove created disk
|
143
|
+
cleanup_disk(disk.name, env) if disk && disk_created_by_vagrant
|
142
144
|
raise Errors::FogError, :message => e.message
|
143
145
|
end
|
144
146
|
|
@@ -149,14 +151,14 @@ module VagrantPlugins
|
|
149
151
|
env[:ui].info(I18n.t("vagrant_google.waiting_for_ready"))
|
150
152
|
begin
|
151
153
|
server.wait_for { ready? }
|
152
|
-
env[:metrics]["instance_ready_time"] = Time.now
|
154
|
+
env[:metrics]["instance_ready_time"] = Time.now.to_i - request_start_time
|
153
155
|
@logger.info("Time for instance ready: #{env[:metrics]["instance_ready_time"]}")
|
154
156
|
env[:ui].info(I18n.t("vagrant_google.ready"))
|
155
157
|
rescue
|
156
158
|
env[:interrupted] = true
|
157
159
|
end
|
158
160
|
|
159
|
-
|
161
|
+
unless env[:terminated]
|
160
162
|
env[:metrics]["instance_ssh_time"] = Util::Timer.time do
|
161
163
|
# Wait for SSH to be ready.
|
162
164
|
env[:ui].info(I18n.t("vagrant_google.waiting_for_ssh"))
|
@@ -194,6 +196,17 @@ module VagrantPlugins
|
|
194
196
|
env[:action_runner].run(Action.action_destroy, destroy_env)
|
195
197
|
end
|
196
198
|
|
199
|
+
def get_disk_type(env, disk_type, zone)
|
200
|
+
begin
|
201
|
+
# TODO(temikus): Outsource parsing logic to fog-google
|
202
|
+
disk_type=env[:google_compute].get_disk_type(disk_type, zone).body["selfLink"]
|
203
|
+
rescue Fog::Errors::NotFound
|
204
|
+
raise Errors::DiskTypeError,
|
205
|
+
:disktype => disk_type
|
206
|
+
end
|
207
|
+
disk_type
|
208
|
+
end
|
209
|
+
|
197
210
|
def get_external_ip(env, external_ip)
|
198
211
|
address = env[:google_compute].addresses.get_by_ip_address_or_name(external_ip)
|
199
212
|
if address.nil?
|
@@ -207,6 +220,22 @@ module VagrantPlugins
|
|
207
220
|
# Resolve the name to IP address
|
208
221
|
address.address
|
209
222
|
end
|
223
|
+
|
224
|
+
def cleanup_instance(env)
|
225
|
+
zone = env[:machine].provider_config.zone
|
226
|
+
zone_config = env[:machine].provider_config.get_zone_config(zone)
|
227
|
+
server = env[:google_compute].servers.get(zone_config.name, zone)
|
228
|
+
server.destroy(false) if server
|
229
|
+
end
|
230
|
+
|
231
|
+
def cleanup_disk(disk_name, env)
|
232
|
+
zone = env[:machine].provider_config.zone
|
233
|
+
autodelete_disk = env[:machine].provider_config.get_zone_config(zone).autodelete_disk
|
234
|
+
if autodelete_disk
|
235
|
+
disk = env[:google_compute].disks.get(disk_name, zone)
|
236
|
+
disk.destroy(false) if disk
|
237
|
+
end
|
238
|
+
end
|
210
239
|
end
|
211
240
|
end
|
212
241
|
end
|
@@ -64,7 +64,7 @@ module VagrantPlugins
|
|
64
64
|
|
65
65
|
@logger.info("Time to instance ready: #{env[:metrics]["instance_ready_time"]}")
|
66
66
|
|
67
|
-
|
67
|
+
unless env[:interrupted]
|
68
68
|
env[:metrics]["instance_ssh_time"] = Util::Timer.time do
|
69
69
|
# Wait for SSH to be ready.
|
70
70
|
env[:ui].info(I18n.t("vagrant_google.waiting_for_ssh"))
|
@@ -29,7 +29,7 @@ module VagrantPlugins
|
|
29
29
|
# Destroy the server and remove the tracking ID
|
30
30
|
# destroy() is called with 'false' to disable asynchronous execution.
|
31
31
|
env[:ui].info(I18n.t("vagrant_google.terminating"))
|
32
|
-
server.destroy(false)
|
32
|
+
server.destroy(false) unless server.nil?
|
33
33
|
env[:machine].id = nil
|
34
34
|
|
35
35
|
@app.call(env)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright 2015 Google Inc. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
module VagrantPlugins
|
15
|
+
module Google
|
16
|
+
module Action
|
17
|
+
class WarnSshKeys
|
18
|
+
def initialize(app, env)
|
19
|
+
@app = app
|
20
|
+
end
|
21
|
+
|
22
|
+
def call(env)
|
23
|
+
# Warn on ssh-key overrides
|
24
|
+
if env[:machine].config.ssh.username.nil?
|
25
|
+
env[:ui].warn(I18n.t("vagrant_google.warn_ssh_vagrant_user"))
|
26
|
+
end
|
27
|
+
|
28
|
+
@app.call(env)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -250,7 +250,8 @@ module VagrantPlugins
|
|
250
250
|
# Default disk type is pd-standard
|
251
251
|
@disk_type = "pd-standard" if @disk_type == UNSET_VALUE
|
252
252
|
|
253
|
-
# Instance name defaults to a new datetime value
|
253
|
+
# Instance name defaults to a new datetime value + random seed
|
254
|
+
# e.g. i-2015081013-15637fdb
|
254
255
|
if @name == UNSET_VALUE
|
255
256
|
t = Time.now
|
256
257
|
@name = "i-#{t.strftime("%Y%m%d%H")}-" + SecureRandom.hex(4)
|
@@ -287,7 +288,7 @@ module VagrantPlugins
|
|
287
288
|
|
288
289
|
# Compile our zone specific configurations only within
|
289
290
|
# NON-zone-SPECIFIC configurations.
|
290
|
-
|
291
|
+
unless @__zone_specific
|
291
292
|
@__zone_config.each do |zone, blocks|
|
292
293
|
config = self.class.new(true).merge(self)
|
293
294
|
|
@@ -326,6 +327,9 @@ module VagrantPlugins
|
|
326
327
|
!config.google_key_location.nil? and !config.google_json_key_location.nil?
|
327
328
|
errors << I18n.t("vagrant_google.config.google_key_location_required") if \
|
328
329
|
config.google_key_location.nil? and config.google_json_key_location.nil?
|
330
|
+
errors << I18n.t("vagrant_google.config.private_key_missing") unless \
|
331
|
+
File.exist?(config.google_key_location.to_s) or \
|
332
|
+
File.exist?(config.google_json_key_location.to_s)
|
329
333
|
|
330
334
|
if config.preemptible
|
331
335
|
errors << I18n.t("vagrant_google.config.auto_restart_invalid_on_preemptible") if \
|
@@ -344,7 +348,7 @@ module VagrantPlugins
|
|
344
348
|
# This gets the configuration for a specific zone. It shouldn't
|
345
349
|
# be called by the general public and is only used internally.
|
346
350
|
def get_zone_config(name)
|
347
|
-
|
351
|
+
unless @__finalized
|
348
352
|
raise "Configuration must be finalized before calling this method."
|
349
353
|
end
|
350
354
|
|
@@ -70,7 +70,7 @@ module VagrantPlugins
|
|
70
70
|
# Some constants, such as "true" resolve to booleans, so the
|
71
71
|
# above error checking doesn't catch it. This will check to make
|
72
72
|
# sure that the log level is an integer, as Log4r requires.
|
73
|
-
level = nil
|
73
|
+
level = nil unless level.is_a?(Integer)
|
74
74
|
|
75
75
|
# Set the logging level on all "vagrant" namespaced
|
76
76
|
# logs as long as we have a valid level.
|
data/locales/en.yml
CHANGED
@@ -25,8 +25,6 @@ en:
|
|
25
25
|
Terminating the instance...
|
26
26
|
waiting_for_ready: |-
|
27
27
|
Waiting for instance to become "ready"...
|
28
|
-
waiting_for_stop: |-
|
29
|
-
Waiting for instance to become terminated...
|
30
28
|
waiting_for_ssh: |-
|
31
29
|
Waiting for SSH to become available...
|
32
30
|
warn_networks: |-
|
@@ -49,13 +47,16 @@ en:
|
|
49
47
|
#-------------------------------------------------------------------------------
|
50
48
|
config:
|
51
49
|
google_client_email_required: |-
|
52
|
-
A Google Service Account client email is required via
|
50
|
+
A Google Service Account client email is required via
|
51
|
+
"google_client_email".
|
53
52
|
private_key_missing: |-
|
54
|
-
|
53
|
+
Private key for Google could not be found in the specified location.
|
55
54
|
zone_required: |-
|
56
|
-
A zone must be specified via "zone"
|
55
|
+
A zone must be specified via "zone" option.
|
57
56
|
name_required: |-
|
58
|
-
An instance name must be specified via "name"
|
57
|
+
An instance name must be specified via "name" option.
|
58
|
+
image_required: |-
|
59
|
+
An image must be specified via "image" option.
|
59
60
|
google_key_location_required: |-
|
60
61
|
A private key pathname is required via:
|
61
62
|
"google_json_key_location" (for JSON keys)
|
@@ -65,7 +66,7 @@ en:
|
|
65
66
|
Both "google_json_key_location" and "google_key_location" are specified.
|
66
67
|
Config must specify only one key location.
|
67
68
|
google_project_id_required: |-
|
68
|
-
A Google Cloud Project ID is required via "google_project_id"
|
69
|
+
A Google Cloud Project ID is required via "google_project_id".
|
69
70
|
auto_restart_invalid_on_preemptible: |-
|
70
71
|
"auto_restart" option must be set to "false" for preemptible instances.
|
71
72
|
on_host_maintenance_invalid_on_preemptible: |-
|
Binary file
|
data/tasks/acceptance.rake
CHANGED
@@ -14,35 +14,44 @@ end
|
|
14
14
|
|
15
15
|
namespace :acceptance do
|
16
16
|
|
17
|
+
desc "Run full acceptance suite"
|
18
|
+
task :full => [:check_env, :run_full]
|
19
|
+
|
20
|
+
desc "Run smoke tests"
|
21
|
+
task :smoke => [:check_env, :run_smoke]
|
22
|
+
|
17
23
|
desc "shows components that can be tested separately"
|
18
24
|
task :components do
|
19
25
|
exec("bundle exec vagrant-spec components")
|
20
26
|
end
|
21
27
|
|
22
|
-
desc "
|
23
|
-
task :
|
24
|
-
|
28
|
+
desc "checks if environment variables are set"
|
29
|
+
task :check_env do
|
25
30
|
yellow "NOTE: For acceptance tests to be functional, correct ssh key needs to be added to GCE metadata."
|
26
31
|
|
27
32
|
if !ENV["GOOGLE_JSON_KEY_LOCATION"] && !ENV["GOOGLE_KEY_LOCATION"]
|
28
33
|
abort ("Environment variables GOOGLE_JSON_KEY_LOCATION or GOOGLE_KEY_LOCATION are not set. Aborting.")
|
29
34
|
end
|
30
35
|
|
31
|
-
|
36
|
+
unless ENV["GOOGLE_PROJECT_ID"]
|
32
37
|
abort ("Environment variable GOOGLE_PROJECT_ID is not set. Aborting.")
|
33
38
|
end
|
34
39
|
|
35
|
-
|
40
|
+
unless ENV["GOOGLE_CLIENT_EMAIL"]
|
36
41
|
abort ("Environment variable GOOGLE_CLIENT_EMAIL is not set. Aborting.")
|
37
42
|
end
|
38
43
|
|
39
|
-
|
44
|
+
unless ENV["GOOGLE_SSH_USER"]
|
40
45
|
puts "WARNING: GOOGLE_SSH_USER variable is not set. Will try to start tests using insecure Vagrant private key."
|
41
46
|
end
|
47
|
+
end
|
42
48
|
|
49
|
+
task :run_full do
|
43
50
|
components = %w(
|
51
|
+
halt
|
44
52
|
multi_instance
|
45
53
|
preemptible
|
54
|
+
reload
|
46
55
|
scopes
|
47
56
|
provisioner/shell
|
48
57
|
provisioner/chef-solo
|
@@ -53,4 +62,15 @@ namespace :acceptance do
|
|
53
62
|
puts
|
54
63
|
exec(command)
|
55
64
|
end
|
65
|
+
|
66
|
+
task :run_smoke do
|
67
|
+
components = %w(
|
68
|
+
provisioner/shell
|
69
|
+
).map{ |s| "provider/google/#{s}" }
|
70
|
+
|
71
|
+
command = "bundle exec vagrant-spec test --components=#{components.join(" ")}"
|
72
|
+
puts command
|
73
|
+
puts
|
74
|
+
exec(command)
|
75
|
+
end
|
56
76
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# This tests that an instance can be halted correctly
|
2
|
+
shared_examples 'provider/halt' do |provider, options|
|
3
|
+
unless options[:box]
|
4
|
+
raise ArgumentError,
|
5
|
+
"box option must be specified for provider: #{provider}"
|
6
|
+
end
|
7
|
+
|
8
|
+
include_context 'acceptance'
|
9
|
+
|
10
|
+
before do
|
11
|
+
environment.skeleton('generic')
|
12
|
+
assert_execute('vagrant', 'box', 'add', 'basic', options[:box])
|
13
|
+
assert_execute('vagrant', 'up', "--provider=#{provider}")
|
14
|
+
end
|
15
|
+
|
16
|
+
after do
|
17
|
+
assert_execute('vagrant', 'destroy', '--force')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should halt the machine and bring it back up' do
|
21
|
+
status("Test: machine can be halted")
|
22
|
+
halt_result = execute("vagrant", "halt")
|
23
|
+
expect(halt_result).to exit_with(0)
|
24
|
+
|
25
|
+
status("Test: machine can be brought up after halt")
|
26
|
+
up_result = execute("vagrant", "up")
|
27
|
+
expect(up_result).to exit_with(0)
|
28
|
+
|
29
|
+
status("Test: machine is running after up")
|
30
|
+
echo_result = execute("vagrant", "ssh", "-c", "echo foo")
|
31
|
+
expect(echo_result).to exit_with(0)
|
32
|
+
expect(echo_result.stdout).to match(/foo\n$/)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# This tests that an instance can be reloaded correctly
|
2
|
+
shared_examples 'provider/reload' do |provider, options|
|
3
|
+
unless options[:box]
|
4
|
+
raise ArgumentError,
|
5
|
+
"box option must be specified for provider: #{provider}"
|
6
|
+
end
|
7
|
+
|
8
|
+
include_context 'acceptance'
|
9
|
+
|
10
|
+
before do
|
11
|
+
environment.skeleton('generic')
|
12
|
+
assert_execute('vagrant', 'box', 'add', 'basic', options[:box])
|
13
|
+
assert_execute('vagrant', 'up', "--provider=#{provider}")
|
14
|
+
end
|
15
|
+
|
16
|
+
after do
|
17
|
+
assert_execute('vagrant', 'destroy', '--force')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should reload the machine correctly' do
|
21
|
+
status("Test: machine can be reloaded")
|
22
|
+
reload_result = execute("vagrant", "reload")
|
23
|
+
expect(reload_result).to exit_with(0)
|
24
|
+
|
25
|
+
echo_result = execute("vagrant", "ssh", "-c", "echo foo")
|
26
|
+
expect(echo_result).to exit_with(0)
|
27
|
+
expect(echo_result.stdout).to match(/foo\n$/)
|
28
|
+
end
|
29
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# available and gcloud GCE aliases can be used.
|
4
4
|
# (see lib/fog/google/models/compute/server.rb in fog-google)
|
5
5
|
shared_examples 'provider/scopes' do |provider, options|
|
6
|
-
|
6
|
+
unless options[:box]
|
7
7
|
raise ArgumentError,
|
8
8
|
"box option must be specified for provider: #{provider}"
|
9
9
|
end
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This is a generic acceptance skeleton with no particular settings, set in
|
2
|
+
# europe-west1-d zone
|
3
|
+
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
config.vm.box = "basic"
|
6
|
+
|
7
|
+
config.vm.provider :google do |google, override|
|
8
|
+
|
9
|
+
google.zone = "europe-west1-d"
|
10
|
+
|
11
|
+
google.zone_config "europe-west1-d" do |zone1d|
|
12
|
+
zone1d.image = "debian-7-wheezy-v20150603"
|
13
|
+
zone1d.zone = "europe-west1-d"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -29,7 +29,7 @@ $GOOGLE_JSON_KEY_LOCATION = "/path/to/your/private-key.json"
|
|
29
29
|
$LOCAL_USER = "mitchellh"
|
30
30
|
$LOCAL_SSH_KEY = "~/.ssh/id_rsa"
|
31
31
|
|
32
|
-
# Example Debian
|
32
|
+
# Example Debian provision script
|
33
33
|
$PROVISION_DEBIAN = <<SCRIPT
|
34
34
|
uname=$(uname -a)
|
35
35
|
ver=$(cat /etc/debian_version)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-google
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Johnson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog-google
|
@@ -87,21 +87,8 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
-
|
91
|
-
-
|
92
|
-
- LICENSE
|
93
|
-
- README.md
|
94
|
-
- Rakefile
|
95
|
-
- example_boxes/README.md
|
96
|
-
- example_boxes/gce-test/Vagrantfile
|
97
|
-
- example_boxes/gce-test/metadata.json
|
98
|
-
- example_boxes/gce/Vagrantfile
|
99
|
-
- example_boxes/gce/metadata.json
|
100
|
-
- google-test.box
|
101
|
-
- google.box
|
102
|
-
- lib/vagrant-google.rb
|
103
|
-
- lib/vagrant-google/action.rb
|
104
|
-
- lib/vagrant-google/action/connect_google.rb
|
90
|
+
- lib/vagrant-google/action/run_instance.rb
|
91
|
+
- lib/vagrant-google/action/sync_folders.rb
|
105
92
|
- lib/vagrant-google/action/is_created.rb
|
106
93
|
- lib/vagrant-google/action/is_terminated.rb
|
107
94
|
- lib/vagrant-google/action/message_already_created.rb
|
@@ -109,44 +96,71 @@ files:
|
|
109
96
|
- lib/vagrant-google/action/message_will_not_destroy.rb
|
110
97
|
- lib/vagrant-google/action/read_ssh_info.rb
|
111
98
|
- lib/vagrant-google/action/read_state.rb
|
112
|
-
- lib/vagrant-google/action/
|
99
|
+
- lib/vagrant-google/action/timed_provision.rb
|
113
100
|
- lib/vagrant-google/action/start_instance.rb
|
114
|
-
- lib/vagrant-google/action/stop_instance.rb
|
115
|
-
- lib/vagrant-google/action/sync_folders.rb
|
116
101
|
- lib/vagrant-google/action/terminate_instance.rb
|
117
|
-
- lib/vagrant-google/action/
|
102
|
+
- lib/vagrant-google/action/connect_google.rb
|
118
103
|
- lib/vagrant-google/action/warn_networks.rb
|
119
|
-
- lib/vagrant-google/
|
104
|
+
- lib/vagrant-google/action/stop_instance.rb
|
105
|
+
- lib/vagrant-google/action/warn_ssh_keys.rb
|
106
|
+
- lib/vagrant-google/util/timer.rb
|
107
|
+
- lib/vagrant-google/provider.rb
|
120
108
|
- lib/vagrant-google/errors.rb
|
109
|
+
- lib/vagrant-google/action.rb
|
110
|
+
- lib/vagrant-google/config.rb
|
121
111
|
- lib/vagrant-google/plugin.rb
|
122
|
-
- lib/vagrant-google/provider.rb
|
123
|
-
- lib/vagrant-google/util/timer.rb
|
124
112
|
- lib/vagrant-google/version.rb
|
113
|
+
- lib/vagrant-google.rb
|
125
114
|
- locales/en.yml
|
126
|
-
-
|
115
|
+
- vagrantfile_examples/Vagrantfile.simple
|
116
|
+
- vagrantfile_examples/Vagrantfile.provision_single
|
117
|
+
- vagrantfile_examples/Vagrantfile.zone_config
|
118
|
+
- vagrantfile_examples/Vagrantfile.multiple_machines
|
119
|
+
- vagrant-google.gemspec
|
120
|
+
- LICENSE
|
121
|
+
- Vagrantfile.testing
|
122
|
+
- Gemfile
|
123
|
+
- example_boxes/gce/metadata.json
|
124
|
+
- example_boxes/gce/Vagrantfile
|
125
|
+
- example_boxes/gce-test/metadata.json
|
126
|
+
- example_boxes/gce-test/Vagrantfile
|
127
|
+
- example_boxes/README.md
|
128
|
+
- CHANGELOG.md
|
129
|
+
- google-test.box
|
130
|
+
- vagrant-spec.config.rb
|
131
|
+
- Vagrantfile.current
|
132
|
+
- Vagrantfile
|
133
|
+
- google.box
|
134
|
+
- Rakefile
|
127
135
|
- tasks/bundler.rake
|
128
136
|
- tasks/lint.rake
|
129
137
|
- tasks/test.rake
|
138
|
+
- tasks/acceptance.rake
|
130
139
|
- test/acceptance/base.rb
|
140
|
+
- test/acceptance/shared/context_google.rb
|
141
|
+
- test/acceptance/provider/halt_spec.rb
|
131
142
|
- test/acceptance/provider/multi_instance_spec.rb
|
132
143
|
- test/acceptance/provider/preemptible_spec.rb
|
144
|
+
- test/acceptance/provider/reload_spec.rb
|
133
145
|
- test/acceptance/provider/scopes_spec.rb
|
134
|
-
- test/acceptance/shared/context_google.rb
|
135
146
|
- test/acceptance/skeletons/multi_instance/Vagrantfile
|
136
147
|
- test/acceptance/skeletons/preemptible/Vagrantfile
|
137
148
|
- test/acceptance/skeletons/scopes/Vagrantfile
|
138
|
-
- test/
|
149
|
+
- test/acceptance/skeletons/generic/Vagrantfile
|
139
150
|
- test/unit/common/config_test.rb
|
140
|
-
-
|
141
|
-
-
|
142
|
-
-
|
143
|
-
-
|
144
|
-
-
|
145
|
-
- vagrantfile_examples/Vagrantfile.zone_config
|
146
|
-
- .gitignore
|
147
|
-
- .rubocop.yml
|
151
|
+
- test/unit/base.rb
|
152
|
+
- Vagrantfile.working
|
153
|
+
- README.md
|
154
|
+
- lib/vagrant-google/action/._sync_folders.rb
|
155
|
+
- lib/vagrant-google/._action.rb
|
148
156
|
- .rubocop_todo.yml
|
157
|
+
- ._README.md
|
158
|
+
- ._CHANGELOG.md
|
149
159
|
- .ruby-version
|
160
|
+
- tasks/._acceptance.rake
|
161
|
+
- test/acceptance/skeletons/._.DS_Store
|
162
|
+
- .gitignore
|
163
|
+
- .rubocop.yml
|
150
164
|
homepage: http://www.vagrantup.com
|
151
165
|
licenses: []
|
152
166
|
metadata: {}
|