vagrant-google 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +12 -4
- data/.ruby-version +2 -2
- data/CHANGELOG.md +28 -0
- data/Gemfile +2 -4
- data/README.md +42 -26
- data/lib/vagrant-google/action.rb +10 -0
- data/lib/vagrant-google/action/run_instance.rb +128 -79
- data/lib/vagrant-google/action/setup_winrm_password.rb +72 -0
- data/lib/vagrant-google/action/start_instance.rb +4 -4
- data/lib/vagrant-google/config.rb +80 -35
- data/lib/vagrant-google/version.rb +1 -1
- data/locales/en.yml +7 -4
- data/tasks/changelog.rake +40 -0
- data/test/acceptance/skeletons/image_family/Vagrantfile +2 -0
- data/test/unit/common/config_test.rb +107 -42
- data/vagrant-google.gemspec +4 -3
- metadata +27 -13
- data/.rubocop_todo.yml +0 -305
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 22135d118cd7749f09bab503e584dce947d56ce3dbe1fe7d43624be1d8edd9bf
|
4
|
+
data.tar.gz: 4d4e3e45565c5a3ce26494ba5942000d404791a46045a990b866ebd401cb4d1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed1cb603bd11da1e6d402490e3a92cc683e2c1060a7982c2809b39fa86200ec62a5921791df6c954e45482918b84531d4df8437c3da368b99df717ac2dfac03f
|
7
|
+
data.tar.gz: fbe0d8f7cb29a6d386cb7d501c3057acf426f390c93146c6acfe23274cc83a422c44a09bf1119c8295f0b92547e79d2e9477cca3e0a9aab1ba3543aa093bbb15
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
inherit_from: .rubocop_todo.yml
|
1
|
+
require: rubocop-performance
|
3
2
|
|
4
3
|
# Custom project config
|
5
4
|
AllCops:
|
@@ -7,11 +6,20 @@ AllCops:
|
|
7
6
|
- './Vagrantfile'
|
8
7
|
- './vagrant-google.gemspec'
|
9
8
|
|
10
|
-
|
9
|
+
Layout/EmptyLinesAroundBlockBody:
|
11
10
|
Enabled: false
|
12
11
|
|
13
12
|
Style/StringLiterals:
|
14
13
|
Enabled: false
|
15
14
|
|
16
15
|
Style/IfUnlessModifier:
|
17
|
-
Enabled: false
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Metrics/LineLength:
|
19
|
+
Max: 120
|
20
|
+
|
21
|
+
Layout/HashAlignment:
|
22
|
+
EnforcedHashRocketStyle: table
|
23
|
+
|
24
|
+
Style/HashSyntax:
|
25
|
+
EnforcedStyle: no_mixed_keys
|
data/.ruby-version
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
2.
|
2
|
-
# Tracking Vagrant 2.
|
1
|
+
2.6.6
|
2
|
+
# Tracking Vagrant 2.2.9
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,34 @@
|
|
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
|
+
## Next
|
6
|
+
|
7
|
+
|
8
|
+
### User-facing
|
9
|
+
|
10
|
+
#### Added
|
11
|
+
|
12
|
+
- \#248 Add support for modifying the configuration of Shielded VM [lcy0321]
|
13
|
+
- \#244 Add accelerator (GPU) configuration [johanvdhaegen]
|
14
|
+
- \#216 Add support for Windows hosts through WinRM [dvanbrug]
|
15
|
+
|
16
|
+
#### Fixed
|
17
|
+
|
18
|
+
- \#246 Fix config override during metadata merge [mavin]
|
19
|
+
- \#249 Fix shielded API failures on non-shielded VM's [temikus]
|
20
|
+
- \#227 Fix additional disks being auto-deleted unless a disk type is specified [chrisgavin]
|
21
|
+
|
22
|
+
### Development
|
23
|
+
|
24
|
+
#### Fixed
|
25
|
+
|
26
|
+
- \#247 chore: Update Gemfile with new `vagrant-spec` branch name [mavin]
|
27
|
+
- \#241 Fix unfortunate CI `on:` trigger typo [temikus]
|
28
|
+
- \#240 Update development environment, add CI functionality [Temikus]
|
29
|
+
- \#239 Remove old fixup in Gemfile [Temikus]
|
30
|
+
- \#237 Bump image size for test skeleton [Temikus]
|
31
|
+
|
32
|
+
|
5
33
|
## 2.5.0 (September 2019)
|
6
34
|
|
7
35
|
### User-facing
|
data/Gemfile
CHANGED
@@ -24,8 +24,6 @@ group :development do
|
|
24
24
|
# gem dependency because we expect to be installed within the
|
25
25
|
# Vagrant environment itself using `vagrant plugin`.
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
gem 'vagrant', git: "https://github.com/hashicorp/vagrant.git", :tag => 'v2.2.4'
|
30
|
-
gem 'vagrant-spec', git: "https://github.com/hashicorp/vagrant-spec.git"
|
27
|
+
gem 'vagrant', git: "https://github.com/hashicorp/vagrant.git"
|
28
|
+
gem 'vagrant-spec', git: "https://github.com/hashicorp/vagrant-spec.git", branch: "main"
|
31
29
|
end
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ The maintainers for this plugin are @temikus(primary), @erjohnso(backup).
|
|
16
16
|
* Boot Google Compute Engine instances.
|
17
17
|
* SSH into the instances.
|
18
18
|
* Provision the instances with any built-in Vagrant provisioner.
|
19
|
-
* Synced folder support via Vagrant's
|
19
|
+
* Synced folder support via Vagrant's
|
20
20
|
[rsync action](https://www.vagrantup.com/docs/synced-folders/rsync.html).
|
21
21
|
* Define zone-specific configurations so Vagrant can manage machines in
|
22
22
|
multiple zones.
|
@@ -73,8 +73,8 @@ Service Account for API Access.
|
|
73
73
|
## Quick Start
|
74
74
|
|
75
75
|
After installing the plugin (instructions above), the quickest way to get
|
76
|
-
started is to actually use a dummy Google box from Atlas and specify all the
|
77
|
-
details manually within a `config.vm.provider` block.
|
76
|
+
started is to actually use a dummy Google box from Atlas and specify all the
|
77
|
+
details manually within a `config.vm.provider` block.
|
78
78
|
|
79
79
|
So first, make a Vagrantfile that looks like the following, filling in
|
80
80
|
your information where necessary:
|
@@ -86,9 +86,9 @@ Vagrant.configure("2") do |config|
|
|
86
86
|
config.vm.provider :google do |google, override|
|
87
87
|
google.google_project_id = "YOUR_GOOGLE_CLOUD_PROJECT_ID"
|
88
88
|
google.google_json_key_location = "/path/to/your/private-key.json"
|
89
|
-
|
89
|
+
|
90
90
|
google.image_family = 'ubuntu-1604-lts'
|
91
|
-
|
91
|
+
|
92
92
|
override.ssh.username = "USERNAME"
|
93
93
|
override.ssh.private_key_path = "~/.ssh/id_rsa"
|
94
94
|
#override.ssh.private_key_path = "~/.ssh/google_compute_engine"
|
@@ -99,10 +99,10 @@ end
|
|
99
99
|
|
100
100
|
And then run `vagrant up --provider=google`.
|
101
101
|
|
102
|
-
This will start a latest version of Ubuntu 16.04 LTS instance in the
|
103
|
-
`us-central1-f` zone, with an `n1-standard-1` machine, and the `"default"`
|
104
|
-
network within your project. And assuming your SSH information (see below) was
|
105
|
-
filled in properly within your Vagrantfile, SSH and provisioning will work as
|
102
|
+
This will start a latest version of Ubuntu 16.04 LTS instance in the
|
103
|
+
`us-central1-f` zone, with an `n1-standard-1` machine, and the `"default"`
|
104
|
+
network within your project. And assuming your SSH information (see below) was
|
105
|
+
filled in properly within your Vagrantfile, SSH and provisioning will work as
|
106
106
|
well.
|
107
107
|
|
108
108
|
Note that normally a lot of this boilerplate is encoded within the box file,
|
@@ -165,13 +165,13 @@ configuration for this provider.
|
|
165
165
|
This provider exposes quite a few provider-specific configuration options:
|
166
166
|
|
167
167
|
* `google_json_key_location` - The location of the JSON private key file matching your
|
168
|
-
Service Account.
|
168
|
+
Service Account.
|
169
169
|
(Can also be configured with `GOOGLE_JSON_KEY_LOCATION` environment variable.)
|
170
|
-
* `google_project_id` - The Project ID for your Google Cloud Platform account.
|
170
|
+
* `google_project_id` - The Project ID for your Google Cloud Platform account.
|
171
171
|
(Can also be configured with `GOOGLE_PROJECT_ID` environment variable.)
|
172
172
|
* `image` - The image name to use when booting your instance.
|
173
|
-
* `image_family` - Specify an "image family" to pull the latest image from. For example: `centos-7`
|
174
|
-
will pull the most recent CentOS 7 image. For more info, refer to
|
173
|
+
* `image_family` - Specify an "image family" to pull the latest image from. For example: `centos-7`
|
174
|
+
will pull the most recent CentOS 7 image. For more info, refer to
|
175
175
|
[Google Image documentation](https://cloud.google.com/compute/docs/images#image_families).
|
176
176
|
* `image_project_id` - The ID of the GCP project to search for the `image` or `image_family`.
|
177
177
|
* `instance_group` - Unmanaged instance group to add the machine to. If one
|
@@ -206,20 +206,36 @@ will pull the most recent CentOS 7 image. For more info, refer to
|
|
206
206
|
utility aliases, for example:
|
207
207
|
`['storage-full', 'bigquery', 'https://www.googleapis.com/auth/compute']`.
|
208
208
|
* `service_account` - The IAM service account email to use for the instance.
|
209
|
-
* `additional_disks` - An array of additional disk configurations. `disk_size` is default to `10`GB;
|
210
|
-
`disk_name` is default to `name` + "-additional-disk-#{index}"; `disk_type` is default to `pd-standard`;
|
209
|
+
* `additional_disks` - An array of additional disk configurations. `disk_size` is default to `10`GB;
|
210
|
+
`disk_name` is default to `name` + "-additional-disk-#{index}"; `disk_type` is default to `pd-standard`;
|
211
211
|
`autodelete_disk` is default to `true`. Here is an example of configuration.
|
212
|
-
```ruby
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
212
|
+
```ruby
|
213
|
+
[{
|
214
|
+
:image_family => "google-image-family",
|
215
|
+
:image => nil,
|
216
|
+
:image_project_id => "google-project-id",
|
217
|
+
:disk_size => 20,
|
218
|
+
:disk_name => "google-additional-disk-0",
|
219
|
+
:disk_type => "pd-standard",
|
220
|
+
:autodelete_disk => true
|
221
|
+
}]
|
222
|
+
```
|
223
|
+
* `accelerators` - An array of accelerator configurations. `type` is the
|
224
|
+
accelerator type (e.g. `nvidia-tesla-k80`); `count` is the number of
|
225
|
+
accelerators and defaults to 1. Note that only `TERMINATE` is supported for
|
226
|
+
`on_host_maintenance`; this should be set explicitly, since the default is
|
227
|
+
`MIGRATE`.
|
228
|
+
```ruby
|
229
|
+
google.accelerators = [{
|
230
|
+
:type => "nvidia-tesla-k80",
|
231
|
+
:count => 2
|
221
232
|
}]
|
222
|
-
|
233
|
+
|
234
|
+
google.on_host_maintenance = "TERMINATE"
|
235
|
+
```
|
236
|
+
* `enable_secure_boot` - For [Shielded VM](https://cloud.google.com/security/shielded-cloud/shielded-vm), whether to enable Secure Boot.
|
237
|
+
* `enable_vtpm` - For [Shielded VM](https://cloud.google.com/security/shielded-cloud/shielded-vm), whether to enable vTPM.
|
238
|
+
* `enable_integrity_monitoring` - For [Shielded VM](https://cloud.google.com/security/shielded-cloud/shielded-vm), whether to enable Integrity monitoring.
|
223
239
|
|
224
240
|
These can be set like typical provider-specific configuration:
|
225
241
|
|
@@ -280,7 +296,7 @@ emit a warning, but will otherwise boot the GCE machine.
|
|
280
296
|
## Synced Folders
|
281
297
|
|
282
298
|
Since plugin version 2.0, this is implemented via built-in `SyncedFolders` action.
|
283
|
-
See Vagrant's [rsync action](https://www.vagrantup.com/docs/synced-folders/rsync.html)
|
299
|
+
See Vagrant's [rsync action](https://www.vagrantup.com/docs/synced-folders/rsync.html)
|
284
300
|
documentation for more info.
|
285
301
|
|
286
302
|
## Development
|
@@ -82,6 +82,15 @@ module VagrantPlugins
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
# This action is called to setup the Windows user/password on the machine.
|
86
|
+
def self.action_setup_winrm_password
|
87
|
+
Vagrant::Action::Builder.new.tap do |b|
|
88
|
+
b.use ConfigValidate
|
89
|
+
b.use ConnectGoogle
|
90
|
+
b.use SetupWinrmPassword
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
85
94
|
# This action is called to read the state of the machine. The
|
86
95
|
# resulting state is expected to be put into the `:machine_state_id`
|
87
96
|
# key.
|
@@ -182,6 +191,7 @@ module VagrantPlugins
|
|
182
191
|
autoload :MessageNotCreated, action_root.join("message_not_created")
|
183
192
|
autoload :MessageWillNotDestroy, action_root.join("message_will_not_destroy")
|
184
193
|
autoload :ReadSSHInfo, action_root.join("read_ssh_info")
|
194
|
+
autoload :SetupWinrmPassword, action_root.join('setup_winrm_password')
|
185
195
|
autoload :ReadState, action_root.join("read_state")
|
186
196
|
autoload :RunInstance, action_root.join("run_instance")
|
187
197
|
autoload :StartInstance, action_root.join("start_instance")
|
@@ -14,6 +14,7 @@
|
|
14
14
|
require "log4r"
|
15
15
|
require 'vagrant/util/retryable'
|
16
16
|
require 'vagrant-google/util/timer'
|
17
|
+
require 'vagrant-google/action/setup_winrm_password'
|
17
18
|
|
18
19
|
module VagrantPlugins
|
19
20
|
module Google
|
@@ -41,65 +42,73 @@ module VagrantPlugins
|
|
41
42
|
zone = env[:machine].provider_config.zone
|
42
43
|
|
43
44
|
# Get the configs
|
44
|
-
zone_config
|
45
|
-
image
|
46
|
-
image_family
|
47
|
-
image_project_id
|
48
|
-
instance_group
|
49
|
-
name
|
50
|
-
machine_type
|
51
|
-
disk_size
|
52
|
-
disk_name
|
53
|
-
disk_type
|
54
|
-
network
|
55
|
-
network_project_id
|
56
|
-
subnetwork
|
57
|
-
metadata
|
58
|
-
labels
|
59
|
-
tags
|
60
|
-
can_ip_forward
|
61
|
-
use_private_ip
|
62
|
-
external_ip
|
63
|
-
network_ip
|
64
|
-
preemptible
|
65
|
-
auto_restart
|
66
|
-
on_host_maintenance
|
67
|
-
autodelete_disk
|
68
|
-
service_account_scopes
|
69
|
-
service_account
|
70
|
-
project_id
|
71
|
-
additional_disks
|
45
|
+
zone_config = env[:machine].provider_config.get_zone_config(zone)
|
46
|
+
image = zone_config.image
|
47
|
+
image_family = zone_config.image_family
|
48
|
+
image_project_id = zone_config.image_project_id
|
49
|
+
instance_group = zone_config.instance_group
|
50
|
+
name = zone_config.name
|
51
|
+
machine_type = zone_config.machine_type
|
52
|
+
disk_size = zone_config.disk_size
|
53
|
+
disk_name = zone_config.disk_name
|
54
|
+
disk_type = zone_config.disk_type
|
55
|
+
network = zone_config.network
|
56
|
+
network_project_id = zone_config.network_project_id
|
57
|
+
subnetwork = zone_config.subnetwork
|
58
|
+
metadata = zone_config.metadata
|
59
|
+
labels = zone_config.labels
|
60
|
+
tags = zone_config.tags
|
61
|
+
can_ip_forward = zone_config.can_ip_forward
|
62
|
+
use_private_ip = zone_config.use_private_ip
|
63
|
+
external_ip = zone_config.external_ip
|
64
|
+
network_ip = zone_config.network_ip
|
65
|
+
preemptible = zone_config.preemptible
|
66
|
+
auto_restart = zone_config.auto_restart
|
67
|
+
on_host_maintenance = zone_config.on_host_maintenance
|
68
|
+
autodelete_disk = zone_config.autodelete_disk
|
69
|
+
service_account_scopes = zone_config.scopes
|
70
|
+
service_account = zone_config.service_account
|
71
|
+
project_id = zone_config.google_project_id
|
72
|
+
additional_disks = zone_config.additional_disks
|
73
|
+
accelerators = zone_config.accelerators
|
74
|
+
enable_secure_boot = zone_config.enable_secure_boot
|
75
|
+
enable_vtpm = zone_config.enable_vtpm
|
76
|
+
enable_integrity_monitoring = zone_config.enable_integrity_monitoring
|
72
77
|
|
73
78
|
# Launch!
|
74
79
|
env[:ui].info(I18n.t("vagrant_google.launching_instance"))
|
75
|
-
env[:ui].info(" -- Name:
|
76
|
-
env[:ui].info(" -- Project:
|
77
|
-
env[:ui].info(" -- Type:
|
78
|
-
env[:ui].info(" -- Disk type:
|
79
|
-
env[:ui].info(" -- Disk size:
|
80
|
-
env[:ui].info(" -- Disk name:
|
81
|
-
env[:ui].info(" -- Image:
|
82
|
-
env[:ui].info(" -- Image family:
|
83
|
-
env[:ui].info(" -- Image Project:
|
84
|
-
env[:ui].info(" -- Instance Group:
|
85
|
-
env[:ui].info(" -- Zone:
|
86
|
-
env[:ui].info(" -- Network:
|
87
|
-
env[:ui].info(" -- Network Project:
|
88
|
-
env[:ui].info(" -- Subnetwork:
|
89
|
-
env[:ui].info(" -- Metadata:
|
90
|
-
env[:ui].info(" -- Labels:
|
91
|
-
env[:ui].info(" -- Network tags:
|
92
|
-
env[:ui].info(" -- IP Forward:
|
93
|
-
env[:ui].info(" -- Use private IP:
|
94
|
-
env[:ui].info(" -- External IP:
|
95
|
-
env[:ui].info(" -- Network IP:
|
96
|
-
env[:ui].info(" -- Preemptible:
|
97
|
-
env[:ui].info(" -- Auto Restart:
|
98
|
-
env[:ui].info(" -- On Maintenance:
|
99
|
-
env[:ui].info(" -- Autodelete Disk:
|
100
|
-
env[:ui].info(" -- Scopes:
|
101
|
-
env[:ui].info(" -- Service Account:
|
102
|
-
env[:ui].info(" -- Additional Disks
|
80
|
+
env[:ui].info(" -- Name: #{name}")
|
81
|
+
env[:ui].info(" -- Project: #{project_id}")
|
82
|
+
env[:ui].info(" -- Type: #{machine_type}")
|
83
|
+
env[:ui].info(" -- Disk type: #{disk_type}")
|
84
|
+
env[:ui].info(" -- Disk size: #{disk_size} GB")
|
85
|
+
env[:ui].info(" -- Disk name: #{disk_name}")
|
86
|
+
env[:ui].info(" -- Image: #{image}")
|
87
|
+
env[:ui].info(" -- Image family: #{image_family}")
|
88
|
+
env[:ui].info(" -- Image Project: #{image_project_id}") if image_project_id
|
89
|
+
env[:ui].info(" -- Instance Group: #{instance_group}")
|
90
|
+
env[:ui].info(" -- Zone: #{zone}") if zone
|
91
|
+
env[:ui].info(" -- Network: #{network}") if network
|
92
|
+
env[:ui].info(" -- Network Project: #{network_project_id}") if network_project_id
|
93
|
+
env[:ui].info(" -- Subnetwork: #{subnetwork}") if subnetwork
|
94
|
+
env[:ui].info(" -- Metadata: '#{metadata}'")
|
95
|
+
env[:ui].info(" -- Labels: '#{labels}'")
|
96
|
+
env[:ui].info(" -- Network tags: '#{tags}'")
|
97
|
+
env[:ui].info(" -- IP Forward: #{can_ip_forward}")
|
98
|
+
env[:ui].info(" -- Use private IP: #{use_private_ip}")
|
99
|
+
env[:ui].info(" -- External IP: #{external_ip}")
|
100
|
+
env[:ui].info(" -- Network IP: #{network_ip}")
|
101
|
+
env[:ui].info(" -- Preemptible: #{preemptible}")
|
102
|
+
env[:ui].info(" -- Auto Restart: #{auto_restart}")
|
103
|
+
env[:ui].info(" -- On Maintenance: #{on_host_maintenance}")
|
104
|
+
env[:ui].info(" -- Autodelete Disk: #{autodelete_disk}")
|
105
|
+
env[:ui].info(" -- Scopes: #{service_account_scopes}") if service_account_scopes
|
106
|
+
env[:ui].info(" -- Service Account: #{service_account}") if service_account
|
107
|
+
env[:ui].info(" -- Additional Disks: #{additional_disks}")
|
108
|
+
env[:ui].info(" -- Accelerators: #{accelerators}")
|
109
|
+
env[:ui].info(" -- Secure Boot: #{enable_secure_boot}") if enable_secure_boot
|
110
|
+
env[:ui].info(" -- vTPM: #{enable_vtpm}") if enable_vtpm
|
111
|
+
env[:ui].info(" -- Integrity Monitoring: #{enable_integrity_monitoring}") if enable_integrity_monitoring
|
103
112
|
|
104
113
|
# Munge image config
|
105
114
|
if image_family
|
@@ -129,6 +138,21 @@ module VagrantPlugins
|
|
129
138
|
# Munge service_accounts / scopes config
|
130
139
|
service_accounts = [ { :email => service_account, :scopes => service_account_scopes } ]
|
131
140
|
|
141
|
+
# Construct accelerator URLs
|
142
|
+
accelerators_url = []
|
143
|
+
accelerators.each do |accelerator|
|
144
|
+
unless accelerator.key?(:type)
|
145
|
+
next
|
146
|
+
end
|
147
|
+
accelerator_type = "https://compute.googleapis.com/compute/v1/projects/#{project_id}/zones/#{zone}/acceleratorTypes/#{accelerator[:type]}"
|
148
|
+
accelerator_count = accelerator.fetch(:count, 1)
|
149
|
+
accelerators_url.push({ :accelerator_type => accelerator_type,
|
150
|
+
:accelerator_count => accelerator_count })
|
151
|
+
end
|
152
|
+
|
153
|
+
# Munge shieldedInstance config
|
154
|
+
shielded_instance_config = { :enable_secure_boot => enable_secure_boot, :enable_vtpm => enable_vtpm, :enable_integrity_monitoring => enable_integrity_monitoring }
|
155
|
+
|
132
156
|
begin
|
133
157
|
request_start_time = Time.now.to_i
|
134
158
|
disk = nil
|
@@ -201,7 +225,7 @@ module VagrantPlugins
|
|
201
225
|
|
202
226
|
# Get additional disk auto delete
|
203
227
|
additional_disk_auto_delete = nil
|
204
|
-
if disk_config[:
|
228
|
+
if disk_config[:autodelete_disk].nil?
|
205
229
|
# Default auto delete to true
|
206
230
|
additional_disk_auto_delete = true
|
207
231
|
else
|
@@ -243,24 +267,33 @@ module VagrantPlugins
|
|
243
267
|
end
|
244
268
|
|
245
269
|
defaults = {
|
246
|
-
:name
|
247
|
-
:zone
|
248
|
-
:machine_type
|
249
|
-
:disk_size
|
250
|
-
:disk_type
|
251
|
-
:image
|
252
|
-
:network_interfaces
|
253
|
-
:metadata
|
254
|
-
:labels
|
255
|
-
:tags
|
256
|
-
:can_ip_forward
|
257
|
-
:use_private_ip
|
258
|
-
:external_ip
|
259
|
-
:network_ip
|
260
|
-
:disks
|
261
|
-
:scheduling
|
262
|
-
:service_accounts
|
270
|
+
:name => name,
|
271
|
+
:zone => zone,
|
272
|
+
:machine_type => machine_type,
|
273
|
+
:disk_size => disk_size,
|
274
|
+
:disk_type => disk_type,
|
275
|
+
:image => image,
|
276
|
+
:network_interfaces => network_interfaces,
|
277
|
+
:metadata => { :items => metadata.each.map { |k, v| { :key => k.to_s, :value => v.to_s } } },
|
278
|
+
:labels => labels,
|
279
|
+
:tags => { :items => tags },
|
280
|
+
:can_ip_forward => can_ip_forward,
|
281
|
+
:use_private_ip => use_private_ip,
|
282
|
+
:external_ip => external_ip,
|
283
|
+
:network_ip => network_ip,
|
284
|
+
:disks => disks,
|
285
|
+
:scheduling => scheduling,
|
286
|
+
:service_accounts => service_accounts,
|
287
|
+
:guest_accelerators => accelerators_url
|
263
288
|
}
|
289
|
+
|
290
|
+
# XXX HACK - only add of the parameters are set in :shielded_instance_config we need to drop the field from
|
291
|
+
# the API call otherwise we'll error out with Google::Apis::ClientError
|
292
|
+
# TODO(temikus): Remove if the API changes, see internal GOOG ref: b/175063371
|
293
|
+
if shielded_instance_config.has_value?(true)
|
294
|
+
defaults[:shielded_instance_config] = shielded_instance_config
|
295
|
+
end
|
296
|
+
|
264
297
|
server = env[:google_compute].servers.create(defaults)
|
265
298
|
@logger.info("Machine '#{zone}:#{name}' created.")
|
266
299
|
rescue *FOG_ERRORS => e
|
@@ -287,10 +320,26 @@ module VagrantPlugins
|
|
287
320
|
env[:interrupted] = true
|
288
321
|
end
|
289
322
|
|
323
|
+
# Parse out the image project in case it was not set
|
324
|
+
# and check if it is part of a public windows project
|
325
|
+
img_project = image.split("/")[6]
|
326
|
+
is_windows_image = img_project.eql?("windows-cloud") || img_project.eql?("windows-sql-cloud")
|
327
|
+
|
328
|
+
# Reset the password if a windows image unless flag overrides
|
329
|
+
setup_winrm_password = zone_config.setup_winrm_password
|
330
|
+
if setup_winrm_password.nil? && is_windows_image
|
331
|
+
setup_winrm_password = true
|
332
|
+
end
|
333
|
+
|
334
|
+
if setup_winrm_password
|
335
|
+
env[:ui].info("Setting up WinRM Password")
|
336
|
+
env[:action_runner].run(Action.action_setup_winrm_password, env)
|
337
|
+
end
|
338
|
+
|
290
339
|
unless env[:terminated]
|
291
|
-
env[:metrics]["
|
292
|
-
# Wait for
|
293
|
-
env[:ui].info(I18n.t("vagrant_google.
|
340
|
+
env[:metrics]["instance_comm_time"] = Util::Timer.time do
|
341
|
+
# Wait for Comms to be ready.
|
342
|
+
env[:ui].info(I18n.t("vagrant_google.waiting_for_comm"))
|
294
343
|
while true
|
295
344
|
# If we're interrupted just back out
|
296
345
|
break if env[:interrupted]
|
@@ -298,8 +347,8 @@ module VagrantPlugins
|
|
298
347
|
sleep 2
|
299
348
|
end
|
300
349
|
end
|
301
|
-
@logger.info("Time for
|
302
|
-
env[:ui].info(I18n.t("vagrant_google.
|
350
|
+
@logger.info("Time for Comms ready: #{env[:metrics]["instance_comm_time"]}")
|
351
|
+
env[:ui].info(I18n.t("vagrant_google.ready_comm")) unless env[:interrupted]
|
303
352
|
end
|
304
353
|
|
305
354
|
# Terminate the instance if we were interrupted
|