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.
Files changed (69) hide show
  1. checksums.yaml +15 -0
  2. data/README.md +155 -66
  3. data/knife-google.gemspec +2 -1
  4. data/lib/chef/knife/google_base.rb +1 -1
  5. data/lib/chef/knife/google_disk_create.rb +17 -9
  6. data/lib/chef/knife/google_disk_delete.rb +2 -2
  7. data/lib/chef/knife/google_disk_list.rb +8 -8
  8. data/lib/chef/knife/google_project_list.rb +178 -0
  9. data/lib/chef/knife/google_region_list.rb +125 -0
  10. data/lib/chef/knife/google_server_create.rb +174 -46
  11. data/lib/chef/knife/google_server_delete.rb +9 -13
  12. data/lib/chef/knife/google_server_list.rb +5 -6
  13. data/lib/chef/knife/google_zone_list.rb +22 -28
  14. data/lib/google/compute.rb +2 -1
  15. data/lib/google/compute/client.rb +12 -7
  16. data/lib/google/compute/creatable_resource_collection.rb +12 -1
  17. data/lib/google/compute/disk.rb +0 -2
  18. data/lib/google/compute/image.rb +1 -2
  19. data/lib/google/compute/project.rb +2 -2
  20. data/lib/google/compute/{kernel.rb → region.rb} +12 -1
  21. data/lib/google/compute/region_operation.rb +62 -0
  22. data/lib/google/compute/server.rb +3 -2
  23. data/lib/google/compute/server/attached_disk.rb +3 -3
  24. data/lib/google/compute/zone.rb +6 -4
  25. data/lib/google/compute/zone_operation.rb +11 -9
  26. data/lib/knife-google/version.rb +1 -1
  27. data/spec/chef/knife/google_base_spec.rb +4 -4
  28. data/spec/chef/knife/google_disk_create_spec.rb +8 -7
  29. data/spec/chef/knife/google_disk_delete_spec.rb +15 -16
  30. data/spec/chef/knife/google_disk_list_spec.rb +6 -6
  31. data/spec/chef/knife/google_region_list_spec.rb +32 -0
  32. data/spec/chef/knife/google_server_create_spec.rb +78 -44
  33. data/spec/chef/knife/google_server_delete_spec.rb +37 -37
  34. data/spec/chef/knife/google_server_list_spec.rb +8 -7
  35. data/spec/chef/knife/google_setup_spec.rb +1 -2
  36. data/spec/chef/knife/google_zone_list_spec.rb +4 -4
  37. data/spec/data/{compute-v1beta15.json → compute-v1.json} +700 -246
  38. data/spec/data/disk.json +3 -4
  39. data/spec/data/firewall.json +2 -2
  40. data/spec/data/global_operation.json +3 -3
  41. data/spec/data/image.json +2 -2
  42. data/spec/data/machine_type.json +1 -1
  43. data/spec/data/network.json +1 -1
  44. data/spec/data/project.json +1 -1
  45. data/spec/data/region.json +23 -0
  46. data/spec/data/serial_port_output.json +1 -1
  47. data/spec/data/server.json +7 -7
  48. data/spec/data/snapshot.json +2 -2
  49. data/spec/data/zone.json +7 -15
  50. data/spec/data/zone_operation.json +3 -3
  51. data/spec/google/compute/disk_spec.rb +32 -32
  52. data/spec/google/compute/firewall_spec.rb +37 -37
  53. data/spec/google/compute/global_operation_spec.rb +9 -9
  54. data/spec/google/compute/image_spec.rb +17 -17
  55. data/spec/google/compute/machine_type_spec.rb +7 -7
  56. data/spec/google/compute/network_spec.rb +14 -14
  57. data/spec/google/compute/project_spec.rb +17 -17
  58. data/spec/google/compute/region_spec.rb +51 -0
  59. data/spec/google/compute/server_spec.rb +35 -42
  60. data/spec/google/compute/snapshot_spec.rb +11 -11
  61. data/spec/google/compute/zone_operation_spec.rb +9 -9
  62. data/spec/google/compute/zone_spec.rb +7 -7
  63. data/spec/spec_helper.rb +1 -0
  64. data/spec/support/mocks.rb +10 -10
  65. data/spec/support/resource_examples.rb +7 -7
  66. data/spec/support/spec_google_base.rb +4 -0
  67. metadata +14 -26
  68. data/spec/data/kernel.json +0 -15
  69. data/spec/google/compute/kernel_spec.rb +0 -49
