kitchen-opennebula 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +3 -3
- data/Gemfile +3 -3
- data/LICENSE +15 -15
- data/README.md +170 -157
- data/Rakefile +21 -21
- data/kitchen-opennebula.gemspec +31 -31
- data/lib/kitchen/driver/opennebula.rb +193 -189
- data/lib/kitchen/driver/opennebula_version.rb +26 -26
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 545f5bb2c0058823f7682d1aeaf6dde47e390950
|
4
|
+
data.tar.gz: 44bcb4d0c4c44a440fd7ab767404326f1c8d35d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e79c21812616427f1b7ae57f27b30d0d58517f1e4a848699e59c40ccf3435dd3ee082de8c317a63c698b86cd9c2e4a1ce8191a6c54dfb9ebf931bd0c67921c28
|
7
|
+
data.tar.gz: 43f0ca7a7e9ef1c3a3aee3eeb32cfc4ac3ec7c6110cd9dff1a413bda589788bfe668504e95dc3e6f6f74cd43c05af73b1a19b051320ce7657d33011fa48534a9
|
data/.gitignore
CHANGED
@@ -1 +1 @@
|
|
1
|
-
.project
|
1
|
+
.project
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
## 0.1.0 / Unreleased
|
2
|
-
|
3
|
-
* Initial release
|
1
|
+
## 0.1.0 / Unreleased
|
2
|
+
|
3
|
+
* Initial release
|
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
data/LICENSE
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
Author:: Andrew J. Brown (<anbrown@blackberry.com>)
|
2
|
-
|
3
|
-
Copyright (C) 2014, BlackBerry, Ltd.
|
4
|
-
|
5
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
you may not use this file except in compliance with the License.
|
7
|
-
You may obtain a copy of the License at
|
8
|
-
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
See the License for the specific language governing permissions and
|
15
|
-
limitations under the License.
|
1
|
+
Author:: Andrew J. Brown (<anbrown@blackberry.com>)
|
2
|
+
|
3
|
+
Copyright (C) 2014, BlackBerry, Ltd.
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
data/README.md
CHANGED
@@ -1,157 +1,170 @@
|
|
1
|
-
# <a name="title"></a> Kitchen::Opennebula
|
2
|
-
|
3
|
-
A Test Kitchen Driver for Opennebula.
|
4
|
-
|
5
|
-
## <a name="requirements"></a> Requirements
|
6
|
-
|
7
|
-
This driver depends on
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
The
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
[
|
157
|
-
[
|
1
|
+
# <a name="title"></a> Kitchen::Opennebula
|
2
|
+
|
3
|
+
A Test Kitchen Driver for Opennebula.
|
4
|
+
|
5
|
+
## <a name="requirements"></a> Requirements
|
6
|
+
|
7
|
+
This driver depends on [fog](https://github.com/fog/fog). Please note possibility that unreleased changes on master branch may depend on patches that can be found at https://github.com/blackberry/fog until they are merged to upstream.
|
8
|
+
|
9
|
+
## <a name="installation"></a> Installation and Setup
|
10
|
+
|
11
|
+
1. Download and install latest [ChefDK](https://downloads.chef.io/chef-dk/).
|
12
|
+
2. Please add bin locations to your PATH:
|
13
|
+
* C:\opscode\chefdk\bin;C:\opscode\chefdk\embedded\bin\ (windows)
|
14
|
+
* /opt/chefdk/bin/:/opt/chefdk/embedded/bin (unix)
|
15
|
+
3. Reopen console or reload your env PATH
|
16
|
+
4. Run following command:
|
17
|
+
gem install kitchen-opennebula --no-user-install --no-ri --no-rdoc
|
18
|
+
|
19
|
+
Please read the [config_yml_kitchen](https://docs.chef.io/config_yml_kitchen.html) page for more details.
|
20
|
+
|
21
|
+
## Virtual Machine Requirements
|
22
|
+
|
23
|
+
This driver requires an OpenNebula OS image that conforms to a number of requirements
|
24
|
+
|
25
|
+
* The VM puts the ssh key defined in the SSH\_PUBLIC\_KEY context variable into `$HOME/.ssh/authorized_keys`
|
26
|
+
* The VM ensures the user has passwordless sudo access
|
27
|
+
|
28
|
+
## <a name="config"></a> Configuration
|
29
|
+
|
30
|
+
### <a name="opennebula_endpoint"></a> opennebula\_endpoint
|
31
|
+
|
32
|
+
URL where the OpenNebula daemon is listening.
|
33
|
+
The default value is taken from the ONE\_XMLRPC environment variable, or `http://127.0.0.1:2633/RPC2` if unset.
|
34
|
+
|
35
|
+
### <a name="oneauth_file"></a> oneauth\_file
|
36
|
+
|
37
|
+
Path to the file containing OpenNebula authentication information. It should contain a single line stating "username:password".
|
38
|
+
The default value is taken from the ONE\_AUTH environment variable, or `$HOME/.one/one_auth` if unset.
|
39
|
+
|
40
|
+
### <a name="template_name"></a> template\_name
|
41
|
+
|
42
|
+
Name of the VM definition file (OpenNebula template) registered with OpenNebula. Can be used with `template_uname` or `template_uid` to further restrict which template to use if multiple users have the same template name. Only one of `template_name` or `template_id` must be specified in the .kitchen.yml file.
|
43
|
+
The default value is unset, or `nil`.
|
44
|
+
|
45
|
+
### <a name="template_id"></a> template\_id
|
46
|
+
|
47
|
+
ID of the VM definition file (OpenNebula template) registered with OpenNebula. Only one of `template_name` or `template_id` must be specified in the .kitchen.yml file.
|
48
|
+
The default value is unset, or `nil`.
|
49
|
+
|
50
|
+
### <a name="template_uname"></a> template\_uname
|
51
|
+
|
52
|
+
Username who owns the VM definition file (OpenNebula template). Can be used with `template_name` to address naming conflicts where multiple users have the same template name.
|
53
|
+
The default value is unset, or `nil`.
|
54
|
+
|
55
|
+
### <a name="template_uid"></a> template\_uid
|
56
|
+
|
57
|
+
UID of the user who owns the VM definition file (OpenNebula template). Can be used with `template_name` to address naming conflicts where multiple users have the same template name.
|
58
|
+
The default value is unset, or `nil`.
|
59
|
+
|
60
|
+
### <a name="vm_hostname"></a> vm\_hostname
|
61
|
+
|
62
|
+
Hostname to set for the newly created VM.
|
63
|
+
The default value is `driver.instance.name`
|
64
|
+
|
65
|
+
### <a name="public_key_path"></a> public\_key\_path
|
66
|
+
|
67
|
+
Path to SSH public key to pass to the VM, to use to authenticate with `username` when logging in or converging a node.
|
68
|
+
The default value is `~/.ssh/id_rsa.pub`, `~/.ssh/id_dsa.pub`, `~/.ssh/identity.pub`, or `~/.ssh/id_ecdsa.pub`, whichever is present on the filesystem.
|
69
|
+
|
70
|
+
### <a name="username"></a> username
|
71
|
+
|
72
|
+
This is the username used for SSH authentication to the new VM.
|
73
|
+
The default value is `local`.
|
74
|
+
|
75
|
+
### <a name="memory"></a> memory
|
76
|
+
|
77
|
+
The amount of memory to provision for the new VM. This parameter will override the memory settings provided in the VM template.
|
78
|
+
The default value is 512MB.
|
79
|
+
|
80
|
+
### <a name="user_variables"></a> user\_variables
|
81
|
+
|
82
|
+
A hash of variables to pass into the "user template" section of the VM, to customize the virtual machine.
|
83
|
+
The default value is `{}`.
|
84
|
+
|
85
|
+
### <a name="context_variables"></a> context\_variables
|
86
|
+
|
87
|
+
A hash of variables to pass into the "CONTEXT" section of the VM, to further customize the virtual machine. These variables override any existing context variables that are provided as part of the specified VM template.
|
88
|
+
The default value is `{}`.
|
89
|
+
|
90
|
+
### <a name="config-require-chef-omnibus"></a> require\_chef\_omnibus
|
91
|
+
|
92
|
+
Determines whether or not a Chef [Omnibus package][chef_omnibus_dl] will be
|
93
|
+
installed. There are several different behaviors available:
|
94
|
+
|
95
|
+
* `true` - the latest release will be installed. Subsequent converges
|
96
|
+
will skip re-installing if chef is present.
|
97
|
+
* `latest` - the latest release will be installed. Subsequent converges
|
98
|
+
will always re-install even if chef is present.
|
99
|
+
* `<VERSION_STRING>` (ex: `10.24.0`) - the desired version string will
|
100
|
+
be passed the the install.sh script. Subsequent converges will skip if
|
101
|
+
the installed version and the desired version match.
|
102
|
+
* `false` or `nil` - no chef is installed.
|
103
|
+
|
104
|
+
The default value is unset, or `nil`.
|
105
|
+
|
106
|
+
### <a name="wait_for"></a> wait_for
|
107
|
+
|
108
|
+
This variable is used to override timeout for Fog's common `wait_for` method which states that it "takes a block and waits for either the block to return true for the object or for a timeout (defaults to 10 minutes)".
|
109
|
+
|
110
|
+
### <a name="no_ssh_tcp_check"></a> no\_ssh\_tcp\_check
|
111
|
+
|
112
|
+
To avoid test-kitchen's ssh tcp check in the create phase you can set `no_ssh_tcp_check` to `true` and do single sleep instead. Sleep period is configured by `no_ssh_tcp_check_sleep`. The default for `no_ssh_tcp_check` is set to `false`.
|
113
|
+
|
114
|
+
### <a name="no_ssh_tcp_check_sleep"></a> no\_ssh\_tcp\_check\_sleep
|
115
|
+
|
116
|
+
This variable configures a single sleep used when `no_ssh_tcp_check` is set to `true`. The default for `no_ssh_tcp_check` is 2 minutes.
|
117
|
+
|
118
|
+
### <a name="no_passwordless_sudo_check"></a> no\_passwordless\_sudo\_check
|
119
|
+
|
120
|
+
To avoid test-kitchen's passwordless sudo check in the create phase you can set `no_passwordless_sudo_check` to `true` and do single sleep instead. Sleep period is configured by `no_passwordless_sudo_sleep`. The default for `no_passwordless_sudo_check` is set to `false`.
|
121
|
+
|
122
|
+
### <a name="no_passwordless_sudo_sleep"></a> no\_passwordless\_sudo\_sleep
|
123
|
+
|
124
|
+
This variable configures a single sleep used when `no_passwordless_sudo_check` is set to `true`. The default for `no_passwordless_sudo_sleep` is 2 minutes.
|
125
|
+
|
126
|
+
### <a name="passwordless_sudo_timeout"></a> passwordless\_sudo\_timeout
|
127
|
+
|
128
|
+
This variable configures the max timeout will wait in the create phase for passwordless sudo to be setup. The variable is used when `no_passwordless_sudo_check` is set to `false`. The default for `passwordless_sudo_timeout` is 5 minutes.
|
129
|
+
|
130
|
+
### <a name="passwordless_sudo_retry_interval"></a> passwordless\_sudo\_retry\_interval
|
131
|
+
|
132
|
+
This variable configures retry interval in the create phase to periodically check that passwordless sudo is setup. It does this until max timeout (set by `passwordless_sudo_timeout`) is reached. The variable is used when `no_passwordless_sudo_check` is set to `false`. The default for `passwordless_sudo_retry_interval` is 10 seconds.
|
133
|
+
|
134
|
+
## <a name="development"></a> Development
|
135
|
+
|
136
|
+
* Source hosted at [GitHub][repo]
|
137
|
+
* Report issues/questions/feature requests on [GitHub Issues][issues]
|
138
|
+
|
139
|
+
Pull requests are very welcome! Make sure your patches are well tested.
|
140
|
+
Ideally create a topic branch for every separate change you make. For
|
141
|
+
example:
|
142
|
+
|
143
|
+
1. Fork the repo
|
144
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
145
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
146
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
147
|
+
5. Create new Pull Request
|
148
|
+
|
149
|
+
## <a name="authors"></a> Authors
|
150
|
+
|
151
|
+
Created by [Andrew Brown][author] (<anbrown@blackberry.com>)
|
152
|
+
|
153
|
+
## <a name="maintainers"></a> Maintainers
|
154
|
+
|
155
|
+
Maintained by
|
156
|
+
* [Andrew Brown][author] (<anbrown@blackberry.com>)
|
157
|
+
* [Philip Oliva][maintainer] (<philoliva8@gmail.com>)
|
158
|
+
|
159
|
+
## <a name="license"></a> License
|
160
|
+
|
161
|
+
Apache 2.0 (see [LICENSE][license])
|
162
|
+
|
163
|
+
|
164
|
+
[author]: https://github.com/andrewjamesbrown
|
165
|
+
[maintainer]: https://github.com/poliva83
|
166
|
+
[issues]: https://github.com/test-kitchen/kitchen-opennebula/issues
|
167
|
+
[license]: https://github.com/test-kitchen/kitchen-opennebula/blob/master/LICENSE
|
168
|
+
[repo]: https://github.com/test-kitchen/kitchen-opennebula
|
169
|
+
[driver_usage]: http://docs.kitchen-ci.org/drivers/usage
|
170
|
+
[chef_omnibus_dl]: http://www.getchef.com/chef/install/
|
data/Rakefile
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require 'cane/rake_task'
|
3
|
-
require 'tailor/rake_task'
|
4
|
-
|
5
|
-
desc "Run cane to check quality metrics"
|
6
|
-
Cane::RakeTask.new do |cane|
|
7
|
-
cane.canefile = './.cane'
|
8
|
-
end
|
9
|
-
|
10
|
-
Tailor::RakeTask.new
|
11
|
-
|
12
|
-
desc "Display LOC stats"
|
13
|
-
task :stats do
|
14
|
-
puts "\n## Production Code Stats"
|
15
|
-
sh "countloc -r lib"
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "Run all quality tasks"
|
19
|
-
task :quality => [:cane, :tailor, :stats]
|
20
|
-
|
21
|
-
task :default => [:quality]
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'cane/rake_task'
|
3
|
+
require 'tailor/rake_task'
|
4
|
+
|
5
|
+
desc "Run cane to check quality metrics"
|
6
|
+
Cane::RakeTask.new do |cane|
|
7
|
+
cane.canefile = './.cane'
|
8
|
+
end
|
9
|
+
|
10
|
+
Tailor::RakeTask.new
|
11
|
+
|
12
|
+
desc "Display LOC stats"
|
13
|
+
task :stats do
|
14
|
+
puts "\n## Production Code Stats"
|
15
|
+
sh "countloc -r lib"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run all quality tasks"
|
19
|
+
task :quality => [:cane, :tailor, :stats]
|
20
|
+
|
21
|
+
task :default => [:quality]
|
data/kitchen-opennebula.gemspec
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'kitchen/driver/opennebula_version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'kitchen-opennebula'
|
8
|
-
spec.version = Kitchen::Driver::OPENNEBULA_VERSION
|
9
|
-
spec.authors = ['Andrew J. Brown']
|
10
|
-
spec.email = ['anbrown@blackberry.com']
|
11
|
-
spec.description = %q{A Test Kitchen Driver for Opennebula}
|
12
|
-
spec.summary = spec.description
|
13
|
-
spec.homepage = ''
|
14
|
-
spec.license = 'Apache 2.0'
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = []
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ['lib']
|
20
|
-
|
21
|
-
spec.add_dependency 'test-kitchen', '~> 1.2'
|
22
|
-
spec.add_dependency 'fog', '~> 1.
|
23
|
-
spec.add_dependency 'opennebula'
|
24
|
-
|
25
|
-
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
|
-
spec.add_development_dependency 'rake'
|
27
|
-
|
28
|
-
spec.add_development_dependency 'cane'
|
29
|
-
spec.add_development_dependency 'tailor'
|
30
|
-
spec.add_development_dependency 'countloc'
|
31
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kitchen/driver/opennebula_version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'kitchen-opennebula'
|
8
|
+
spec.version = Kitchen::Driver::OPENNEBULA_VERSION
|
9
|
+
spec.authors = ['Andrew J. Brown']
|
10
|
+
spec.email = ['anbrown@blackberry.com']
|
11
|
+
spec.description = %q{A Test Kitchen Driver for Opennebula}
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'Apache 2.0'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = []
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'test-kitchen', '~> 1.2'
|
22
|
+
spec.add_dependency 'fog', '~> 1.30'
|
23
|
+
spec.add_dependency 'opennebula'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
|
+
spec.add_development_dependency 'rake'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'cane'
|
29
|
+
spec.add_development_dependency 'tailor'
|
30
|
+
spec.add_development_dependency 'countloc'
|
31
|
+
end
|
@@ -1,189 +1,193 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Author:: Andrew J. Brown (<anbrown@blackberry.com>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2014, BlackBerry, Ltd.
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
|
19
|
-
require 'fog'
|
20
|
-
require 'kitchen'
|
21
|
-
|
22
|
-
module Kitchen
|
23
|
-
|
24
|
-
module Driver
|
25
|
-
|
26
|
-
# Opennebula driver for Kitchen.
|
27
|
-
#
|
28
|
-
# @author Andrew J. Brown <anbrown@blackberry.com>
|
29
|
-
class Opennebula < Kitchen::Driver::SSHBase
|
30
|
-
default_config :opennebula_endpoint,
|
31
|
-
ENV.fetch('ONE_XMLRPC', 'http://127.0.0.1:2633/RPC2')
|
32
|
-
|
33
|
-
default_config :oneauth_file,
|
34
|
-
ENV.fetch('ONE_AUTH', "#{ENV['HOME']}/.one/one_auth")
|
35
|
-
|
36
|
-
default_config :vm_hostname do |driver|
|
37
|
-
"#{driver.instance.name}"
|
38
|
-
end
|
39
|
-
|
40
|
-
default_config :public_key_path do
|
41
|
-
[
|
42
|
-
File.expand_path('~/.ssh/id_rsa.pub'),
|
43
|
-
File.expand_path('~/.ssh/id_dsa.pub'),
|
44
|
-
File.expand_path('~/.ssh/identity.pub'),
|
45
|
-
File.expand_path('~/.ssh/id_ecdsa.pub')
|
46
|
-
].find { |path| File.exist?(path) }
|
47
|
-
end
|
48
|
-
|
49
|
-
default_config :username, 'local'
|
50
|
-
default_config :memory, 512
|
51
|
-
default_config :user_variables, { }
|
52
|
-
default_config :context_variables, { }
|
53
|
-
|
54
|
-
default_config :wait_for, 600
|
55
|
-
default_config :no_ssh_tcp_check, false
|
56
|
-
default_config :no_ssh_tcp_check_sleep, 120
|
57
|
-
default_config :no_passwordless_sudo_check, false
|
58
|
-
default_config :no_passwordless_sudo_sleep, 120
|
59
|
-
|
60
|
-
def initialize(config)
|
61
|
-
super
|
62
|
-
Fog.timeout = config[:wait_for].to_i
|
63
|
-
end
|
64
|
-
|
65
|
-
def create(state)
|
66
|
-
conn = opennebula_connect
|
67
|
-
|
68
|
-
#
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
newvm.flavor =
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
end
|
158
|
-
|
159
|
-
def
|
160
|
-
super
|
161
|
-
end
|
162
|
-
|
163
|
-
def
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Andrew J. Brown (<anbrown@blackberry.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, BlackBerry, Ltd.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require 'fog'
|
20
|
+
require 'kitchen'
|
21
|
+
|
22
|
+
module Kitchen
|
23
|
+
|
24
|
+
module Driver
|
25
|
+
|
26
|
+
# Opennebula driver for Kitchen.
|
27
|
+
#
|
28
|
+
# @author Andrew J. Brown <anbrown@blackberry.com>
|
29
|
+
class Opennebula < Kitchen::Driver::SSHBase
|
30
|
+
default_config :opennebula_endpoint,
|
31
|
+
ENV.fetch('ONE_XMLRPC', 'http://127.0.0.1:2633/RPC2')
|
32
|
+
|
33
|
+
default_config :oneauth_file,
|
34
|
+
ENV.fetch('ONE_AUTH', "#{ENV['HOME']}/.one/one_auth")
|
35
|
+
|
36
|
+
default_config :vm_hostname do |driver|
|
37
|
+
"#{driver.instance.name}"
|
38
|
+
end
|
39
|
+
|
40
|
+
default_config :public_key_path do
|
41
|
+
[
|
42
|
+
File.expand_path('~/.ssh/id_rsa.pub'),
|
43
|
+
File.expand_path('~/.ssh/id_dsa.pub'),
|
44
|
+
File.expand_path('~/.ssh/identity.pub'),
|
45
|
+
File.expand_path('~/.ssh/id_ecdsa.pub')
|
46
|
+
].find { |path| File.exist?(path) }
|
47
|
+
end
|
48
|
+
|
49
|
+
default_config :username, 'local'
|
50
|
+
default_config :memory, 512
|
51
|
+
default_config :user_variables, { }
|
52
|
+
default_config :context_variables, { }
|
53
|
+
|
54
|
+
default_config :wait_for, 600
|
55
|
+
default_config :no_ssh_tcp_check, false
|
56
|
+
default_config :no_ssh_tcp_check_sleep, 120
|
57
|
+
default_config :no_passwordless_sudo_check, false
|
58
|
+
default_config :no_passwordless_sudo_sleep, 120
|
59
|
+
|
60
|
+
def initialize(config)
|
61
|
+
super
|
62
|
+
Fog.timeout = config[:wait_for].to_i
|
63
|
+
end
|
64
|
+
|
65
|
+
def create(state)
|
66
|
+
conn = opennebula_connect
|
67
|
+
|
68
|
+
# Ensure we can authenticate with OpenNebula
|
69
|
+
rc = conn.client.get_version
|
70
|
+
raise(rc.message) if OpenNebula.is_error?(rc)
|
71
|
+
|
72
|
+
# Check if VM is already created.
|
73
|
+
if state[:vm_id] && !conn.list_vms({:id => state[:vm_id]}).empty?
|
74
|
+
info("OpenNebula instance #{instance.to_str} already created.")
|
75
|
+
return
|
76
|
+
end
|
77
|
+
|
78
|
+
if config[:template_id].nil? and config[:template_name].nil?
|
79
|
+
raise "template_name or template_id not specified in .kitchen.yml"
|
80
|
+
elsif !config[:template_id].nil? and !config[:template_name].nil?
|
81
|
+
raise "Only one of template_name or template_id should be specified in .kitchen.yml"
|
82
|
+
end
|
83
|
+
|
84
|
+
newvm = conn.servers.new
|
85
|
+
if config[:template_id]
|
86
|
+
newvm.flavor = conn.flavors.get config[:template_id]
|
87
|
+
elsif config[:template_name]
|
88
|
+
filter = {
|
89
|
+
:name => config[:template_name],
|
90
|
+
:uname => config[:template_uname],
|
91
|
+
:uid => config[:template_uid]
|
92
|
+
}
|
93
|
+
newvm.flavor = conn.flavors.get_by_filter filter
|
94
|
+
if !newvm.flavor.nil? and newvm.flavor.length > 1
|
95
|
+
raise 'More than one template found. Please restrict using template_uname'
|
96
|
+
end
|
97
|
+
newvm.flavor = newvm.flavor.first unless newvm.flavor.nil?
|
98
|
+
end
|
99
|
+
if newvm.flavor.nil?
|
100
|
+
raise "Could not find template to create VM. -- Verify your template filters and one_auth credentials"
|
101
|
+
end
|
102
|
+
newvm.name = config[:vm_hostname]
|
103
|
+
|
104
|
+
newvm.flavor.user_variables = {} if newvm.flavor.user_variables.nil? || newvm.flavor.user_variables.empty?
|
105
|
+
config[:user_variables].each do |key, val|
|
106
|
+
newvm.flavor.user_variables[key.to_s] = val
|
107
|
+
end
|
108
|
+
|
109
|
+
newvm.flavor.context = {} if newvm.flavor.context.nil? || newvm.flavor.context.empty?
|
110
|
+
newvm.flavor.context['SSH_PUBLIC_KEY'] = File.read(config[:public_key_path]).chomp
|
111
|
+
newvm.flavor.context['TEST_KITCHEN'] = "YES"
|
112
|
+
# Support for overriding context variables in the VM template
|
113
|
+
config[:context_variables].each do |key, val|
|
114
|
+
newvm.flavor.context[key.to_s] = val
|
115
|
+
end
|
116
|
+
newvm.flavor.memory = config[:memory]
|
117
|
+
|
118
|
+
# TODO: Set up NIC and disk if not specified in template
|
119
|
+
vm = newvm.save
|
120
|
+
vm.wait_for { ready? }
|
121
|
+
state[:vm_id] = vm.id
|
122
|
+
state[:hostname] = vm.ip
|
123
|
+
state[:username] = config[:username]
|
124
|
+
tcp_check(state)
|
125
|
+
passwordless_sudo_check(state)
|
126
|
+
info("OpenNebula instance #{instance.to_str} created.")
|
127
|
+
end
|
128
|
+
|
129
|
+
def tcp_check(state)
|
130
|
+
wait_for_sshd(state[:hostname]) unless config[:no_ssh_tcp_check]
|
131
|
+
sleep(config[:no_ssh_tcp_check_sleep]) if config[:no_ssh_tcp_check]
|
132
|
+
debug("SSH ready on #{instance.to_str}")
|
133
|
+
end
|
134
|
+
|
135
|
+
def passwordless_sudo_check(state)
|
136
|
+
wait_for_passwordless_sudo(state) unless config[:no_passwordless_sudo_check]
|
137
|
+
sleep(config[:no_passwordless_sudo_sleep]) if config[:no_passwordless_sudo_check]
|
138
|
+
debug("Passwordless sudo ready on #{instance.to_str}")
|
139
|
+
end
|
140
|
+
|
141
|
+
def wait_for_passwordless_sudo(state)
|
142
|
+
Kitchen::SSH.new(*build_ssh_args(state)) do |conn|
|
143
|
+
retries = config[:passwordless_sudo_timeout] || 300
|
144
|
+
retry_interval = config[:passwordless_sudo_retry_interval] || 10
|
145
|
+
begin
|
146
|
+
logger.info("Waiting #{retries.to_s} seconds for #{config[:username]} user to be granted passwordless sudo on #{state[:hostname]}...")
|
147
|
+
retries -= retry_interval
|
148
|
+
run_remote("sudo -n true", conn)
|
149
|
+
rescue ActionFailed => e
|
150
|
+
if (e.message.eql? "SSH exited (1) for command: [sudo -n true]") && (retries >= 0)
|
151
|
+
sleep retry_interval
|
152
|
+
retry
|
153
|
+
end
|
154
|
+
raise ActionFailed, e.message
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def converge(state)
|
160
|
+
super
|
161
|
+
end
|
162
|
+
|
163
|
+
def verify(state)
|
164
|
+
super
|
165
|
+
end
|
166
|
+
|
167
|
+
def destroy(state)
|
168
|
+
conn = opennebula_connect
|
169
|
+
conn.servers.destroy(state[:vm_id])
|
170
|
+
end
|
171
|
+
|
172
|
+
protected
|
173
|
+
|
174
|
+
def opennebula_connect()
|
175
|
+
opennebula_creds = nil
|
176
|
+
if File.exists?(config[:oneauth_file])
|
177
|
+
opennebula_creds = File.read(config[:oneauth_file])
|
178
|
+
else
|
179
|
+
raise ActionFailed, "Could not find one_auth file #{config[:oneauth_file]}"
|
180
|
+
end
|
181
|
+
opennebula_username = opennebula_creds.split(':')[0]
|
182
|
+
opennebula_password = opennebula_creds.split(':')[1]
|
183
|
+
conn = Fog::Compute.new( {
|
184
|
+
:provider => 'OpenNebula',
|
185
|
+
:opennebula_username => opennebula_username,
|
186
|
+
:opennebula_password => opennebula_password,
|
187
|
+
:opennebula_endpoint => config[:opennebula_endpoint]
|
188
|
+
} )
|
189
|
+
conn
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Author:: Andrew Brown (<anbrown@blackberry.com>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2014, BlackBerry, Ltd.
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
|
19
|
-
module Kitchen
|
20
|
-
|
21
|
-
module Driver
|
22
|
-
|
23
|
-
# Version string for Opennebula Kitchen driver
|
24
|
-
OPENNEBULA_VERSION = "0.1.
|
25
|
-
end
|
26
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Andrew Brown (<anbrown@blackberry.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, BlackBerry, Ltd.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
module Kitchen
|
20
|
+
|
21
|
+
module Driver
|
22
|
+
|
23
|
+
# Version string for Opennebula Kitchen driver
|
24
|
+
OPENNEBULA_VERSION = "0.1.2"
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-opennebula
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew J. Brown
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.30'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.30'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: opennebula
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,9 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
158
|
version: '0'
|
159
159
|
requirements: []
|
160
160
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.
|
161
|
+
rubygems_version: 2.0.14
|
162
162
|
signing_key:
|
163
163
|
specification_version: 4
|
164
164
|
summary: A Test Kitchen Driver for Opennebula
|
165
165
|
test_files: []
|
166
|
-
has_rdoc:
|