vagrant-ovirt4 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +54 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +131 -16
- data/README.md +31 -3
- data/Rakefile +4 -0
- data/SECURITY.md +23 -0
- data/lib/vagrant-ovirt4/action/connect_ovirt.rb +29 -7
- data/lib/vagrant-ovirt4/action/create_vm.rb +9 -6
- data/lib/vagrant-ovirt4/action/disconnect_ovirt.rb +4 -1
- data/lib/vagrant-ovirt4/action/read_ssh_info.rb +20 -11
- data/lib/vagrant-ovirt4/action/snapshot_list.rb +15 -19
- data/lib/vagrant-ovirt4/action/start_vm.rb +5 -2
- data/lib/vagrant-ovirt4/config.rb +31 -1
- data/lib/vagrant-ovirt4/errors.rb +4 -0
- data/lib/vagrant-ovirt4/util/connection.rb +40 -0
- data/lib/vagrant-ovirt4/util/machine_names.rb +21 -0
- data/lib/vagrant-ovirt4/version.rb +1 -1
- data/lib/vagrant-ovirt4.rb +4 -0
- data/locales/en.yml +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/shared_context.rb +39 -0
- data/spec/vagrant-ovirt4/action/create_vm_spec.rb +47 -0
- data/spec/vagrant-ovirt4/action/read_ssh_info_spec.rb +31 -17
- data/spec/vagrant-ovirt4/action/start_vm_spec.rb +54 -0
- data/spec/vagrant-ovirt4/config_spec.rb +200 -15
- data/spec/vagrant-ovirt4/util/connection_spec.rb +80 -0
- data/vagrant-ovirt4.gemspec +2 -2
- metadata +24 -13
- data/.github/workflows/release.yml +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9d8f5174e1f8b016b4b832ec0ad9b90306bfb2bddde338213d29c697010b43d
|
4
|
+
data.tar.gz: '0637690ae57219b53d018430ab5573495a086ec7ed1ceb2d90d6f2f6f670c629'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90e8331a727b24e155d29dcf1d3f8567903f5b7eef088d64dd4b7da363ee32e68bae8ee2ff32e80e002cfa57745d1047b0c3b521b08322bab74457f5095f251d
|
7
|
+
data.tar.gz: c5b3b0a0c3d05a34ad1f89c716314b50ec39c0157c40f93d3a74cc0b531f37d76c16468b7ed20386751da2683eda9bdcbcc45999e5eaac724e9ea44209c53f8b
|
data/CHANGELOG
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
v2.2.0
|
2
|
+
ef555e3 Config spec: assert that we test all attributes
|
3
|
+
6e47c1b Add tests for additional configuration params
|
4
|
+
|
5
|
+
v2.1.2
|
6
|
+
79a0074 Fix lock file
|
7
|
+
|
8
|
+
v2.1.1
|
9
|
+
605663e Bump nokogiri from 1.13.3 to 1.13.4
|
10
|
+
2981f5c Default to disabling run-once mode
|
11
|
+
f048313 Enable oVirt conn debugging when VAGRANT_LOG=info
|
12
|
+
3555e36 Add safe connection closing methods
|
13
|
+
cdb765c Support :timeout and :timeout_connect options
|
14
|
+
tomeon/test-all-vmtype-andvmaffinity-values
|
15
|
+
2a9a653 Rakefile: add RSpec task
|
16
|
+
7641780 test all valid VmType and VmAffinity values
|
17
|
+
54efcde Add tests for vmname and hostname settings
|
18
|
+
dc3ab3e Add "vmname" provider option
|
19
|
+
233e4bb read_ssh_info: return nil on IPv4 lookup failure
|
20
|
+
fcff147 Bump nokogiri from 1.12.5 to 1.13.3
|
21
|
+
da44f24 Bump nokogiri from 1.11.4 to 1.12.5
|
22
|
+
9025f4e Bump nokogiri from 1.11.3 to 1.11.4
|
23
|
+
|
24
|
+
v2.1.0
|
25
|
+
41b8c63 Move where rspec-mocks is included.
|
26
|
+
0015c45 Update engine binding.
|
27
|
+
b2a0015 Not actually using the vagrant-spec thing.
|
28
|
+
a598043 Address the change in parsing.
|
29
|
+
0ad3b72 Get the tests runnable.
|
30
|
+
a8f1d5f Test the connection before passing it on for use.
|
31
|
+
8adf277 list only snapshots for vm's defined in the environment
|
32
|
+
a2ee89b Add security.md
|
33
|
+
3399aab Add CHANGELOG
|
34
|
+
|
35
|
+
v2.0.0
|
36
|
+
|
37
|
+
1810832 Attempt to fix gem push
|
38
|
+
9d1ef6b handle fallback with rescue
|
39
|
+
6cc0f90 fix for backwards compatibility with ovirt 4.3
|
40
|
+
2298314 Make no assumptions on biosdevname/systemd device naming
|
41
|
+
1d870df Support for network interfaces named by biosdevname
|
42
|
+
5c8035a add missing translation
|
43
|
+
f9b6e28 fixed double disconnect due to action_up used in combination wth with_ovirt
|
44
|
+
96f17c0 fixed doule disconnect on reload due to use of with_ovirt
|
45
|
+
697e3d4 fixed inconsistent usages of memory units (MB/MiB and GB/GiB)
|
46
|
+
5a68e8b vagrant destroy only calls halt if vm is up
|
47
|
+
8772ee9 fix for erroneous rsync and state error due to missing ip address
|
48
|
+
5b49114 Bump nokogiri from 1.10.9 to 1.11.0
|
49
|
+
b8314fb fix for waiting indefinitely for an ip when deploying on ovirt 4.4
|
50
|
+
722f2e0 Default to rsync instead of NFS like before
|
51
|
+
2582f53 Use vagrant builtin rsync folder sync
|
52
|
+
84c6c53 In case graceful shutdown failed, fallback to stopping VM immediately
|
53
|
+
640d640 Fix up dependencies
|
54
|
+
029b53b give guests a chance to shutdown gracefully before pulling the plug with a poweroff
|
data/Gemfile
CHANGED
@@ -3,10 +3,13 @@ source 'http://rubygems.org'
|
|
3
3
|
group :development do
|
4
4
|
gem 'rake'
|
5
5
|
gem 'rspec-core'
|
6
|
+
gem 'rspec-its'
|
7
|
+
gem "rspec-mocks", "~> 3.5"
|
6
8
|
gem 'pry'
|
7
9
|
gem 'byebug'
|
8
10
|
gem 'pry-byebug'
|
9
11
|
gem 'rake-release'
|
12
|
+
gem "vagrant", git: "https://github.com/hashicorp/vagrant.git"
|
10
13
|
end
|
11
14
|
|
12
15
|
group :plugins do
|
data/Gemfile.lock
CHANGED
@@ -1,38 +1,150 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/hashicorp/vagrant.git
|
3
|
+
revision: 22795b161bf67a4c0ebbe32c9ce8777cb888c4a7
|
4
|
+
specs:
|
5
|
+
vagrant (2.2.11.dev)
|
6
|
+
bcrypt_pbkdf (~> 1.0.0)
|
7
|
+
childprocess (~> 4.0.0)
|
8
|
+
ed25519 (~> 1.2.4)
|
9
|
+
erubi
|
10
|
+
hashicorp-checkpoint (~> 0.1.5)
|
11
|
+
i18n (~> 1.8)
|
12
|
+
listen (~> 3.1)
|
13
|
+
log4r (~> 1.1.9, < 1.1.11)
|
14
|
+
mime (~> 0.4.4)
|
15
|
+
net-scp (~> 1.2.0)
|
16
|
+
net-sftp (~> 3.0)
|
17
|
+
net-ssh (~> 6.0)
|
18
|
+
rb-kqueue (~> 0.2.0)
|
19
|
+
rest-client (>= 1.6.0, < 3.0)
|
20
|
+
ruby_dep (<= 1.3.1)
|
21
|
+
rubyzip (~> 2.0)
|
22
|
+
vagrant_cloud (~> 2.0.3)
|
23
|
+
wdm (~> 0.1.0)
|
24
|
+
winrm (>= 2.3.4, < 3.0)
|
25
|
+
winrm-elevated (>= 1.2.1, < 2.0)
|
26
|
+
winrm-fs (>= 1.3.4, < 2.0)
|
27
|
+
|
1
28
|
PATH
|
2
29
|
remote: .
|
3
30
|
specs:
|
4
|
-
vagrant-ovirt4 (2.
|
31
|
+
vagrant-ovirt4 (2.2.0)
|
5
32
|
filesize (~> 0)
|
6
|
-
nokogiri (
|
7
|
-
ovirt-engine-sdk (~> 4
|
33
|
+
nokogiri (~> 1)
|
34
|
+
ovirt-engine-sdk (~> 4)
|
8
35
|
|
9
36
|
GEM
|
10
37
|
remote: http://rubygems.org/
|
11
38
|
specs:
|
39
|
+
bcrypt_pbkdf (1.0.1)
|
40
|
+
builder (3.2.4)
|
12
41
|
byebug (11.1.3)
|
13
|
-
|
42
|
+
childprocess (4.0.0)
|
43
|
+
coderay (1.1.3)
|
44
|
+
concurrent-ruby (1.1.10)
|
45
|
+
diff-lcs (1.5.0)
|
46
|
+
domain_name (0.5.20190701)
|
47
|
+
unf (>= 0.0.5, < 1.0.0)
|
48
|
+
ed25519 (1.2.4)
|
49
|
+
erubi (1.10.0)
|
50
|
+
ffi (1.15.5)
|
14
51
|
filesize (0.2.0)
|
15
|
-
|
52
|
+
gssapi (1.3.1)
|
53
|
+
ffi (>= 1.0.1)
|
54
|
+
gyoku (1.4.0)
|
55
|
+
builder (>= 2.1.2)
|
56
|
+
rexml (~> 3.0)
|
57
|
+
hashicorp-checkpoint (0.1.5)
|
58
|
+
http-cookie (1.0.4)
|
59
|
+
domain_name (~> 0.5)
|
60
|
+
httpclient (2.8.3)
|
61
|
+
i18n (1.10.0)
|
62
|
+
concurrent-ruby (~> 1.0)
|
63
|
+
json (2.6.1)
|
64
|
+
listen (3.7.1)
|
65
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
66
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
67
|
+
little-plugger (1.1.4)
|
68
|
+
log4r (1.1.10)
|
69
|
+
logging (2.3.0)
|
70
|
+
little-plugger (~> 1.1)
|
71
|
+
multi_json (~> 1.14)
|
16
72
|
method_source (1.0.0)
|
17
|
-
|
18
|
-
|
19
|
-
|
73
|
+
mime (0.4.4)
|
74
|
+
mime-types (3.4.1)
|
75
|
+
mime-types-data (~> 3.2015)
|
76
|
+
mime-types-data (3.2022.0105)
|
77
|
+
multi_json (1.15.0)
|
78
|
+
net-scp (1.2.1)
|
79
|
+
net-ssh (>= 2.6.5)
|
80
|
+
net-sftp (3.0.0)
|
81
|
+
net-ssh (>= 5.0.0, < 7.0.0)
|
82
|
+
net-ssh (6.1.0)
|
83
|
+
netrc (0.11.0)
|
84
|
+
nokogiri (1.13.4-x86_64-darwin)
|
20
85
|
racc (~> 1.4)
|
21
|
-
|
22
|
-
|
86
|
+
nori (2.6.0)
|
87
|
+
ovirt-engine-sdk (4.4.1)
|
88
|
+
json (>= 1, < 3)
|
23
89
|
pry (0.13.1)
|
24
90
|
coderay (~> 1.1)
|
25
91
|
method_source (~> 1.0)
|
26
92
|
pry-byebug (3.9.0)
|
27
93
|
byebug (~> 11.0)
|
28
94
|
pry (~> 0.13.0)
|
29
|
-
racc (1.
|
30
|
-
rake (13.0.
|
31
|
-
rake-release (1.
|
95
|
+
racc (1.6.0)
|
96
|
+
rake (13.0.6)
|
97
|
+
rake-release (1.3.0)
|
32
98
|
bundler (>= 1.11, < 3)
|
33
|
-
|
34
|
-
|
35
|
-
|
99
|
+
rb-fsevent (0.11.1)
|
100
|
+
rb-inotify (0.10.1)
|
101
|
+
ffi (~> 1.0)
|
102
|
+
rb-kqueue (0.2.8)
|
103
|
+
ffi (>= 0.5.0)
|
104
|
+
rest-client (2.0.2)
|
105
|
+
http-cookie (>= 1.0.2, < 2.0)
|
106
|
+
mime-types (>= 1.16, < 4.0)
|
107
|
+
netrc (~> 0.8)
|
108
|
+
rexml (3.2.5)
|
109
|
+
rspec-core (3.11.0)
|
110
|
+
rspec-support (~> 3.11.0)
|
111
|
+
rspec-expectations (3.11.0)
|
112
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
113
|
+
rspec-support (~> 3.11.0)
|
114
|
+
rspec-its (1.3.0)
|
115
|
+
rspec-core (>= 3.0.0)
|
116
|
+
rspec-expectations (>= 3.0.0)
|
117
|
+
rspec-mocks (3.11.1)
|
118
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
119
|
+
rspec-support (~> 3.11.0)
|
120
|
+
rspec-support (3.11.0)
|
121
|
+
ruby_dep (1.3.1)
|
122
|
+
rubyntlm (0.6.3)
|
123
|
+
rubyzip (2.3.2)
|
124
|
+
unf (0.1.4)
|
125
|
+
unf_ext
|
126
|
+
unf_ext (0.0.8.1)
|
127
|
+
vagrant_cloud (2.0.3)
|
128
|
+
rest-client (~> 2.0.2)
|
129
|
+
wdm (0.1.1)
|
130
|
+
winrm (2.3.6)
|
131
|
+
builder (>= 2.1.2)
|
132
|
+
erubi (~> 1.8)
|
133
|
+
gssapi (~> 1.2)
|
134
|
+
gyoku (~> 1.0)
|
135
|
+
httpclient (~> 2.2, >= 2.2.0.2)
|
136
|
+
logging (>= 1.6.1, < 3.0)
|
137
|
+
nori (~> 2.0)
|
138
|
+
rubyntlm (~> 0.6.0, >= 0.6.3)
|
139
|
+
winrm-elevated (1.2.3)
|
140
|
+
erubi (~> 1.8)
|
141
|
+
winrm (~> 2.0)
|
142
|
+
winrm-fs (~> 1.0)
|
143
|
+
winrm-fs (1.3.5)
|
144
|
+
erubi (~> 1.8)
|
145
|
+
logging (>= 1.6.1, < 3.0)
|
146
|
+
rubyzip (~> 2.0)
|
147
|
+
winrm (~> 2.0)
|
36
148
|
|
37
149
|
PLATFORMS
|
38
150
|
ruby
|
@@ -44,6 +156,9 @@ DEPENDENCIES
|
|
44
156
|
rake
|
45
157
|
rake-release
|
46
158
|
rspec-core
|
159
|
+
rspec-its
|
160
|
+
rspec-mocks (~> 3.5)
|
161
|
+
vagrant!
|
47
162
|
vagrant-ovirt4!
|
48
163
|
|
49
164
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[OvirtSDK4::Connection#initialize]: https://rubydoc.info/gems/ovirt-engine-sdk/OvirtSDK4%2FConnection:initialize
|
2
|
+
|
1
3
|
# Vagrant oVirt v4 Provider
|
2
4
|
|
3
5
|
This is a [Vagrant](http://www.vagrantup.com) 1.1+ plugin that adds an
|
@@ -76,8 +78,12 @@ Vagrant.configure("2") do |config|
|
|
76
78
|
ovirt.password = "password"
|
77
79
|
ovirt.insecure = true
|
78
80
|
ovirt.debug = true
|
81
|
+
ovirt.timeout = 120 # seconds
|
82
|
+
ovirt.connect_timeout = 30 # seconds
|
79
83
|
ovirt.filtered_api = true #see http://www.ovirt.org/develop/release-management/features/infra/user-portal-permissions/
|
80
84
|
ovirt.cluster = 'Default'
|
85
|
+
ovirt.vmname = 'my-vm'
|
86
|
+
ovirt.run_once = false
|
81
87
|
ovirt.template = 'Vagrant-Centos7-test'
|
82
88
|
ovirt.console = 'vnc'
|
83
89
|
ovirt.disk_size = '15 GiB' # only growing is supported. works the same way as below memory settings
|
@@ -105,8 +111,8 @@ end
|
|
105
111
|
### Configuration options
|
106
112
|
|
107
113
|
1. Vagrant specific
|
108
|
-
1. `config.vm.hostname` => Sets the hostname of the VM
|
109
|
-
|
114
|
+
1. `config.vm.hostname` => Sets the hostname of the VM. Optional. String.
|
115
|
+
Default is `"vagrant"`.
|
110
116
|
a. Is the 'hostname' of the VM configured by `cloud-init`
|
111
117
|
1. `config.vm.network` => Sets the network information of the VM.
|
112
118
|
a. Note: `:ip` => is ignored, but `:ovirt__ip` is used and merged with `:ip`
|
@@ -118,7 +124,22 @@ end
|
|
118
124
|
1. `username` => The username for the API. Required. String. No default value.
|
119
125
|
1. `password` => The password for the API. Required. String. No default value.
|
120
126
|
1. `insecure` => Allow connecting to SSL sites without certificates. Optional. Bool. Default is `false`
|
121
|
-
1. `debug` => Turn on additional log statements. Optional. Bool. Default is
|
127
|
+
1. `debug` => Turn on additional log statements. Optional. Bool. Default is
|
128
|
+
`true` if Vagrant's logging verbosity is set to `info` or above
|
129
|
+
(`VAGRANT_LOG={info,debug,...}`); otherwise, the default is `false`.
|
130
|
+
1. `timeout` => Per [the oVirt SDK docs][OvirtSDK4::Connection#initialize],
|
131
|
+
"The maximun (_sic_) total time to wait for the response, in seconds. A value of
|
132
|
+
zero (the default) means wait for ever." Optional. Integer. Uses the
|
133
|
+
`OvirtSDK4::Connection` default if omitted; as of the time of writing,
|
134
|
+
this is `0` (i.e. wait forever).
|
135
|
+
1. `connect_timeout` => Per [the oVirt SDK docs][OvirtSDK4::Connection#initialize],
|
136
|
+
"The maximun (_sic_) time to wait for connection establishment, in
|
137
|
+
seconds." Optional. Integer. Uses the `OvirtSDK4::Connection` default if
|
138
|
+
omitted; as of the time of writing, this is `300`.
|
139
|
+
1. `vmname` => Sets the name of the VM. Optional. String. Default is
|
140
|
+
`config.vm.hostname`, if defined, otherwise `"vagrant"`.
|
141
|
+
a. Is the 'name' in the Virtual Machine tab of the UI
|
142
|
+
1. `run_once` => Launch VM in run-once mode. Optional. Default is `false`.
|
122
143
|
1. `template` => The name of the template to use for creation. Required. String. No Default value.
|
123
144
|
1. `cluster` => The name of the ovirt cluster to create within. Required. String. No Default value.
|
124
145
|
1. `console` => The type of remote viewing protocol to use. Required. String. No Default value.
|
@@ -145,3 +166,10 @@ end
|
|
145
166
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
146
167
|
4. Push to the branch (`git push origin my-new-feature`)
|
147
168
|
5. Create new Pull Request
|
169
|
+
|
170
|
+
Some pointers:
|
171
|
+
|
172
|
+
* To install the requirements when developing:
|
173
|
+
* `bundle install`
|
174
|
+
* To run the test suite:
|
175
|
+
* `bundle exec rspec spec/`
|
data/Rakefile
CHANGED
data/SECURITY.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
## Security
|
2
|
+
|
3
|
+
If you believe you have found a security vulnerability, please report it to me as described below.
|
4
|
+
|
5
|
+
## Reporting Security Issues
|
6
|
+
|
7
|
+
**Please do not report security vulnerabilities through public GitHub issues.** Instead, please report them to me directly at [myoung34@my.apsu.edu](mailto:myoung34@my.apsu.edu).
|
8
|
+
|
9
|
+
If you'd like to communicate securely, my keybase is [here](https://keybase.io/3vilpenguin)
|
10
|
+
|
11
|
+
Please include the requested information listed below (as much as you can provide) to help better understand the nature and scope of the possible issue:
|
12
|
+
|
13
|
+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
14
|
+
* Full paths of source file(s) related to the manifestation of the issue
|
15
|
+
* The location of the affected source code (tag/branch/commit or direct URL)
|
16
|
+
* Any special configuration required to reproduce the issue
|
17
|
+
* Step-by-step instructions to reproduce the issue
|
18
|
+
* Proof-of-concept or exploit code (if possible)
|
19
|
+
* Impact of the issue, including how an attacker might exploit the issue
|
20
|
+
|
21
|
+
## Preferred Languages
|
22
|
+
|
23
|
+
I prefer all communications to be in English.
|
@@ -19,17 +19,39 @@ module VagrantPlugins
|
|
19
19
|
conn_attr[:url] = "#{config.url}"
|
20
20
|
conn_attr[:username] = config.username if config.username
|
21
21
|
conn_attr[:password] = config.password if config.password
|
22
|
-
conn_attr[:debug] = config.debug if config.debug
|
23
22
|
conn_attr[:insecure] = true if config.insecure
|
24
23
|
conn_attr[:headers] = {'Filter' => true} if config.filtered_api
|
24
|
+
conn_attr[:timeout] = config.timeout unless config.timeout.nil?
|
25
|
+
conn_attr[:connect_timeout] = config.connect_timeout unless config.connect_timeout.nil?
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
# Respect VAGRANT_LOG setting -- any level at least as verbose as
|
28
|
+
# "info" will result in logging oVirt connection debugging messages
|
29
|
+
# (read: libcurl verbose output).
|
30
|
+
conn_attr[:debug] = config.debug or @logger.info?
|
31
|
+
|
32
|
+
# Inject our own logger so that messages are namespaced under
|
33
|
+
# "connect_ovirt"
|
34
|
+
conn_attr[:log] = @logger
|
31
35
|
|
32
|
-
@
|
36
|
+
@logger.info("Connecting to oVirt (#{config.url}) ...")
|
37
|
+
ovirt_connection = OvirtSDK4::Connection.new(conn_attr)
|
38
|
+
vms_service = ovirt_connection.system_service.vms_service
|
39
|
+
|
40
|
+
# XXX: Continue setting deprecated global properties. Use of the
|
41
|
+
# related values from env should be preferred.
|
42
|
+
OVirtProvider.ovirt_connection = ovirt_connection
|
43
|
+
OVirtProvider.vms_service = vms_service
|
44
|
+
|
45
|
+
begin
|
46
|
+
ovirt_connection.test(true, 30)
|
47
|
+
rescue => error
|
48
|
+
raise Errors::ServiceConnectionError,
|
49
|
+
:error_message => error.message
|
50
|
+
else
|
51
|
+
env[:connection] = ovirt_connection
|
52
|
+
env[:vms_service] = vms_service
|
53
|
+
@app.call(env)
|
54
|
+
end
|
33
55
|
end
|
34
56
|
|
35
57
|
end
|
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'log4r'
|
2
|
+
require 'vagrant-ovirt4/util/connection'
|
3
|
+
require 'vagrant-ovirt4/util/machine_names'
|
2
4
|
require 'vagrant/util/retryable'
|
3
5
|
|
4
6
|
module VagrantPlugins
|
5
7
|
module OVirtProvider
|
6
8
|
module Action
|
7
9
|
class CreateVM
|
10
|
+
include Util::Connection
|
11
|
+
include Util::MachineNames
|
8
12
|
include Vagrant::Util::Retryable
|
9
13
|
|
10
14
|
def initialize(app, env)
|
@@ -16,12 +20,11 @@ module VagrantPlugins
|
|
16
20
|
# Get config.
|
17
21
|
config = env[:machine].provider_config
|
18
22
|
|
19
|
-
|
20
|
-
hostname = 'vagrant' if hostname.nil?
|
23
|
+
vmname = machine_vmname(env[:machine])
|
21
24
|
|
22
25
|
# Output the settings we're going to use to the user
|
23
26
|
env[:ui].info(I18n.t("vagrant_ovirt4.creating_vm"))
|
24
|
-
env[:ui].info(" -- Name: #{
|
27
|
+
env[:ui].info(" -- Name: #{vmname}")
|
25
28
|
env[:ui].info(" -- Cluster: #{config.cluster}")
|
26
29
|
env[:ui].info(" -- Template: #{config.template}")
|
27
30
|
env[:ui].info(" -- Console Type: #{config.console}")
|
@@ -46,7 +49,7 @@ module VagrantPlugins
|
|
46
49
|
|
47
50
|
# Create oVirt VM.
|
48
51
|
attr = {
|
49
|
-
:name =>
|
52
|
+
:name => vmname,
|
50
53
|
:description => config.description,
|
51
54
|
:comment => config.comment,
|
52
55
|
:cpu => {
|
@@ -127,7 +130,7 @@ module VagrantPlugins
|
|
127
130
|
OvirtSDK4::DiskAttachment.new(
|
128
131
|
disk: {
|
129
132
|
name: disk[:name],
|
130
|
-
description:
|
133
|
+
description: "#{vmname} storage disk",
|
131
134
|
format: disk[:type] == 'qcow2' ? OvirtSDK4::DiskFormat::COW : OvirtSDK4::DiskFormat::RAW,
|
132
135
|
provisioned_size: disk[:size],
|
133
136
|
storage_domains: [{
|
@@ -192,7 +195,7 @@ module VagrantPlugins
|
|
192
195
|
destroy_env[:config_validate] = false
|
193
196
|
destroy_env[:force_confirm_destroy] = true
|
194
197
|
env[:action_runner].run(Action.action_destroy, destroy_env)
|
195
|
-
env
|
198
|
+
safe_close_connection_standard!(env)
|
196
199
|
end
|
197
200
|
end
|
198
201
|
end
|
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'log4r'
|
2
2
|
require 'ovirtsdk4'
|
3
|
+
require 'vagrant-ovirt4/util/connection'
|
3
4
|
|
4
5
|
module VagrantPlugins
|
5
6
|
module OVirtProvider
|
6
7
|
module Action
|
7
8
|
class DisconnectOVirt
|
9
|
+
include Util::Connection
|
10
|
+
|
8
11
|
def initialize(app, env)
|
9
12
|
@logger = Log4r::Logger.new("vagrant_ovirt4::action::disconnect_ovirt")
|
10
13
|
@app = app
|
@@ -14,7 +17,7 @@ module VagrantPlugins
|
|
14
17
|
|
15
18
|
# Get config options for ovirt provider.
|
16
19
|
@logger.info("Disconnecting oVirt connection")
|
17
|
-
env
|
20
|
+
safe_close_connection_standard!(env)
|
18
21
|
|
19
22
|
@app.call(env)
|
20
23
|
end
|
@@ -17,31 +17,31 @@ module VagrantPlugins
|
|
17
17
|
@app.call(env)
|
18
18
|
end
|
19
19
|
|
20
|
+
# This method powers OVirtProvider::Provider#ssh_info. It returns a
|
21
|
+
# hash of SSH connection information if and only if at least one IPv4
|
22
|
+
# address associated with the machine in question could be retrieved
|
23
|
+
# from the oVirt API. Otherwise, it returns nil.
|
20
24
|
def read_ssh_info(env)
|
21
25
|
vms_service, machine = env[:vms_service], env[:machine]
|
22
|
-
return
|
26
|
+
return nil if machine.id.nil?
|
23
27
|
|
24
28
|
# Find the machine
|
25
29
|
server = vms_service.vm_service(machine.id)
|
26
30
|
begin
|
27
31
|
if server.get.nil?
|
28
32
|
machine.id = nil
|
29
|
-
return
|
33
|
+
return nil
|
30
34
|
end
|
31
35
|
rescue Exception => e
|
32
36
|
machine.id = nil
|
33
|
-
return
|
34
|
-
raise e
|
37
|
+
return nil
|
35
38
|
end
|
36
39
|
|
37
40
|
nics_service = server.nics_service
|
38
41
|
nics = nics_service.list
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
# for backwards compatibility with ovirt 4.3
|
43
|
-
ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment).reported_devices.collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first rescue nil
|
44
|
-
end
|
42
|
+
ip_addr = first_active_ipv4_address(env, nics)
|
43
|
+
|
44
|
+
return nil if ip_addr.nil?
|
45
45
|
|
46
46
|
# Return the info
|
47
47
|
# TODO: Some info should be configurable in Vagrantfile
|
@@ -54,7 +54,16 @@ module VagrantPlugins
|
|
54
54
|
:forward_x11 => machine.config.ssh.forward_x11,
|
55
55
|
}
|
56
56
|
|
57
|
-
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def first_active_ipv4_address(env, nics)
|
62
|
+
nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment.reported_devices).collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first
|
63
|
+
rescue
|
64
|
+
# for backwards compatibility with ovirt 4.3
|
65
|
+
nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment).reported_devices.collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } unless dev.ips.nil? } }.flatten.reject { |ip| ip.nil? }.first rescue nil
|
66
|
+
end
|
58
67
|
end
|
59
68
|
end
|
60
69
|
end
|
@@ -14,34 +14,30 @@ module VagrantPlugins
|
|
14
14
|
|
15
15
|
system_service = env[:connection].system_service
|
16
16
|
|
17
|
-
#
|
17
|
+
#Find all storage domains and store the id and name in a
|
18
18
|
# hash, so that looking them up later will be faster:
|
19
|
-
vms_map = Hash[env[:vms_service].list.map { |vm| [vm.id, vm.name] }]
|
20
|
-
|
21
|
-
# Same for storage domains:
|
22
19
|
sds_service = system_service.storage_domains_service
|
23
20
|
sds_map = Hash[sds_service.list.map { |sd| [sd.id, sd.name] }]
|
24
21
|
|
25
22
|
# For each virtual machine find its snapshots, then for each snapshot
|
26
23
|
# find its disks:
|
27
24
|
xs = [['id', 'description', 'date']]
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
xs.push([snap_id, snap_description, snap_date.to_s])
|
42
|
-
end
|
25
|
+
vm_service = env[:vms_service].vm_service(env[:machine].id)
|
26
|
+
snaps_service = vm_service.snapshots_service
|
27
|
+
snaps_map = Hash[snaps_service.list.map { |snap| [snap.id, { description: snap.description, date: snap.date }] }]
|
28
|
+
snaps_map.each do |snap_id, metadata|
|
29
|
+
snap_description = metadata[:description]
|
30
|
+
snap_date = metadata[:date]
|
31
|
+
snap_service = snaps_service.snapshot_service(snap_id)
|
32
|
+
disks_service = snap_service.disks_service
|
33
|
+
disks_service.list.each do |disk|
|
34
|
+
next unless disk.storage_domains.any?
|
35
|
+
sd_id = disk.storage_domains.first.id
|
36
|
+
sd_name = sds_map[sd_id]
|
37
|
+
xs.push([snap_id, snap_description, snap_date.to_s])
|
43
38
|
end
|
44
39
|
end
|
40
|
+
|
45
41
|
widths = xs.transpose.map { |column_arr| column_arr.map(&:size).max }
|
46
42
|
env[:machine_snapshot_list] =
|
47
43
|
xs.map { |row_arr|
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'log4r'
|
2
|
+
require 'vagrant-ovirt4/errors'
|
3
|
+
require 'vagrant-ovirt4/util/machine_names'
|
2
4
|
require 'vagrant/util/scoped_hash_override'
|
3
5
|
|
4
6
|
module VagrantPlugins
|
@@ -7,6 +9,7 @@ module VagrantPlugins
|
|
7
9
|
|
8
10
|
# Just start the VM.
|
9
11
|
class StartVM
|
12
|
+
include Util::MachineNames
|
10
13
|
include Vagrant::Util::ScopedHashOverride
|
11
14
|
|
12
15
|
def initialize(app, env)
|
@@ -26,8 +29,7 @@ module VagrantPlugins
|
|
26
29
|
end
|
27
30
|
|
28
31
|
# FIX MULTIPLE NETWORK INTERFACES
|
29
|
-
hostname = env[:machine]
|
30
|
-
hostname = 'vagrant' if hostname.nil?
|
32
|
+
hostname = machine_hostname(env[:machine])
|
31
33
|
|
32
34
|
initialization = {
|
33
35
|
host_name: hostname,
|
@@ -81,6 +83,7 @@ module VagrantPlugins
|
|
81
83
|
vm_configuration = {
|
82
84
|
initialization: initialization,
|
83
85
|
placement_policy: {},
|
86
|
+
run_once: config.run_once
|
84
87
|
}
|
85
88
|
|
86
89
|
vm_configuration[:placement_policy][:hosts] = [{ :name => config.placement_host }] unless config.placement_host.nil?
|