knife-clc 0.0.1 → 0.0.2.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +62 -40
  3. data/lib/chef/knife/clc_ip_create.rb +1 -0
  4. data/lib/chef/knife/clc_server_create.rb +25 -528
  5. data/lib/clc/client.rb +1 -1
  6. data/lib/knife-clc/async/config_options.rb +18 -0
  7. data/lib/knife-clc/async.rb +11 -0
  8. data/lib/knife-clc/base/config_options.rb +26 -0
  9. data/lib/knife-clc/base.rb +56 -0
  10. data/lib/knife-clc/bootstrap/bootstrapper.rb +92 -0
  11. data/lib/knife-clc/bootstrap/config_options.rb +66 -0
  12. data/lib/knife-clc/bootstrap/connectivity_helper.rb +39 -0
  13. data/lib/knife-clc/bootstrap/methods/async_linux_package.rb +41 -0
  14. data/lib/knife-clc/bootstrap/methods/async_windows_package.rb +69 -0
  15. data/lib/knife-clc/bootstrap/methods/sync_linux_ssh.rb +67 -0
  16. data/lib/knife-clc/bootstrap/methods/sync_windows_winrm.rb +61 -0
  17. data/lib/knife-clc/bootstrap/subcommand_loader.rb +18 -0
  18. data/lib/knife-clc/bootstrap/validator.rb +149 -0
  19. data/lib/knife-clc/bootstrap.rb +20 -0
  20. data/lib/knife-clc/cloud_extensions/cloud_adapter.rb +35 -0
  21. data/lib/knife-clc/cloud_extensions.rb +11 -0
  22. data/lib/knife-clc/ip_assignment/config_options.rb +29 -0
  23. data/lib/knife-clc/ip_assignment/ip_assigner.rb +41 -0
  24. data/lib/knife-clc/ip_assignment/mapper.rb +20 -0
  25. data/lib/knife-clc/ip_assignment/validator.rb +74 -0
  26. data/lib/knife-clc/ip_assignment.rb +20 -0
  27. data/lib/knife-clc/server_launch/config_options.rb +145 -0
  28. data/lib/knife-clc/server_launch/mapper.rb +40 -0
  29. data/lib/knife-clc/server_launch/server_launcher.rb +40 -0
  30. data/lib/knife-clc/server_launch/validator.rb +100 -0
  31. data/lib/knife-clc/server_launch.rb +21 -0
  32. data/lib/knife-clc/version.rb +1 -1
  33. metadata +44 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a85ae0911463b0f9cfb9f35282d3e945cdb42dd
4
- data.tar.gz: 8131e5aad080f31b8d4aa41dafe5cd8835084cf8
3
+ metadata.gz: 000fe34de838800cf1f4759fcd93da92641e0ab4
4
+ data.tar.gz: bb2fc50621cc92e9363f297e30ad32e5e88888df
5
5
  SHA512:
6
- metadata.gz: a9d3b1e710f91c34273f35ea183a4614d5be89194e999b6368c2694967e93735d3cb52c6e292adac6a12ef217019b7a7814eef7aa316bbddd0fe1f1c53605e84
7
- data.tar.gz: d87fcd6ec5ad94b9bdd1aa43ee018afdfc7a91f15610d04c01e55143f44725c80fa93189a3985ac549bd2dd1605e9464a1a364f611f55ac3aa4c834951570dc8
6
+ metadata.gz: 3867db4a72e1953f12a618404aef6822ac01bce7e9dfc5ab16776a7beb4dd9bbb38f09fdbde2289a446a19ea2e44443327a6852b5916e4737da40b1b4f8ac3b9
7
+ data.tar.gz: 3f79fc3d2083a100acb455dbd76ac34af4bf49ae3fbdf422d081307f560d1a5328cce516538ea1acfcbc8d04e2ac3121e491fe04413d960d966d79b3360a4c9f
data/README.md CHANGED
@@ -3,10 +3,10 @@
3
3
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
4
4
 
5
5
  # Knife CLC
6
-
7
- This is the Chef Knife plugin for CenturyLink Cloud. It gives Knife the ability to manage servers and query for additional resources like datacenters, templates and groups.
6
+ This is the Chef Knife plugin for CenturyLink Cloud. It gives Knife the ability to manage servers and query for additional resources like data centers, templates and groups.
8
7
 
9
8
  ## Installation
9
+ There are three ways to install the Chef Knife plugin on your CenturyLink Cloud platform.
10
10
 
11
11
  If you're using [ChefDK](https://downloads.chef.io/chef-dk/), simply install the Gem:
