vagrant-google 0.1.4 → 0.1.5.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1579f21e576ddd84be0534329d26b18519f25a3c
4
+ data.tar.gz: 4bca2bc0bc4be2b3bf8dc0e41fcd44ccd80aa49d
5
+ SHA512:
6
+ metadata.gz: 950faaf3aa714e6599d15292af92b66f3f1f23c621873b5f2ca724c4ad3a0f014ab726dbddd79400644b64e7af123fd48ec49ff84ce408de7d8b0183b55964ce
7
+ data.tar.gz: aac7d0ae3087361428a9556826b7b7ab20d863b81067da24f61867aef93cabc5c237aa0eaac640b856a7b377ca71a5069c9c6f234c361677235d09f5075df6d8
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p598
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 0.1.5 (May 2015)
2
+
3
+ * Added support for JSON private keys [temikus]
4
+ * Added disk_type parameter support [temikus]
5
+ * Added acceptance tests [temikus]
6
+ * Added can_ip_forward, external_ip, autodelete_disk and disk_name parameters support [phueper]
7
+ * Added support for user specified rsync excludes [patkar]
8
+ * Miscellaneous bugfixes [mbrukman, beauzeaux, iceydee, mklbtz, temikus]
9
+
1
10
  # 0.1.4 (October 2014)
2
11
 
3
12
  * Add option for disk size [franzs]
data/Gemfile CHANGED
@@ -1,11 +1,11 @@
1
1
  # Copyright 2013 Google Inc. All Rights Reserved.
2
- #
2
+ #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
- #
6
+ #
7
7
  # http://www.apache.org/licenses/LICENSE-2.0
8
- #
8
+ #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,5 +20,10 @@ group :development do
20
20
  # We depend on Vagrant for development, but we don't add it as a
21
21
  # gem dependency because we expect to be installed within the
22
22
  # Vagrant environment itself using `vagrant plugin`.
23
- gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.2.7"
23
+ gem 'vagrant', git: "git://github.com/mitchellh/vagrant.git"
24
+ gem 'vagrant-spec', git: "https://github.com/mitchellh/vagrant-spec.git"
25
+ end
26
+
27
+ group :plugins do
28
+ gem "vagrant-google" , path: "."
24
29
  end
data/README.md CHANGED
@@ -40,8 +40,7 @@ Service Account for API Access.
40
40
  1. Log in with your Google Account and go to
