vagrant-google 2.2.1 → 2.3.0.rc0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +15 -3
- data/lib/vagrant-google/action/run_instance.rb +84 -3
- data/lib/vagrant-google/config.rb +6 -0
- data/lib/vagrant-google/version.rb +1 -1
- data/test/unit/base.rb +1 -0
- data/test/unit/common/config_test.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08471e3d05bc8414569638e5fdc304ee522d743f'
|
4
|
+
data.tar.gz: a91555ed68b59ce5e1b84d1bab7b681ebb1ce890
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91a2d9310f63eb4eb3755d5a7d7d68c19bfc1975b5ba77521bbebcfc87089f07bf7f790e5f474c390bae626324fa7b7fde3c1e85eef8432f5e31f6efae6f6331
|
7
|
+
data.tar.gz: 1f666a0801fc61431bbe3c970483a5b09672de88441d5671631ef4f988a67db9bfbe145900d636bd2488a5bfee4df73e0844b9f4cc2c31cc3abfb0023210e4f1
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
4
4
|
|
5
|
+
## 2.3.0 (February 2019)
|
6
|
+
|
7
|
+
### User-facing
|
8
|
+
|
9
|
+
- \#210 Allow adding additional disks to the instances. [whynick1]
|
10
|
+
|
11
|
+
### Development
|
12
|
+
|
13
|
+
- \#211 Rspec-its is now explicitly required for unit tests. [temikus]
|
14
|
+
|
5
15
|
## 2.2.1 (October 2018)
|
6
16
|
|
7
17
|
### User-facing
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Vagrant Google Compute Engine (GCE) Provider
|
2
2
|
|
3
|
-
|
4
|
-
[][gem]
|
5
|
-
[][gemnasium]
|
3
|
+
[](https://badge.fury.io/rb/vagrant-google)
|
6
4
|
|
7
5
|
[gem]: https://rubygems.org/gems/vagrant-google
|
8
6
|
[gemnasium]: https://gemnasium.com/mitchellh/vagrant-google
|
@@ -210,6 +208,20 @@ will pull the most recent CentOS 7 image. For more info, refer to
|
|
210
208
|
utility aliases, for example:
|
211
209
|
`['storage-full', 'bigquery', 'https://www.googleapis.com/auth/compute']`.
|
212
210
|
* `service_account` - The IAM service account email to use for the instance.
|
211
|
+
* `additional_disks` - An array of additional disk configurations. `disk_size` is default to `10`GB;
|
212
|
+
`disk_name` is default to `name` + "-additional-disk-#{index}"; `disk_type` is default to `pd-standard`;
|
213
|
+
`autodelete_disk` is default to `true`. Here is an example of configuration.
|
214
|
+
```ruby
|
215
|
+
[{
|
216
|
+
:image_family => "google-image-family",
|
217
|
+
:image => nil,
|
218
|
+
:image_project_id => "google-project-id",
|
219
|
+
:disk_size => 20,
|
220
|
+
:disk_name => "google-additional-disk-0",
|
221
|
+
:disk_type => "pd-standard",
|
222
|
+
:autodelete_disk => true
|
223
|
+
}]
|
224
|
+
```
|
213
225
|
|
214
226
|
These can be set like typical provider-specific configuration:
|
215
227
|
|
@@ -67,6 +67,7 @@ module VagrantPlugins
|
|
67
67
|
service_account_scopes = zone_config.scopes
|
68
68
|
service_account = zone_config.service_account
|
69
69
|
project_id = zone_config.google_project_id
|
70
|
+
additional_disks = zone_config.additional_disks
|
70
71
|
|
71
72
|
# Launch!
|
72
73
|
env[:ui].info(I18n.t("vagrant_google.launching_instance"))
|
@@ -96,6 +97,7 @@ module VagrantPlugins
|
|
96
97
|
env[:ui].info(" -- Autodelete Disk: #{autodelete_disk}")
|
97
98
|
env[:ui].info(" -- Scopes: #{service_account_scopes}") if service_account_scopes
|
98
99
|
env[:ui].info(" -- Service Account: #{service_account}") if service_account
|
100
|
+
env[:ui].info(" -- Additional Disks:#{additional_disks}")
|
99
101
|
|
100
102
|
# Munge image config
|
101
103
|
if image_family
|
@@ -127,7 +129,7 @@ module VagrantPlugins
|
|
127
129
|
|
128
130
|
begin
|
129
131
|
request_start_time = Time.now.to_i
|
130
|
-
|
132
|
+
disk = nil
|
131
133
|
# Check if specified external ip is available
|
132
134
|
external_ip = get_external_ip(env, external_ip) if external_ip
|
133
135
|
# Check if disk type is available in the zone and set the proper resource link
|
@@ -161,6 +163,83 @@ module VagrantPlugins
|
|
161
163
|
end
|
162
164
|
end
|
163
165
|
|
166
|
+
# Add boot disk to the instance
|
167
|
+
disks = [disk.get_as_boot_disk(true, autodelete_disk)]
|
168
|
+
|
169
|
+
# Configure additional disks
|
170
|
+
additional_disks.each_with_index do |disk_config, index|
|
171
|
+
additional_disk = nil
|
172
|
+
|
173
|
+
# Get additional disk image
|
174
|
+
# Create a blank disk if neither image nor additional_disk_image is provided
|
175
|
+
additional_disk_image = nil
|
176
|
+
if disk_config[:image_family]
|
177
|
+
additional_disk_image = env[:google_compute].images.get_from_family(disk_config[:image_family], disk_config[:image_project_id]).self_link
|
178
|
+
elsif disk_config[:image]
|
179
|
+
additional_disk_image = env[:google_compute].images.get(disk_config[:image], disk_config[:image_project_id]).self_link
|
180
|
+
end
|
181
|
+
|
182
|
+
# Get additional disk size
|
183
|
+
additional_disk_size = nil
|
184
|
+
if disk_config[:disk_size].nil?
|
185
|
+
# Default disk size is 10 GB
|
186
|
+
additional_disk_size = 10
|
187
|
+
else
|
188
|
+
additional_disk_size = disk_config[:disk_size]
|
189
|
+
end
|
190
|
+
|
191
|
+
# Get additional disk type
|
192
|
+
additional_disk_type = nil
|
193
|
+
if disk_config[:disk_type].nil?
|
194
|
+
# Default disk type is pd-standard
|
195
|
+
additional_disk_type = get_disk_type(env, "pd-standard", zone)
|
196
|
+
else
|
197
|
+
additional_disk_type = get_disk_type(env, disk_config[:disk_type], zone)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Get additional disk auto delete
|
201
|
+
additional_disk_auto_delete = nil
|
202
|
+
if disk_config[:disk_type].nil?
|
203
|
+
# Default auto delete to true
|
204
|
+
additional_disk_auto_delete = true
|
205
|
+
else
|
206
|
+
additional_disk_auto_delete = disk_config[:autodelete_disk]
|
207
|
+
end
|
208
|
+
|
209
|
+
# Get additional disk name
|
210
|
+
additional_disk_name = nil
|
211
|
+
if disk_config[:disk_name].nil?
|
212
|
+
# no disk_name... disk_name defaults to instance (name + "-additional-disk-#{index}"
|
213
|
+
additional_disk_name = name + "-additional-disk-#{index}"
|
214
|
+
additional_disk = env[:google_compute].disks.create(
|
215
|
+
name: additional_disk_name,
|
216
|
+
size_gb: additional_disk_size,
|
217
|
+
type: additional_disk_type,
|
218
|
+
zone_name: zone,
|
219
|
+
source_image: additional_disk_image
|
220
|
+
)
|
221
|
+
else
|
222
|
+
# additional_disk_name set in disk_config
|
223
|
+
additional_disk_name = disk_config[:disk_name]
|
224
|
+
|
225
|
+
additional_disk = env[:google_compute].disks.get(additional_disk_name, zone)
|
226
|
+
if additional_disk.nil?
|
227
|
+
# disk not found... create it with name
|
228
|
+
additional_disk = env[:google_compute].disks.create(
|
229
|
+
name: additional_disk_name,
|
230
|
+
size_gb: additional_disk_size,
|
231
|
+
type: additional_disk_type,
|
232
|
+
zone_name: zone,
|
233
|
+
source_image: additional_disk_image
|
234
|
+
)
|
235
|
+
additional_disk.wait_for { additional_disk.ready? }
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
# Add additional disk to the instance
|
240
|
+
disks.push(additional_disk.attached_disk_obj(boot:false, writable:true, auto_delete:additional_disk_auto_delete))
|
241
|
+
end
|
242
|
+
|
164
243
|
defaults = {
|
165
244
|
:name => name,
|
166
245
|
:zone => zone,
|
@@ -175,7 +254,7 @@ module VagrantPlugins
|
|
175
254
|
:can_ip_forward => can_ip_forward,
|
176
255
|
:use_private_ip => use_private_ip,
|
177
256
|
:external_ip => external_ip,
|
178
|
-
:disks =>
|
257
|
+
:disks => disks,
|
179
258
|
:scheduling => scheduling,
|
180
259
|
:service_accounts => service_accounts
|
181
260
|
}
|
@@ -185,7 +264,9 @@ module VagrantPlugins
|
|
185
264
|
# TODO: Cleanup the Fog catch-all once Fog implements better exceptions
|
186
265
|
# There is a chance Google has failed to create an instance, so we need
|
187
266
|
# to clean up the created disk.
|
188
|
-
|
267
|
+
disks.each do |disk|
|
268
|
+
cleanup_disk(disk.name, env) if disk && disk_created_by_vagrant
|
269
|
+
end
|
189
270
|
raise Errors::FogError, :message => e.message
|
190
271
|
end
|
191
272
|
|
@@ -173,6 +173,11 @@ module VagrantPlugins
|
|
173
173
|
# @return [String]
|
174
174
|
attr_accessor :service_account
|
175
175
|
|
176
|
+
# The configuration for additional disks.
|
177
|
+
#
|
178
|
+
# @return [Array<Hash>]
|
179
|
+
attr_accessor :additional_disks
|
180
|
+
|
176
181
|
def initialize(zone_specific=false)
|
177
182
|
@google_client_email = UNSET_VALUE
|
178
183
|
@google_json_key_location = UNSET_VALUE
|
@@ -204,6 +209,7 @@ module VagrantPlugins
|
|
204
209
|
@scopes = UNSET_VALUE
|
205
210
|
@service_accounts = UNSET_VALUE
|
206
211
|
@service_account = UNSET_VALUE
|
212
|
+
@additional_disks = []
|
207
213
|
|
208
214
|
# Internal state (prefix with __ so they aren't automatically
|
209
215
|
# merged)
|
data/test/unit/base.rb
CHANGED
@@ -46,6 +46,7 @@ describe VagrantPlugins::Google::Config do
|
|
46
46
|
its("tags") { should == [] }
|
47
47
|
its("labels") { should == {} }
|
48
48
|
its("scopes") { should == nil }
|
49
|
+
its("additional_disks") { should == [] }
|
49
50
|
its("preemptible") { should be_falsey }
|
50
51
|
its("auto_restart") { should }
|
51
52
|
its("on_host_maintenance") { should == "MIGRATE" }
|
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: 2.
|
4
|
+
version: 2.3.0.rc0
|
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:
|
12
|
+
date: 2019-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog-google
|