@@ -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. But in
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 Egnine](https://developers.google.com/appengine/),
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 does not check the validity of an SSL certificate during a TLS handshake.
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. Now make ruby aware of your certificate authority by setting SSL_CERT_FILE.
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-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe
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 list --google-compute-zone ZONE (options)
155
- knife google zone list (options)
156
- knife google server delete SERVER [SERVER] --google-compute-zone ZONE (options)
157
- knife google server create NAME --google-compute-zone ZONE (options)
158
- knife google disk create NAME --google-disk-size N --google-compute-zone ZONE (options)
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 server list --google-compute-zone ZONE (options)
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 foo --help
169
- knife google server list --google-compute-zone ZONE (options)
170
- -s, --server-url URL Chef Server URL
171
- -k, --key KEY API Client Key
172
- --[no-]color Use colored output, defaults to enabled
173
- -f CREDENTIAL_FILE, Google Compute credential file (google setup can create this)
174
- --google-compute-credential-file
175
- -c, --config CONFIG The configuration file to use
176
- --defaults Accept default values for all questions
177
- -d, --disable-editing Do not open EDITOR, just accept the data as is
178
- -e, --editor EDITOR Set the editor to use for interactive commands
179
- -E, --environment ENVIRONMENT Set the Chef environment
180
- -F, --format FORMAT Which format to use for output
181
- -u, --user USER API Client Username
182
- --print-after Show the data after a destructive operation
183
- -V, --verbose More verbose output. Use twice for max verbosity
184
- -v, --version Show chef version
185
- -y, --yes Say yes to all prompts for confirmation
186
- -Z, --google-compute-zone ZONE The Zone for this server (required)
187
- -h, --help Show this message
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` parameter, you'll need to use the `-f` switch for *all* sub-commands.
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, number of deployed servers, disks,
205
- and upcoming maintenance windows. The output should look similar to:
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
- Name Status Servers Disks Maintainance Window
209
- europe-west1-a up 0 0 2013-08-03 19:00:00 +0000 to 2013-08-18 19:00:00 +0000
210
- europe-west1-b up 0 0 2013-05-11 19:00:00 +0000 to 2013-05-26 19:00:00 +0000
211
- us-central1-a up 0 1 2013-08-17 19:00:00 +0000 to 2013-09-01 19:00:00 +0000
212
- us-central1-b up 0 0 2013-06-08 19:00:00 +0000 to 2013-06-23 19:00:00 +0000
213
- us-central2-a up 10 6 2013-05-25 19:00:00 +0000 to 2013-06-09 19:00:00 +0000
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). You must specify a name, the machine type, the zone, and
220
- the the image name. Images provided by Google follow this naming
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 `-J IMAGE_PROJECT_ID` option can be specified to force the
232
- plugin to look for the image in an alternate project location.
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. Use `knife google server
247
- delete --help` for other options.
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. Your output should
340
+ include servers that are *not* managed by Chef. Your output should
253
341
  look something like:
254
342
 
255
343
  ```
256
- Name Type Image Public IP Private IP Disks Zone Status
257
- chef-svr n1-standard-1 gcel-12-04-v20130325 103.59.80.113 10.240.45.78 us-central2-a running
258
- chef-workstation n1-standard-1 gcel-12-04-v20130325 103.59.85.188 10.240.9.140 us-central2-a running
259
- fuse-dev n1-standard-1 gcel-12-04-v20130225 103.59.80.147 10.240.166.18 pd-fuse us-central2-a running
260
- magfs-c1 n1-standard-2 gcel-12-04-v20130225 103.59.87.217 10.240.61.92 us-central2-a running
261
- magfs-c2 n1-standard-2 gcel-12-04-v20130225 103.59.80.161 10.240.175.240 us-central2-a running
262
- magfs-c3 n1-standard-2 gcel-12-04-v20130325 178.255.120.69 10.240.34.197 jay-scratch us-central2-a running
263
- magfs-svr n1-standard-4 gcel-12-04-v20130225 103.59.80.178 10.240.81.25 pd28g us-central2-a running
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. You must provide a name, size in
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. Note that the
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. For example,
367
+ See a listing of disks defined for a specific zone. Your output should
368
+ look something like:
280
369
 
281
370
  ```
282
- Name Zone Source Snapshot Size (In GB) Status
283
- jay-scratch us-central2-a 10 ready
284
- pd-fuse us-central2-a 10 ready
285
- pd28g us-central2-a 28 ready
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
-
@@ -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 = "raggi@google.com"
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 => "--compute-credential-file CREDENTIAL_FILE",
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 --google-disk-sizeGb N --google-compute-zone ZONE (options)"
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 => "--google-compute-zone ZONE",
31
+ :long => "--gce-zone ZONE",
32
32
  :description => "The Zone for this disk",
33
33
  :required => true
34
34
 
35
- option :sizeGb,
36
- :short => "-s SIZE",
37
- :long => "--google-disk-sizeGb SIZE",
38
- :description => "Disk size in GB",
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
- zone_operation = client.disks.create(:name=>@name_args.first,
56
- :sizeGb=>config[:sizeGb], :zone=>zone.name)
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 --google-compute-zone ZONE"
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 => "--google-compute-zone ZONE",
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 --google-compute-zone ZONE (options)"
23
+ banner "knife google disk list -Z ZONE (options)"
24
24
 
25
25
  option :zone,
26
26
  :short => "-Z ZONE",
27
- :long => "--google-compute-zone ZONE",
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("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
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