vagrant-google 2.4.0.rc0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 537db391735594007a72b2a4af1a464f90ac943e
4
- data.tar.gz: 5235acd34a609e6e348cfd732fd1ed9d5c89ef8b
2
+ SHA256:
3
+ metadata.gz: e73203fa43c1cabe0743140ded9044c95a64205d087742bab467ea297ab84020
4
+ data.tar.gz: 1c3caa2a146208ead776c380062c2e6624c04c47ecfd71feb7f8098ea2e86c06
5
5
  SHA512:
6
- metadata.gz: 9415a9c4f8a8fa50c6f648750d925c75cac489d618840dc1ba05ff4330d3707a23275835c5566bb135b01ea44d2249fae577a42d721aebd7c42961734cb7b63c
7
- data.tar.gz: 79a35f14f4a8886037fb28b0485b3ec04bc3e4222b300c401f07766403b3a9d64df3b0c524f87b56806f7795d83d1e39af20aca13019f651c044f4fb3a15c26e
6
+ metadata.gz: cbfae2e6b86e8435d9a0ac43e31002d150de566234c642742ef08120112182c3b2b037e88c2e7bdd465ad25147d36aa35991deb1977929d63f93ab2abe64dcf1
7
+ data.tar.gz: 38575138577c86d47d85630c1fe92a16bba8b686db894bf54bdddb548819100959ceaceeea3038472d656d593025778c3fe9d1b5691427f4fe95adca10dd7896
data/.gitignore CHANGED
@@ -17,3 +17,6 @@ vendor/*
17
17
 
18
18
  # Intellij projects folder
19
19
  .idea
20
+
21
+ # Env
22
+ setenv_*.sh
data/.rubocop.yml CHANGED
@@ -1,5 +1,4 @@
1
- # Importing TODO list to sanely lint new submissions.
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
- Style/EmptyLinesAroundBlockBody:
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.4.3
2
- # Tracking Vagrant 2.0.3
1
+ 2.7.4
2
+ # Tracking Vagrant 2.2.19
data/CHANGELOG.md CHANGED
@@ -2,6 +2,67 @@
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
+ ## 2.7.0 (November 2021)
9
+
10
+ ### User-facing
11
+
12
+ #### Added
13
+
14
+ - \#255 Adds enable_display option [dcode]
15
+ - \#248 Use google_application_default credentials by default [pecigonzalo]
16
+
17
+ ## 2.6.0 (December 2020)
18
+
19
+ ### User-facing
20
+
21
+ #### Added
22
+
23
+ - \#248 Add support for modifying the configuration of Shielded VM [lcy0321]
24
+ - \#244 Add accelerator (GPU) configuration [johanvdhaegen]
25
+ - \#216 Add support for Windows hosts through WinRM [dvanbrug]
26
+
27
+ #### Fixed
28
+
29
+ - \#246 Fix config override during metadata merge [mavin]
30
+ - \#249 Fix shielded API failures on non-shielded VM's [temikus]
31
+ - \#227 Fix additional disks being auto-deleted unless a disk type is specified [chrisgavin]
32
+
33
+ ### Development
34
+
35
+ #### Fixed
36
+
37
+ - \#247 chore: Update Gemfile with new `vagrant-spec` branch name [mavin]
38
+ - \#241 Fix unfortunate CI `on:` trigger typo [temikus]
39
+ - \#240 Update development environment, add CI functionality [Temikus]
40
+ - \#239 Remove old fixup in Gemfile [Temikus]
41
+ - \#237 Bump image size for test skeleton [Temikus]
42
+
43
+
44
+ ## 2.5.0 (September 2019)
45
+
46
+ ### User-facing
47
+
48
+ #### Added
49
+ - \#222 Added internal IP support [andrewh1978]
50
+
51
+ #### Deprecated
52
+
53
+ - \#220 Deprecated google_client_email parameter, as it's no longer needed or
54
+ supported by fog-google [temikus]
55
+
56
+ ### Development
57
+
58
+ #### Added
59
+
60
+ - \#223 Set up unit test GitHub Action worflow [temikus]
61
+
62
+ #### Fixed
63
+
64
+ - \#225 Locked the vagrant dep to 2.2.4 due to bundler issues on 2.2.5 [temikus]
65
+
5
66
  ## 2.4.0 (April 2019)
6
67
 
7
68
  ### User-facing
@@ -11,7 +72,7 @@ The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1
11
72
 
12
73
  #### Fixed
13
74
  - \#214 Set a default zone only if `default` network is used [mavin]
14
- - \#215 Allow tags,labels and additional_disks to be merged with multiple
75
+ - \#215 Allow tags,labels and additional_disks to be merged with multiple
15
76
  configs [mavin]
16
77
 
17
78
  ### Development
@@ -33,14 +94,14 @@ The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1
33
94
 
34
95
  ### User-facing
35
96
 
36
- - \#206 Fix image selection logic - Plugin no longer traces back with
97
+ - \#206 Fix image selection logic - Plugin no longer traces back with
37
98
  `image_family` config option. [temikus]
38
99
 
39
100
  ### Development
40
101
 
41
102
  - \#206 Bumped dependencies. [temikus]
42
- - fog-google version to 1.8.1
43
- - vagrant & vagrant-spec are now pointing to new upstream Hashicorp org repos
103
+ - fog-google version to 1.8.1
104
+ - vagrant & vagrant-spec are now pointing to new upstream Hashicorp org repos
44
105
 
45
106
  ## 2.2.0 (June 2018)
46
107
 
@@ -59,13 +120,13 @@ platforms.
59
120
  ## 2.0.0 (March 2018)
60
121
 
61
122
  * Update to use fog-google gem v1
62
- * Add new configuration option `labels` for setting [labels](https://cloud.google.com/compute/docs/labeling-resources)
123
+ * Add new configuration option `labels` for setting [labels](https://cloud.google.com/compute/docs/labeling-resources)
63
124
  on GCE instances
64
125
  * Fix disk cleanup issue causing the disk to be marked as created before insertion
65
126
  * Test environment fixups to avoid 'Encoded files can't be read outside of the Vagrant installer.'
66
127
  * Breaking changes:
67
128
  * Drop support for configuration option `google_key_location`(GCP P12 key)
68
- * `image` parameter no longer defaults to an arbitrary image and must be
129
+ * `image` parameter no longer defaults to an arbitrary image and must be
69
130
  specified at runtime
70
131
  * Rsync behavior now consistent with Vagrant's default, removed old rsync code
71
132
 
data/Gemfile CHANGED
@@ -23,6 +23,7 @@ group :development do
23
23
  # We depend on Vagrant for development, but we don't add it as a
24
24
  # gem dependency because we expect to be installed within the
25
25
  # Vagrant environment itself using `vagrant plugin`.
26
+
26
27
  gem 'vagrant', git: "https://github.com/hashicorp/vagrant.git"
27
- gem 'vagrant-spec', git: "https://github.com/hashicorp/vagrant-spec.git"
28
+ gem 'vagrant-spec', git: "https://github.com/hashicorp/vagrant-spec.git", branch: "main"
28
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:
@@ -85,11 +85,10 @@ Vagrant.configure("2") do |config|
85
85
 
86
86
  config.vm.provider :google do |google, override|
87
87
  google.google_project_id = "YOUR_GOOGLE_CLOUD_PROJECT_ID"
88
- google.google_client_email = "YOUR_SERVICE_ACCOUNT_EMAIL_ADDRESS"
89
88
  google.google_json_key_location = "/path/to/your/private-key.json"
90
-
89
+
91
90
  google.image_family = 'ubuntu-1604-lts'
92
-
91
+
93
92
  override.ssh.username = "USERNAME"
94
93
  override.ssh.private_key_path = "~/.ssh/id_rsa"
95
94
  #override.ssh.private_key_path = "~/.ssh/google_compute_engine"
@@ -100,10 +99,10 @@ end
100
99
 
101
100
  And then run `vagrant up --provider=google`.
102
101
 
103
- This will start a latest version of Ubuntu 16.04 LTS instance in the
104
- `us-central1-f` zone, with an `n1-standard-1` machine, and the `"default"`
105
- network within your project. And assuming your SSH information (see below) was
106
- 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
107
106
  well.
108
107
 
109
108
  Note that normally a lot of this boilerplate is encoded within the box file,
@@ -165,16 +164,14 @@ configuration for this provider.
165
164
 
166
165
  This provider exposes quite a few provider-specific configuration options:
167
166
 
168
- * `google_client_email` - The Client Email address for your Service Account.
169
- (Can also be configured with `GOOGLE_CLIENT_EMAIL` environment variable.)
170
167
  * `google_json_key_location` - The location of the JSON private key file matching your
171
- Service Account.
168
+ Service Account.
172
169
  (Can also be configured with `GOOGLE_JSON_KEY_LOCATION` environment variable.)
173
- * `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.
174
171
  (Can also be configured with `GOOGLE_PROJECT_ID` environment variable.)
175
172
  * `image` - The image name to use when booting your instance.
176
- * `image_family` - Specify an "image family" to pull the latest image from. For example: `centos-7`
177
- 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
178
175
  [Google Image documentation](https://cloud.google.com/compute/docs/images#image_families).
179
176
  * `image_project_id` - The ID of the GCP project to search for the `image` or `image_family`.
180
177
  * `instance_group` - Unmanaged instance group to add the machine to. If one
@@ -198,6 +195,7 @@ will pull the most recent CentOS 7 image. For more info, refer to
198
195
  * `zone` - The zone name where the instance will be created.
199
196
  * `can_ip_forward` - Boolean whether to enable IP Forwarding.
200
197
  * `external_ip` - The external IP address to use (supports names). Set to `false` to not assign an external address.
198
+ * `network_ip` - The internal IP address to use. Default is to use next available address.
201
199
  * `use_private_ip` - Boolean whether to use private IP for SSH/provisioning. Default is false.
202
200
  * `preemptible` - Boolean whether to enable preemptibility. Default is false.
203
201
  * `auto_restart` - Boolean whether to enable auto_restart. Default is true.
@@ -208,20 +206,36 @@ will pull the most recent CentOS 7 image. For more info, refer to
208
206
  utility aliases, for example:
209
207
  `['storage-full', 'bigquery', 'https://www.googleapis.com/auth/compute']`.
210
208
  * `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`;
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`;
213
211
  `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
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
223
232
  }]
224
- ```
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.
225
239
 
226
240
  These can be set like typical provider-specific configuration:
227
241
 
@@ -231,7 +245,6 @@ Vagrant.configure("2") do |config|
231
245
 
232
246
  config.vm.provider :google do |google|
233
247
  google.google_project_id = "YOUR_GOOGLE_CLOUD_PROJECT_ID"
234
- google.google_client_email = "YOUR_SERVICE_ACCOUNT_EMAIL_ADDRESS"
235
248
  google.google_json_key_location = "/path/to/your/private-key.json"
236
249
  end
237
250
  end
@@ -249,7 +262,6 @@ Vagrant.configure("2") do |config|
249
262
 
250
263
  config.vm.provider :google do |google|
251
264
  google.google_project_id = "YOUR_GOOGLE_CLOUD_PROJECT_ID"
252
- google.google_client_email = "YOUR_SERVICE_ACCOUNT_EMAIL_ADDRESS"
253
265
  google.google_json_key_location = "/path/to/your/private-key.json"
254
266
 
255
267
  # Make sure to set this to trigger the zone_config
@@ -284,7 +296,7 @@ emit a warning, but will otherwise boot the GCE machine.
284
296
  ## Synced Folders
285
297
 
286
298
  Since plugin version 2.0, this is implemented via built-in `SyncedFolders` action.
287
- 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)
288
300
  documentation for more info.
289
301
 
290
302
  ## Development
@@ -320,7 +332,6 @@ Before you start acceptance tests, you'll need to set the authentication
320
332
  shell variables accordingly:
321
333
 
322
334
  ```sh
323
- export GOOGLE_CLIENT_EMAIL="your-google_service_account_email@developer.gserviceaccount.com"
324
335
  export GOOGLE_PROJECT_ID="your-google-cloud-project-id"
325
336
  export GOOGLE_JSON_KEY_LOCATION="/full/path/to/your/private-key.json"
326
337
 
@@ -36,15 +36,9 @@ module VagrantPlugins
36
36
  :google_project => provider_config.google_project_id,
37
37
  }
38
38
 
39
- unless provider_config.google_client_email.nil?
40
- fog_config[:google_client_email] = provider_config.google_client_email
41
- end
42
-
43
39
  unless provider_config.google_json_key_location.nil?
44
40
  fog_config[:google_json_key_location] = find_key(provider_config.google_json_key_location, env)
45
- end
46
-
47
- if provider_config.google_client_email.nil? and provider_config.google_json_key_location.nil?
41
+ else
48
42
  fog_config[:google_application_default] = true
49
43
  end
50
44
 
@@ -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,63 +42,75 @@ module VagrantPlugins
41
42
  zone = env[:machine].provider_config.zone
42
43
 
43
44
  # Get the configs
44
- zone_config = env[:machine].provider_config.get_zone_config(zone)
45
- image = zone_config.image
46
- image_family = zone_config.image_family
47
- image_project_id = zone_config.image_project_id
48
- instance_group = zone_config.instance_group
49
- name = zone_config.name
50
- machine_type = zone_config.machine_type
51
- disk_size = zone_config.disk_size
52
- disk_name = zone_config.disk_name
53
- disk_type = zone_config.disk_type
54
- network = zone_config.network
55
- network_project_id = zone_config.network_project_id
56
- subnetwork = zone_config.subnetwork
57
- metadata = zone_config.metadata
58
- labels = zone_config.labels
59
- tags = zone_config.tags
60
- can_ip_forward = zone_config.can_ip_forward
61
- use_private_ip = zone_config.use_private_ip
62
- external_ip = zone_config.external_ip
63
- preemptible = zone_config.preemptible
64
- auto_restart = zone_config.auto_restart
65
- on_host_maintenance = zone_config.on_host_maintenance
66
- autodelete_disk = zone_config.autodelete_disk
67
- service_account_scopes = zone_config.scopes
68
- service_account = zone_config.service_account
69
- project_id = zone_config.google_project_id
70
- additional_disks = zone_config.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_display = zone_config.enable_display
76
+ enable_vtpm = zone_config.enable_vtpm
77
+ enable_integrity_monitoring = zone_config.enable_integrity_monitoring
71
78
 
72
79
  # Launch!
73
80
  env[:ui].info(I18n.t("vagrant_google.launching_instance"))
74
- env[:ui].info(" -- Name: #{name}")
75
- env[:ui].info(" -- Project: #{project_id}")
76
- env[:ui].info(" -- Type: #{machine_type}")
77
- env[:ui].info(" -- Disk type: #{disk_type}")
78
- env[:ui].info(" -- Disk size: #{disk_size} GB")
79
- env[:ui].info(" -- Disk name: #{disk_name}")
80
- env[:ui].info(" -- Image: #{image}")
81
- env[:ui].info(" -- Image family: #{image_family}")
82
- env[:ui].info(" -- Image Project: #{image_project_id}") if image_project_id
83
- env[:ui].info(" -- Instance Group: #{instance_group}")
84
- env[:ui].info(" -- Zone: #{zone}") if zone
85
- env[:ui].info(" -- Network: #{network}") if network
86
- env[:ui].info(" -- Network Project: #{network_project_id}") if network_project_id
87
- env[:ui].info(" -- Subnetwork: #{subnetwork}") if subnetwork
88
- env[:ui].info(" -- Metadata: '#{metadata}'")
89
- env[:ui].info(" -- Labels: '#{labels}'")
90
- env[:ui].info(" -- Network tags: '#{tags}'")
91
- env[:ui].info(" -- IP Forward: #{can_ip_forward}")
92
- env[:ui].info(" -- Use private IP: #{use_private_ip}")
93
- env[:ui].info(" -- External IP: #{external_ip}")
94
- env[:ui].info(" -- Preemptible: #{preemptible}")
95
- env[:ui].info(" -- Auto Restart: #{auto_restart}")
96
- env[:ui].info(" -- On Maintenance: #{on_host_maintenance}")
97
- env[:ui].info(" -- Autodelete Disk: #{autodelete_disk}")
98
- env[:ui].info(" -- Scopes: #{service_account_scopes}") if service_account_scopes
99
- env[:ui].info(" -- Service Account: #{service_account}") if service_account
100
- env[:ui].info(" -- Additional Disks:#{additional_disks}")
81
+ env[:ui].info(" -- Name: #{name}")
82
+ env[:ui].info(" -- Project: #{project_id}")
83
+ env[:ui].info(" -- Type: #{machine_type}")
84
+ env[:ui].info(" -- Disk type: #{disk_type}")
85
+ env[:ui].info(" -- Disk size: #{disk_size} GB")
86
+ env[:ui].info(" -- Disk name: #{disk_name}")
87
+ env[:ui].info(" -- Image: #{image}")
88
+ env[:ui].info(" -- Image family: #{image_family}")
89
+ env[:ui].info(" -- Image Project: #{image_project_id}") if image_project_id
90
+ env[:ui].info(" -- Instance Group: #{instance_group}")
91
+ env[:ui].info(" -- Zone: #{zone}") if zone
92
+ env[:ui].info(" -- Network: #{network}") if network
93
+ env[:ui].info(" -- Network Project: #{network_project_id}") if network_project_id
94
+ env[:ui].info(" -- Subnetwork: #{subnetwork}") if subnetwork
95
+ env[:ui].info(" -- Metadata: '#{metadata}'")
96
+ env[:ui].info(" -- Labels: '#{labels}'")
97
+ env[:ui].info(" -- Network tags: '#{tags}'")
98
+ env[:ui].info(" -- IP Forward: #{can_ip_forward}")
99
+ env[:ui].info(" -- Use private IP: #{use_private_ip}")
100
+ env[:ui].info(" -- External IP: #{external_ip}")
101
+ env[:ui].info(" -- Network IP: #{network_ip}")
102
+ env[:ui].info(" -- Preemptible: #{preemptible}")
103
+ env[:ui].info(" -- Auto Restart: #{auto_restart}")
104
+ env[:ui].info(" -- On Maintenance: #{on_host_maintenance}")
105
+ env[:ui].info(" -- Autodelete Disk: #{autodelete_disk}")
106
+ env[:ui].info(" -- Scopes: #{service_account_scopes}") if service_account_scopes
107
+ env[:ui].info(" -- Service Account: #{service_account}") if service_account
108
+ env[:ui].info(" -- Additional Disks: #{additional_disks}")
109
+ env[:ui].info(" -- Accelerators: #{accelerators}")
110
+ env[:ui].info(" -- Secure Boot: #{enable_secure_boot}") if enable_secure_boot
111
+ env[:ui].info(" -- Display Device: #{enable_display}") if enable_display
112
+ env[:ui].info(" -- vTPM: #{enable_vtpm}") if enable_vtpm
113
+ env[:ui].info(" -- Integrity Monitoring: #{enable_integrity_monitoring}") if enable_integrity_monitoring
101
114
 
102
115
  # Munge image config
103
116
  if image_family
@@ -127,6 +140,24 @@ module VagrantPlugins
127
140
  # Munge service_accounts / scopes config
128
141
  service_accounts = [ { :email => service_account, :scopes => service_account_scopes } ]
129
142
 
143
+ # Construct accelerator URLs
144
+ accelerators_url = []
145
+ accelerators.each do |accelerator|
146
+ unless accelerator.key?(:type)
147
+ next
148
+ end
149
+ accelerator_type = "https://compute.googleapis.com/compute/v1/projects/#{project_id}/zones/#{zone}/acceleratorTypes/#{accelerator[:type]}"
150
+ accelerator_count = accelerator.fetch(:count, 1)
151
+ accelerators_url.push({ :accelerator_type => accelerator_type,
152
+ :accelerator_count => accelerator_count })
153
+ end
154
+
155
+ # Munge shieldedInstance config
156
+ shielded_instance_config = { :enable_secure_boot => enable_secure_boot, :enable_vtpm => enable_vtpm, :enable_integrity_monitoring => enable_integrity_monitoring }
157
+
158
+ # Munge displayDevice config
159
+ display_device = { :enable_display => enable_display }
160
+
130
161
  begin
131
162
  request_start_time = Time.now.to_i
132
163
  disk = nil
@@ -199,7 +230,7 @@ module VagrantPlugins
199
230
 
200
231
  # Get additional disk auto delete
201
232
  additional_disk_auto_delete = nil
202
- if disk_config[:disk_type].nil?
233
+ if disk_config[:autodelete_disk].nil?
203
234
  # Default auto delete to true
204
235
  additional_disk_auto_delete = true
205
236
  else
@@ -241,23 +272,37 @@ module VagrantPlugins
241
272
  end
242
273
 
243
274
  defaults = {
244
- :name => name,
245
- :zone => zone,
246
- :machine_type => machine_type,
247
- :disk_size => disk_size,
248
- :disk_type => disk_type,
249
- :image => image,
250
- :network_interfaces => network_interfaces,
251
- :metadata => { :items => metadata.each.map { |k, v| {:key => k.to_s, :value => v.to_s} } },
252
- :labels => labels,
253
- :tags => { :items => tags },
254
- :can_ip_forward => can_ip_forward,
255
- :use_private_ip => use_private_ip,
256
- :external_ip => external_ip,
257
- :disks => disks,
258
- :scheduling => scheduling,
259
- :service_accounts => service_accounts
275
+ :name => name,
276
+ :zone => zone,
277
+ :machine_type => machine_type,
278
+ :disk_size => disk_size,
279
+ :disk_type => disk_type,
280
+ :image => image,
281
+ :network_interfaces => network_interfaces,
282
+ :metadata => { :items => metadata.each.map { |k, v| { :key => k.to_s, :value => v.to_s } } },
283
+ :labels => labels,
284
+ :tags => { :items => tags },
285
+ :can_ip_forward => can_ip_forward,
286
+ :use_private_ip => use_private_ip,
287
+ :external_ip => external_ip,
288
+ :network_ip => network_ip,
289
+ :disks => disks,
290
+ :scheduling => scheduling,
291
+ :service_accounts => service_accounts,
292
+ :guest_accelerators => accelerators_url
260
293
  }
294
+
295
+ # XXX HACK - only add of the parameters are set in :shielded_instance_config we need to drop the field from
296
+ # the API call otherwise we'll error out with Google::Apis::ClientError
297
+ # TODO(temikus): Remove if the API changes, see internal GOOG ref: b/175063371
298
+ if shielded_instance_config.has_value?(true)
299
+ defaults[:shielded_instance_config] = shielded_instance_config
300
+ end
301
+
302
+ if display_device.has_value?(true)
303
+ defaults[:display_device] = display_device
304
+ end
305
+
261
306
  server = env[:google_compute].servers.create(defaults)
262
307
  @logger.info("Machine '#{zone}:#{name}' created.")
263
308
  rescue *FOG_ERRORS => e
@@ -284,10 +329,26 @@ module VagrantPlugins
284
329
  env[:interrupted] = true
285
330
  end
286
331
 
332
+ # Parse out the image project in case it was not set
333
+ # and check if it is part of a public windows project
334
+ img_project = image.split("/")[6]
335
+ is_windows_image = img_project.eql?("windows-cloud") || img_project.eql?("windows-sql-cloud")
336
+
337
+ # Reset the password if a windows image unless flag overrides
338
+ setup_winrm_password = zone_config.setup_winrm_password
339
+ if setup_winrm_password.nil? && is_windows_image
340
+ setup_winrm_password = true
341
+ end
342
+
343
+ if setup_winrm_password
344
+ env[:ui].info("Setting up WinRM Password")
345
+ env[:action_runner].run(Action.action_setup_winrm_password, env)
346
+ end
347
+
287
348
  unless env[:terminated]
288
- env[:metrics]["instance_ssh_time"] = Util::Timer.time do
289
- # Wait for SSH to be ready.
290
- env[:ui].info(I18n.t("vagrant_google.waiting_for_ssh"))
349
+ env[:metrics]["instance_comm_time"] = Util::Timer.time do
350
+ # Wait for Comms to be ready.
351
+ env[:ui].info(I18n.t("vagrant_google.waiting_for_comm"))
291
352
  while true
292
353
  # If we're interrupted just back out
293
354
  break if env[:interrupted]
@@ -295,8 +356,8 @@ module VagrantPlugins
295
356
  sleep 2
296
357
  end
297
358
  end
298
- @logger.info("Time for SSH ready: #{env[:metrics]["instance_ssh_time"]}")
299
- env[:ui].info(I18n.t("vagrant_google.ready_ssh")) unless env[:interrupted]
359
+ @logger.info("Time for Comms ready: #{env[:metrics]["instance_comm_time"]}")
360
+ env[:ui].info(I18n.t("vagrant_google.ready_comm")) unless env[:interrupted]
300
361
  end
301
362
 
302
363
  # Terminate the instance if we were interrupted