knife-vcloud 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +14 -0
- data/LICENSE +202 -0
- data/README.md +218 -0
- data/lib/chef/knife/common.rb +56 -0
- data/lib/chef/knife/vc_catalog_item_show.rb +88 -0
- data/lib/chef/knife/vc_catalog_show.rb +88 -0
- data/lib/chef/knife/vc_login.rb +71 -0
- data/lib/chef/knife/vc_org_list.rb +81 -0
- data/lib/chef/knife/vc_org_show.rb +112 -0
- data/lib/chef/knife/vc_vapp_config_network.rb +80 -0
- data/lib/chef/knife/vc_vapp_create.rb +81 -0
- data/lib/chef/knife/vc_vapp_delete.rb +78 -0
- data/lib/chef/knife/vc_vapp_show.rb +92 -0
- data/lib/chef/knife/vc_vapp_start.rb +77 -0
- data/lib/chef/knife/vc_vapp_stop.rb +77 -0
- data/lib/chef/knife/vc_vdc_show.rb +94 -0
- data/lib/chef/knife/vc_vm_config_guest.rb +80 -0
- data/lib/chef/knife/vc_vm_config_network.rb +80 -0
- data/lib/chef/knife/vc_vm_show.rb +97 -0
- metadata +113 -0
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Changes
|
2
|
+
==
|
3
|
+
2012-12-21 (0.1.0)
|
4
|
+
--
|
5
|
+
|
6
|
+
Initial release
|
7
|
+
|
8
|
+
* Add support for main operations:
|
9
|
+
* login (useful for testing connectivity/credentials)
|
10
|
+
* organization _list/show_
|
11
|
+
* vdc _show_
|
12
|
+
* catalog _show_
|
13
|
+
* catalog item _show_
|
14
|
+
* vapp _create/delete/startup/shutdown_
|
data/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
knife-vcloud
|
2
|
+
===========
|
3
|
+
|
4
|
+
DESCRIPTION
|
5
|
+
--
|
6
|
+
A knife plugin for the VMWare® vCloud API.
|
7
|
+
|
8
|
+
It uses [vcloud-rest](https://github.com/astratto/vcloud-rest) to communicate with a VMWare vCloud Server.
|
9
|
+
|
10
|
+
This code is BETA QUALITY.
|
11
|
+
|
12
|
+
INSTALLATION
|
13
|
+
--
|
14
|
+
This plugin is distributed as a Ruby Gem. To install it, run:
|
15
|
+
|
16
|
+
gem install knife-vcloud
|
17
|
+
|
18
|
+
Depending on your system's configuration, you may need to run this command with root privileges.
|
19
|
+
|
20
|
+
|
21
|
+
FEATURES
|
22
|
+
--
|
23
|
+
- login/logout
|
24
|
+
- list/show Organizations
|
25
|
+
- show VDCs
|
26
|
+
- show Catalogs
|
27
|
+
- show Catalog Items
|
28
|
+
- create/start/stop/delete vApps
|
29
|
+
|
30
|
+
PREREQUISITES
|
31
|
+
--
|
32
|
+
- chef >= 0.10.0
|
33
|
+
- knife-windows
|
34
|
+
- vcloud-rest"
|
35
|
+
|
36
|
+
USAGE
|
37
|
+
--
|
38
|
+
|
39
|
+
###Available commands
|
40
|
+
|
41
|
+
knife vc catalog item show [ITEM_ID] (options)
|
42
|
+
knife vc catalog show [CATALOG_ID] (options)
|
43
|
+
knife vc login (options)
|
44
|
+
knife vc org list (options)
|
45
|
+
knife vc org show [ORG_ID] (options)
|
46
|
+
knife vc vapp create [VDC_ID] [NAME] [DESCRIPTION] [TEMPLATE_ID] (options)
|
47
|
+
knife vc vapp delete [VAPP_ID] (options)
|
48
|
+
knife vc vapp start [VAPP_ID] (options)
|
49
|
+
knife vc vapp stop [VAPP_ID] (options)
|
50
|
+
knife vc vdc show [VDC_ID] (options)
|
51
|
+
|
52
|
+
###Configuration
|
53
|
+
All commands accept the following options:
|
54
|
+
|
55
|
+
--vcloud-url URL
|
56
|
+
--vcloud-user USER
|
57
|
+
--vcloud-password SECRET
|
58
|
+
--vcloud-organization ORGANIZATION
|
59
|
+
--vcloud-api-version API_VERSION
|
60
|
+
|
61
|
+
In addition, those options can be specified inside your _.chef/knife.rb_ file.
|
62
|
+
|
63
|
+
####Knife.rb configuration:
|
64
|
+
|
65
|
+
knife[:vcloud_url] = 'https://vcloud.server.org'
|
66
|
+
knife[:vcloud_org] = 'vcloud_organization'
|
67
|
+
knife[:vcloud_user] = 'vcloud_user'
|
68
|
+
knife[:vcloud_password] = 'vcloud_password'
|
69
|
+
(OPTIONAL) knife[:vcloud_api_version] = '1.5'
|
70
|
+
|
71
|
+
###Login
|
72
|
+
This command can be used to verify that the vCloud Server can be reached and credentials are correct.
|
73
|
+
|
74
|
+
_Example:_
|
75
|
+
|
76
|
+
$ knife vc login
|
77
|
+
Authenticated successfully, code: 9NkgOPh8tH6hPmujAvc99UBSyuqm713/23mFW1f7lJ0=
|
78
|
+
|
79
|
+
###List organizations
|
80
|
+
This command lists the available organizations.
|
81
|
+
|
82
|
+
_Example:_
|
83
|
+
|
84
|
+
$ knife vc org list
|
85
|
+
Name ID
|
86
|
+
TEST-ORG 9f3ac2a8-92dd-4921-b48b-85b42f4d247c
|
87
|
+
|
88
|
+
###Show organization's details
|
89
|
+
This command shows details about a given organization.
|
90
|
+
|
91
|
+
_Example:_
|
92
|
+
|
93
|
+
$ knife vc org show 9f3ac2a8-92dd-4921-b48b-85b42f4d247c
|
94
|
+
CATALOGS
|
95
|
+
Name ID
|
96
|
+
Catalog_1 7414bc46-44fc-44ed-9844-0aa6ea9f5cf9
|
97
|
+
Catalog_2 97a1e07f-7c1a-49fe-9cda-6ccfd4658ab7
|
98
|
+
|
99
|
+
VDCs
|
100
|
+
Name ID
|
101
|
+
Test_vDC_1 440d5134-d2dd-4be7-8692-79a28c86f55b
|
102
|
+
|
103
|
+
NETWORKS
|
104
|
+
Name ID
|
105
|
+
TestNet_1 35e5bed1-8475-4fd9-b495-ed1f062ca9c1
|
106
|
+
TestNet_2 d56d8035-4b9e-454e-aa75-6ff450fb432d
|
107
|
+
|
108
|
+
TASKLISTS
|
109
|
+
Name ID
|
110
|
+
<unnamed list> 9f3ac2a8-92dd-4921-b48b-85b42f4d247c
|
111
|
+
|
112
|
+
###Show catalog's details
|
113
|
+
This command shows details about a given catalog.
|
114
|
+
|
115
|
+
_Example:_
|
116
|
+
|
117
|
+
$ knife vc catalog show 7414bc46-44fc-44ed-9844-0aa6ea9f5cf9
|
118
|
+
Description: Test Catalog description
|
119
|
+
Name ID
|
120
|
+
CentOS 6.3 40e5e071-8231-46c1-92b7-fbe8f633e259
|
121
|
+
...
|
122
|
+
|
123
|
+
###Show catalog item's details
|
124
|
+
This command shows details about a given catalog item.
|
125
|
+
e.g., retrieve a template ID
|
126
|
+
|
127
|
+
_Example:_
|
128
|
+
|
129
|
+
$ knife vc catalog item show 40e5e071-8231-46c1-92b7-fbe8f633e259
|
130
|
+
Description: Linux CentOS 64 bit 6 update 3
|
131
|
+
Name Template ID
|
132
|
+
CentOS 6.3 edb5bb2f-58bc-4a44-aaf6-c244543e4a1b
|
133
|
+
|
134
|
+
###Show vDC's details
|
135
|
+
This command shows details about a given vDC.
|
136
|
+
|
137
|
+
_Example:_
|
138
|
+
|
139
|
+
$ knife vc vdc show 440d5134-d2dd-4be7-8692-79a28c86f55b
|
140
|
+
Description:
|
141
|
+
vAPPS
|
142
|
+
Name ID Status IP
|
143
|
+
TestKnife (1 VMs) 09551b42-dca9-474d-aa50-201b223522db running 10.102.46.237
|
144
|
+
TestCENTOS (1 VMs) 4338a436-19fc-47b9-aaba-024841acfd66 stopped 10.102.46.23
|
145
|
+
|
146
|
+
###Startup vApp
|
147
|
+
This command starts up a given vApp.
|
148
|
+
|
149
|
+
_Example:_
|
150
|
+
|
151
|
+
$ knife vc vapp start 4338a436-19fc-47b9-aaba-024841acfd66
|
152
|
+
vApp startup...Done!
|
153
|
+
Summary: Status: success - started at 2012-12-19T16:50:31.030+01:00 and ended at 2012-12-19T16:50:38.487+01:00
|
154
|
+
|
155
|
+
###Shutdown vApp
|
156
|
+
This command halts a given vApp.
|
157
|
+
|
158
|
+
_Example:_
|
159
|
+
|
160
|
+
$ knife vc vapp $ knife vc vapp stop 09551b42-dca9-474d-aa50-201b223522db
|
161
|
+
vApp shutdown...Done!
|
162
|
+
Summary: Status: success - started at 2012-12-19T16:56:31.100+01:00 and ended at 2012-12-19T16:56:38.667+01:00
|
163
|
+
|
164
|
+
###Delete vApp
|
165
|
+
This command deletes a given vApp.
|
166
|
+
|
167
|
+
_Example:_
|
168
|
+
|
169
|
+
$ knife vc vapp delete c1bad644-6c4d-40fc-a46b-7624ff6d5e75
|
170
|
+
Do you really want to DELETE vApp c1bad644-6c4d-40fc-a46b-7624ff6d5e75?? (Y/N) Y
|
171
|
+
vApp deletion...Done!
|
172
|
+
Summary: Status: success - started at 2012-12-19T17:00:20.503+01:00 and ended at 2012-12-19T17:00:21.133+01:00
|
173
|
+
|
174
|
+
###Create vApp from template
|
175
|
+
This command creates a vApp starting from a template (see catalog item).
|
176
|
+
|
177
|
+
_Example:_
|
178
|
+
|
179
|
+
$ knife vc vapp create 440d5134-d2dd-4be7-8692-79a28c86f55b TestVM "Test vm description" 14b63ef2-fe93-4d0b-91f0-ccbd3847c665
|
180
|
+
vApp creation...Done!
|
181
|
+
Summary: Status: success - started at 2012-12-19T17:02:32.797+01:00 and ended at 2012-12-19T17:02:53.943+01:00
|
182
|
+
vApp created with ID: 9cdd92ad-ab65-467f-abe1-075e35c050ec
|
183
|
+
|
184
|
+
###Show vApp's details
|
185
|
+
This command shows details about a given vApp.
|
186
|
+
|
187
|
+
_Example:_
|
188
|
+
|
189
|
+
$ knife vc vapp show 4338a436-19fc-47b9-aaba-024841acfd66
|
190
|
+
Name: TEST_CENTOS
|
191
|
+
Status: running
|
192
|
+
IP: 10.102.46.237
|
193
|
+
Name Status IPs ID
|
194
|
+
CENTOS63 running 10.102.46.237 8b943bf9-a8ca-4d41-b97f-316c3aa891ea
|
195
|
+
|
196
|
+
LICENSE
|
197
|
+
--
|
198
|
+
|
199
|
+
Author:: Stefano Tortarolo <stefano.tortarolo@gmail.com>
|
200
|
+
|
201
|
+
Copyright:: Copyright (c) 2012
|
202
|
+
License:: Apache License, Version 2.0
|
203
|
+
|
204
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
205
|
+
you may not use this file except in compliance with the License.
|
206
|
+
You may obtain a copy of the License at
|
207
|
+
|
208
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
209
|
+
|
210
|
+
Unless required by applicable law or agreed to in writing, software
|
211
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
212
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
213
|
+
See the License for the specific language governing permissions and
|
214
|
+
limitations under the License.
|
215
|
+
|
216
|
+
CREDITS
|
217
|
+
--
|
218
|
+
This code was inspired by [knife-cloudstack](https://github.com/CloudStack-extras/knife-cloudstack).
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Stefano Tortarolo (<stefano.tortarolo@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012
|
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
|
+
module KnifeVCloud
|
20
|
+
# Module for operations common among commands
|
21
|
+
module Common
|
22
|
+
def connection
|
23
|
+
unless @connection
|
24
|
+
@connection = VCloudClient::Connection.new(
|
25
|
+
locate_config_value(:vcloud_url),
|
26
|
+
locate_config_value(:vcloud_user),
|
27
|
+
locate_config_value(:vcloud_password),
|
28
|
+
locate_config_value(:vcloud_org),
|
29
|
+
locate_config_value(:vcloud_api_version)
|
30
|
+
)
|
31
|
+
end
|
32
|
+
@connection
|
33
|
+
end
|
34
|
+
|
35
|
+
def msg(label, value)
|
36
|
+
if value && !value.empty?
|
37
|
+
puts "#{ui.color(label, :cyan)}: #{value}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def locate_config_value(key)
|
42
|
+
key = key.to_sym
|
43
|
+
Chef::Config[:knife][key] || config[key]
|
44
|
+
end
|
45
|
+
|
46
|
+
def wait_task(connection, task_id)
|
47
|
+
status, errormsg, start_time, end_time = connection.wait_task_completion task_id
|
48
|
+
puts "Done!"
|
49
|
+
msg("Summary", "Status: #{ui.color(status, :cyan)} - started at #{start_time} and ended at #{end_time}")
|
50
|
+
|
51
|
+
if errormsg
|
52
|
+
puts ui.color("ATTENTION: #{errormsg}", :red)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Stefano Tortarolo (<stefano.tortarolo@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012
|
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'
|
20
|
+
|
21
|
+
module KnifeVCloud
|
22
|
+
class VcCatalogItemShow < Chef::Knife
|
23
|
+
include KnifeVCloud::Common
|
24
|
+
|
25
|
+
deps do
|
26
|
+
require 'vcloud-rest/connection'
|
27
|
+
require 'chef/api_client'
|
28
|
+
end
|
29
|
+
|
30
|
+
banner "knife vc catalog item show [CATALOG_ID] (options)"
|
31
|
+
|
32
|
+
option :vcloud_url,
|
33
|
+
:short => "-H URL",
|
34
|
+
:long => "--vcloud-url URL",
|
35
|
+
:description => "The vCloud endpoint URL",
|
36
|
+
:proc => Proc.new { |url| Chef::Config[:knife][:vcloud_url] = url }
|
37
|
+
|
38
|
+
option :vcloud_user,
|
39
|
+
:short => "-U USER",
|
40
|
+
:long => "--vcloud-user USER",
|
41
|
+
:description => "Your vCloud User",
|
42
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_user] = key }
|
43
|
+
|
44
|
+
option :vcloud_password,
|
45
|
+
:short => "-P SECRET",
|
46
|
+
:long => "--vcloud-password SECRET",
|
47
|
+
:description => "Your vCloud secret key",
|
48
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_password] = key }
|
49
|
+
|
50
|
+
option :vcloud_org,
|
51
|
+
:short => "-O ORGANIZATION",
|
52
|
+
:long => "--vcloud-organization ORGANIZATION",
|
53
|
+
:description => "Your vCloud Organization",
|
54
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_org] = key }
|
55
|
+
|
56
|
+
option :vcloud_api_version,
|
57
|
+
:short => "-A API_VERSION",
|
58
|
+
:long => "--vcloud-api-version API_VERSION",
|
59
|
+
:description => "vCloud API version (1.5 and 5.1 supported)",
|
60
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_api_version] = key }
|
61
|
+
|
62
|
+
def run
|
63
|
+
$stdout.sync = true
|
64
|
+
|
65
|
+
item_id = @name_args.first
|
66
|
+
|
67
|
+
connection.login
|
68
|
+
|
69
|
+
header = [
|
70
|
+
ui.color('Name', :bold),
|
71
|
+
ui.color('Template ID', :bold)
|
72
|
+
]
|
73
|
+
|
74
|
+
description, items = connection.show_catalog_item item_id
|
75
|
+
connection.logout
|
76
|
+
|
77
|
+
puts "#{ui.color('Description:', :cyan)} #{description}"
|
78
|
+
list = header
|
79
|
+
list.flatten!
|
80
|
+
items.each do |k, v|
|
81
|
+
list << (k || '')
|
82
|
+
list << (v || '')
|
83
|
+
end
|
84
|
+
|
85
|
+
puts ui.list(list, :columns_across, 2)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Stefano Tortarolo (<stefano.tortarolo@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012
|
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'
|
20
|
+
|
21
|
+
module KnifeVCloud
|
22
|
+
class VcCatalogShow < Chef::Knife
|
23
|
+
include KnifeVCloud::Common
|
24
|
+
|
25
|
+
deps do
|
26
|
+
require 'vcloud-rest/connection'
|
27
|
+
require 'chef/api_client'
|
28
|
+
end
|
29
|
+
|
30
|
+
banner "knife vc catalog show [CATALOG_ID] (options)"
|
31
|
+
|
32
|
+
option :vcloud_url,
|
33
|
+
:short => "-H URL",
|
34
|
+
:long => "--vcloud-url URL",
|
35
|
+
:description => "The vCloud endpoint URL",
|
36
|
+
:proc => Proc.new { |url| Chef::Config[:knife][:vcloud_url] = url }
|
37
|
+
|
38
|
+
option :vcloud_user,
|
39
|
+
:short => "-U USER",
|
40
|
+
:long => "--vcloud-user USER",
|
41
|
+
:description => "Your vCloud User",
|
42
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_user] = key }
|
43
|
+
|
44
|
+
option :vcloud_password,
|
45
|
+
:short => "-P SECRET",
|
46
|
+
:long => "--vcloud-password SECRET",
|
47
|
+
:description => "Your vCloud secret key",
|
48
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_password] = key }
|
49
|
+
|
50
|
+
option :vcloud_org,
|
51
|
+
:short => "-O ORGANIZATION",
|
52
|
+
:long => "--vcloud-organization ORGANIZATION",
|
53
|
+
:description => "Your vCloud Organization",
|
54
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_org] = key }
|
55
|
+
|
56
|
+
option :vcloud_api_version,
|
57
|
+
:short => "-A API_VERSION",
|
58
|
+
:long => "--vcloud-api-version API_VERSION",
|
59
|
+
:description => "vCloud API version (1.5 and 5.1 supported)",
|
60
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_api_version] = key }
|
61
|
+
|
62
|
+
def run
|
63
|
+
$stdout.sync = true
|
64
|
+
|
65
|
+
catalog_id = @name_args.first
|
66
|
+
|
67
|
+
connection.login
|
68
|
+
|
69
|
+
header = [
|
70
|
+
ui.color('Name', :bold),
|
71
|
+
ui.color('ID', :bold)
|
72
|
+
]
|
73
|
+
|
74
|
+
description, items = connection.show_catalog catalog_id
|
75
|
+
connection.logout
|
76
|
+
|
77
|
+
puts "#{ui.color('Description:', :cyan)} #{description}"
|
78
|
+
list = header
|
79
|
+
list.flatten!
|
80
|
+
items.each do |k, v|
|
81
|
+
list << (k || '')
|
82
|
+
list << (v || '')
|
83
|
+
end
|
84
|
+
|
85
|
+
puts ui.list(list, :columns_across, 2)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|