knife-cloudstack 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.rdoc +50 -0
- data/README.rdoc +221 -42
- data/lib/chef/knife/cs_account_list.rb +130 -0
- data/lib/chef/knife/cs_base.rb +98 -0
- data/lib/chef/knife/cs_baselist.rb +81 -0
- data/lib/chef/knife/cs_cluster_list.rb +93 -0
- data/lib/chef/knife/cs_config_list.rb +85 -0
- data/lib/chef/knife/cs_disk_list.rb +89 -0
- data/lib/chef/knife/cs_domain_list.rb +83 -0
- data/lib/chef/knife/cs_firewallrule_list.rb +95 -0
- data/lib/chef/knife/cs_host_list.rb +95 -0
- data/lib/chef/knife/cs_hosts.rb +2 -2
- data/lib/chef/knife/cs_iso_list.rb +103 -0
- data/lib/chef/knife/cs_network_list.rb +56 -46
- data/lib/chef/knife/cs_oscategory_list.rb +78 -0
- data/lib/chef/knife/cs_ostype_list.rb +80 -0
- data/lib/chef/knife/cs_pod_list.rb +93 -0
- data/lib/chef/knife/cs_project_list.rb +92 -0
- data/lib/chef/knife/cs_router_list.rb +94 -0
- data/lib/chef/knife/cs_server_create.rb +185 -144
- data/lib/chef/knife/cs_server_delete.rb +62 -79
- data/lib/chef/knife/cs_server_list.rb +136 -57
- data/lib/chef/knife/cs_server_reboot.rb +50 -54
- data/lib/chef/knife/cs_server_start.rb +48 -52
- data/lib/chef/knife/cs_server_stop.rb +54 -55
- data/lib/chef/knife/cs_service_list.rb +62 -41
- data/lib/chef/knife/cs_stack_create.rb +2 -2
- data/lib/chef/knife/cs_stack_delete.rb +2 -2
- data/lib/chef/knife/cs_template_create.rb +121 -0
- data/lib/chef/knife/cs_template_extract.rb +104 -0
- data/lib/chef/knife/cs_template_list.rb +65 -63
- data/lib/chef/knife/cs_template_register.rb +180 -0
- data/lib/chef/knife/cs_user_list.rb +93 -0
- data/lib/chef/knife/cs_volume_list.rb +94 -0
- data/lib/chef/knife/cs_zone_list.rb +55 -36
- data/lib/knife-cloudstack/connection.rb +75 -22
- data/lib/knife-cloudstack/string_to_regexp.rb +32 -0
- metadata +93 -61
data/CHANGES.rdoc
CHANGED
@@ -1,4 +1,54 @@
|
|
1
1
|
= Changes
|
2
|
+
|
3
|
+
== 2013-04-14 (0.0.14)
|
4
|
+
* Added bash/addinstance.sh script in onder to ease instance creation from cli.
|
5
|
+
|
6
|
+
* Added the cs_base.rb to merge all common options.
|
7
|
+
* Added the cs_base_list.rb to merge all common options and functions for the list commands.
|
8
|
+
* Added the option: <tt>-P</tt> / <tt>--cloudstack-project</tt> to the following commands: <tt>account list</tt>, <tt>firewallrule list</tt>, <tt>hosts</tt>,
|
9
|
+
<tt>iso list</tt>, <tt>network list</tt>, <tt>router list</tt>, <tt>server list</tt>, <tt>template list</tt>, <tt>volume list</tt>
|
10
|
+
|
11
|
+
* Added subcommands: <tt>account list</tt>, <tt>cluster list</tt>, <tt>config list</tt>, <tt>disk create</tt>,
|
12
|
+
<tt>disk list</tt>, <tt>domain list</tt>,<tt>firewallrule list</tt>, <tt>host list</tt>,
|
13
|
+
<tt>iso list</tt>, <tt>ostype list</tt>, <tt>oscategory list</tt>, <tt>pod list</tt>, <tt>project list</tt>,
|
14
|
+
<tt>service create</tt>, <tt>template create</tt>, <tt>template extract</tt>, <tt>template register</tt>, <tt>router list</tt>, <tt>user list</tt>, <tt>volume list</tt>
|
15
|
+
|
16
|
+
* Updated subcommands: <tt>hosts</tt>, <tt>network list</tt>, <tt>server list</tt>, <tt>service list</tt>,
|
17
|
+
<tt>template list</tt>, <tt>zone list</tt>
|
18
|
+
|
19
|
+
* Added option: <tt>--filter</tt> to all list commands. This filters your output on the fields that you specify.
|
20
|
+
Filter can be a string <tt>'name'</tt> or regexp <tt>'/name/i'</tt>. Example: <tt>--filter "instancename:/i-xxx/i,accountname:jenkins"</tt>
|
21
|
+
Additional filters can be added by separating them using a comma ','
|
22
|
+
NOTE: --filter is done client side, filtering by --name or --keyword is faster and is done server side.
|
23
|
+
|
24
|
+
* Added option: <tt>--fields</tt> to all list commands. Here you specify the fields that you want to display in your output.
|
25
|
+
Default outputs will be shown if no fields are defined. Example: <tt>--fields "name, instancename, domain"</tt>
|
26
|
+
|
27
|
+
* Added option: <tt>--noheader</tt> to all list commands.
|
28
|
+
This will remove the header from the output.
|
29
|
+
|
30
|
+
* Added option: <tt>--fieldlist</tt> to all list commands. This will display the fields that you can use to filter or
|
31
|
+
use in your output. Example will be given with the first result that you specify in your filter.
|
32
|
+
|
33
|
+
* Added option: <tt>--listall</tt> to: <tt>account list</tt>, <tt>domain list</tt>, <tt>firewallrule list</tt>, <tt>hosts</tt>, <tt>iso list</tt>,
|
34
|
+
<tt>network list</tt>, <tt>project list</tt>, <tt>router list</tt>, <tt>server list</tt>, <tt>template list</tt>, <tt>user list</tt>, <tt>volume list</tt>.
|
35
|
+
|
36
|
+
* Added option: <tt>--keyword</tt> to: <tt>account list</tt>, <tt>cluster list</tt>, <tt>config list</tt>, <tt>disk list</tt>, <tt>firewallrule list</tt>,
|
37
|
+
<tt>hosts</tt>, <tt>iso list</tt>, <tt>network list</tt>, <tt>ostype list</tt>, <tt>oscategory list</tt>, <tt>pod list</tt>, <tt>project list</tt>, <tt>router list</tt>,
|
38
|
+
<tt>server list</tt>, <tt>service list</tt>, <tt>user list</tt>, <tt>volume list</tt>, <tt>zone list</tt>.
|
39
|
+
|
40
|
+
* Added option: <tt>--name</tt> to: <tt>account list</tt>, <tt>cluster list</tt>, <tt>config list</tt>, <tt>disk list</tt>, <tt>host list</tt>, <tt>hosts</tt>, <tt>iso list</tt>,
|
41
|
+
<tt>pod list</tt>, <tt>project list</tt>, <tt>router list</tt>, <tt>server list</tt>, <tt>service list</tt>, <tt>volume list</tt>
|
42
|
+
|
43
|
+
* Added option: <tt>--action</tt> to: <tt>server list</tt> which <tt>start</tt>, <tt>stop</tt> or <tt>destroy</tt> the machines based on the result.
|
44
|
+
* Added option: <tt>--cloudstack-password</tt> to let cloudstack generate the password (only works if your template supports this.)
|
45
|
+
* Added option: <tt>--ipfwd-rules</tt> and <tt>--fw-rules</tt> to: <tt>server create</tt>
|
46
|
+
* Fixed delay-loading.
|
47
|
+
* Fixed <tt>-F json</tt> / <tt>--format json</tt> option for every list command.
|
48
|
+
* Fixed <tt>--no-bootstrap</tt> option to ignore the chef bootstrap
|
49
|
+
* Fixed default bootstrap template to: <tt>chef-full</tt>
|
50
|
+
|
51
|
+
|
2
52
|
== 2012-11-29 (0.0.13)
|
3
53
|
* Windows support
|
4
54
|
https://github.com/CloudStack-extras/knife-cloudstack/issues/31
|
data/README.rdoc
CHANGED
@@ -46,12 +46,27 @@ To get this plugin to work in public clouds, it is essential that the virtual ne
|
|
46
46
|
|
47
47
|
This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a <tt>--help</tt> flag
|
48
48
|
|
49
|
+
=== knife cs <command> list
|
50
|
+
|
51
|
+
<tt>--filter</tt> Filters your output on the fields that you specify. Filter can be a string 'name' or regexp '/name/i'
|
52
|
+
Example: knife cs server list --filter "instancename:/i-xxx/i, account:accname"
|
53
|
+
|
54
|
+
<tt>--fields</tt> The fields that you want to display in your output. Default outputs will be shown if no fields are defined.
|
55
|
+
Example: knife cs server list --fields "name, instancename, domain"
|
56
|
+
|
57
|
+
<tt>--fieldlist</tt> This will display all information returned by the cloudstack API. These fields can be used within the <tt>--fields</tt> or <tt>--filter</tt> to create custom output.
|
58
|
+
The data displayed is based on first result returned in your output. You can get other result by using the <tt>--filter</tt> option.
|
59
|
+
|
60
|
+
<tt>--noheader</tt> this will remove the column header from the output.
|
61
|
+
|
62
|
+
|
49
63
|
=== knife cs server create
|
50
64
|
|
51
65
|
Provisions a new server in CloudStack and then performs a Chef bootstrap (using the SSH protocol). The goal of the bootstrap is to get Chef installed on the target
|
52
66
|
system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists (provided by the provisioning). It is primarily
|
53
|
-
intended for Chef Client systems that talk to a Chef server. By default the server is bootstrapped using the
|
54
|
-
|
67
|
+
intended for Chef Client systems that talk to a Chef server. By default the server is bootstrapped using the 'chef-full' template (default bootstrap option for knife,
|
68
|
+
(Ref. http://docs.opscode.com/knife_bootstrap.html). This can be overridden using the <tt>-d</tt> or <tt>--template-file</tt> command options.
|
69
|
+
VM provided with <tt>--no-bootstrap</tt> option have no forwarded ports or forwared ip rules (in case <tt>--static-nat</tt> is used).
|
55
70
|
|
56
71
|
By default, new servers are allocated a public IP address mapping to the CloudStack private IP address. If you do not want this behavior, pass the <tt>--no-public-ip</tt> option.
|
57
72
|
|
@@ -69,6 +84,24 @@ single number when the public and private ports are the same. For example, a rul
|
|
69
84
|
private port 25 can be stated as simply <tt>25</tt>. A list of such rules for a webserver might look like
|
70
85
|
<tt>80,443</tt>.
|
71
86
|
|
87
|
+
==== IP forwarding rules
|
88
|
+
The <tt>--ipfwd-rules</tt> option takes a comma separated list of ip forwarding rules. These rules are created on public ip appdress assigned obtained with <tt>--static-nat</tt> option.
|
89
|
+
(Ref. http://cloudstack.apache.org/docs/api/apidocs-4.0.0/root_admin/createIpForwardingRule.html)
|
90
|
+
|
91
|
+
Ip forwarding rules have the syntax <tt>START_PORT[:END_PORT[:PROTOCOL]]</tt>. <tt>END_PORT</tt> and <tt>PROTOCOL</tt> are optional.
|
92
|
+
The default value of <tt>END_PORT</tt> is <tt>START_PORT</tt> and the default <tt>PROTOCOL</tt> is 'TCP'.
|
93
|
+
For example, a rule to forward ports range from 1024 to 10000 would look like <tt>1024:10000:TCP</tt>.
|
94
|
+
Since 'TCP' is the default protocol, the rule can be shortened to <tt>1024:10000</tt>. A rule can even be shortened to a
|
95
|
+
single number when the start and end ports are the same. For example, a rule to forward port 22 can be stated as simply <tt>22</tt>. A list of such rules for a webserver might look like <tt>80,443</tt>.
|
96
|
+
|
97
|
+
==== Create Firewall Rule for given ip address
|
98
|
+
The <tt>-f, --fw-rules</tt> option takes a comma separated list of firewall rules which are applied to the public ip address assigned to the current server.
|
99
|
+
|
100
|
+
Firewall rules have the syntax <tt>START_PORT[:END_PORT[:PROTOCOL[:CIDR_LIST]]]</tt>. <tt>END_PORT</tt>, <tt>PROTOCOL</tt> and <tt>CIDR_LIST</tt> are optional.
|
101
|
+
The default value of <tt>END_PORT</tt> is <tt>START_PORT</tt>, the default <tt>PROTOCOL</tt> is 'TCP' and the default <tt>CIDR_LIST</tt> is '0.0.0.0/0'.
|
102
|
+
For example, a rule to open firewall for port 80 to everyone would look like <tt>80:80:TCP:0.0.0.0/0</tt>.
|
103
|
+
In this case ,it could even be shortened to <tt>80</tt>.
|
104
|
+
|
72
105
|
=== knife cs server delete
|
73
106
|
|
74
107
|
Deletes an existing server in the currently configured CloudStack account. <b>PLEASE NOTE</b> - this does not delete
|
@@ -79,16 +112,36 @@ the associated node and client objects from the Chef server.
|
|
79
112
|
Displays a list of all servers in the currently configured CloudStack account. <b>PLEASE NOTE</b> - this shows all
|
80
113
|
servers associated with the cloudstack account including servers that are not registered with a Chef server.
|
81
114
|
|
115
|
+
<tt>--listall</tt> This will list all the servers, depending on the account that you are using.
|
116
|
+
|
117
|
+
<tt>--keyword</tt> Filters your output on the instance name that you specify:
|
118
|
+
Example: --keyword "i-324", This will display all servers with <tt>'i-324'</tt> inside the instancename.
|
119
|
+
|
120
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
121
|
+
Example: --name "webserver", This will display all servers that contains 'webserver' inside the hostname.
|
122
|
+
|
123
|
+
<tt>--action</tt> This action will be executed on the output of the list command. Actions can be start, stop or destroy.
|
124
|
+
|
82
125
|
=== knife cs network list
|
83
126
|
Displays a list of all networks available in the currently configured CloudStack account. A network can be specified
|
84
127
|
when creating a new server by passing the network name as an argument to the -W (or --network) option of the
|
85
128
|
<tt>knife cs server create</tt> command.
|
86
129
|
|
130
|
+
<tt>--listall</tt> This will list all the networks, depending on the account that you are using.
|
131
|
+
|
132
|
+
<tt>--keyword</tt> Filters your output on the keyword that you specify.
|
133
|
+
Example: --keyword "network1", This will display all networks with 'network1' inside the name.
|
134
|
+
|
87
135
|
=== knife cs service list
|
88
136
|
Displays a list of all service offerings available in the currently configured CloudStack account. A service offering
|
89
137
|
can be specified when creating a new server by passing the name as an argument to the -S (or --service) option of the
|
90
138
|
<tt>knife cs server create</tt> command.
|
91
139
|
|
140
|
+
<tt>--keyword</tt> Filters your output on the service name, just like <tt>--name</tt> here below.
|
141
|
+
|
142
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
143
|
+
Example: --name "medium" or --keyword "medium", This will display all cpu service offerings with 'medium' inside the name.
|
144
|
+
|
92
145
|
=== knife cs template list
|
93
146
|
Displays a list of all templates in the currently configured CloudStack account. Featured templates are displayed by default.
|
94
147
|
Use the -F (or --filter) option to use a different filter. The allowable filter values are:
|
@@ -102,60 +155,185 @@ Use the -F (or --filter) option to use a different filter. The allowable filter
|
|
102
155
|
A template can be specified when creating a new server by passing the template name as an argument to the -T
|
103
156
|
(or --template) option of the <tt>knife cs server create</tt> command.
|
104
157
|
|
158
|
+
<tt>--listall</tt> This will list all the templates, depending on the account that you are using.
|
159
|
+
|
160
|
+
=== knife cs template create
|
161
|
+
Creates a template based on a volumeID
|
162
|
+
|
163
|
+
=== knife cs template extract
|
164
|
+
Returns a link where an extractable template can be downloaded
|
165
|
+
|
166
|
+
=== knife cs template register
|
167
|
+
Creates a template based on a file
|
168
|
+
|
105
169
|
=== knife cs zone list
|
106
170
|
Displays a list of all zones available in the currently configured CloudStack account. A zone can be specified
|
107
171
|
when creating a new server by passing the zone name as an argument to the -Z (or --zone) option of the
|
108
172
|
<tt>knife cs server create</tt> command.
|
109
173
|
|
174
|
+
<tt>--keyword</tt> Filters your output on the keyword that you specify.
|
175
|
+
Example: --keyword "zone1", This will display all zones with 'zone1' inside the name
|
176
|
+
|
110
177
|
=== knife cs hosts
|
111
178
|
Convenience command that displays the public ip address and fqdn for all servers. Matches /etc/hosts file format.
|
112
179
|
|
180
|
+
<tt>--listall</tt> This will list all the servers, depending on the account that you are using.
|
181
|
+
|
182
|
+
<tt>--keyword</tt> Filters your result based on a keyword.
|
183
|
+
|
184
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
185
|
+
|
186
|
+
==== knife cs account list
|
187
|
+
Displays all accounts that are currently in your cloudstack environment.
|
188
|
+
|
189
|
+
<tt>--listall</tt> This will list all the possible results, depending on the account that you are using.
|
190
|
+
|
191
|
+
<tt>--keyword</tt> Filters your result based on a keyword.
|
192
|
+
|
193
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
194
|
+
|
195
|
+
==== knife cs cluster list
|
196
|
+
Displays all clusters that are currently available in your cloudstack environment.
|
197
|
+
|
198
|
+
<tt>--keyword</tt> Filters your result based on a keyword.
|
199
|
+
|
200
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
201
|
+
|
202
|
+
==== knife cs config list
|
203
|
+
Displays all the configuration settings that are configured inside the cloudstack environment.
|
204
|
+
|
205
|
+
<tt>--keyword</tt> Filters your result based on a keyword.
|
206
|
+
|
207
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
208
|
+
|
209
|
+
==== knife cs disk list
|
210
|
+
Displays all the disks that are available within cloudstack.
|
211
|
+
|
212
|
+
<tt>--keyword</tt> Filters your result based on a keyword.
|
213
|
+
|
214
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
215
|
+
|
216
|
+
==== knife cs domain list
|
217
|
+
Displays all domains within the cloudstack environment.
|
218
|
+
|
219
|
+
<tt>--listall</tt> This will list all the domains, depending on the account that you are using.
|
220
|
+
|
221
|
+
==== knife cs firewallrule list
|
222
|
+
Displays all firewall rules that are currently active within your cloudstack environment.
|
223
|
+
|
224
|
+
<tt>--listall</tt> This will list all the firewallrules, depending on the account that you are using.
|
225
|
+
|
226
|
+
<tt>--keyword</tt> Filters your result based on a keyword.
|
227
|
+
|
228
|
+
==== knife cs host list
|
229
|
+
Displays all hosts from the cloudstack environment.
|
230
|
+
|
231
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
232
|
+
|
233
|
+
==== knife cs iso list
|
234
|
+
Displays all iso's that are available within the cloudstack environment.
|
235
|
+
|
236
|
+
<tt>--listall</tt> This will list all the iso's, depending on the account that you are using.
|
237
|
+
|
238
|
+
<tt>--keyword</tt> Filters your result based on a keyword.
|
239
|
+
|
240
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
241
|
+
|
242
|
+
==== knife cs ostype list
|
243
|
+
Displays all the os types that are available within the cloudstack environment.
|
244
|
+
|
245
|
+
<tt>--keyword</tt> Filters your output on the keyword that you specify.
|
246
|
+
|
247
|
+
==== knife cs oscategory list
|
248
|
+
Displays all os categories that are available
|
249
|
+
<tt>--keyword</tt> Filters your output on the keyword that you specify.
|
250
|
+
|
251
|
+
==== knife cs pod list
|
252
|
+
Displays all the pods that are currently available within the cloudstack environment.
|
253
|
+
|
254
|
+
<tt>--keyword</tt> Filters your result based on a keyword.
|
255
|
+
|
256
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
257
|
+
|
258
|
+
==== knife project list
|
259
|
+
Displays all the projects that are within the cloudstack environment.
|
260
|
+
|
261
|
+
<tt>--listall</tt> This will list all the projects, depending on the account that you are using.
|
262
|
+
|
263
|
+
<tt>--keyword</tt> Filters your result based on a keyword.
|
264
|
+
|
265
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
266
|
+
|
267
|
+
==== knife cs router list
|
268
|
+
Displays all the routers that are within the cloudstack environment.
|
269
|
+
|
270
|
+
<tt>--listall</tt> This will list all the routers, depending on the account that you are using.
|
271
|
+
|
272
|
+
<tt>--keyword</tt> Filters your result based on a keyword.
|
273
|
+
|
274
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
275
|
+
|
276
|
+
==== knife cs user list
|
277
|
+
Displays all the users that are available within your account.
|
278
|
+
|
279
|
+
<tt>--listall</tt> This will list all the users, depending on the account that you are using.
|
280
|
+
|
281
|
+
<tt>--keyword</tt> Filters your output on the keyword that you specify.
|
282
|
+
|
283
|
+
==== knife cs volume list:
|
284
|
+
Displays all the volumes that are currently available within the cloudstack environment.
|
285
|
+
|
286
|
+
<tt>--listall</tt> This will list all the volumes, depending on the account that you are using.
|
287
|
+
|
288
|
+
<tt>--keyword</tt> Filters your output on the keyword that you specify.
|
289
|
+
|
290
|
+
<tt>--name</tt> Filters your output on the name that you specify.
|
291
|
+
|
113
292
|
=== knife cs stack create
|
114
293
|
Creates a "stack" of servers based on a JSON definition file. Simple orchestration can be performed by
|
115
294
|
specifying one or more actions to be executed after a server (or group of servers) is created.
|
116
295
|
|
117
296
|
==== Example Stack Definition File:
|
118
|
-
|
119
|
-
{
|
120
|
-
"name": "hadoop_cluster_a",
|
121
|
-
"description": "A small hadoop cluster with hbase",
|
122
|
-
"version": "1.0",
|
123
|
-
"environment": "production",
|
124
|
-
"servers": [
|
125
|
-
{
|
126
|
-
"name": "zookeeper-a, zookeeper-b, zookeeper-c",
|
127
|
-
"description": "Zookeeper nodes",
|
128
|
-
"template": "rhel-5.6-base",
|
129
|
-
"service": "small",
|
130
|
-
"port_rules": "2181",
|
131
|
-
"run_list": "role[cluster_a], role[zookeeper_server]",
|
132
|
-
"actions": [
|
133
|
-
{ "knife_ssh": ["role:zookeeper_server", "sudo chef-client"] }
|
134
|
-
]
|
135
|
-
},
|
136
|
-
{
|
137
|
-
"name": "hadoop-master",
|
138
|
-
"description": "Hadoop master node",
|
139
|
-
"template": "rhel-5.6-base",
|
140
|
-
"service": "large",
|
141
|
-
"networks": "app-net, storage-net",
|
142
|
-
"port_rules": "50070, 50030, 60010",
|
143
|
-
"run_list": "role[cluster_a], role[hadoop_master], role[hbase_master]"
|
144
|
-
},
|
297
|
+
|
145
298
|
{
|
146
|
-
"name": "
|
147
|
-
"description": "
|
148
|
-
"
|
149
|
-
"
|
150
|
-
"
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
299
|
+
"name": "hadoop_cluster_a",
|
300
|
+
"description": "A small hadoop cluster with hbase",
|
301
|
+
"version": "1.0",
|
302
|
+
"environment": "production",
|
303
|
+
"servers": [
|
304
|
+
{
|
305
|
+
"name": "zookeeper-a, zookeeper-b, zookeeper-c",
|
306
|
+
"description": "Zookeeper nodes",
|
307
|
+
"template": "rhel-5.6-base",
|
308
|
+
"service": "small",
|
309
|
+
"port_rules": "2181",
|
310
|
+
"run_list": "role[cluster_a], role[zookeeper_server]",
|
311
|
+
"actions": [
|
312
|
+
{ "knife_ssh": ["role:zookeeper_server", "sudo chef-client"] }
|
313
|
+
]
|
314
|
+
},
|
315
|
+
{
|
316
|
+
"name": "hadoop-master",
|
317
|
+
"description": "Hadoop master node",
|
318
|
+
"template": "rhel-5.6-base",
|
319
|
+
"service": "large",
|
320
|
+
"networks": "app-net, storage-net",
|
321
|
+
"port_rules": "50070, 50030, 60010",
|
322
|
+
"run_list": "role[cluster_a], role[hadoop_master], role[hbase_master]"
|
323
|
+
},
|
324
|
+
{
|
325
|
+
"name": "hadoop-worker-a hadoop-worker-b hadoop-worker-c",
|
326
|
+
"description": "Hadoop worker nodes",
|
327
|
+
"template": "rhel-5.6-base",
|
328
|
+
"service": "medium",
|
329
|
+
"port_rules": "50075, 50060, 60030",
|
330
|
+
"run_list": "role[cluster_a], role[hadoop_worker], role[hbase_regionserver]",
|
331
|
+
"actions": [
|
332
|
+
{ "knife_ssh": ["role:hadoop_master", "sudo chef-client"] },
|
333
|
+
{ "http_request": "http://${hadoop-master}:50070/index.jsp" }
|
334
|
+
]
|
335
|
+
}
|
156
336
|
}
|
157
|
-
}
|
158
|
-
</tt>
|
159
337
|
|
160
338
|
==== Stack Attributes
|
161
339
|
name:: Stack name. May be used in the future to e.g. look up a stack in a databag.
|
@@ -199,8 +377,9 @@ Reboots the specified virtual machines(s).
|
|
199
377
|
Author:: Ryan Holmes <rholmes@edmunds.com>
|
200
378
|
Author:: KC Braunschweig <kcbraunschweig@gmail.com>
|
201
379
|
Author:: John E. Vincent <lusis.org+github.com@gmail.com>
|
202
|
-
|
380
|
+
Author:: Sander Botman <sbotman@schubergphilis.com>
|
203
381
|
Copyright:: Copyright (c) 2011 Edmunds, Inc.
|
382
|
+
Copyright:: Copyright (c) 2013 Sander Botman.
|
204
383
|
License:: Apache License, Version 2.0
|
205
384
|
|
206
385
|
Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -0,0 +1,130 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Sander Botman (<sbotman@schubergphilis.com>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Sander Botman.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/knife/cs_base'
|
20
|
+
require 'chef/knife/cs_baselist'
|
21
|
+
|
22
|
+
module KnifeCloudstack
|
23
|
+
class CsAccountList < Chef::Knife
|
24
|
+
|
25
|
+
include Chef::Knife::KnifeCloudstackBase
|
26
|
+
include Chef::Knife::KnifeCloudstackBaseList
|
27
|
+
|
28
|
+
deps do
|
29
|
+
require 'knife-cloudstack/connection'
|
30
|
+
Chef::Knife::Bootstrap.load_deps
|
31
|
+
end
|
32
|
+
|
33
|
+
banner "knife cs account list (options)"
|
34
|
+
|
35
|
+
option :listall,
|
36
|
+
:long => "--listall",
|
37
|
+
:description => "List all the accounts",
|
38
|
+
:boolean => true
|
39
|
+
|
40
|
+
option :name,
|
41
|
+
:long => "--name NAME",
|
42
|
+
:description => "Specify account name to list"
|
43
|
+
|
44
|
+
option :keyword,
|
45
|
+
:long => "--keyword KEY",
|
46
|
+
:description => "List by keyword"
|
47
|
+
|
48
|
+
def run
|
49
|
+
validate_base_options
|
50
|
+
|
51
|
+
if locate_config_value(:fields)
|
52
|
+
object_list = []
|
53
|
+
locate_config_value(:fields).split(',').each { |n| object_list << ui.color(("#{n}").strip, :bold) }
|
54
|
+
else
|
55
|
+
if locate_config_value(:cloudstack_project)
|
56
|
+
object_list = [
|
57
|
+
ui.color('Account', :bold),
|
58
|
+
ui.color('Domain', :bold),
|
59
|
+
ui.color('Type', :bold),
|
60
|
+
ui.color('Role', :bold),
|
61
|
+
ui.color('Users', :bold)
|
62
|
+
]
|
63
|
+
else
|
64
|
+
object_list = [
|
65
|
+
ui.color('Name', :bold),
|
66
|
+
ui.color('Domain', :bold),
|
67
|
+
ui.color('State', :bold),
|
68
|
+
ui.color('Type', :bold),
|
69
|
+
ui.color('Users', :bold)
|
70
|
+
]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
columns = object_list.count
|
75
|
+
object_list = [] if locate_config_value(:noheader)
|
76
|
+
|
77
|
+
if locate_config_value(:cloudstack_project)
|
78
|
+
api_command = "listProjectAccounts"
|
79
|
+
api_result = "projectaccount"
|
80
|
+
else
|
81
|
+
api_command = "listAccounts"
|
82
|
+
api_result = "account"
|
83
|
+
end
|
84
|
+
|
85
|
+
connection_result = connection.list_object(
|
86
|
+
api_command,
|
87
|
+
api_result,
|
88
|
+
locate_config_value(:filter),
|
89
|
+
locate_config_value(:listall),
|
90
|
+
locate_config_value(:keyword),
|
91
|
+
locate_config_value(:name)
|
92
|
+
)
|
93
|
+
|
94
|
+
output_format(connection_result)
|
95
|
+
|
96
|
+
connection_result.each do |r|
|
97
|
+
if locate_config_value(:fields)
|
98
|
+
locate_config_value(:fields).downcase.split(',').each { |n| object_list << ((r[("#{n}").strip]).to_s || 'N/A') }
|
99
|
+
else
|
100
|
+
if locate_config_value(:cloudstack_project)
|
101
|
+
object_list << r['account'].to_s
|
102
|
+
object_list << r['domain'].to_s
|
103
|
+
case r['accounttype']
|
104
|
+
when 0 then object_list << "User"
|
105
|
+
when 1 then object_list << "Admin"
|
106
|
+
when 2 then object_list << "Domain Admin"
|
107
|
+
else object_list << "unknown"
|
108
|
+
end
|
109
|
+
object_list << r['role'].to_s
|
110
|
+
object_list << r['user'].count.to_s
|
111
|
+
else
|
112
|
+
object_list << r['name'].to_s
|
113
|
+
object_list << r['domain'].to_s
|
114
|
+
object_list << r['state'].to_s
|
115
|
+
case r['accounttype']
|
116
|
+
when 0 then object_list << "User"
|
117
|
+
when 1 then object_list << "Admin"
|
118
|
+
when 2 then object_list << "Domain Admin"
|
119
|
+
else object_list << "unknown"
|
120
|
+
end
|
121
|
+
object_list << r['user'].count.to_s
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
puts ui.list(object_list, :uneven_columns_across, columns)
|
126
|
+
list_object_fields(connection_result) if locate_config_value(:fieldlist)
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|