chef-provisioning-opennebula 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +201 -0
- data/README.md +532 -0
- data/Rakefile +6 -0
- data/lib/chef/provider/one_image.rb +244 -0
- data/lib/chef/provider/one_template.rb +95 -0
- data/lib/chef/provider/one_user.rb +105 -0
- data/lib/chef/provider/one_vnet.rb +122 -0
- data/lib/chef/provider/one_vnet_lease.rb +133 -0
- data/lib/chef/provisioning/driver_init/opennebula.rb +17 -0
- data/lib/chef/provisioning/opennebula_driver.rb +18 -0
- data/lib/chef/provisioning/opennebula_driver/credentials.rb +105 -0
- data/lib/chef/provisioning/opennebula_driver/driver.rb +572 -0
- data/lib/chef/provisioning/opennebula_driver/one_lib.rb +352 -0
- data/lib/chef/provisioning/opennebula_driver/resources.rb +20 -0
- data/lib/chef/provisioning/opennebula_driver/version.rb +30 -0
- data/lib/chef/resource/one_image.rb +65 -0
- data/lib/chef/resource/one_template.rb +46 -0
- data/lib/chef/resource/one_user.rb +50 -0
- data/lib/chef/resource/one_vnet.rb +51 -0
- data/lib/chef/resource/one_vnet_lease.rb +46 -0
- data/spec/integration/test_all_integration_spec.rb +102 -0
- data/spec/recipes/attach_back_one_vm_spec.rb +20 -0
- data/spec/recipes/attach_back_two_vm_spec.rb +20 -0
- data/spec/recipes/attach_one_image_spec.rb +20 -0
- data/spec/recipes/converge_back_one_vm_spec.rb +19 -0
- data/spec/recipes/converge_back_two_vm_spec.rb +19 -0
- data/spec/recipes/converge_bootstrap_vm_spec.rb +34 -0
- data/spec/recipes/create_back_one_vm_spec.rb +20 -0
- data/spec/recipes/create_back_two_vm_spec.rb +20 -0
- data/spec/recipes/create_bootstrap_vm_spec.rb +34 -0
- data/spec/recipes/create_one_image_spec.rb +21 -0
- data/spec/recipes/create_one_template_spec.rb +52 -0
- data/spec/recipes/delete_all_spec.rb +47 -0
- data/spec/recipes/driver_options_spec.rb +70 -0
- data/spec/recipes/instantiate_one_template_spec.rb +35 -0
- data/spec/recipes/snapshot_one_image_spec.rb +21 -0
- data/spec/recipes/snapshot_two_image_spec.rb +21 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/support/opennebula_support.rb +64 -0
- metadata +168 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 83946a6cacda760aea3647d4a9d7ca929da411be
|
4
|
+
data.tar.gz: f6c1ae25e0f01c63048bfe38f7721932b4483961
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a63666bb3a258be1fb452934670697170d7cb4e3bfbae8769a0ac810fb5c855f6dc0dcbabc041d3b0997c93b5df86695714f9dfddd86a8f79de7f70b006b4528
|
7
|
+
data.tar.gz: a1d9bb1a0b235c0659c3f7373d4805bf03a93b3d3c741cf7123534e634ffd2ab5435a507c75d3e216ac9eac8eae052783e44ee83919c5f0b03bb0c438c0fe7d6
|
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,532 @@
|
|
1
|
+
chef-provisioning-opennebula
|
2
|
+
============================
|
3
|
+
|
4
|
+
This is the implementation of the OpenNebula driver for chef-provisioning. It also comes with additional chef resources to manage OpenNebula:
|
5
|
+
|
6
|
+
* Template (one_template)
|
7
|
+
* Image (one_image)
|
8
|
+
* VNET (one_vnet)
|
9
|
+
* Lease (one_vnet_lease)
|
10
|
+
|
11
|
+
Setup
|
12
|
+
-----
|
13
|
+
In order to use this driver with chef-provisioning the driver URL needs to be specified via environment variable or ```with_driver``` directive.
|
14
|
+
|
15
|
+
Starting in version 0.3.3 the driver URL has the following format:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
opennebula:<endpoint_url>:<profile>
|
19
|
+
```
|
20
|
+
|
21
|
+
Example:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
with_driver "opennebula:http://1.2.3.4:443/api:boggi"
|
25
|
+
```
|
26
|
+
|
27
|
+
Where ```boggi``` profile is stored the profile file. The file will be searched in the following order:
|
28
|
+
1. ```ENV['ONE_CONFIG']```
|
29
|
+
2. ```"#{ENV['HOME']}/.one/one_config"```
|
30
|
+
3. ```/var/lib/one/.one/one_config```
|
31
|
+
|
32
|
+
A sample one_config file would look like this:
|
33
|
+
|
34
|
+
```json
|
35
|
+
"boggi": {
|
36
|
+
"credentials": "boggi:my_token",
|
37
|
+
"options": {
|
38
|
+
"timeout": 2,
|
39
|
+
"sync": true,
|
40
|
+
"http_proxy": "http://my.proxy.com"
|
41
|
+
}
|
42
|
+
},
|
43
|
+
"testuser": {
|
44
|
+
"credentials": "testuser:test_token"
|
45
|
+
}
|
46
|
+
```
|
47
|
+
|
48
|
+
If no profile is specified the driver will attempt to read and use the ```ENV['ONE_AUTH']``` file or ```~/.one/one_auth``` or ```/var/lib/one/.one/one_auth```.
|
49
|
+
The driver is still backward compatible with previous format and passing ```:secret_file``` or ```:credentials``` in```:driver_options```.
|
50
|
+
|
51
|
+
Additional options to OpenNebual client can be passed vi ```:one_options```.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
with_driver "opennebula:http://1.2.3.4/endpoint:port",
|
55
|
+
:credentials => "<username>:<text_password>",
|
56
|
+
:one_options => { :timeout => 3 }
|
57
|
+
```
|
58
|
+
|
59
|
+
or
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
with_driver "opennebula:http://1.2.3.4/endpoint:port",
|
63
|
+
:secret_file => "<local_path_to_file_with_credentials>",
|
64
|
+
:one_options => { :timeout => 3 }
|
65
|
+
```
|
66
|
+
|
67
|
+
If additional OpenNebula client options need to be passed they can be specified as a hash ```:one_options => {}```.
|
68
|
+
|
69
|
+
In context of OpenNebula ```machine``` resource will take the following additional options:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
machine_options {
|
73
|
+
:bootstrap_options => {
|
74
|
+
:template => Hash defining the VM template,
|
75
|
+
:template_file => String location of the VM template file,
|
76
|
+
:template_name => String name of the OpenNebula template to use
|
77
|
+
:template_id => Integer id of the OpenNebula template to use
|
78
|
+
:template_options => Hash values to be merged with VM template
|
79
|
+
:enforce_chef_fqdn => [TrueClass, FalseClass] flag indicating if fqdn names should be used for machine names
|
80
|
+
:is_shutdown => [TrueClass, FalseClass] call vm.shutodwn instead of vm.stop during :stop action
|
81
|
+
:shutdown_hard => [TrueClass, FalseClass] flag indicating hard or soft shutdown
|
82
|
+
},
|
83
|
+
:sudo => true,
|
84
|
+
:ssh_username => 'local',
|
85
|
+
:ssh_options => {
|
86
|
+
Hash containing SSH options as specified by net-ssh gem
|
87
|
+
please see https://github.com/net-ssh/net-ssh for all options
|
88
|
+
Example options:
|
89
|
+
:paranoid => false,
|
90
|
+
:auth_methods => ['publickey'],
|
91
|
+
:keys => [ File.open(File.expand_path('~/.ssh/id_rsa_new')).read ]
|
92
|
+
:keys_only => false,
|
93
|
+
:forward_agent => true,
|
94
|
+
:use_agent => true,
|
95
|
+
:user_known_hosts_file => '/dev/null'
|
96
|
+
}
|
97
|
+
}
|
98
|
+
```
|
99
|
+
|
100
|
+
Resources
|
101
|
+
---------
|
102
|
+
|
103
|
+
## one_template
|
104
|
+
|
105
|
+
This resource will allow to create and delete OpenNebula templates.
|
106
|
+
|
107
|
+
### Attributes
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
:template => Hash defining OpenNebula template
|
111
|
+
:template_file => String location of the VM template file
|
112
|
+
```
|
113
|
+
|
114
|
+
### Actions
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
actions :create, :delete, :instantiate
|
118
|
+
default_action :create
|
119
|
+
```
|
120
|
+
|
121
|
+
### Examples
|
122
|
+
|
123
|
+
#### 1. Create OpenNebula template from file
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
one_template "my_one_template" do
|
127
|
+
template_file "/opt/one/templates/my_template.tpl"
|
128
|
+
action :create
|
129
|
+
end
|
130
|
+
```
|
131
|
+
|
132
|
+
#### 2. Create OpenNebula template from a template definition
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
one_template "my_one_template" do
|
136
|
+
template ({
|
137
|
+
"HTTPBASE" => "http://my.server.com",
|
138
|
+
"MEMORY" => "4096",
|
139
|
+
"CPU" => "2",
|
140
|
+
"VCPU" => "2",
|
141
|
+
"OS" => {
|
142
|
+
"ARCH" => "x86_64"
|
143
|
+
},
|
144
|
+
"DISK" => {
|
145
|
+
"IMAGE" => "Ubuntu-12.04.5-pre-prod-20141216",
|
146
|
+
"IMAGE_UNAME" => "my_user",
|
147
|
+
"DRIVER" => "qcow2"
|
148
|
+
},
|
149
|
+
"NIC" => {
|
150
|
+
"NETWORK" => "my_network",
|
151
|
+
"NETWORK_UNAME" => "my_network_user"
|
152
|
+
},
|
153
|
+
"GRAPHICS" => {
|
154
|
+
"LISTEN" => "0.0.0.0",
|
155
|
+
"TYPE" => "vnc"
|
156
|
+
},
|
157
|
+
"CONTEXT" => {
|
158
|
+
"NETWORK" => "YES",
|
159
|
+
"HOSTNAME" => "$NAME",
|
160
|
+
"INSTALL_CHEF_CLIENT_COMMAND" => "dpkg -E -i /mnt/chef-client.deb",
|
161
|
+
"SSH_USER" => 'local',
|
162
|
+
"SSH_PUBLIC_KEY" => "ssh-rsa blahblahblahpublickey root@my_host",
|
163
|
+
"FILES" => "$HTTPBASE/01_chef $HTTPBASE/../chef-client.deb"
|
164
|
+
}
|
165
|
+
})
|
166
|
+
action :create
|
167
|
+
end
|
168
|
+
```
|
169
|
+
|
170
|
+
#### 3. Delete an existing template in OpenNebula
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
one_template "my_one_template" do
|
174
|
+
action :delete
|
175
|
+
end
|
176
|
+
```
|
177
|
+
|
178
|
+
## one_image
|
179
|
+
|
180
|
+
This resource will manage images within OpenNebula.
|
181
|
+
|
182
|
+
### Attributes
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
:name => String name of the image to be created or to be used
|
186
|
+
:size => Integer size of the image to allocate in MB
|
187
|
+
:datastore_id => Integer id of the datastore in OpenNebula to use
|
188
|
+
:type => ['OS', 'CDROM', 'DATABLOCK', 'KERNEL', 'RAMDISK', 'CONTEXT'] type of the image to create
|
189
|
+
:description => String description of the image
|
190
|
+
:fs_type => String type of the filesystem to create
|
191
|
+
:img_driver => String driver type
|
192
|
+
:prefix => String prefix
|
193
|
+
:persistent => [ TrueClass, FalseClass] flag indicating if the image should be persistent; default: false
|
194
|
+
:public => [ TrueClass, FalseClass ] flag indicating if the image is public
|
195
|
+
:disk_type => String Image disk type eq. ext3
|
196
|
+
:source => String Image source attribute
|
197
|
+
:target => String Image target attribute
|
198
|
+
:image_file => String Local path to the qcow image file. Default: Chef::Config[:file_cache_path]
|
199
|
+
:image_id => Integer ID of the image to download
|
200
|
+
:download_url => String OpenNebula download URL. Default is ENV['ONE_DOWNLOAD']
|
201
|
+
:driver => String Image driver eq. 'qcow2'
|
202
|
+
:machine_id => [String, Integer] id of the machine (VM) for disk attach
|
203
|
+
:disk_id => [String, Integer] id or name of the disk to attach/snapshot
|
204
|
+
```
|
205
|
+
|
206
|
+
### Actions
|
207
|
+
|
208
|
+
```ruby
|
209
|
+
actions :allocate, :create, :destroy, :attach, :snapshot, :upload, :download
|
210
|
+
default_action :create
|
211
|
+
```
|
212
|
+
|
213
|
+
```ruby
|
214
|
+
Default attribute values ONLY for image :create and :allocate actions
|
215
|
+
:type = 'OS'
|
216
|
+
:fs_type = 'ext2'
|
217
|
+
:img_driver = 'qcow2'
|
218
|
+
:prefix = 'vd'
|
219
|
+
:persistent = false
|
220
|
+
```
|
221
|
+
|
222
|
+
### Examples
|
223
|
+
|
224
|
+
#### 1. Create a datablock image with size 10Gb.
|
225
|
+
|
226
|
+
```ruby
|
227
|
+
one_image "bootstrap-img" do
|
228
|
+
type "DATABLOCK"
|
229
|
+
size 10240
|
230
|
+
datastore_id 103
|
231
|
+
action :create
|
232
|
+
end
|
233
|
+
```
|
234
|
+
|
235
|
+
#### 2. Delete a datablock image with name 'bootstrap-img'
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
one_image "bootstrap-img" do
|
239
|
+
action :destroy
|
240
|
+
end
|
241
|
+
```
|
242
|
+
|
243
|
+
#### 3. Attach a datablock image 'bootstrap-img' to a VM (test-vm) and attach it as 'vde' target. 'target' is optional.
|
244
|
+
|
245
|
+
```ruby
|
246
|
+
one_image "bootstrap-img" do
|
247
|
+
machine_id 'test-vm'
|
248
|
+
target 'vde'
|
249
|
+
action :attach
|
250
|
+
end
|
251
|
+
```
|
252
|
+
|
253
|
+
#### 4. Take a persistent snapshot of disk 1 on VM (test-vm) and save it as 'snapshot-img'
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
one_image "snapshot-img" do
|
257
|
+
machine_id "test-vm"
|
258
|
+
disk_id 1
|
259
|
+
persistent true
|
260
|
+
action :snapshot
|
261
|
+
end
|
262
|
+
```
|
263
|
+
|
264
|
+
#### 5. Take a persistent snapshot of disk 'bootstrap-img' on VM (test-vm) and save it as 'snapshot-img
|
265
|
+
|
266
|
+
```ruby
|
267
|
+
one_image "snapshot-img" do
|
268
|
+
machine_id "test-vm"
|
269
|
+
disk_id "bootstrap-img"
|
270
|
+
persistent true
|
271
|
+
action :snapshot
|
272
|
+
end
|
273
|
+
```
|
274
|
+
|
275
|
+
#### 6. Upload a local qcow2 image file to OpenNebula
|
276
|
+
|
277
|
+
```ruby
|
278
|
+
one_image "snapshot-img" do
|
279
|
+
datastore_id 103
|
280
|
+
image_file "/local/path/to/qcow/image/file"
|
281
|
+
img_driver "qcow2"
|
282
|
+
type "OS"
|
283
|
+
description "This is my cool qcow image"
|
284
|
+
action :upload
|
285
|
+
end
|
286
|
+
```
|
287
|
+
|
288
|
+
#### 7. Download a 'boggi-test-img' and store it in /home/local/my-image.qcow2. Download URL read from ENV[ONE_DOWNLOAD] variable. It will be stored locally in Chef::Config[:file_cache_path]/boggi-test-img.qcow2.
|
289
|
+
|
290
|
+
```ruby
|
291
|
+
one_image "boggi-test-img" do
|
292
|
+
action :download
|
293
|
+
end
|
294
|
+
```
|
295
|
+
|
296
|
+
#### 8. Download image ID 12345 and store it in /tmp/image.qcow2.
|
297
|
+
|
298
|
+
```ruby
|
299
|
+
one_image "boggi-test-img" do
|
300
|
+
download_url "http://my.opennebula.download.endpoint/"
|
301
|
+
image_id 12345
|
302
|
+
image_file "/tmp/image.qcow2"
|
303
|
+
action :download
|
304
|
+
end
|
305
|
+
```
|
306
|
+
|
307
|
+
## one_vnet
|
308
|
+
|
309
|
+
This resource will allow to create and delete OpenNebula vnets.
|
310
|
+
|
311
|
+
### Attributes
|
312
|
+
|
313
|
+
```ruby
|
314
|
+
:name => String name of the vnet
|
315
|
+
:vnet_id => Integer ID of the vnet that is modified
|
316
|
+
:network => Integer ID of the vnet from which a new vnet will be reserved
|
317
|
+
:size => Integer size of the new vnet
|
318
|
+
:ar_id => Integer address range identifier
|
319
|
+
:mac_ip => String ip or mac address
|
320
|
+
:template_file => String local file containing the template of a new vnet
|
321
|
+
:cluster_id => Integer cluster in which to create a vnet
|
322
|
+
```
|
323
|
+
|
324
|
+
### Actions
|
325
|
+
|
326
|
+
```ruby
|
327
|
+
actions :create, :delete, :reserve
|
328
|
+
default_action :reserve
|
329
|
+
```
|
330
|
+
|
331
|
+
### Examples
|
332
|
+
|
333
|
+
#### 1. Reserver vnet 'boggi_vnet' from parent vnet 12345 with default size 1
|
334
|
+
|
335
|
+
```ruby
|
336
|
+
one_vnet "boggi_vnet" do
|
337
|
+
network 12345
|
338
|
+
action :reserve
|
339
|
+
end
|
340
|
+
```
|
341
|
+
|
342
|
+
#### 2. Reserver vnet 'boggi_vnet' from parent vnet 12345 with size 100
|
343
|
+
|
344
|
+
```ruby
|
345
|
+
one_vnet "boggi_vnet" do
|
346
|
+
network 12345
|
347
|
+
size 100
|
348
|
+
action :reserve
|
349
|
+
end
|
350
|
+
```
|
351
|
+
|
352
|
+
#### 3. Create a VNET from template file in cluster 12345. This requires the template file not to have NAME variable populated. The resource will add NAME attribute to the template with the value being the name of the resource.
|
353
|
+
|
354
|
+
```ruby
|
355
|
+
one_vnet "boggi_vnet" do
|
356
|
+
template_file "/tmp/my_vnet.tpl"
|
357
|
+
cluster_id 12345
|
358
|
+
action :create
|
359
|
+
end
|
360
|
+
```
|
361
|
+
|
362
|
+
#### 4. Delete a vnet 'boggi_vnet'. NOTE!!! The vnet cannot have any leases in order to be deleted.
|
363
|
+
|
364
|
+
```ruby
|
365
|
+
one_vnet "boggi_vnet" do
|
366
|
+
action :delete
|
367
|
+
end
|
368
|
+
```
|
369
|
+
|
370
|
+
#### 5. Delete vnet by its ID number (12345). NOTE!!! The vnet cannot have any leases in order to be deleted.
|
371
|
+
|
372
|
+
```ruby
|
373
|
+
one_vnet "boggi_vnet" do
|
374
|
+
vnet_id 12345
|
375
|
+
action :delete
|
376
|
+
end
|
377
|
+
```
|
378
|
+
|
379
|
+
## one_vnet_lease
|
380
|
+
|
381
|
+
This resource will allow to hold and release leases within OpenNebula vnets.
|
382
|
+
|
383
|
+
### Attributes
|
384
|
+
|
385
|
+
```ruby
|
386
|
+
:name => String ip or mac address to hold/release
|
387
|
+
:vnet_id => Integer ID of the vnet that is modified
|
388
|
+
:ar_id => Integer address range identifier, where to allocate the address
|
389
|
+
:mac_ip => String ip or mac address to hold/release, same as :name
|
390
|
+
```
|
391
|
+
|
392
|
+
### Actions
|
393
|
+
|
394
|
+
```ruby
|
395
|
+
actions :hold, :release
|
396
|
+
default_action :hold
|
397
|
+
```
|
398
|
+
|
399
|
+
### Examples
|
400
|
+
|
401
|
+
#### 1. Hold a lease on a specific IP (1.2.3.4) in 'boggi_vnet' (6789)
|
402
|
+
|
403
|
+
```ruby
|
404
|
+
one_vnet_lease "1.2.3.4" do
|
405
|
+
vnet "boggi_vnet"
|
406
|
+
action :hold
|
407
|
+
end
|
408
|
+
```
|
409
|
+
|
410
|
+
#### 2. Hold a lease on a specific MAC (00:00:00:00:01) in a specific address range of 'boggi_vnet' (6789). Assuming that vnet 6789 has more than one address range.
|
411
|
+
|
412
|
+
```ruby
|
413
|
+
one_vnet_lease "00:00:00:00:01" do
|
414
|
+
vnet "boggi_vnet"
|
415
|
+
ar_id 1
|
416
|
+
action :hold
|
417
|
+
end
|
418
|
+
```
|
419
|
+
|
420
|
+
#### 3. Release a lease on a specific IP (1.2.3.4) in 'boggi_vnet' (6789). If the IP is already allocated to a VM, that VM must be deleted first, otherwise it will throw an error.
|
421
|
+
|
422
|
+
```ruby
|
423
|
+
one_vnet_lease "1.2.3.4" do
|
424
|
+
vnet "boggi_vnet"
|
425
|
+
action :release
|
426
|
+
end
|
427
|
+
```
|
428
|
+
|
429
|
+
## one_user
|
430
|
+
|
431
|
+
This resource will allow to create/delete/update OpenNebula users. Right now it does not have the full functionality as `oneuser`, but it can add key=value pairs to an existing user so that sensitive data could be stored there.
|
432
|
+
|
433
|
+
### Attributes
|
434
|
+
|
435
|
+
```ruby
|
436
|
+
:name => String ip or mac address to hold/release
|
437
|
+
:password => String password
|
438
|
+
:user_id => Integer user id
|
439
|
+
:template_file => String local template file defining a user
|
440
|
+
:template => Hash with key/value pairs that will be added to the user
|
441
|
+
:append => Boolean append to template or overwrite
|
442
|
+
```
|
443
|
+
|
444
|
+
### Actions
|
445
|
+
|
446
|
+
```ruby
|
447
|
+
actions :create, :delete, :update
|
448
|
+
default_action :update
|
449
|
+
```
|
450
|
+
|
451
|
+
### Examples
|
452
|
+
|
453
|
+
#### 1. Create a new user from template file, assuming the current ONE user has the permission to do so.
|
454
|
+
|
455
|
+
```ruby
|
456
|
+
one_user "boggi" do
|
457
|
+
template_file "<local_template_file>"
|
458
|
+
action :create
|
459
|
+
end
|
460
|
+
```
|
461
|
+
|
462
|
+
#### 2. Delete 'boggi' user, assuming the current ONE user has the permission to do so.
|
463
|
+
|
464
|
+
```ruby
|
465
|
+
one_user "boggi" do
|
466
|
+
action :delete
|
467
|
+
end
|
468
|
+
```
|
469
|
+
|
470
|
+
#### 3. Add new key/value pairs to user 'boggi', assuming the current ONE user has the permission to do so.
|
471
|
+
|
472
|
+
```ruby
|
473
|
+
one_user "boggi" do
|
474
|
+
template ({"BOGGI" => "MAGIC"})
|
475
|
+
action :update
|
476
|
+
end
|
477
|
+
```
|
478
|
+
|
479
|
+
## Rspec Integration tests
|
480
|
+
|
481
|
+
Run 'bundle exec rspec ./spec/integration/test_all_integration_spec.rb' in your chef-provisioning-opennebula folder
|
482
|
+
|
483
|
+
Set the following environment variables according to your needs:
|
484
|
+
|
485
|
+
```ruby
|
486
|
+
ENV['HOME'] - your home directory
|
487
|
+
ENV['ONE_XMLRPC'] - this is the OpenNebula endpoint url
|
488
|
+
ENV['ONE_AUTH'] - the path to your one_auth file
|
489
|
+
ENV['ONE_HTTPBASE'] - the base URL from which files are downloaded eg. chef-client.deb, init.sh, service.gz etc.
|
490
|
+
ENV['CHEF_REPO_PATH'] - the path to your local chef repo
|
491
|
+
```
|
492
|
+
|
493
|
+
## <a name="development"></a> Development
|
494
|
+
|
495
|
+
* Source hosted at [GitHub][repo]
|
496
|
+
* Report issues/questions/feature requests on [GitHub Issues][issues]
|
497
|
+
|
498
|
+
Pull requests are very welcome! Make sure your patches are well tested.
|
499
|
+
Ideally create a topic branch for every separate change you make. For
|
500
|
+
example:
|
501
|
+
|
502
|
+
1. Fork the repo
|
503
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
504
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
505
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
506
|
+
5. Create new Pull Request
|
507
|
+
|
508
|
+
## <a name="authors"></a> Authors
|
509
|
+
|
510
|
+
Created by [Bogdan Buczynski][author] (<bbuczynski@blackberry.com>)
|
511
|
+
|
512
|
+
## <a name="maintainers"></a> Maintainers
|
513
|
+
|
514
|
+
Maintained by
|
515
|
+
* [Bogdan Buczynski][author] (<bbuczynski@blackberry.com>)
|
516
|
+
* [Philip Oliva][maintainer] (<philoliva8@gmail.com>)
|
517
|
+
* [Andrew J. Brown][maintainer] (<anbrown@blackberry.com>)
|
518
|
+
* [Evgeny Yurchenko][maintainer] (<eyurchenko@blackberry.com>)
|
519
|
+
|
520
|
+
## <a name="license"></a> License
|
521
|
+
|
522
|
+
Apache 2.0 (see [LICENSE][license])
|
523
|
+
|
524
|
+
[author]: https://github.com/bbuczynski
|
525
|
+
[maintainer]: https://github.com/poliva83
|
526
|
+
[maintainer]: https://github.com/andrewjamesbrown
|
527
|
+
[maintainer]: https://github.com/EYurchenko
|
528
|
+
[issues]: https://github.com/blackberry/chef-provisioning-opennebula/issues
|
529
|
+
[license]: https://github.com/blackberry/chef-provisioning-opennebula/blob/master/LICENSE
|
530
|
+
[repo]: https://github.com/blackberry/chef-provisioning-opennebula
|
531
|
+
[driver_usage]: https://github.com/chef/chef-provisioning/blob/master/docs/building_drivers.md#writing-drivers
|
532
|
+
[chefdk_dl]: https://downloads.chef.io/chef-dk/
|