knife-google 1.3.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +5 -13
  2. data/.gitignore +1 -0
  3. data/.travis.yml +15 -3
  4. data/CHANGELOG.md +4 -6
  5. data/Gemfile +3 -9
  6. data/README.md +208 -355
  7. data/RELEASE_NOTES.md +8 -17
  8. data/Rakefile +8 -49
  9. data/knife-google.gemspec +20 -17
  10. data/lib/chef/knife/cloud/google_service.rb +491 -0
  11. data/lib/chef/knife/cloud/google_service_helpers.rb +62 -0
  12. data/lib/chef/knife/cloud/google_service_options.rb +58 -0
  13. data/lib/chef/knife/google_disk_create.rb +40 -44
  14. data/lib/chef/knife/google_disk_delete.rb +22 -40
  15. data/lib/chef/knife/google_disk_list.rb +57 -51
  16. data/lib/chef/knife/google_project_quotas.rb +59 -0
  17. data/lib/chef/knife/google_region_list.rb +43 -102
  18. data/lib/chef/knife/google_region_quotas.rb +77 -0
  19. data/lib/chef/knife/google_server_create.rb +224 -505
  20. data/lib/chef/knife/google_server_delete.rb +20 -78
  21. data/lib/chef/knife/google_server_list.rb +42 -53
  22. data/lib/chef/knife/google_server_show.rb +44 -0
  23. data/lib/chef/knife/google_zone_list.rb +39 -50
  24. data/lib/knife-google/version.rb +3 -2
  25. data/spec/cloud/google_service_helpers_spec.rb +120 -0
  26. data/spec/cloud/google_service_spec.rb +832 -0
  27. data/spec/google_disk_create_spec.rb +72 -0
  28. data/spec/google_disk_delete_spec.rb +64 -0
  29. data/spec/google_disk_list_spec.rb +93 -0
  30. data/spec/google_project_quotas_spec.rb +63 -0
  31. data/spec/google_region_list_spec.rb +65 -0
  32. data/spec/google_region_quotas_spec.rb +108 -0
  33. data/spec/google_server_create_spec.rb +177 -0
  34. data/spec/google_server_delete_spec.rb +39 -0
  35. data/spec/google_server_list_spec.rb +77 -0
  36. data/spec/google_server_show_spec.rb +60 -0
  37. data/spec/google_zone_list_spec.rb +59 -0
  38. metadata +91 -114
  39. data/CONTRIB.md +0 -64
  40. data/lib/chef/knife/google_base.rb +0 -76
  41. data/lib/chef/knife/google_project_list.rb +0 -178
  42. data/lib/chef/knife/google_setup.rb +0 -31
  43. data/lib/google/compute.rb +0 -47
  44. data/lib/google/compute/client.rb +0 -216
  45. data/lib/google/compute/config.rb +0 -23
  46. data/lib/google/compute/creatable_resource_collection.rb +0 -55
  47. data/lib/google/compute/deletable_resource_collection.rb +0 -51
  48. data/lib/google/compute/disk.rb +0 -38
  49. data/lib/google/compute/exception.rb +0 -30
  50. data/lib/google/compute/firewall.rb +0 -65
  51. data/lib/google/compute/global_operation.rb +0 -60
  52. data/lib/google/compute/image.rb +0 -29
  53. data/lib/google/compute/listable_resource_collection.rb +0 -33
  54. data/lib/google/compute/machine_type.rb +0 -36
  55. data/lib/google/compute/mixins/utils.rb +0 -58
  56. data/lib/google/compute/network.rb +0 -29
  57. data/lib/google/compute/project.rb +0 -76
  58. data/lib/google/compute/region.rb +0 -31
  59. data/lib/google/compute/region_operation.rb +0 -62
  60. data/lib/google/compute/resource.rb +0 -81
  61. data/lib/google/compute/resource_collection.rb +0 -78
  62. data/lib/google/compute/server.rb +0 -88
  63. data/lib/google/compute/server/attached_disk.rb +0 -39
  64. data/lib/google/compute/server/network_interface.rb +0 -38
  65. data/lib/google/compute/server/network_interface/access_config.rb +0 -35
  66. data/lib/google/compute/server/serial_port_output.rb +0 -31
  67. data/lib/google/compute/snapshot.rb +0 -30
  68. data/lib/google/compute/version.rb +0 -19
  69. data/lib/google/compute/zone.rb +0 -34
  70. data/lib/google/compute/zone_operation.rb +0 -62
  71. data/spec/chef/knife/google_base_spec.rb +0 -46
  72. data/spec/chef/knife/google_disk_create_spec.rb +0 -37
  73. data/spec/chef/knife/google_disk_delete_spec.rb +0 -64
  74. data/spec/chef/knife/google_disk_list_spec.rb +0 -36
  75. data/spec/chef/knife/google_region_list_spec.rb +0 -32
  76. data/spec/chef/knife/google_server_create_spec.rb +0 -138
  77. data/spec/chef/knife/google_server_delete_spec.rb +0 -127
  78. data/spec/chef/knife/google_server_list_spec.rb +0 -39
  79. data/spec/chef/knife/google_setup_spec.rb +0 -24
  80. data/spec/chef/knife/google_zone_list_spec.rb +0 -32
  81. data/spec/data/client.json +0 -14
  82. data/spec/data/compute-v1.json +0 -6734
  83. data/spec/data/disk.json +0 -14
  84. data/spec/data/firewall.json +0 -13
  85. data/spec/data/global_operation.json +0 -36
  86. data/spec/data/image.json +0 -12
  87. data/spec/data/machine_type.json +0 -24
  88. data/spec/data/network.json +0 -10
  89. data/spec/data/project.json +0 -21
  90. data/spec/data/region.json +0 -23
  91. data/spec/data/serial_port_output.json +0 -5
  92. data/spec/data/server.json +0 -46
  93. data/spec/data/snapshot.json +0 -12
  94. data/spec/data/zone.json +0 -22
  95. data/spec/data/zone_operation.json +0 -36
  96. data/spec/google/compute/disk_spec.rb +0 -115
  97. data/spec/google/compute/firewall_spec.rb +0 -129
  98. data/spec/google/compute/global_operation_spec.rb +0 -62
  99. data/spec/google/compute/image_spec.rb +0 -75
  100. data/spec/google/compute/machine_type_spec.rb +0 -53
  101. data/spec/google/compute/network_spec.rb +0 -68
  102. data/spec/google/compute/project_spec.rb +0 -71
  103. data/spec/google/compute/region_spec.rb +0 -51
  104. data/spec/google/compute/server_spec.rb +0 -118
  105. data/spec/google/compute/snapshot_spec.rb +0 -57
  106. data/spec/google/compute/zone_operation_spec.rb +0 -62
  107. data/spec/google/compute/zone_spec.rb +0 -51
  108. data/spec/spec_helper.rb +0 -45
  109. data/spec/support/mocks.rb +0 -62
  110. data/spec/support/resource_examples.rb +0 -70
  111. data/spec/support/spec_google_base.rb +0 -60
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZTFlMWVhYzJkYjU0NmRhNGFmNThmZmQwZjc2Y2JlYmZkMzMxMDc5Yw==
5
- data.tar.gz: !binary |-
6
- ODk4M2I4ODEwYjkwNzg3ODI4ZTIzNmM1NDllMWNhNmU2MmE0OTI0Nw==
2
+ SHA1:
3
+ metadata.gz: 99ff46ae852794142abaae910482f89dd799b057
4
+ data.tar.gz: 2e76ef1b04265a9271a7664a2cd9488eb74c357b
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NDBiZDgyMGU4NmIzNTAzNmFiYmVjODg2ZGJlNzZiNTBmNzJhODlhOTk3NWE3
10
- NTA0ZTI4NzZmOTIzMTFhZGMzNzIwY2RlYTIzMmUxNTA2ZjViZDAxZjUwZDM5
11
- NTg0MjQ2YzIxZGVhMzY5N2YzZDNmYTExNThlZDM4YmMyOTI2NjM=
12
- data.tar.gz: !binary |-
13
- MjQ0MDU5YmUyYjFlYWVlNTJkYzQyOTcxZjY0M2M2N2MxZDJkNzJjYzBkMDc4
14
- MGZjODIyYjA4M2M4NDBiNTQ2OGI0YWZkYjE3NTQwNTA4MGI3ZTk0YTZhMjky
15
- ODkzY2Q0YzhjNWI4NDQwNDRmMGQzNjY1MzY3NDE1NjFmOWJmNTc=
6
+ metadata.gz: 98d48fa470acd31b44a668c15ea2a35026bf87a047ee3ac6faf415556fc379a3d22ca687c1ca317727d0df9d45c48688b38c8ef66cfabdcf10fab4e5c19cfd2e
7
+ data.tar.gz: 3731acd0adf71b71771a36568d452e8bf817cb9b69d30fbcfd7fb16487f3ead978bff21f627e7a594fd20086c1f999fe0de4fd20fb54103fcd99cb56ec8115e2
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ doc/
20
20
  .swo
