knife-google 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.md +155 -66
- data/knife-google.gemspec +2 -1
- data/lib/chef/knife/google_base.rb +1 -1
- data/lib/chef/knife/google_disk_create.rb +17 -9
- data/lib/chef/knife/google_disk_delete.rb +2 -2
- data/lib/chef/knife/google_disk_list.rb +8 -8
- data/lib/chef/knife/google_project_list.rb +178 -0
- data/lib/chef/knife/google_region_list.rb +125 -0
- data/lib/chef/knife/google_server_create.rb +174 -46
- data/lib/chef/knife/google_server_delete.rb +9 -13
- data/lib/chef/knife/google_server_list.rb +5 -6
- data/lib/chef/knife/google_zone_list.rb +22 -28
- data/lib/google/compute.rb +2 -1
- data/lib/google/compute/client.rb +12 -7
- data/lib/google/compute/creatable_resource_collection.rb +12 -1
- data/lib/google/compute/disk.rb +0 -2
- data/lib/google/compute/image.rb +1 -2
- data/lib/google/compute/project.rb +2 -2
- data/lib/google/compute/{kernel.rb → region.rb} +12 -1
- data/lib/google/compute/region_operation.rb +62 -0
- data/lib/google/compute/server.rb +3 -2
- data/lib/google/compute/server/attached_disk.rb +3 -3
- data/lib/google/compute/zone.rb +6 -4
- data/lib/google/compute/zone_operation.rb +11 -9
- data/lib/knife-google/version.rb +1 -1
- data/spec/chef/knife/google_base_spec.rb +4 -4
- data/spec/chef/knife/google_disk_create_spec.rb +8 -7
- data/spec/chef/knife/google_disk_delete_spec.rb +15 -16
- data/spec/chef/knife/google_disk_list_spec.rb +6 -6
- data/spec/chef/knife/google_region_list_spec.rb +32 -0
- data/spec/chef/knife/google_server_create_spec.rb +78 -44
- data/spec/chef/knife/google_server_delete_spec.rb +37 -37
- data/spec/chef/knife/google_server_list_spec.rb +8 -7
- data/spec/chef/knife/google_setup_spec.rb +1 -2
- data/spec/chef/knife/google_zone_list_spec.rb +4 -4
- data/spec/data/{compute-v1beta15.json → compute-v1.json} +700 -246
- data/spec/data/disk.json +3 -4
- data/spec/data/firewall.json +2 -2
- data/spec/data/global_operation.json +3 -3
- data/spec/data/image.json +2 -2
- data/spec/data/machine_type.json +1 -1
- data/spec/data/network.json +1 -1
- data/spec/data/project.json +1 -1
- data/spec/data/region.json +23 -0
- data/spec/data/serial_port_output.json +1 -1
- data/spec/data/server.json +7 -7
- data/spec/data/snapshot.json +2 -2
- data/spec/data/zone.json +7 -15
- data/spec/data/zone_operation.json +3 -3
- data/spec/google/compute/disk_spec.rb +32 -32
- data/spec/google/compute/firewall_spec.rb +37 -37
- data/spec/google/compute/global_operation_spec.rb +9 -9
- data/spec/google/compute/image_spec.rb +17 -17
- data/spec/google/compute/machine_type_spec.rb +7 -7
- data/spec/google/compute/network_spec.rb +14 -14
- data/spec/google/compute/project_spec.rb +17 -17
- data/spec/google/compute/region_spec.rb +51 -0
- data/spec/google/compute/server_spec.rb +35 -42
- data/spec/google/compute/snapshot_spec.rb +11 -11
- data/spec/google/compute/zone_operation_spec.rb +9 -9
- data/spec/google/compute/zone_spec.rb +7 -7
- data/spec/spec_helper.rb +1 -0
- data/spec/support/mocks.rb +10 -10
- data/spec/support/resource_examples.rb +7 -7
- data/spec/support/spec_google_base.rb +4 -0
- metadata +14 -26
- data/spec/data/kernel.json +0 -15
- data/spec/google/compute/kernel_spec.rb +0 -49
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDBmNTIyNjhmNzNlYzBkNjQxMGEwYzQzOWMzM2E4MGE5MmYzZjU4YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
M2EzNGQ1NWE2NzJiYjUwMzgwMjliYWM2MjQ3Njg1YjY1ZGY1OWQ4NQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YmUyZmFlMGIyM2EwYzFkM2ZiODFmYTYzMjA5NDNjZDM5NTA2M2MxYWI0N2Rh
|
10
|
+
YmY5YmM4MjQzM2E1MDZlMzM0NDkzYTdmNzc5MTAyNGU4NjgyOWVjZWZhMzZm
|
11
|
+
NjliMTVmOTRhMTlkMmM0OGMzYjYxMzIxZTY5NTcxNzcxNjdjNmU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NmYxODc2MjRkNDM2NGNlMmRlYTU3MzZlZTQ5YjY1ZmZhMGYwZTI5ZDhkNTRk
|
14
|
+
NzczODgwMTI4M2Q5ZGE4MWY3ZmZlOWY0YzcxZTdkYjhmZTA4ZWE0MmM0NDgy
|
15
|
+
ZDg0YzhlOThiMzBkMjlkODQyZDAyMjg4ZTZjYTNjMzIxYmIxZjU=
|
data/README.md
CHANGED
@@ -12,10 +12,20 @@ delete, and manage
|
|
12
12
|
[Google Compute Engine](https://cloud.google.com/products/compute-engine)
|
13
13
|
servers and disks.
|
14
14
|
|
15
|
+
### Compatibility
|
16
|
+
|
17
|
+
This plugin utilizes Google Compute Engine API v1. Please review API v1
|
18
|
+
[release notes](https://developers.google.com/compute/docs/release-notes#december032013)
|
19
|
+
for additional information.
|
20
|
+
|
21
|
+
With knife-google 1.3.0 options have changed. Several GCE specific short
|
22
|
+
options have been deprecated and GCE specific long options now start
|
23
|
+
with '--gce-'.
|
24
|
+
|
15
25
|
### Nomenclature
|
16
26
|
|
17
27
|
This plugin conforms to the nomenclature used by similar plugins and uses
|
18
|
-
the term "server" when referencing nodes managed by the plugin.
|
28
|
+
the term "server" when referencing nodes managed by the plugin. In
|
19
29
|
Google Compute Engine parlance, this is equivalent to an "instance" or
|
20
30
|
"virtual machine instance".
|
21
31
|
|
@@ -25,7 +35,7 @@ Before getting started with this plugin, you must first create a
|
|
25
35
|
[Google Cloud Platform](https://cloud.google.com/) "project" and add the
|
26
36
|
Google Compute Engine service to your project. Once you have created your
|
27
37
|
project, you will have access to other Google Cloud Platform services such as
|
28
|
-
[App
|
38
|
+
[App Engine](https://developers.google.com/appengine/),
|
29
39
|
[Cloud Storage](https://developers.google.com/storage/),
|
30
40
|
[Cloud SQL](https://developers.google.com/cloud-sql/)
|
31
41
|
and others, but this plugin only requires you enable Google Compute Engine in
|
@@ -65,10 +75,12 @@ or, for Gemfile:
|
|
65
75
|
gem 'knife-google'
|
66
76
|
```
|
67
77
|
|
68
|
-
There is a long standing issue in Ruby where the net/http library by default
|
78
|
+
There is a long standing issue in Ruby where the net/http library by default
|
79
|
+
does not check the validity of an SSL certificate during a TLS handshake.
|
69
80
|
|
70
81
|
To configure Windows system to validate SSL certificate please download
|
71
|
-
[cacert.pem](http://curl.haxx.se/ca/cacert.pem) file and save to C: drive.
|
82
|
+
[cacert.pem](http://curl.haxx.se/ca/cacert.pem) file and save to C: drive.
|
83
|
+
Now make ruby aware of your certificate authority by setting SSL_CERT_FILE.
|
72
84
|
|
73
85
|
To set this in your current command prompt session, type:
|
74
86
|
|
@@ -139,7 +151,10 @@ Some usage examples follow:
|
|
139
151
|
$ knife google server list -Z us-central2-a
|
140
152
|
|
141
153
|
# Create a server
|
142
|
-
$ knife google server create www1 -m n1-standard-1 -I debian-7-wheezy-
|
154
|
+
$ knife google server create www1 -m n1-standard-1 -I debian-7-wheezy-v20131120 -Z us-central1-a -i ~/.ssh/id_rsa -x jdoe
|
155
|
+
|
156
|
+
# Create a server with service account scopes
|
157
|
+
$ knife google server create www1 -m n1-standard-1 -I debian-7-wheezy-v20131120 -Z us-central1-a -i ~/.ssh/id_rsa -x jdoe --gce-service-account-scopes https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/devstorage.full_control
|
143
158
|
|
144
159
|
# Delete a server (along with Chef node and API client via --purge)
|
145
160
|
$ knife google server delete www1 --purge -Z us-central2-a
|
@@ -151,40 +166,44 @@ For a full list of commands, run `knife google` without additional arguments:
|
|
151
166
|
$ knife google
|
152
167
|
|
153
168
|
** GOOGLE COMMANDS **
|
154
|
-
knife google disk
|
155
|
-
knife google
|
156
|
-
knife google
|
157
|
-
knife google
|
158
|
-
knife google
|
169
|
+
knife google disk create NAME --gce-disk-size N -Z ZONE (options)
|
170
|
+
knife google disk delete NAME -Z ZONE (options)
|
171
|
+
knife google disk list -Z ZONE (options)
|
172
|
+
knife google project list (options)
|
173
|
+
knife google region list (options)
|
174
|
+
knife google server create NAME -m MACHINE_TYPE -I IMAGE -Z ZONE (options)
|
175
|
+
knife google server delete SERVER [SERVER] -Z ZONE (options)
|
176
|
+
knife google server list -Z ZONE (options)
|
159
177
|
knife google setup
|
160
|
-
knife google
|
161
|
-
knife google disk delete NAME --google-compute-zone ZONE
|
178
|
+
knife google zone list (options)
|
162
179
|
```
|
163
180
|
|
164
181
|
More detailed help can be obtained by specifying sub-commands. For
|
165
182
|
instance,
|
166
183
|
|
167
184
|
```sh
|
168
|
-
$ knife google server list -Z
|
169
|
-
knife google server list
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
185
|
+
$ knife google server list -Z us-central1-a --help
|
186
|
+
knife google server list -Z ZONE (options)
|
187
|
+
-s, --server-url URL Chef Server URL
|
188
|
+
--chef-zero-port PORT Port to start chef-zero on
|
189
|
+
-k, --key KEY API Client Key
|
190
|
+
--[no-]color Use colored output, defaults to false on Windows, true otherwise
|
191
|
+
-f CREDENTIAL_FILE, Google Compute credential file (google setup can create this)
|
192
|
+
--gce-credential-file
|
193
|
+
-c, --config CONFIG The configuration file to use
|
194
|
+
--defaults Accept default values for all questions
|
195
|
+
-d, --disable-editing Do not open EDITOR, just accept the data as is
|
196
|
+
-e, --editor EDITOR Set the editor to use for interactive commands
|
197
|
+
-E, --environment ENVIRONMENT Set the Chef environment
|
198
|
+
-F, --format FORMAT Which format to use for output
|
199
|
+
-z, --local-mode Point knife commands at local repository instead of server
|
200
|
+
-u, --user USER API Client Username
|
201
|
+
--print-after Show the data after a destructive operation
|
202
|
+
-V, --verbose More verbose output. Use twice for max verbosity
|
203
|
+
-v, --version Show chef version
|
204
|
+
-y, --yes Say yes to all prompts for confirmation
|
205
|
+
-Z, --gce-zone ZONE The Zone for this server (required)
|
206
|
+
-h, --help Show this message
|
188
207
|
```
|
189
208
|
|
190
209
|
## Sub-commands
|
@@ -193,43 +212,102 @@ instance,
|
|
193
212
|
|
194
213
|
Use this command to initially set up authorization (see above for more
|
195
214
|
details). Note that if you override the default credential file with the
|
196
|
-
`-f`
|
215
|
+
`-f` switch, you'll need to use the `-f` switch for *all* sub-commands.
|
197
216
|
When prompted, make sure to specify the "Project ID" (and not the name or
|
198
217
|
number) or you will see 404/not found errors even if the setup command
|
199
218
|
completes successfully.
|
200
219
|
|
201
220
|
### knife google zone list
|
202
221
|
|
222
|
+
A zone is an isolated location within a region that is independent of
|
223
|
+
other zones in the same region. Zones are designed to support instances
|
224
|
+
or applications that have high availability requirements. Zones are
|
225
|
+
designed to be fault-tolerant, so that you can distribute instances
|
226
|
+
and resources across multiple zones to protect against the system
|
227
|
+
failure of a single zone. This keeps your application available even
|
228
|
+
in the face of expected and unexpected failures. The fully-qualified
|
229
|
+
name is made up of `<region>/<zone>`. For example, the fully-qualified
|
230
|
+
name for zone `a` in region `us-central1` is `us-central1-a`. Depending on
|
231
|
+
how widely you want to distribute your resources, you may choose to
|
232
|
+
create instances across multiple zones within one region or across
|
233
|
+
multiple regions and multiple zones.
|
234
|
+
|
203
235
|
Use this command to list out the available Google Compute Engine zones.
|
204
|
-
You can find a zone's current status
|
205
|
-
|
236
|
+
You can find a zone's current status and upcoming maintenance windows.
|
237
|
+
|
238
|
+
The output for `knife google zone list` should look similar to:
|
206
239
|
|
207
240
|
```
|
208
|
-
|
209
|
-
europe-west1-a up
|
210
|
-
europe-west1-b up
|
211
|
-
us-central1-a up
|
212
|
-
us-central1-b up
|
213
|
-
us-central2-a up
|
241
|
+
name status deprecation maintainance window
|
242
|
+
europe-west1-a up - 2014-01-18 12:00:00 -0800 to 2014-02-02 12:00:00 -0800
|
243
|
+
europe-west1-b up - 2014-03-15 12:00:00 -0700 to 2014-03-30 12:00:00 -0700
|
244
|
+
us-central1-a up - -
|
245
|
+
us-central1-b up - -
|
246
|
+
us-central2-a up - 2013-12-31 12:00:00 -0800 to 2014-07-01 12:00:00 -0700
|
247
|
+
```
|
248
|
+
|
249
|
+
### knife google region list
|
250
|
+
|
251
|
+
Each region in Google Compute Engine contains any number of zones.
|
252
|
+
The region describes the geographic location where your resources
|
253
|
+
are stored. For example, a zone named `us-east1-a` is in region `us-east1`.
|
254
|
+
A region contains one or more zones.
|
255
|
+
|
256
|
+
Choose a region that makes sense for your scenario. For example, if you
|
257
|
+
only have customers on the east coast of the US, or if you have specific
|
258
|
+
needs that require your data to live in the US, it makes sense to store
|
259
|
+
your resources in a zone with a us-east region.
|
260
|
+
|
261
|
+
Use this command to list out the available Google Compute Engine regions.
|
262
|
+
You can find the region's current status, cpus, disks-total-gb,
|
263
|
+
in-use-addresses and static-addresses. Use the `-L` switch to also list
|
264
|
+
the quota limit for each resource.
|
265
|
+
|
266
|
+
The output for `knife google region list -L` should look similar to:
|
267
|
+
|
268
|
+
```
|
269
|
+
Name status deprecation cpus disks-total-gb in-use-addresses static-addresses
|
270
|
+
europe-west1 up - 1/10 100/100000 1/10 1/7
|
271
|
+
us-central1 up - 0/10 0/100000 0/10 0/7
|
272
|
+
us-central2 up - 1/10 50/100000 1/10 1/7
|
273
|
+
```
|
274
|
+
|
275
|
+
### knife google project list
|
276
|
+
|
277
|
+
A project resource is the root collection and settings resource for
|
278
|
+
all Google Compute Engine resources.
|
279
|
+
|
280
|
+
Use this command to list out your project's current usage of snapshots,
|
281
|
+
networks, firewalls, images, routes, forwarding-rules, target-pools and
|
282
|
+
health-checks. Use the `-L` switch to also list the quota limit for
|
283
|
+
each resource.
|
284
|
+
|
285
|
+
The output for `knife google project list -L` should look similar to:
|
286
|
+
|
287
|
+
```
|
288
|
+
name status deprecation cpus disks-total-gb in-use-addresses static-addresses
|
289
|
+
europe-west1 up - 0 0 0 0
|
290
|
+
us-central1 up - 100 1000 10 1
|
291
|
+
us-central2 up - 0 0 0 0
|
214
292
|
```
|
215
293
|
|
216
294
|
### knife google server create
|
217
295
|
|
218
296
|
Use this command to create a new Google Compute Engine server (a.k.a.
|
219
|
-
instance).
|
220
|
-
the the image name. Images provided by
|
221
|
-
convention:
|
297
|
+
instance) with a persistent boot disk. You must specify a name, the
|
298
|
+
machine type, the zone, and the the image name. Images provided by
|
299
|
+
Google follow this naming convention:
|
222
300
|
|
223
301
|
```
|
224
302
|
debian-7-wheezy-vYYYYMMDD
|
225
|
-
debian-6-squeeze-vYYYYMMDD
|
226
303
|
centos-6-vYYYYMMDD
|
227
304
|
```
|
228
305
|
|
229
306
|
By default, the plugin will look for the specified image in the instance's
|
230
307
|
primary project first and then consult GCE's officially supported image
|
231
|
-
locations. The
|
232
|
-
plugin to look for the image in an alternate project
|
308
|
+
locations. The `--gce-image-project-id IMAGE_PROJECT_ID` option can be
|
309
|
+
specified to force the plugin to look for the image in an alternate project
|
310
|
+
location.
|
233
311
|
|
234
312
|
Note that if you are bootstrapping the node, make sure to follow the
|
235
313
|
preparation instructions earlier and use the `-x` and `-i` commands
|
@@ -237,52 +315,63 @@ to specify the username and the identity file for that user. Make sure
|
|
237
315
|
to use the private key file (e.g. `~/.ssh/id_rsa`) for the identity
|
238
316
|
file and *not* the public key file.
|
239
317
|
|
318
|
+
If you would like to set up your server with a service account, provide
|
319
|
+
the --gce-service-account-scopes argument during server creation. The service
|
320
|
+
account associated with your project will be used by default unless otherwise
|
321
|
+
specified with the optional --gce-service-account-name argument.
|
322
|
+
|
240
323
|
See the extended options that also allow bootstrapping the node with
|
241
324
|
`knife google server create --help`.
|
242
325
|
|
243
326
|
### knife google server delete
|
244
327
|
|
245
328
|
This command terminates and deletes a server. Use the `--purge`
|
246
|
-
option to also remove it from Chef.
|
247
|
-
|
329
|
+
option to also remove it from Chef.
|
330
|
+
|
331
|
+
Note that persistent disks associated with the server, including the
|
332
|
+
boot disk, are not deleted with this operation. To delete persistent
|
333
|
+
disks use `knife google disk delete`.
|
334
|
+
|
335
|
+
Use `knife google server delete --help` for other options.
|
248
336
|
|
249
337
|
### knife google server list
|
250
338
|
|
251
339
|
Get a list of servers in the specified zone. Note that this may
|
252
|
-
include servers that are *not* managed by Chef.
|
340
|
+
include servers that are *not* managed by Chef. Your output should
|
253
341
|
look something like:
|
254
342
|
|
255
343
|
```
|
256
|
-
|
257
|
-
chef-
|
258
|
-
chef-workstation n1-standard-1
|
259
|
-
fuse-dev n1-standard-1
|
260
|
-
magfs-c1 n1-standard-2
|
261
|
-
magfs-c2 n1-standard-2
|
262
|
-
magfs-c3 n1-standard-2
|
263
|
-
magfs-svr n1-standard-4
|
344
|
+
name type public ip private ip disks zone status
|
345
|
+
chef-server n1-standard-1 103.59.80.113 10.240.45.78 chef-server us-central1-a running
|
346
|
+
chef-workstation n1-standard-1 103.59.85.188 10.240.9.140 chef-workstation us-central1-a running
|
347
|
+
fuse-dev n1-standard-1 103.59.80.147 10.240.166.18 fuse-dev us-central1-a running
|
348
|
+
magfs-c1 n1-standard-2 103.59.87.217 10.240.61.92 magfs-c1 us-central1-a running
|
349
|
+
magfs-c2 n1-standard-2 103.59.80.161 10.240.175.240 magfs-c2 us-central1-a running
|
350
|
+
magfs-c3 n1-standard-2 178.255.120.69 10.240.34.197 magfs-c3 us-central1-a running
|
351
|
+
magfs-svr n1-standard-4 103.59.80.178 10.240.81.25 magfs-svr us-central1-a running
|
264
352
|
```
|
265
353
|
|
266
354
|
### knife google disk create
|
267
355
|
|
268
|
-
Create a new persistent disk.
|
356
|
+
Create a new persistent disk. You must provide a name, size in
|
269
357
|
gigabytes, and the desired zone.
|
270
358
|
|
271
359
|
### knife google disk delete
|
272
360
|
|
273
|
-
Delete an existing disk in the specified zone.
|
361
|
+
Delete an existing disk in the specified zone. Note that the
|
274
362
|
disk will *not* be deleted if it is currently attached to a
|
275
363
|
running server.
|
276
364
|
|
277
365
|
### knife google disk list
|
278
366
|
|
279
|
-
See a listing of disks defined for a specific zone.
|
367
|
+
See a listing of disks defined for a specific zone. Your output should
|
368
|
+
look something like:
|
280
369
|
|
281
370
|
```
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
371
|
+
name zone source snapshot size (in GB) status
|
372
|
+
dev-1 us-central1-a 10 ready
|
373
|
+
dev-2 us-central1-a 10 ready
|
374
|
+
test-1 us-central1-a 20 ready
|
286
375
|
```
|
287
376
|
|
288
377
|
## Troubleshooting
|
@@ -306,9 +395,9 @@ Standard rake commands for building, installing, testing, and uninstalling the m
|
|
306
395
|
# Uninstall
|
307
396
|
$ rake uninstall
|
308
397
|
```
|
398
|
+
|
309
399
|
## Contributing
|
310
400
|
* See [CONTRIB.md](https://github.com/opscode/knife-google/blob/master/CONTRIB.md)
|
311
401
|
|
312
402
|
## Licensing
|
313
403
|
* See [LICENSE](https://raw.github.com/opscode/knife-google/master/LICENSE)
|
314
|
-
|
data/knife-google.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Knife::Google::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Chiraq Jog", "Ranjib Dey", "James Tucker", "Paul Rossman", "Eric Johnson"]
|
10
|
-
s.email = "
|
10
|
+
s.email = "paulrossman@google.com"
|
11
11
|
s.has_rdoc = true
|
12
12
|
s.extra_rdoc_files = ["README.md", "LICENSE", "CONTRIB.md" ]
|
13
13
|
s.summary = "Manage Google Compute Engine servers, disks, and zones"
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_dependency "multi_json"
|
20
20
|
s.add_dependency "mixlib-config"
|
21
21
|
s.files = `git ls-files`.split($/)
|
22
|
+
#s.files = Dir['CONTRIB.md', 'Gemfile', 'LICENSE', 'README.md', 'Rakefile', 'knife-google.gemspec', 'lib/**/*', 'spec/**/*']
|
22
23
|
|
23
24
|
s.add_development_dependency "rspec"
|
24
25
|
s.add_development_dependency "rake"
|
@@ -30,7 +30,7 @@ class Chef
|
|
30
30
|
|
31
31
|
option :compute_credential_file,
|
32
32
|
:short => "-f CREDENTIAL_FILE",
|
33
|
-
:long => "--
|
33
|
+
:long => "--gce-credential-file CREDENTIAL_FILE",
|
34
34
|
:description => "Google Compute credential file (google setup can create this)"
|
35
35
|
end
|
36
36
|
end
|
@@ -20,7 +20,7 @@ class Chef
|
|
20
20
|
|
21
21
|
include Knife::GoogleBase
|
22
22
|
|
23
|
-
banner "knife google disk create NAME --
|
23
|
+
banner "knife google disk create NAME --gce-disk-size N -Z ZONE (options)"
|
24
24
|
|
25
25
|
deps do
|
26
26
|
require 'google/compute'
|
@@ -28,15 +28,14 @@ class Chef
|
|
28
28
|
|
29
29
|
option :zone,
|
30
30
|
:short => "-Z ZONE",
|
31
|
-
:long => "--
|
31
|
+
:long => "--gce-zone ZONE",
|
32
32
|
:description => "The Zone for this disk",
|
33
33
|
:required => true
|
34
34
|
|
35
|
-
option :
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:required => true
|
35
|
+
option :disk_size,
|
36
|
+
:long => "--gce-disk-size SIZE",
|
37
|
+
:description => "Size of the persistent disk between 1 and 10000 GB, specified in GB; default is '1' GB",
|
38
|
+
:default => "1"
|
40
39
|
|
41
40
|
def run
|
42
41
|
$stdout.sync = true
|
@@ -52,8 +51,17 @@ class Chef
|
|
52
51
|
exit 1
|
53
52
|
end
|
54
53
|
|
55
|
-
|
56
|
-
|
54
|
+
begin
|
55
|
+
disk_size = config[:disk_size].to_i
|
56
|
+
raise if !disk_size.between?(1, 10000)
|
57
|
+
rescue
|
58
|
+
ui.error("Size of the persistent disk must be between 1 and 10000 GB.")
|
59
|
+
exit 1
|
60
|
+
end
|
61
|
+
|
62
|
+
zone_operation = client.disks.create(:name => @name_args.first,
|
63
|
+
:sizeGb => config[:disk_size],
|
64
|
+
:zone => zone.name)
|
57
65
|
end
|
58
66
|
end
|
59
67
|
end
|
@@ -20,7 +20,7 @@ class Chef
|
|
20
20
|
|
21
21
|
include Knife::GoogleBase
|
22
22
|
|
23
|
-
banner "knife google disk delete NAME
|
23
|
+
banner "knife google disk delete NAME -Z ZONE (options)"
|
24
24
|
|
25
25
|
deps do
|
26
26
|
require 'google/compute'
|
@@ -28,7 +28,7 @@ class Chef
|
|
28
28
|
|
29
29
|
option :zone,
|
30
30
|
:short => "-Z ZONE",
|
31
|
-
:long => "--
|
31
|
+
:long => "--gce-zone ZONE",
|
32
32
|
:description => "The Zone for this disk",
|
33
33
|
:required => true
|
34
34
|
|
@@ -20,11 +20,11 @@ class Chef
|
|
20
20
|
|
21
21
|
include Knife::GoogleBase
|
22
22
|
|
23
|
-
banner "knife google disk list
|
23
|
+
banner "knife google disk list -Z ZONE (options)"
|
24
24
|
|
25
25
|
option :zone,
|
26
26
|
:short => "-Z ZONE",
|
27
|
-
:long => "--
|
27
|
+
:long => "--gce-zone ZONE",
|
28
28
|
:description => "The Zone for disk listing",
|
29
29
|
:required => true
|
30
30
|
|
@@ -39,11 +39,11 @@ class Chef
|
|
39
39
|
end
|
40
40
|
|
41
41
|
disk_list = [
|
42
|
-
ui.color("
|
43
|
-
ui.color('
|
44
|
-
ui.color('
|
45
|
-
ui.color('
|
46
|
-
ui.color('
|
42
|
+
ui.color("name", :bold),
|
43
|
+
ui.color('zone', :bold),
|
44
|
+
ui.color('source snapshot', :bold),
|
45
|
+
ui.color('size (in GB)', :bold),
|
46
|
+
ui.color('status', :bold)].flatten.compact
|
47
47
|
|
48
48
|
output_column_count = disk_list.length
|
49
49
|
|
@@ -53,7 +53,7 @@ class Chef
|
|
53
53
|
if disk.source_snapshot.nil?
|
54
54
|
disk_list << " "
|
55
55
|
else
|
56
|
-
selflink2name(disk.source_snapshot)
|
56
|
+
disk_list << selflink2name(disk.source_snapshot)
|
57
57
|
end
|
58
58
|
disk_list << disk.size_gb
|
59
59
|
disk_list << begin
|