12
12
 
@@ -14,58 +14,62 @@ If you're using [ChefDK](https://downloads.chef.io/chef-dk/), simply install the
14
14
  $ chef gem install knife-clc
15
15
  ```
16
16
 
17
- If you're using Bundler, add this line to your application's Gemfile:
17
+ If you're using Bundler:
18
+
19
+ Add this line to your application's Gemfile:
18
20
 
19
21
  ```ruby
20
22
  gem 'knife-clc'
21
23
  ```
22
24
 
23
- And then execute:
25
+ And then, execute:
24
26
 
25
27
  ```bash
26
28
  $ bundle
27
29
  ```
28
30
 
29
- Or install it yourself as:
31
+ If you're installing it yourself:
30
32
 
31
33
  ```
32
34
  $ gem install knife-clc
33
35
  ```
34
36
 
35
37
  ## Configuration
36
- In order to use CLC API, user must supply API username & password. This can be done in several ways:
38
+ In order to use the CLC API (which Chef Knife uses for configuration) a user must supply an API username & password. This can be done in several ways.
37
39
 
38
40
  ### knife.rb
39
- Credentials can be specified in [knife.rb](https://docs.chef.io/config_rb_knife.html) file:
41
+ Credentials can be specified in the [knife.rb](https://docs.chef.io/config_rb_knife.html) file:
40
42
 
41
43
  ```ruby
42
44
  knife[:clc_username] = "CLC API Username"
43
45
  knife[:clc_password] = "CLC API Password"
44
46
  ```
45
47
 
46
- Note: If your `knife.rb` file will be checked into a source control management system, or will be otherwise accessible by others, you may want to use one of the other configuration methods to avoid exposing your credentials.
48
+ **Note:** If your `knife.rb` file will be checked into a source control management system, or will be otherwise accessible by others, you may want to use one of the other configuration methods to avoid exposing your credentials.
47
49
 
48
50
  ### ENV & knife.rb
49
- It is also possible to specify credentials as environment variables. Here's an example:
51
+ It is also possible to specify credentials as environment (ENV) variables. Here's an example:
50
52
 
51
53
  ```ruby
52
54
  knife[:clc_username] = ENV['CLC_USERNAME']
53
55
  knife[:clc_password] = ENV['CLC_PASSWORD']
54
56
  ```
55
57
 
56
- Note that since most CLC tools use the same set of ENV variables, plugin would read `CLC_USERNAME` and `CLC_PASSWORD` variables automatically if no other options were specified in `knife.rb`.
58
+ **Note:** Since most CLC tools use the same set of ENV variables, the plugin would read the `CLC_USERNAME` and `CLC_PASSWORD` variables automatically if no other options were specified in `knife.rb`.
57
59
 
58
60
  ### CLI Arguments
59
- If you prefer to specify credentials on per-command basis, you can do it with CLI arguments:
61
+ If you prefer to specify credentials on a per-command basis, you can do it with CLI arguments:
60
62
 
61
63
  ```bash
62
64
  $ knife clc datacenter list \
63
- --username 'api_username' \
65
+ --username 'api_username' \
64
66
  --password 'api_password'
65
67
  ```
66
68
 
67
69
  ## Advanced Configuration
68
- In order to speed up your workflow, you can specify some defaults for every command option in `knife.rb`. Since `knife.rb` is basically a Ruby file, we use `snake_case` notation there. Also, we prefix CLC options with `clc_`. It means that `--source-server` turns into `clc_source_server`:
70
+ In order to speed up your workflow, you can specify some defaults for every command option in `knife.rb`.
71
+
72
+ **Note:** Since `knife.rb` is basically a Ruby file, we use `snake_case` notation. Also, we prefix CLC options with `clc_`. For example, `--source-server` turns into `clc_source_server`.
69
73
 
70
74
  ```ruby
71
75
  knife[:clc_name] = 'QAEnv'
@@ -75,11 +79,11 @@ knife[:clc_source_server] = 'DEBIAN-7-64-TEMPLATE'
75
79
  knife[:clc_cpu] = 2
76
80
  knife[:clc_memory] = 2
77
81
  ```
78
- Options like `--disk`, `--custom-field`, `--package` can be specified several times. In configuration file they will look like an Array with plural config option name:
82
+ Options like `--disk`, `--custom-field`, `--package` can be specified several times. In the configuration file they will look like an Array with a plural config option name. For example:
79
83
 
80
84
  ```ruby