41
41
  [Google Cloud Platform](https://cloud.google.com) and click on the
42
42
  `Try it now` button.
43
- 1. Create a new project and remember to record the `Project ID` you
44
- specify.
43
+ 1. Create a new project and remember to record the `Project ID`
45
44
  1. Next, visit the [Developers Console](https://console.developers.google.com)
46
45
  make sure to enable the `Google Compute Engine` service for your project
47
46
  If prompted, review and agree to the terms of service.
@@ -49,9 +48,9 @@ Service Account for API Access.
49
48
  section and click the `Create new Client ID` button. In the pop-up dialog,
50
49
  select the `Service Account` radio button and the click the `Create Client ID`
51
50
  button.
52
- 1. When prompted, select the `Download private key` button and make sure
53
- to save this file in a secure and reliable location. This key file
54
- will be used to authorize all Vagrant commands available in this plugin.
51
+ 1. Make sure to download the *P12 private key* and save this file in a secure
52
+ and reliable location. This key file will be used to authorize all API
53
+ requests to Google Compute Engine.
55
54
  1. Still on the same page, find the newly created `Service Account` text
56
55
  block on the API Access page. Record the `Email address` (it should end
57
56
  with `@developer.gserviceaccount.com`) associated with the new Service
@@ -80,7 +79,7 @@ Vagrant.configure("2") do |config|
80
79
  config.vm.provider :google do |google, override|
81
80
  google.google_project_id = "YOUR_GOOGLE_CLOUD_PROJECT_ID"
82
81
  google.google_client_email = "YOUR_SERVICE_ACCOUNT_EMAIL_ADDRESS"
83
- google.google_key_location = "/PATH/TO/YOUR/PRIVATE_KEY.p12"
82
+ google.google_json_key_location = "/path/to/your/private-key.json"
84
83
 
85
84
  override.ssh.username = "USERNAME"
86
85
  override.ssh.private_key_path = "~/.ssh/id_rsa"
@@ -94,13 +93,36 @@ And then run `vagrant up --provider=google`.
94
93
 
95
94
  This will start an Debian 7 (Wheezy) instance in the us-central1-f zone,
96
95
  with an n1-standard-1 machine, and the "default" network within your project.
97
- And assuming your SSH information was filled in properly within your
98
- Vagrantfile, SSH and provisioning will work as well.
96
+ And assuming your SSH information (see below) was filled in properly within
97
+ your Vagrantfile, SSH and provisioning will work as well.
99
98
 
100
99
  Note that normally a lot of this boilerplate is encoded within the box file,
101
100
  but the box file used for the quick start, the "google" box, has no
102
101
  preconfigured defaults.
103
102
 
103
+ ## SSH Support
104
+
105
+ In order for SSH to work properly to the GCE VM, you will first need to add
106
+ your public key to the GCE metadata service for the desired VM user account.
107
+ When a VM first boots, a Google-provided daemon is responsible for talking to
108
+ the internal GCE metadata service and creates local user accounts and their
109
+ respective `~/.ssh/authorized_keys` entries. Most new GCE users will use the
110
+ [Cloud SDK](https://cloud.google.com/sdk/) `gcloud compute` utility when first
111
+ getting started with GCE. This utility has built in support for creating SSH
112
+ key pairs, and uploading the public key to the GCE metadata service. By
113
+ default, `glcoud compute` creates a key pair named
114
+ `~/.ssh/google_compute_engine[.pub]`.
115
+
116
+ Note that you can use the more standard `~/.ssh/id_rsa[.pub]` files, but you
117
+ will need to manually add your public key to the GCE metadata service so your
118
+ VMs will pick up the the key. Note that they public key is typically
119
+ prefixed with the username, so that the daemon on the VM adds the public key
120
+ to the correct user account. See the blow links for more help with SSH and
121
+ GCE VMs.
122
+
123
+ * https://cloud.google.com/compute/docs/instances#sshing
124
+ * https://cloud.google.com/compute/docs/console#sshkeys
125
+
104
126
  ## Box Format
105
127
 
106
128
  Every provider in Vagrant must introduce a custom box format. This provider
@@ -117,7 +139,9 @@ configuration for this provider.
117
139
  This provider exposes quite a few provider-specific configuration options:
118
140
 
119
141
  * `google_client_email` - The Client Email address for your Service Account.
120
- * `google_key_location` - The location to the private key file matching your
142
+ * `google_key_location` - The location of the P12 private key file matching your
143
+ Service Account.
144
+ * `google_json_key_location` - The location of the JSON private key file matching your
121
145
  Service Account.
122
146
  * `google_project_id` - The Project ID for your Google Cloud Platform account.
123
147
  * `image` - The image name to use when booting your instance.
@@ -125,12 +149,15 @@ This provider exposes quite a few provider-specific configuration options:
125
149
  to become "ready" in GCE. Defaults to 20 seconds.
126
150
  * `machine_type` - The machine type to use. The default is "n1-standard-1".
127
151
  * `disk_size` - The disk size in GB. The default is 10.
152
+ * `disk_name` - The disk name to use. If the disk exists, it will be reused, otherwise created.
128
153
  * `metadata` - Custom key/value pairs of metadata to add to the instance.
129
- * `name` - The name of your instance. The default is "new".
154
+ * `name` - The name of your instance. The default is "i-yyyyMMddHH". Example 2014/10/01 10:00:00 is "i-2014100101".
130
155
  * `network` - The name of the network to use for the instance. Default is
131
156
  "default".
132
157
  * `tags` - An array of tags to apply to this instance.
133
158
  * `zone` - The zone name where the instance will be created.
159
+ * `can_ip_forward` - Boolean wether to enable IP Forwarding.
160
+ * `external_ip` - The external IP address to use.
134
161
 
135
162
  These can be set like typical provider-specific configuration:
136
163
 
@@ -139,9 +166,9 @@ Vagrant.configure("2") do |config|
139
166
  # ... other stuff
140
167
 
141
168
  config.vm.provider :google do |google|
142
- google.google_project_id = "my_project"
143
- google.google_client_email = "hashstring@example.com"
144
- google.google_key_location = "/tmp/private-key.p12"
169
+ google.google_project_id = "YOUR_GOOGLE_CLOUD_PROJECT_ID"
170
+ google.google_client_email = "YOUR_SERVICE_ACCOUNT_EMAIL_ADDRESS"
171
+ google.google_json_key_location = "/path/to/your/private-key.json"
145
172
  end
146
173
  end
147
174
  ```
@@ -157,16 +184,16 @@ Vagrant.configure("2") do |config|
157
184
  config.vm.box = "gce"
158
185
 
159
186
  config.vm.provider :google do |google|
160
- google.google_project_id = "my_project"
161
- google.google_client_email = "hashstring@example.com"
162
- google.google_key_location = "/tmp/private-key.p12"
187
+ google.google_project_id = "YOUR_GOOGLE_CLOUD_PROJECT_ID"
188
+ google.google_client_email = "YOUR_SERVICE_ACCOUNT_EMAIL_ADDRESS"
189
+ google.google_json_key_location = "/path/to/your/private-key.json"
163
190
 
164
191
  # Make sure to set this to trigger the zone_config
165
192
  google.zone = "us-central1-f"
166
193
 
167
194
  google.zone_config "us-central1-f" do |zone1f|
168
195
  zone1f.name = "testing-vagrant"
169
- zone1f.image = "debian-7-wheezy-v20140926"
196
+ zone1f.image = "debian-7-wheezy-v20150127"
170
197
  zone1f.machine_type = "n1-standard-4"
171
198
  zone1f.zone = "us-central1-f"
172
199
  zone1f.metadata = {'custom' => 'metadata', 'testing' => 'foobarbaz'}
@@ -199,10 +226,6 @@ machine over SSH.
199
226
  This is good enough for all built-in Vagrant provisioners (shell, chef, and
200
227
  puppet) to work!
201
228
 
202
- ## Known Issues
203
-
204
- * https://github.com/mitchellh/vagrant-google/issues/17
205
-
206
229
  ## Development
207
230
 
208
231
  To work on the `vagrant-google` plugin, clone this repository out, and use
@@ -227,11 +250,31 @@ that uses it, and uses bundler to execute Vagrant:
227
250
  $ bundle exec vagrant up --provider=google
228
251
  ```
229
252
 
253
+ ## Acceptance testing
254
+
255
+ **Work-in-progress:** Acceptance tests are based on vagrant-spec library which
256
+ is currently under active development so they may occasionally break.
257
+
258
+ Before you start acceptance tests, you'll need to set the authentication variables accordingly.
259
+
260
+ Next, export your GCP authentication data:
261
+
262
+ ```
263
+ export GOOGLE_CLIENT_EMAIL="your-google_service_account_email@developer.gserviceaccount.com"
264
+ export GOOGLE_PROJECT_ID="your-google-cloud-project-id"
265
+ export GOOGLE_JSON_KEY_LOCATION="/full/path/to/your/private-key.json"
266
+
267
+ export GOOGLE_SSH_USER="testuser"
268
+ export GOOGLE_SSH_KEY_LOCATION="/home/testuser/.ssh/id_rsa"
269
+ ```
270
+
271
+ After, you can run acceptance tests by running the `run` task in `acceptance` namespace:
272
+ ```
273
+ bundle exec rake acceptance:run
274
+ ```
275
+
230
276
  ## Changelog
231
277
  * See [CHANGELOG.md](https://github.com/mitchellh/vagrant-google/blob/master/CHANGELOG.md)
232
278
 
233
- ## Contributing
234
- * See [CONTRIB.md](https://github.com/mitchellh/vagrant-google/blob/master/CONTRIB.md)
235
-
236
279
  ## Licensing
237
280
  * See [LICENSE](https://github.com/mitchellh/vagrant-google/blob/master/LICENSE)
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  # Copyright 2013 Google Inc. All Rights Reserved.
2
- #
2
+ #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
- #
6
+ #
7
7
  # http://www.apache.org/licenses/LICENSE-2.0
8
- #
8
+ #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -14,22 +14,19 @@
14
14
 
15
15
  require 'rubygems'
16
16
  require 'bundler/setup'
17
- require 'rspec/core/rake_task'
18
17
 
19
18
  # Immediately sync all stdout so that tools like buildbot can
20
19
  # immediately load in the output.
21
20
  $stdout.sync = true
22
21
  $stderr.sync = true
23
22
 
24
- # Change to the directory of this file.
25
- Dir.chdir(File.expand_path("../", __FILE__))
23
+ # Load all the rake tasks from the "tasks" folder. This folder
24
+ # allows us to nicely separate rake tasks into individual files
25
+ # based on their role, which makes development and debugging easier
26
+ # than one monolithic file.
27
+ task_dir = File.expand_path("../tasks", __FILE__)
28
+ Dir["#{task_dir}/**/*.rake"].each do |task_file|
29
+ load task_file
30
+ end
26
31
 
27
- # This installs the tasks that help with gem creation and
28
- # publishing.
29
- Bundler::GemHelper.install_tasks
30
-
31
- # Install the `spec` task so that we can run tests.
32
- RSpec::Core::RakeTask.new
33
-
34
- # Default task is to run the unit tests
35
- task :default => "spec"
32
+ task default: "test:unit"
@@ -5,7 +5,7 @@ This folder shows the example contents of a box for the `google` provider.
5
5
  To turn this into a box:
6
6
 
7
7
  ```
8
- $ tar cvzf ../google.box ./metadata.json ./Vagrantfile
8
+ $ tar cvzf ../../google.box ./metadata.json ./Vagrantfile
9
9
  ```
10
10
 
11
11
  This box works by using Vagrant's built-in Vagrantfile merging to setup
@@ -0,0 +1,3 @@
1
+ {
2
+ "provider": "google"
3
+ }
data/google-test.box ADDED
Binary file
@@ -29,13 +29,21 @@ module VagrantPlugins
29
29
  def call(env)
30
30
  provider_config = env[:machine].provider_config
31
31
 
32
- # Build the fog config
33
- fog_config = {
34
- :provider => :google,
35
- :google_project => provider_config.google_project_id,
36
- :google_client_email => provider_config.google_client_email,
37
- :google_key_location => provider_config.google_key_location
38
- }
32
+ unless provider_config.google_json_key_location.nil?
33
+ fog_config = {
34
+ :provider => :google,
35
+ :google_project => provider_config.google_project_id,
36
+ :google_client_email => provider_config.google_client_email,
37
+ :google_json_key_location => provider_config.google_json_key_location
38
+ }
39
+ else
40
+ fog_config = {
41
+ :provider => :google,
42
+ :google_project => provider_config.google_project_id,
43
+ :google_client_email => provider_config.google_client_email,
44
+ :google_key_location => provider_config.google_key_location
45
+ }
46
+ end
39
47
 
40
48
  @logger.info("Connecting to Google...")
41
49
  env[:google_compute] = Fog::Compute.new(fog_config)
@@ -40,42 +40,90 @@ module VagrantPlugins
40
40
  name = zone_config.name
41
41
  machine_type = zone_config.machine_type
42
42
  disk_size = zone_config.disk_size
43
+ disk_name = zone_config.disk_name
44
+ disk_type = zone_config.disk_type
43
45
  network = zone_config.network
44
46
  metadata = zone_config.metadata
45
47
  tags = zone_config.tags
48
+ can_ip_forward = zone_config.can_ip_forward
49
+ external_ip = zone_config.external_ip
50
+ autodelete_disk = zone_config.autodelete_disk
46
51
 
47
52
  # Launch!
48
53
  env[:ui].info(I18n.t("vagrant_google.launching_instance"))
49
- env[:ui].info(" -- Name: #{name}")
50
- env[:ui].info(" -- Type: #{machine_type}")
51
- env[:ui].info(" -- Disk size: #{disk_size} GB")
52
- env[:ui].info(" -- Image: #{image}")
53
- env[:ui].info(" -- Zone: #{zone}") if zone
54
- env[:ui].info(" -- Network: #{network}") if network
55
- env[:ui].info(" -- Metadata: '#{metadata}'")
56
- env[:ui].info(" -- Tags: '#{tags}'")
54
+ env[:ui].info(" -- Name: #{name}")
55
+ env[:ui].info(" -- Type: #{machine_type}")
56
+ env[:ui].info(" -- Disk type: #{disk_type}")
57
+ env[:ui].info(" -- Disk size: #{disk_size} GB")
58
+ env[:ui].info(" -- Disk name: #{disk_name}")
59
+ env[:ui].info(" -- Image: #{image}")
60
+ env[:ui].info(" -- Zone: #{zone}") if zone
61
+ env[:ui].info(" -- Network: #{network}") if network
62
+ env[:ui].info(" -- Metadata: '#{metadata}'")
63
+ env[:ui].info(" -- Tags: '#{tags}'")
64
+ env[:ui].info(" -- IP Forward: #{can_ip_forward}")
65
+ env[:ui].info(" -- External IP: #{external_ip}")
66
+ env[:ui].info(" -- Autodelete Disk: #{autodelete_disk}")
57
67
  begin
58
68
  request_start_time = Time.now().to_i
59
- disk = env[:google_compute].disks.create(
60
- name: name,
61
- size_gb: disk_size,
62
- zone_name: zone,
63
- source_image: image
64
- )
65
- disk.wait_for { disk.ready? }
69
+ if !external_ip.nil?
70
+ address = env[:google_compute].addresses.get_by_ip_address(external_ip)
71
+ if !address.nil?
72
+ if address.in_use?
73
+ raise Errors::ExternalIpError,
74
+ :externalip => external_ip
75
+ end
76
+ end
77
+ end
78
+ #Check if disk type is available in the zone
79
+ if !disk_type.nil?
80
+ disk_type_obj = env[:google_compute].list_disk_types(zone).body['items'].select { |dt| dt['name'] == disk_type } || []
81
+ if !disk_type_obj.empty?
82
+ disk_type = disk_type_obj[0]["selfLink"]
83
+ else
84
+ raise Errors::DiskTypeError,
85
+ :disktype => disk_type
86
+ end
87
+ end
88
+
89
+ if disk_name.nil?
90
+ # no disk_name... disk_name defaults to instance name
91
+ disk = env[:google_compute].disks.create(
92
+ name: name,
93
+ size_gb: disk_size,
94
+ type: disk_type,
95
+ zone_name: zone,
96
+ source_image: image
97
+ )
98
+ disk.wait_for { disk.ready? }
99
+ else
100
+ disk = env[:google_compute].disks.get(disk_name, zone)
101
+ if disk.nil?
102
+ # disk not found... create it with name
103
+ disk = env[:google_compute].disks.create(
104
+ name: disk_name,
105
+ size_gb: disk_size,
106
+ type: disk_type,
107
+ zone_name: zone,
108
+ source_image: image
109
+ )
110
+ disk.wait_for { disk.ready? }
111
+ end
112
+ end
66
113
 
67
114
  defaults = {
68
115
  :name => name,
69
116
  :zone_name => zone,
70
117
  :machine_type => machine_type,
71
118
  :disk_size => disk_size,
119
+ :disk_type => disk_type,
72
120
  :image => image,
73
121
  :network => network,
74
122
  :metadata => metadata,
75
123
  :tags => tags,
76
- # Second arg to get_as_boot_disk is 'autodelete_disk', defaulting
77
- # to true
78
- :disks => [disk.get_as_boot_disk(true, true)],
124
+ :can_ip_forward => can_ip_forward,
125
+ :external_ip => external_ip,
126
+ :disks => [disk.get_as_boot_disk(true, autodelete_disk)],
79
127
  }
80
128
  server = env[:google_compute].servers.create(defaults)
81
129
  @logger.info("Machine '#{zone}:#{name}' created.")
@@ -14,6 +14,7 @@
14
14
  require "log4r"
15
15
  require "vagrant/util/subprocess"
16
16
  require "vagrant/util/scoped_hash_override"
17
+ require "vagrant/util/which"
17
18
 
18
19
  module VagrantPlugins
19
20
  module Google
@@ -38,6 +39,11 @@ module VagrantPlugins
38
39
 
39
40
  # Ignore disabled shared folders
40
41
  next if data[:disabled]
42
+
43
+ unless Vagrant::Util::Which.which('rsync')
44
+ env[:ui].warn(I18n.t('vagrant_aws.rsync_not_found_warning'))
45
+ break
46
+ end
41
47
 
42
48
  hostpath = File.expand_path(data[:hostpath], env[:root_path])
43
49
  guestpath = data[:guestpath]
@@ -46,6 +52,11 @@ module VagrantPlugins
46
52
  # avoid creating an additional directory with rsync
47
53
  hostpath = "#{hostpath}/" if hostpath !~ /\/$/
48
54
 
55
+ # on windows rsync.exe requires cygdrive-style paths
56
+ if Vagrant::Util::Platform.windows?
57
+ hostpath = hostpath.gsub(/^(\w):/) { "/cygdrive/#{$1}" }
58
+ end
59
+
49
60
  env[:ui].info(I18n.t("vagrant_google.rsync_folder",
50
61
  :hostpath => hostpath,
51
62
  :guestpath => guestpath))
@@ -61,14 +72,23 @@ module VagrantPlugins
61
72
  Array(ssh_info[:private_key_path]).map { |path| "-i '#{path}' " }.join
62
73
  end
63
74
 
75
+ #collect rsync excludes specified :rsync__excludes=>['path1',...] in synced_folder options
76
+ excludes = ['.vagrant/', *Array(data[:rsync__excludes])]
77
+
64
78
  # Rsync over to the guest path using the SSH info
65
79
  command = [
66
80
  "rsync", "--verbose", "--archive", "-z",
67
- "--exclude", ".vagrant/",
81
+ *excludes.map{|e|['--exclude', e]}.flatten,
68
82
  "-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no #{ssh_key_options(ssh_info)}",
69
83
  hostpath,
70
84
  "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
71
85
 
86
+ # we need to fix permissions when using rsync.exe on windows, see
87
+ # http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions
88
+ if Vagrant::Util::Platform.windows?
89
+ command.insert(1, "--chmod", "ugo=rwX")
90
+ end
91
+
72
92
  r = Vagrant::Util::Subprocess.execute(*command)
73
93
  if r.exit_code != 0
74
94
  raise Errors::RsyncError,
@@ -27,8 +27,9 @@ module VagrantPlugins
27
27
  server = env[:google_compute].servers.get(env[:machine].id, env[:machine].provider_config.zone)
28
28
 
29
29
  # Destroy the server and remove the tracking ID
30
+ # destroy() is called with 'false' to disable asynchronous execution.
30
31
  env[:ui].info(I18n.t("vagrant_google.terminating"))
31
- server.destroy if not server.nil?
32
+ server.destroy(false) if not server.nil?
32
33
  env[:machine].id = nil
33
34
 
34
35
  @app.call(env)
@@ -104,7 +104,7 @@ module VagrantPlugins
104
104
  # This action is called to bring the box up from nothing.
105
105
  def self.action_up
106
106
  Vagrant::Action::Builder.new.tap do |b|
107
- b.use HandleBoxUrl
107
+ b.use HandleBox
108
108
  b.use ConfigValidate
109
109
  b.use ConnectGoogle
110
110
  b.use Call, IsCreated do |env, b2|
@@ -26,6 +26,11 @@ module VagrantPlugins
26
26
  # @return [String]
27
27
  attr_accessor :google_key_location
28
28
 
29
+ # The path to the Service Account json-formatted private key
30
+ #
31
+ # @return [String]
32
+ attr_accessor :google_json_key_location
33
+
29
34
  # The Google Cloud Project ID (not name or number)
30
35
  #
31
36
  # @return [String]
@@ -46,6 +51,16 @@ module VagrantPlugins
46
51
  # @return [Int]
47
52
  attr_accessor :disk_size
48
53
 
54
+ # The name of the disk to be used, it it exists, it will be reused, otherwise created.
55
+ #
56
+ # @return [String]
57
+ attr_accessor :disk_name
58
+
59
+ # The type of the disk to be used, such as "pd-standard"
60
+ #
61
+ # @return [String]
62
+ attr_accessor :disk_type
63
+
49
64
  # The user metadata string
50
65
  #
51
66
  # @return [Hash<String, String>]
@@ -66,6 +81,21 @@ module VagrantPlugins
66
81
  # @return [Array]
67
82
  attr_accessor :tags
68
83
 
84
+ # wether to enable ip forwarding
85
+ #
86
+ # @return Boolean
87
+ attr_accessor :can_ip_forward
88
+
89
+ # The external IP Address to use
90
+ #
91
+ # @return String
92
+ attr_accessor :external_ip
93
+
94
+ # wether to autodelete disk on instance delete
95
+ #
96
+ # @return Boolean
97
+ attr_accessor :autodelete_disk
98
+
69
99
  # The timeout value waiting for instance ready
70
100
  #
71
101
  # @return [Int]
@@ -86,14 +116,20 @@ module VagrantPlugins
86
116
  def initialize(zone_specific=false)
87
117
  @google_client_email = UNSET_VALUE
88
118
  @google_key_location = UNSET_VALUE
119
+ @google_json_key_location = UNSET_VALUE
89
120
  @google_project_id = UNSET_VALUE
90
121
  @image = UNSET_VALUE
91
122
  @machine_type = UNSET_VALUE
92
123
  @disk_size = UNSET_VALUE
124
+ @disk_name = UNSET_VALUE
125
+ @disk_type = UNSET_VALUE
93
126
  @metadata = {}
94
127
  @name = UNSET_VALUE
95
128
  @network = UNSET_VALUE
96
129
  @tags = []
130
+ @can_ip_forward = UNSET_VALUE
131
+ @external_ip = UNSET_VALUE
132
+ @autodelete_disk = UNSET_VALUE
97
133
  @instance_ready_timeout = UNSET_VALUE
98
134
  @zone = UNSET_VALUE
99
135
 
@@ -110,7 +146,7 @@ module VagrantPlugins
110
146
  # image and machine type name for zones. Example:
111
147
  #
112
148
  # google.zone_config "us-central1-f" do |zone|
113
- # zone.image = "debian-7-wheezy-v20140926"
149
+ # zone.image = "debian-7-wheezy-v20150127"
114
150
  # zone.machine_type = "n1-standard-4"
115
151
  # end
116
152
  #
@@ -170,10 +206,11 @@ module VagrantPlugins
170
206
  # will default to nil if the environment variables are not present.
171
207
  @google_client_email = ENV['GOOGLE_CLIENT_EMAIL'] if @google_client_email == UNSET_VALUE
172
208
  @google_key_location = ENV['GOOGLE_KEY_LOCATION'] if @google_key_location == UNSET_VALUE
209
+ @google_json_key_location = ENV['GOOGLE_JSON_KEY_LOCATION'] if @google_json_key_location == UNSET_VALUE
173
210
  @google_project_id = ENV['GOOGLE_PROJECT_ID'] if @google_project_id == UNSET_VALUE
174
211
 
175
212
  # Image must be nil, since we can't default that
176
- @image = "debian-7-wheezy-v20140926" if @image == UNSET_VALUE
213
+ @image = "debian-7-wheezy-v20150127" if @image == UNSET_VALUE
177
214
 
178
215
  # Default instance type is an n1-standard-1
179
216
  @machine_type = "n1-standard-1" if @machine_type == UNSET_VALUE
@@ -181,6 +218,12 @@ module VagrantPlugins
181
218
  # Default disk size is 10 GB
182
219
  @disk_size = 10 if @disk_size == UNSET_VALUE
183
220
 
221
+ # Default disk name is nil
222
+ @disk_name = nil if @disk_name == UNSET_VALUE
223
+
224
+ # Default disk type is pd-standard
225
+ @disk_type = "pd-standard" if @disk_type == UNSET_VALUE
226
+
184
227
  # Instance name defaults to a new datetime value (hour granularity)
185
228
  t = Time.now
186
229
  @name = "i-#{t.year}#{t.month.to_s.rjust(2,'0')}#{t.day.to_s.rjust(2,'0')}#{t.hour.to_s.rjust(2,'0')}" if @name == UNSET_VALUE
@@ -191,6 +234,15 @@ module VagrantPlugins
191
234
  # Default zone is us-central1-f.
192
235
  @zone = "us-central1-f" if @zone == UNSET_VALUE
193
236
 
237
+ # autodelete_disk defaults to true
238
+ @autodelete_disk = true if @autodelete_disk == UNSET_VALUE
239
+
240
+ # can_ip_forward defaults to nil
241
+ @can_ip_forward = nil if @can_ip_forward == UNSET_VALUE
242
+
243
+ # external_ip defaults to nil
244
+ @external_ip = nil if @external_ip == UNSET_VALUE
245
+
194
246
  # Default instance_ready_timeout
195
247
  @instance_ready_timeout = 20 if @instance_ready_timeout == UNSET_VALUE
196
248
 
@@ -231,8 +283,11 @@ module VagrantPlugins
231
283
  config.google_project_id.nil?
232
284
  errors << I18n.t("vagrant_google.config.google_client_email_required") if \
233
285
  config.google_client_email.nil?
286
+ errors << I18n.t("vagrant_google.config.google_duplicate_key_location") if \
287
+ !config.google_key_location.nil? and !config.google_json_key_location.nil?
234
288
  errors << I18n.t("vagrant_google.config.google_key_location_required") if \
235
- config.google_key_location.nil?
289
+ config.google_key_location.nil? and config.google_json_key_location.nil?
290
+
236
291
  end
237
292
 
238
293
  errors << I18n.t("vagrant_google.config.image_required") if config.image.nil?
@@ -20,6 +20,14 @@ module VagrantPlugins
20
20
  error_namespace("vagrant_google.errors")
21
21
  end
22
22
 
23
+ class ExternalIpError < VagrantGoogleError
24
+ error_key(:external_ip_error)
25
+ end
26
+
27
+ class DiskTypeError <VagrantGoogleError
28
+ error_key(:disk_type_error)
29
+ end
30
+
23
31
  class FogError < VagrantGoogleError
24
32
  error_key(:fog_error)
25
33
  end