21
21
  Gemfile.lock
22
22
  .rvmrc
23
+ .ruby-version
data/.travis.yml CHANGED
@@ -1,4 +1,16 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
1
4
  rvm:
2
- - 1.9.3
3
-
4
- script: bundle exec rake spec
5
+ - 2.0.0
6
+ - 2.1
7
+ - 2.2
8
+ branches:
9
+ only:
10
+ - master
11
+ notifications:
12
+ slack:
13
+ on_success: change
14
+ on_failure: always
15
+ rooms:
16
+ secure: ml+Ph8FuoU4TgEqGmjERaF5peoNTRhllG5rBFDUgGxPCKRxE9snYDwc+29RAhA7izlaUABIA3fWT11SdF2RMTUorsrz0PbYtyBZuI9AKloww1CUFMl2kr8+DRt/AzMcGYs8OgQW12NLNNRV72X4wUKsJXpazVHsXctU/Fh/AqX0=
data/CHANGELOG.md CHANGED
@@ -1,14 +1,12 @@
1
1
  # knife-google Change Log
2
2
 
3
- ## Unreleased:
3
+ ## v2.0.0 (2016-03-01)
4
+ * [pr#94](https://github.com/chef/knife-google/pull/94) Full rewrite using knife-cloud, newer Google API client library, Windows instance support, and better user feedback.
4
5
 
5
- None
6
-
7
- ## Last Release 1.3.1 (04/24/2014)
6
+ ## v1.3.1 (04/24/2014)
8
7
 
9
8
  * Refresh access token (KNIFE-473)
10
9
 
11
-
12
- ## Release: 1.2.0 (02/17/2014)
10
+ ## v1.2.0 (02/17/2014)
13
11
 
14
12
  See source control commit history for earlier changes.
data/Gemfile CHANGED
@@ -1,11 +1,5 @@
1
- source 'https://rubygems.org'
2
-
3
- group(:development, :test) do
4
- platforms :mswin, :mingw do
5
- gem "ffi", "1.3.1"
6
- gem "rdp-ruby-wmi", "0.3.1"
7
- gem "win32-service", "0.7.2"
8
- end
9
- end
1
+ source "https://rubygems.org"
10
2
 
11
3
  gemspec
4
+
5
+ gem "chefstyle", git: "https://github.com/chef/chefstyle"
data/README.md CHANGED
@@ -1,414 +1,267 @@
1
1
  # knife-google
2
2
 
3
- A [knife] (http://wiki.opscode.com/display/chef/Knife) plugin to create,
4
- delete and enlist
5
- [Google Compute Engine] (https://cloud.google.com/products/compute-engine)
3
+ [![Gem Version](https://badge.fury.io/rb/knife-google.svg)](http://badge.fury.io/rb/knife-google)
4
+ [![Build Status](https://travis-ci.org/chef/knife-google.svg?branch=master)](https://travis-ci.org/chef/knife-google)
5
+ [![Dependency Status](https://gemnasium.com/chef/knife-google.svg)](https://gemnasium.com/chef/knife-google)
6
+
7
+ A plugin for Chef's [knife](https://docs.chef.io/knife.html) tool to create and manage
8
+ [Google Compute Engine](https://cloud.google.com/products/compute-engine)
6
9
  resources.
7
10
 
8
- ## Overview
11
+ # Getting Started
9
12
 
10
- This plugin adds functionality to Chef through a knife plugin to create,
11
- delete, and manage
12
- [Google Compute Engine](https://cloud.google.com/products/compute-engine)
13
- servers and disks.
13
+ ## Install the gem
14
14
 
15
- ### Compatibility
15
+ Install the gem with:
16
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.
17
+ ```sh
18
+ gem install knife-google
19
+ ```
20
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-'.
21
+ Or, even better, if you're using the ChefDK:
24
22
 
25
- ### Nomenclature
23
+ ```sh
24
+ chef gem install knife-google
25
+ ```
26
26
 
27
- This plugin conforms to the nomenclature used by similar plugins and uses
28
- the term "server" when referencing nodes managed by the plugin. In
29
- Google Compute Engine parlance, this is equivalent to an "instance" or
30
- "virtual machine instance".
27
+ If you're using Bundler, simply add it to your Gemfile:
31
28
 
32
- ### Create a Google Cloud Platform project
29
+ ```ruby
30
+ gem "knife-google", "~> 2.0"
31
+ ```
32
+
33
+ ... and then run `bundle install`.
34
+
35
+ ## Create a Google Cloud Platform project
33
36
 
34
37
  Before getting started with this plugin, you must first create a
35
- [Google Cloud Platform](https://cloud.google.com/) "project" and add the
36
- Google Compute Engine service to your project. Once you have created your
37
- project, you will have access to other Google Cloud Platform services such as
38
- [App Engine](https://developers.google.com/appengine/),
39
- [Cloud Storage](https://developers.google.com/storage/),
40
- [Cloud SQL](https://developers.google.com/cloud-sql/)
41
- and others, but this plugin only requires you enable Google Compute Engine in
42
- your project. Note that you will need to be logged in with your Google
43
- Account before creating the project and adding services.
44
-
45
- ### Authorizing Setup
46
-
47
- In order for the knife plugin to programmatically manage your servers, you
48
- will first need to authorize its use of the Google Compute Engine API.
49
- Authorization to use any of Google's Cloud service API's utilizes the
50
- [OAuth 2.0](https://developers.google.com/accounts/docs/OAuth2) standard.
51
- Once your project has been created, log in to your Google Account and visit the
52
- [API Console](http://code.google.com/apis/console) and follow the "API Access"
53
- menu. Create a new "Client ID" and specify the
54
- [Installed Application](https://developers.google.com/accounts/docs/OAuth2#installed)
55
- Application type with sub-type "Other". These actions will generate a new
56
- "Client ID", "Client secret", and "Redirect URI's".
57
-
58
- This knife plugin includes a 'setup' sub-command that requires you to supply
59
- the client ID and secret in order to obtain an "authorization token". You
60
- will only need to run this command one time and the plugin will record your
61
- credential information and tokens for future API calls.
62
-
63
- ## Installation
64
-
65
- Be sure you are running Chef version 0.10.0 or higher in order to use knife
66
- plugins.
38
+ [Google Cloud Platform](https://cloud.google.com/) (GCP) "project" and add the
39
+ Google Compute Engine service to your project. While GCP has many other services,
40
+ such as App Enging and Cloud Storage, this plugin only provides an integration with
41
+ Google Compute Engine (GCE).
42
+
43
+ ## Authentication and Authorization
44
+
45
+ The [underlying API](https://github.com/google/google-api-ruby-client) this plugin uses relies on the
46
+ [Google Auth Library](https://github.com/google/google-auth-library-ruby) to handle authentication to the
47
+ Google Cloud API. The auth library expects that there is a JSON credentials file located at:
48
+
49
+ `~/.config/gcloud/application_default_credentials.json`
50
+
51
+ The easiest way to create this is to download and install the [Google Cloud SDK](https://cloud.google.com/sdk/) and run the
52
+ `gcloud auth login` command which will create the credentials file for you.
53
+
54
+ If you already have a file you'd like to use that is in a different location, set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable with the full path to that file
55
+
56
+ ## Configuration
57
+
58
+ All knife-google commands require a project name and zone name to be supplied. You can supply these on the command line:
67
59
 
68
60
  ```sh
69
- gem install knife-google
61
+ knife google server list --gce-project my-test-project --gce-zone us-east1-b
70
62
  ```
71
63
 
72
- or, for Gemfile:
64
+ ... or you can set them in your `knife.rb` file:
73
65
 
74
66
  ```ruby
75
- gem 'knife-google'
67
+ knife[:gce_project] = 'my-test-project'
68
+ knife[:gce_zone] = 'us-east1-b'
76
69
  ```
77
70
 
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.
71
+ ## SSH Keys
72
+
73
+ In order to Linux bootstrap nodes, you will first need to ensure your SSH
74
+ keys are set up correctly. Ensure your SSH public key is properly entered
75
+ into your project's Metadata tab in the GCP Console.
76
+
77
+ You can find [more information on configuring SSH keys](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys) in
78
+ the Google Compute Engine documentation.
79
+
80
+ # Usage
81
+
82
+ To see all knife-google commands, run: `knife google`
83
+
84
+ All commands have additional help output. Simply append `--help` to any command.
85
+ For example, to see additional help and flags available for the `knife google disk create` command,
86
+ run: `knife google disk create --help`
87
+
88
+ ## knife google disk create DISKNAME
80
89
 
81
- To configure Windows system to validate SSL certificate please download
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.
90
+ Create a disk in GCE.
84
91
 
85
- To set this in your current command prompt session, type:
92
+ ### Parameters
93
+
94
+ * **DISKNAME**: required. The name of the disk to create.
95
+ * **gce-disk-size**: optional. The size of the disk, in GB, to create. Valid options are between 10 and 10,000. The default is 10.
96
+ * **gce-disk-type**: optional. The type of GCE disk to create, such as `pd-ssd`. Default is `pd-standard`.
97
+ * **gce-disk-source**: optional. Image to use when creating a disk. By default, the disk will be created blank.
98
+
99
+ ### Example
86
100
 
87
101
  ```sh
88
- set SSL_CERT_FILE = C:\cacert.pem
102
+ knife google disk create my-test-disk --gce-disk-type pd-ssd --gce-disk-size 50
89
103
  ```
90
104
 
91
- On Linux system the configuration for SSL certificate validation is present by default.
105
+ ## knife google disk delete DISKNAME [DISKNAME]
92
106
 
93
- Depending on your system's configuration, you may need to run this command
94
- with root/Administrator privileges.
107
+ Deletes one or more disks from GCE.
95
108
 
96
- ## Configuration
109
+ ### Parameters
110
+
111
+ * **DISKNAME**: required. The name of the disk to delete. You can specify more than one disk to delete at a time.
97
112
 
98
- ### Setting up the plugin
99
-
100
- For initial setup, you must first have created your Google Cloud Platform
101
- project, enabled Google Compute Engine, and set up the Client ID described
102
- above. Run the 'setup' sub-command and supply the Project ID, the Client
103
- ID, Client secret, and authorization tokens when prompted. It will also
104
- prompt you to open a URL in a browser. Make sure sure the you are logged
105
- in with the Google account associated with the project and client
106
- id/secrete in order to authorize the plugin.
107
-
108
- ```sh
109
- knife google setup
110
- ```
111
-
112
- By default, the credential and token information will be stored in
113
- `~/.google-compute.json`. You can override this location with
114
- `-f <credential_file>` flag with all plugin commands.
115
-
116
- ### Bootstrap Preparation and SSH
117
-
118
- In order to bootstrap nodes, you will first need to ensure your SSH
119
- keys are set up correctly. In Google Compute Engine, you can store
120
- SSH keys in project metadata that will get copied over to new servers
121
- and placed in the appropriate user's `~/.ssh/authorized_keys` file.
122
-
123
- If you don't already have SSH keys set up, you can create them with
124
- the `ssh-keygen` program. Open up the Metadata page from the
125
- GCE section of the cloud console. If it doesn't already exist, create
126
- a new `sshKeys` key and paste in your user's `~/.ssh/id_rsa.pub`
127
- file; make sure to prefix the entry with the username that corresponds
128
- to the username specified with the `-x` (aka `--ssh-user`) argument of the knife
129
- command or its default value of `root`. An example entry should look
130
- something like this -- notice the prepended username of `myuser`:
131
-
132
- ```
133
- myuser:ssh-rsa AYAAB3Nwejwejjfjawlwl990sefjsfC5lPulcP4eZB+z1zcMF
134
- 76gTV4vojT/SWXymTfGpBL2KHTmF4jnGfEKPwjHIiLrZNHM2ISMi/atlKjOoUCVT
135
- AvUyjqqp3z2KVXSP9P50Kgf8JYWjjXKApiZHkJOHJZ8GGf7aTnRU9NEGLbQK6Q1k
136
- 4UHbVG4ps4kSLWsJ7eVcu981GvlwP3ooiJ6YWcOX9PS58d4SNtq41/XaoLibKt/Y
137
- Wzd/4tjYwMRVcxJdAy1T2474vkU/Qr7ibFinKeJymgouoQpEGhF64cF2pncCcmR7
138
- zRk7CzL3mhcma8Zvwj234-2f3/+234/AR#@R#y1EEFsbzGbxOJfEVSTgJfvY7KYp
139
- 329df/2348sd3ARTx99 mymail@myhost
140
- ```
141
-
142
- ## Usage
143
-
144
- Some usage examples follow:
145
-
146
- ```sh
147
- # See a list of all zones, their statuses and maintenance windows
148
- $ knife google zone list
149
-
150
- # List all servers (including those that may not be managed by Chef)
151
- $ knife google server list -Z us-central1-a
152
-
153
- # Create a server
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
158
-
159
- # Delete a server (along with Chef node and API client via --purge)
160
- $ knife google server delete www1 --purge -Z us-central1-a
161
- ```
162
-
163
- For a full list of commands, run `knife google` without additional arguments:
164
-
165
- ```sh
166
- $ knife google
167
-
168
- ** GOOGLE COMMANDS **
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)
177
- knife google setup
178
- knife google zone list (options)
179
- ```
180
-
181
- More detailed help can be obtained by specifying sub-commands. For
182
- instance,
183
-
184
- ```sh
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
207
- ```
208
-
209
- ## Sub-commands
210
-
211
- ### knife google setup
212
-
213
- Use this command to initially set up authorization (see above for more
214
- details). Note that if you override the default credential file with the
215
- `-f` switch, you'll need to use the `-f` switch for *all* sub-commands.
216
- When prompted, make sure to specify the "Project ID" (and not the name or
217
- number) or you will see 404/not found errors even if the setup command
218
- completes successfully.
219
-
220
- ### knife google zone list
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
-
235
- Use this command to list out the available Google Compute Engine zones.
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:
239
-
240
- ```
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
- ```
247
-
248
- ### knife google region list
249
-
250
- Each region in Google Compute Engine contains any number of zones.
251
- The region describes the geographic location where your resources
252
- are stored. For example, a zone named `us-east1-a` is in region `us-east1`.
253
- A region contains one or more zones.
254
-
255
- Choose a region that makes sense for your scenario. For example, if you
256
- only have customers on the east coast of the US, or if you have specific
257
- needs that require your data to live in the US, it makes sense to store
258
- your resources in a zone with a us-east region.
259
-
260
- Use this command to list out the available Google Compute Engine regions.
261
- You can find the region's current status, cpus, disks-total-gb,
262
- in-use-addresses and static-addresses. Use the `-L` switch to also list
263
- the quota limit for each resource.
264
-
265
- The output for `knife google region list -L` should look similar to:
266
-
267
- ```
268
- Name status deprecation cpus disks-total-gb in-use-addresses static-addresses
269
- europe-west1 up - 1/10 100/100000 1/10 1/7
270
- us-central1 up - 0/10 0/100000 0/10 0/7
271
- us-central2 up - 1/10 50/100000 1/10 1/7
272
- ```
273
-
274
- ### knife google project list
275
-
276
- A project resource is the root collection and settings resource for
277
- all Google Compute Engine resources.
278
-
279
- Use this command to list out your project's current usage of snapshots,
280
- networks, firewalls, images, routes, forwarding-rules, target-pools and
281
- health-checks. Use the `-L` switch to also list the quota limit for
282
- each resource.
283
-
284
- The output for `knife google project list -L` should look similar to:
285
-
286
- ```
287
- name status deprecation cpus disks-total-gb in-use-addresses static-addresses
288
- europe-west1 up - 0 0 0 0
289
- us-central1 up - 100 1000 10 1
290
- us-central2 up - 0 0 0 0
291
- ```
292
-
293
- ### knife google server create
294
-
295
- Use this command to create a new Google Compute Engine server (a.k.a.
296
- instance) with a persistent boot disk. You must specify a name, the
297
- machine type, the zone, and the the image name. Images provided by
298
- Google follow this naming convention:
299
-
300
- ```
301
- debian-7-wheezy-vYYYYMMDD
302
- centos-6-vYYYYMMDD
303
- ```
304
-
305
- By default, the plugin will look for the specified image in the instance's
306
- primary project first and then consult GCE's officially supported image
307
- locations. The `--gce-image-project-id IMAGE_PROJECT_ID` option can be
308
- specified to force the plugin to look for the image in an alternate project
309
- location.
113
+ ### Example
310
114
 
311
- Note that if you are bootstrapping the node, make sure to follow the
312
- preparation instructions earlier and use the `-x` and `-i` commands
313
- to specify the username and the identity file for that user. Make sure
314
- to use the private key file (e.g. `~/.ssh/id_rsa`) for the identity
315
- file and *not* the public key file.
115
+ ```sh
116
+ knife google disk delete my-test-disk1 my-test-disk2
117
+ ```
316
118
 
317
- If you would like to set up your server with a service account, provide
318
- the --gce-service-account-scopes argument during server creation. The service
319
- account associated with your project will be used by default unless otherwise
320
- specified with the optional --gce-service-account-name argument.
119
+ ## knife google disk list
321
120
 
322
- See the extended options that also allow bootstrapping the node with
323
- `knife google server create --help`.
121
+ List all disks in the currently-configured GCE project and zone.
324
122
 
325
- ### knife google server delete
123
+ ### Parameters
326
124
 
327
- This command terminates and deletes a server. Use the `--purge`
328
- option to also remove it from Chef.
125
+ None.
329
126
 
330
- Note that persistent disks associated with the server, including the
331
- boot disk, are not deleted with this operation. To delete persistent
332
- disks use `knife google disk delete`.
127
+ ## knife google project quotas
333
128
 
334
- Use `knife google server delete --help` for other options.
129
+ Display all project resources and quotas for the currently-configured project, such as the number of snapshots allowed and currently consumed.
335
130
 
336
- ### knife google server list
131
+ ### Parameters
337
132
 
338
- Get a list of servers in the specified zone. Note that this may
339
- include servers that are *not* managed by Chef. Your output should
340
- look something like:
133
+ None.
341
134
 
342
- ```
343
- name type public ip private ip disks zone status
344
- chef-server n1-standard-1 103.59.80.113 10.240.45.78 chef-server us-central1-a running
345
- chef-workstation n1-standard-1 103.59.85.188 10.240.9.140 chef-workstation us-central1-a running
346
- fuse-dev n1-standard-1 103.59.80.147 10.240.166.18 fuse-dev us-central1-a running
347
- magfs-c1 n1-standard-2 103.59.87.217 10.240.61.92 magfs-c1 us-central1-a running
348
- magfs-c2 n1-standard-2 103.59.80.161 10.240.175.240 magfs-c2 us-central1-a running
349
- magfs-c3 n1-standard-2 178.255.120.69 10.240.34.197 magfs-c3 us-central1-a running
350
- magfs-svr n1-standard-4 103.59.80.178 10.240.81.25 magfs-svr us-central1-a running
351
- ```
135
+ ## knife google region list
352
136
 
353
- ### knife google disk create
137
+ Display all regions available to the currently-configured project, what each region's status is, and what zones exist in each region.
354
138
 
355
- Create a new persistent disk. You must provide a name, size in
356
- gigabytes, and the desired zone.
139
+ ### Parameters
357
140
 
358
- ### knife google disk delete
141
+ None.
359
142
 
360
- Delete an existing disk in the specified zone. Note that the
361
- disk will *not* be deleted if it is currently attached to a
362
- running server.
143
+ ## knife google region quotas
363
144
 
364
- ### knife google disk list
145
+ Display all resources and quotas for all regions in the currently-configured project, such as how many instances are allowed and currently configured in a given region.
365
146
 
366
- See a listing of disks defined for a specific zone. Your output should
367
- look something like:
147
+ ### Parameters
368
148
 
369
- ```
370
- name zone source snapshot size (in GB) status
371
- dev-1 us-central1-a 10 ready
372
- dev-2 us-central1-a 10 ready
373
- test-1 us-central1-a 20 ready
374
- ```
149
+ None.
375
150
 
376
- ## Troubleshooting
151
+ ## knife google server create INSTANCE_NAME
377
152
 
378
- * Seeing 404 errors or zone not found?
379
- This can result if you mistakenly specified an invalid "Project ID"
380
- while going through the `knife google setup` command. Make sure
381
- you specified the "Project ID" (not the project name or number).
153
+ Create a GCE server instance and bootstrap it with Chef.
382
154
 
383
- ## Build and Development
155
+ ### Parameters
384
156
 
385
- Standard rake commands for building, installing, testing, and uninstalling the module.
157
+ * **INSTANCE_NAME**: required. The name to use when creating the instance.
158
+ * **--gce-machine-type**: required. The machine type to use when creating the server, such as `n1-standard-2` or `n1-highcpu-2-d`.
159
+ * **--gce-network**: The name of the network to which your instance will be attached. Defaults to "default".
160
+ * **--gce-image**: required. The name of the disk image to use when creating the server. knife-google will search your current project for this disk image. If the image cannot be found but looks like a common public image, the public image project will be searched as well.
161
+ * Example: if you supply a gce-image of `centos-7-v20160219`, knife-google will first look for an image with that name in your currently-configured project. If it cannot be found, it will look in the `centos-cloud` project.
162
+ * This behavior can be overridden with the `--gce-image-project` parameter.
163
+ * **--gce-image-project**: optional. The name of the GCP project that contains the image specified with the `--gce-image` flag. If this is specified, knife-google will not search any known public projects for your image.
164
+ * **--gce-boot-disk-name**: The name to use when creating the instance's boot disk. Defaults to the instance name.
165
+ * **--gce-boot-disk-size**: The size of the boot disk to create, in GB. Defaults to 10.
166
+ * **--[no-]gce-boot-disk-ssd**: If true, the boot disk will be created as a `pd-ssd` disk type. By default, this is false, and the boot disk will be created as a `pd-standard` disk type.
167
+ * **--[no-]gce-boot-disk-autodelete**: If true, the boot disk will be automatically deleted whenever the instance is deleted. Defaults to true.
168
+ * **--additional_disks**: A comma-separated list of disk names to attach to the instance when creating it. The disks must already exist.
169
+ * **--[no-]gce-auto-server-restart**: If true, the instance will be automatically restarted if it was terminated for non-user-initiated actions, such as host maintenance. Defaults to true.
170
+ * **--[no-]gce-auto-server-migrate**: If true, the instance will be automatically migrated to another host if maintenance would require the instance to be terminated. Defaulst to true.
171
+ * **--[no-]gce-can-ip-forward**: If true, the instance will be allowed to perform network forwarding. Defaults to false.
172
+ * **--gce-tags**: A comma-separated list of tag values to add to the instance.
173
+ * **--gce-metadata**: A comma-separated list of key=value pairs to be added to the instance metadata. Example: `--gce-metadata mykey=myvalue,yourkey=yourvalue`
174
+ * **--gce-service-account-scopes**: A comma-separated list of account scopes for this instance. View a list of scoped by running `gcloud compute instances create --help` and searching for the documentation for the `--scopes` parameter. You must supply the full URI (i.e. "https://www.googleapis.com/auth/devstorage.full_control") or the final part of the URI (i.e. "devstorage.full_control"). Alias names (i.e. "storage-rw") are not permitted.
175
+ * **--gce-service-account-name**: the service account name to use when adding service account scopes. This usually looks like an email address and can be created in the Permissions tab of the Google Cloud Console. Defaults to "default"
176
+ * **--gce-use-private-ip**: If true, Chef will attempt to bootstrap the device using the private IP rather than the public IP. Defaulst to false.
177
+ * **--gce-public-ip**: The type of public IP to associate with this instance. If "ephemeral", an ephemeral IP will be assigned. If "none", no public IP will be assigned. If a specific IP address is provided, knife-google will attempt to attach that specific IP address to the instance. Default is "ephemeral".
178
+ * **--gce-email**: required when creating and bootstrapping Microsoft Windows instances. The email address of the currently-logged-in Google Cloud user. This is required when resetting the Windows instance's password.
386
179
 
387
- ```
388
- # Run spec tests
389
- $ rake
180
+ Additionally, all the normal `knife bootstrap` flags are supported. See the output of `knife bootstrap --help` and `knife google server create --help` for additional information.
390
181
 
391
- # Build and install the module
392
- $ rake install
393
-
394
- # Uninstall
395
- $ rake uninstall
396
- ```
182
+ ### Example
397
183
 
398
- ## Versioning and Release Protocol
184
+ ```sh
185
+ knife google server create test-instance-1 --gce-image centos-7-v20160219 --gce-machine-type n1-standard-2 --gce-public-ip ephemeral --ssh-user myuser --identity-file /Users/myuser/.ssh/google_compute_engine
186
+ ```
187
+
188
+ ## knife google server delete INSTANCE_NAME [INSTANCE_NAME]
189
+
190
+ Deletes one or more GCE server instance. Additionally, if requested, the client and node object for the given instance will be deleted off of the Chef Server as well.
191
+
192
+ ### Parameters
193
+
194
+ * **INSTANCE_NAME**: required. The name of the GCE instance to delete. You may provide more than one instance to delete.
195
+ * **--purge**: optional. If provided, the instances' client and node objects will be deleted off the Chef Server. Default is NOT to delete the objects.
196
+
197
+ ### Example
198
+
199
+ ```sh
200
+ knife google server delete my-instance-1 my-instance-2 --purge
201
+ ```
202
+
203
+ ## knife google server list
204
+
205
+ Display the instances in the currently-configured project and zone, their statuses, machine types, IP addresses, and network.
206
+
207
+ ### Parameters
208
+
209
+ None.
210
+
211
+ ## knife google server show INSTANCE_NAME
212
+
213
+ Display information about a single GCE instance, including its status, machine type, IP addresses, and network. Only one server may be displayed at a time.
214
+
215
+ ### Parameters
216
+
217
+ * **INSTANCE_NAME**: required. The name of the instance to show.
218
+
219
+ ## knife google zone list
220
+
221
+ List all available zones in the currently-configured project and what each zone's status is.
222
+
223
+ ### Parameters
224
+
225
+ None.
226
+
227
+ ## Bootstrapping Windows Nodes
228
+
229
+ WinRM is used by Chef to bootstrap Windows nodes. The default settings of the GCE Windows images and GCP projects are not conducive to successful bootstrapping. Therefore, you will likely need to make some changes to your project settings and create your own image based on your company's policies. Some settings you will likely have to change include:
230
+
231
+ * inbound firewall rule in the GCP console to allow inbound WinRM (such as port 5985/tcp)
232
+ * inbound firewall rule in Windows Firewall to allow the inbound WinRM connections
233
+ * enable the appropriate WinRM transports
234
+
235
+ # License and Authors
236
+
237
+ Version 3.0.0 of knife-google was rewritten by Chef Partner Engineering but is largely inspired by initial versions of knife-google, thanks to the work of the great folks at Google.
238
+
239
+ Author:: Chef Partner Engineering (<partnereng@chef.io>)
240
+
241
+ Copyright:: Copyright (c) 2016 Chef Software, Inc.
242
+
243
+ License:: Apache License, Version 2.0
244
+
245
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
246
+ this file except in compliance with the License. You may obtain a copy of the License at
247
+
248
+ ```
249
+ http://www.apache.org/licenses/LICENSE-2.0
250
+ ```
399
251
 
400
- Knife-google is released by the maintainer of this source repository to the gem
401
- repository at [RubyGems](https://rubygems.org). Releases are versioned
402
- according to [SemVer](http://semver.org) as much as possible, with a specific
403
- provision for GCE API changes:
252
+ Unless required by applicable law or agreed to in writing, software distributed under the
253
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
254
+ either express or implied. See the License for the specific language governing permissions
255
+ and limitations under the License.
404
256
 
405
- * When the implementation of knife-google switches to a new GCE API revision,
406
- the minor version **MUST** be incremented.
257
+ # Contributing
407
258
 
408
- The version number of the release is simply the gem version. All releases to RubyGems **MUST** be tagged in git with the version number of the release.
259
+ We'd love to hear from you if you find this isn't working for you. Please submit a GitHub issue with any problems you encounter.
409
260
 
410
- ## Contributing
411
- * See [CONTRIB.md](https://github.com/opscode/knife-google/blob/master/CONTRIB.md)
261
+ Additionally, contributions are welcome! If you'd like to send up any fixes or changes:
412
262
 
413
- ## Licensing
414
- * See [LICENSE](https://raw.github.com/opscode/knife-google/master/LICENSE)
263
+ 1. Fork it ( https://github.com/chef/knife-google/fork )
264
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
265
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
266
+ 4. Push to the branch (`git push origin my-new-feature`)
267
+ 5. Create a new Pull Request