81
85
  knife[:clc_custom_fields] = [
82
- 'KEY=VALUE',
86
+ 'KEY=VALUE',
83
87
  'ANOTHER=VALUE'
84
88
  ]
85
89
 
@@ -89,7 +93,9 @@ knife[:clc_disks] = [
89
93
  ```
90
94
 
91
95
  ## Supported Commands
92
- This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a `--help` flag:
96
+ This plugin provides the following Knife subcommands.
97
+
98
+ Specific command options can be found by invoking the subcommand with a `--help` flag.
93
99
 
94
100
  * [knife clc datacenter list (options)](#knife-clc-datacenter-list)
95
101
  * [knife clc group create (options)](#knife-clc-group-create)
@@ -106,21 +112,21 @@ This plugin provides the following Knife subcommands. Specific command options c
106
112
  * [knife clc server show ID (options)](#knife-clc-server-show)
107
113
  * [knife clc template list (options)](#knife-clc-template-list)
108
114
 
109
- Note that some commands provide an access to long-running cloud operations. These commands are **asynchronous** by default (they don't wait for completion and return some output immediately). All of them support `--wait` option which makes command to wait until operation is completed or failed.
115
+ **Note:** Some commands provide access to long-running cloud operations. These commands are **asynchronous**(async) by default (they don't wait for the operation to complete before continuing their work and they don't return an output immediately). All of them support the `--wait` option, which makes the command pause until the operation either completes or fails.
110
116
 
111
- Several types of resources are **scoped by datacenter** they reside in. Commands querying for these resources support `--datacenter ID` option. Some of them support `--all` option to return all resources from all datacenters (which is much slower).
117
+ Several types of resources are scoped by the datacenter they reside in. Commands querying for these resources support the `--datacenter ID` option, which returns resources for a specific data center. Some of the commands support the `--all` option, which returns all resources from all data centers (this command is much slower).
112
118
 
113
- Also, resources like ip addresses are **scoped by server** they belong to. Related commands require `--server ID` option.
119
+ Also, resources like IP addresses are scoped by the server they belong to. The related commands require the `--server ID` option.
114
120
 
115
121
  ### `knife clc datacenter list`
116
- Outputs list of all available CLC datacenters.
122
+ Outputs a list of all available CLC data centers.
117
123
 
118
124
  ```bash
119
125
  $ knife clc datacenter list
120
126
  ```
121
127
 
122
128
  ### `knife clc group create`
123
- Creates a child group for specified parent. Unlike other modification operations, that command is synchronous and does not support `--wait` flag.
129
+ Creates a child group for a specified parent. Unlike other modification operations, this command is synchronous and does not support the `--wait` flag.
124
130
 
125
131
  ```bash
126
132
  $ knife clc group create --name 'Custom Group' \
@@ -129,14 +135,14 @@ $ knife clc group create --name 'Custom Group' \
129
135
  ```
130
136
 
131
137
  ### `knife clc group list`
132
- **Scoped by datacenter**. Outputs list of datacenter groups. By default, reflects logical group structure as a tree. Supports `--view` option with values `table` and `tree`.
138
+ **Scoped by datacenter**. Outputs a list of datacenter groups. By default, it reflects a logical group structure as a tree. Supports the `--view` option with the values `table` and `tree`.
133
139
 
134
140
  ```
135
141
  $ knife clc group list --datacenter ca1 --view table
136
142
  ```
137
143
 
138
144
  ### `knife clc ip create`
139
- **Asynchronous**. **Scoped by server**. Assigns a public IP to specified server. Applies passes protocol and source restrictions. While CLC API supports TCP, UDP and ICMP permissions only, this command provides several useful aliases to most ofthen used protocols: `ssh`, `sftp`, `ftp`, `http`, `https`, `ftp`, `ftps`. Same options can be provided during server creation.
145
+ **Asynchronous**. **Scoped by server**. Assigns a public IP to a specified server. Applies the passes protocol and source restrictions. While the CLC API supports TCP, UDP and ICMP permissions only, this command provides several useful aliases to the most frequently used protocols: `ssh`, `sftp`, `ftp`, `http`, `https`, `ftp`, and `ftps`. These same options can be provided during server creation.
140
146
 
141
147
  ```bash
142
148
  $ knife clc ip create --server ca1altdqasrv01 \
@@ -152,21 +158,21 @@ $ knife clc ip create --server ca1altdqasrv01 \
152
158
  ```
153
159
 
154
160
  ### `knife clc ip delete`
155
- **Asynchronous**. **Scoped by server**. Deletes previously assigned public IP of the server.
161
+ **Asynchronous**. **Scoped by server**. Deletes a previously assigned public IP of a server.
156
162
 
157
163
  ```bash
158
164
  $ knife clc ip delete 65.39.184.23 --server ca1altdqasrv01 --wait
159
165
  ```
160
166
 
161
167
  ### `knife clc operation show`
162
- **Asynchronous**. Outputs current operation status. User can use `--wait` flag to wait for operation completion. Operation IDs are usually printed by other asynchronous commands when they are executed without `--wait` option.
168
+ **Asynchronous**. Outputs the current operation status. User can use the `--wait` flag to wait for operation completion. Operation IDs are usually printed by other async commands when they are executed without the `--wait` option.
163
169
 
164
170
  ```bash
165
171
  $ knife clc operation show ca1-43089 --wait
166
172
  ```
167
173
 
168
174
  ### `knife clc server create`
169
- **Asynchronous**. Launches a server using specified parameters. It is recommended to allow SSH/RDP access to the server if user plans to use it from external network later.
175
+ **Asynchronous**. Launches a server using specified parameters. It is recommended to allow SSH/RDP access to the server if the user plans to use it from an external network later.
170
176
 
171
177
  ```bash
172
178
  $ knife clc server create --name 'QASrv' \
@@ -180,9 +186,12 @@ $ knife clc server create --name 'QASrv' \
180
186
  --wait
181
187
  ```
182
188
 
183
- Command supports `--bootstrap` flag which allows to connect launched machine to your Chef Server installation. Only **Linux** platform is supported.
189
+ #### Bootstrap flag
190
+ This command supports the `--bootstrap` flag, which allows the launched machine to connect to your Chef Server installation. Only the **Linux** platform is supported.
184
191
 
185
- Async bootstrap variant does not require public IP access to the machine. Chef Server credentials and other parameters will be sent to the server. They will be used by Chef Client installation script during launch. Note that bootstrapping errors cancel launch operation.
192
+ The async bootstrap variant does not require public IP access to the machine. Chef Server credentials and other parameters will be sent to the server. They will be used by the Chef Client installation script during launch.
193
+
194
+ **Note:** Bootstrapping errors will cancel a launch operation.
186
195
 
187
196
  ```bash
188
197
  $ knife clc server create --name 'QASrv' \
@@ -196,7 +205,11 @@ $ knife clc server create --name 'QASrv' \
196
205
  --tags one,two,three
197
206
  ```
198
207
 
199
- Sync bootstrap is very similar to bootstrap from other Knife plugins. It requires SSH connection to the server. Note that plugin will refuse to launch a server unless public IP with SSH access is requested. Example for custom SSH port:
208
+ The synchronous(sync) bootstrap variant is very similar to the bootstrap used in other Knife plugins. It requires an SSH connection to the server.
209
+
210
+ **Note:** The plugin will refuse to launch a server unless a public IP with SSH access is requested.
211
+
212
+ Example for custom SSH port:
200
213
 
201
214
  ```bash
202
215
  $ knife clc server create --name 'QASrv' \
@@ -214,7 +227,7 @@ $ knife clc server create --name 'QASrv' \
214
227
  --wait
215
228
  ```
216
229
 
217
- It is also possible to bootstrap a machine without public IP. If there's a machine with opened SSH access and it belongs to the same network, it can be used as a SSH gateway via `--ssh-gateway` option. Another way is to run Knife plugin inside of the network with `--bootstrap-private` flag to skip public IP checks.
230
+ It is also possible to bootstrap a machine without using a public IP address. A machine with open SSH access that belongs to the same network can be used as an SSH gateway via the `--ssh-gateway` option. Users can also run the Knife plugin inside of the network with the `--bootstrap-private` flag to bypass public IP checks.
218
231
 
219
232
  ```bash
220
233
  $ knife clc server create --name 'QASrv' \
@@ -232,60 +245,69 @@ $ knife clc server create --name 'QASrv' \
232
245
  ```
233
246
 
234
247
  ### `knife clc server delete`
235
- **Asynchronous**. Deletes an existing server by its ID. Note that Chef Server objects (if there are any) are left intact.
248
+ **Asynchronous**. Deletes an existing server by its ID. Note that all Chef Server objects (if there are any) are left intact after the deletion.
236
249
 
237
250
  ```bash
238
251
  $ knife clc server delete ca1altdqasrv01 --wait
239
252
  ```
240
253
 
241
254
  ### `knife clc server list`
242
- **Scoped by datacenter**. Outputs a list of all servers in specified datacenter. Can be used with `--chef-nodes` option to add `Chef Node` column. Servers managed by Chef Server will have their node names there. Note that Chef API credentials are required for this to work. Supports `--all` option.
255
+ **Scoped by datacenter**. Outputs a list of all servers in a specified datacenter. This also supports `--all` option (which returns a list of servers in all datacenters).
256
+
257
+ Can be used with the `--chef-nodes` option to add a `Chef Node` column. The node names of servers managed by Chef Server will appear in the `Chef Node` column.
258
+
259
+ **Note:** Chef API credentials are required for this operation to work.
243
260
 
244
261
  ```bash
245
262
  $ knife clc server list --datacenter ca1 --chef-nodes
246
263
  ```
247
264
 
248
265
  ### `knife clc server power_off`
249
- **Asynchronous**. Turns server power off. Note that all SSH/RDP sessions will be forcibly closed.
266
+ **Asynchronous**. Turns the server power off.
267
+
268
+ **Note:** All SSH/RDP sessions will be forcibly closed when this command runs.
250
269
 
251
270
  ```bash
252
271
  $ knife clc server power_off ca1altdqasrv01 --wait
253
272
  ```
254
273
 
255
274
  ### `knife clc server power_on`
256
- **Asynchronous**. Turns server power on. The server will be available for connections after operation is completed.
275
+ **Asynchronous**. Turns the server power on. The server will be available for connections after this operation is complete.
257
276
 
258
277
  ```bash
259
278
  $ knife clc server power_off ca1altdqasrv01 --wait
260
279
  ```
261
280
 
262
281
  ### `knife clc server reboot`
263
- **Asynchronous**. Performs OS-level reboot on the server. All applications will be requested to finish current tasks and close.
282
+ **Asynchronous**. Performs an OS-level reboot on the server.
283
+
284
+ **Note:** All applications that are running will finish the current task and then close.
264
285
 
265
286
  ```bash
266
287
  $ knife clc server reboot ca1altdqasrv01 --wait
267
288
  ```
268
289
 
269
290
  ### `knife clc server show`
270
- Outputs details for specified server ID. Supports `--uuid` flag to interpret primary argument as UUID. By default, does not show server credentials and opened ports. User may request more information with `--creds` and `--ports` options. Requesting additional information slows command down.
291
+ Outputs details for a specified server ID. This command supports the `--uuid` flag, which interprets the primary argument as a UUID (instead of a server ID). By default, the output does not show server credentials or opened ports. Users may request more information with the `--creds` and `--ports` options.
292
+
293
+ **Note:** Requesting additional information will slow this command down.
271
294
 
272
295
  ```bash
273
296
  $ knife clc server show 406282c5116443029576a2b9ac56f5cc \
274
- --uuid \
297
+ --uuid \
275
298
  --creds
276
299
 
277
300
  $ knife clc server show ca1altdqasrv01 --ports
278
301
  ```
279
302
 
280
303
  ### `knife clc template list`
281
- **Scoped by datacenter**. Outputs available server templates. Supports `--all` option.
304
+ **Scoped by datacenter**. Outputs available server templates in a specified datacenter. Supports the `--all` option, which returns a list of templates from all datacenters.
282
305
 
283
306
  ```bash
284
307
  $ knife clc template list --datacenter ca1
285
308
  ```
286
309
 
287
310
  ## Contributing
288
-
289
311
  1. Fork it [https://github.com/CenturyLinkCloud/clc-knife/fork](https://github.com/CenturyLinkCloud/clc-knife/fork)
290
312
  2. Create your feature branch `git checkout -b my-new-feature`
291
313
  3. Commit your changes `git commit -am 'Add some feature'`
@@ -294,4 +316,4 @@ $ knife clc template list --datacenter ca1
294
316
  6. Specs and Code Style checks should pass before Code Review.
295
317
 
296
318
  ## License
297
- The project is licensed under the [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
319
+ The project is licensed under the [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
@@ -72,6 +72,7 @@ class Chef
72
72
  when 'https' then { 'protocol' => 'tcp', 'port' => 443 }
73
73
  when 'ftp' then { 'protocol' => 'tcp', 'port' => 21 }
74
74
  when 'ftps' then { 'protocol' => 'tcp', 'port' => 990 }
75
+ when 'winrm' then [{ 'protocol' => 'tcp', 'port' => 5985 }, { 'protocol' => 'tcp', 'port' => 5986 }]
75
76
  when 'udp', 'tcp'
76
77
  unless port_range
77
78
  errors << "No ports specified for #{param}"