vagrant-ovirt4 1.1.0 → 2.0.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 +5 -5
- data/.github/FUNDING.yml +3 -0
- data/.github/workflows/release.yml +20 -0
- data/.gitignore +2 -0
- data/Dockerfile +11 -0
- data/Gemfile +5 -11
- data/Gemfile.lock +31 -37
- data/README.md +26 -12
- data/Rakefile +1 -7
- data/lib/vagrant-ovirt4/action.rb +29 -9
- data/lib/vagrant-ovirt4/action/connect_ovirt.rb +1 -0
- data/lib/vagrant-ovirt4/action/create_network_interfaces.rb +62 -26
- data/lib/vagrant-ovirt4/action/create_vm.rb +98 -14
- data/lib/vagrant-ovirt4/action/destroy_vm.rb +14 -1
- data/lib/vagrant-ovirt4/action/disconnect_ovirt.rb +25 -0
- data/lib/vagrant-ovirt4/action/halt_vm.rb +11 -0
- data/lib/vagrant-ovirt4/action/read_ssh_info.rb +6 -1
- data/lib/vagrant-ovirt4/action/read_state.rb +7 -1
- data/lib/vagrant-ovirt4/action/resize_disk.rb +18 -17
- data/lib/vagrant-ovirt4/action/start_vm.rb +76 -34
- data/lib/vagrant-ovirt4/action/wait_til_suspended.rb +1 -1
- data/lib/vagrant-ovirt4/action/wait_till_down.rb +13 -2
- data/lib/vagrant-ovirt4/action/wait_till_up.rb +35 -6
- data/lib/vagrant-ovirt4/config.rb +81 -1
- data/lib/vagrant-ovirt4/errors.rb +20 -0
- data/lib/vagrant-ovirt4/plugin.rb +3 -3
- data/lib/vagrant-ovirt4/version.rb +1 -1
- data/locales/en.yml +17 -1
- data/spec/vagrant-ovirt4/config_spec.rb +53 -3
- data/templates/Vagrantfile.erb +199 -0
- data/tools/prepare_redhat_for_box.sh +18 -2
- data/vagrant-ovirt4.gemspec +3 -1
- metadata +35 -13
- data/docker-compose.yml +0 -9
- data/lib/vagrant-ovirt4/action/sync_folders.rb +0 -69
- data/lib/vagrant-ovirt4/cap/nic_mac_addresses.rb +0 -15
- data/test.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 48a3502fc6d918fe1418248df8be2ca6ba8d2e0f477eb79784c0dbfd6a12c2e2
|
4
|
+
data.tar.gz: f33988dd5f134f0f6336e62ab21e4a4de534a434eb721e754301e6319e9043be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a84a0d2994268c8fa8df3715fbc5d3c5b40c1505cfdbb750e94539561498cc2d803ca532478bf24d9fc45d1a220bee0bcd1fd00b977f9bf221f841deed5860ec
|
7
|
+
data.tar.gz: 2533a97a3cfe3435cad9c3d9dc9199380874736f9221991e8b3072504a07dc7a590aceaf616450f4ddb7d0f52b169f57ef7855e3e3f7a75df1ea81e5ff638600
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
paths:
|
6
|
+
- lib/vagrant-ovirt4/version.rb
|
7
|
+
branches:
|
8
|
+
- master
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- uses: fregante/setup-git-user@v1
|
15
|
+
- name: Release Gem
|
16
|
+
uses: cadwallion/publish-rubygems-action@master
|
17
|
+
env:
|
18
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
19
|
+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
20
|
+
RELEASE_COMMAND: rake release
|
data/Dockerfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
FROM ruby:2.2.6
|
2
|
+
ARG jenkins_uid=997
|
3
|
+
ARG jenkins_gid=994
|
4
|
+
ENV JENKINS_UID=$jenkins_uid
|
5
|
+
ENV JENKINS_GID=$jenkins_gid
|
6
|
+
RUN apt-get update && apt-get install -y sudo
|
7
|
+
RUN groupadd -g $JENKINS_GID jenkins
|
8
|
+
RUN useradd jenkins -u $JENKINS_UID -g $JENKINS_GID --shell /bin/bash --create-home
|
9
|
+
RUN echo '%jenkins ALL=NOPASSWD: ALL' >> /etc/sudoers
|
10
|
+
RUN chown -R :jenkins /usr/local/bundle /usr/local/bin
|
11
|
+
USER jenkins
|
data/Gemfile
CHANGED
@@ -1,20 +1,14 @@
|
|
1
|
-
source '
|
2
|
-
|
3
|
-
gemspec
|
1
|
+
source 'http://rubygems.org'
|
4
2
|
|
5
3
|
group :development do
|
6
|
-
|
4
|
+
gem 'rake'
|
5
|
+
gem 'rspec-core'
|
7
6
|
gem 'pry'
|
8
7
|
gem 'byebug'
|
9
8
|
gem 'pry-byebug'
|
10
|
-
|
11
|
-
|
12
|
-
group :testing do
|
13
|
-
gem 'rspec-its'
|
14
|
-
gem 'rspec'
|
15
|
-
gem 'rake'
|
9
|
+
gem 'rake-release'
|
16
10
|
end
|
17
11
|
|
18
12
|
group :plugins do
|
19
|
-
|
13
|
+
gem 'vagrant-ovirt4', :path => '.'
|
20
14
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,44 +1,38 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
vagrant-ovirt4 (
|
5
|
-
|
4
|
+
vagrant-ovirt4 (2.0.0)
|
5
|
+
filesize (~> 0)
|
6
|
+
nokogiri (>= 1.10.8)
|
7
|
+
ovirt-engine-sdk (~> 4.0.1)
|
6
8
|
|
7
9
|
GEM
|
8
|
-
remote:
|
10
|
+
remote: http://rubygems.org/
|
9
11
|
specs:
|
10
|
-
byebug (
|
11
|
-
coderay (1.1.
|
12
|
-
|
13
|
-
json (2.
|
14
|
-
method_source (0.
|
15
|
-
|
12
|
+
byebug (11.1.3)
|
13
|
+
coderay (1.1.2)
|
14
|
+
filesize (0.2.0)
|
15
|
+
json (2.5.1)
|
16
|
+
method_source (1.0.0)
|
17
|
+
mini_portile2 (2.5.0)
|
18
|
+
nokogiri (1.11.1)
|
19
|
+
mini_portile2 (~> 2.5.0)
|
20
|
+
racc (~> 1.4)
|
21
|
+
ovirt-engine-sdk (4.0.12)
|
16
22
|
json
|
17
|
-
pry (0.
|
18
|
-
coderay (~> 1.1
|
19
|
-
method_source (~> 0
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
rake (0.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
rspec-
|
29
|
-
rspec-
|
30
|
-
rspec-support (~> 3.5.0)
|
31
|
-
rspec-expectations (3.5.0)
|
32
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
-
rspec-support (~> 3.5.0)
|
34
|
-
rspec-its (1.2.0)
|
35
|
-
rspec-core (>= 3.0.0)
|
36
|
-
rspec-expectations (>= 3.0.0)
|
37
|
-
rspec-mocks (3.5.0)
|
38
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
-
rspec-support (~> 3.5.0)
|
40
|
-
rspec-support (3.5.0)
|
41
|
-
slop (3.6.0)
|
23
|
+
pry (0.13.1)
|
24
|
+
coderay (~> 1.1)
|
25
|
+
method_source (~> 1.0)
|
26
|
+
pry-byebug (3.9.0)
|
27
|
+
byebug (~> 11.0)
|
28
|
+
pry (~> 0.13.0)
|
29
|
+
racc (1.5.2)
|
30
|
+
rake (13.0.3)
|
31
|
+
rake-release (1.2.1)
|
32
|
+
bundler (>= 1.11, < 3)
|
33
|
+
rspec-core (3.10.1)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-support (3.10.1)
|
42
36
|
|
43
37
|
PLATFORMS
|
44
38
|
ruby
|
@@ -48,9 +42,9 @@ DEPENDENCIES
|
|
48
42
|
pry
|
49
43
|
pry-byebug
|
50
44
|
rake
|
51
|
-
|
52
|
-
rspec-
|
45
|
+
rake-release
|
46
|
+
rspec-core
|
53
47
|
vagrant-ovirt4!
|
54
48
|
|
55
49
|
BUNDLED WITH
|
56
|
-
1.
|
50
|
+
1.17.2
|
data/README.md
CHANGED
@@ -56,12 +56,19 @@ $ vagrant up --provider=ovirt4
|
|
56
56
|
```
|
57
57
|
Vagrant.configure("2") do |config|
|
58
58
|
config.vm.box = 'ovirt4'
|
59
|
-
config.vm.hostname = "foo"
|
59
|
+
config.vm.hostname = "foo"
|
60
60
|
config.vm.box_url = 'https://github.com/myoung34/vagrant-ovirt4/blob/master/example_box/dummy.box?raw=true'
|
61
61
|
|
62
62
|
config.vm.network :private_network,
|
63
|
-
:
|
64
|
-
|
63
|
+
:ovirt__network_name => 'ovirtmgmt' #DHCP
|
64
|
+
# Static configuration
|
65
|
+
#:ovirt__ip => '192.168.2.198', :ovirt__network_name => 'ovirtmgmt', :ovirt__gateway => '192.168.2.125', :ovirt__netmask => '255.255.0.0', :ovirt__dns_servers => '192.168.2.1', :ovirt__dns_search => 'test.local'
|
66
|
+
# Static configuration with biosdevname. Guest OS assigns interface names (ens3, em1 or something else). ovirt__interface_name has to match that name.
|
67
|
+
#:ovirt__ip => '192.168.2.198', :ovirt__network_name => 'ovirtmgmt', :ovirt__gateway => '192.168.2.125', :ovirt__netmask => '255.255.0.0', :ovirt__dns_servers => '192.168.2.1', :ovirt__dns_search => 'test.local', :ovirt__interface_name => 'ens3'
|
68
|
+
|
69
|
+
# configure additional interface
|
70
|
+
# config.vm.network :private_network,
|
71
|
+
# :ovirt__ip => '192.168.2.199', :ovirt__network_name => 'ovirtmgmt', :ovirt__netmask => '255.255.0.0', :ovirt__interface_name => 'ens4'
|
65
72
|
|
66
73
|
config.vm.provider :ovirt4 do |ovirt|
|
67
74
|
ovirt.url = 'https://server/ovirt-engine/api'
|
@@ -69,14 +76,18 @@ Vagrant.configure("2") do |config|
|
|
69
76
|
ovirt.password = "password"
|
70
77
|
ovirt.insecure = true
|
71
78
|
ovirt.debug = true
|
79
|
+
ovirt.filtered_api = true #see http://www.ovirt.org/develop/release-management/features/infra/user-portal-permissions/
|
72
80
|
ovirt.cluster = 'Default'
|
73
81
|
ovirt.template = 'Vagrant-Centos7-test'
|
74
82
|
ovirt.console = 'vnc'
|
75
|
-
ovirt.
|
76
|
-
ovirt.
|
83
|
+
ovirt.disk_size = '15 GiB' # only growing is supported. works the same way as below memory settings
|
84
|
+
ovirt.memory_size = '1 GiB' #see https://github.com/dominikh/filesize for usage
|
85
|
+
ovirt.memory_guaranteed = '256 MiB' #see https://github.com/dominikh/filesize for usage
|
77
86
|
ovirt.cpu_cores = 2
|
78
87
|
ovirt.cpu_sockets = 2
|
79
88
|
ovirt.cpu_threads = 2
|
89
|
+
ovirt.bios_serial = aaabbbb-ccc-dddd
|
90
|
+
ovirt.optimized_for = 'server'
|
80
91
|
ovirt.cloud_init =<<EOF
|
81
92
|
write_files:
|
82
93
|
- content: |
|
@@ -85,6 +96,8 @@ write_files:
|
|
85
96
|
permissions: '0644'
|
86
97
|
EOF
|
87
98
|
|
99
|
+
# additional disks
|
100
|
+
ovirt.storage :file, size: "8 GiB", type: 'qcow2', storage_domain: "mystoragedomain"
|
88
101
|
end
|
89
102
|
end
|
90
103
|
```
|
@@ -106,18 +119,23 @@ end
|
|
106
119
|
1. `password` => The password for the API. Required. String. No default value.
|
107
120
|
1. `insecure` => Allow connecting to SSL sites without certificates. Optional. Bool. Default is `false`
|
108
121
|
1. `debug` => Turn on additional log statements. Optional. Bool. Default is `false`.
|
109
|
-
1. `datacenter` => The name of the ovirt datacenter to create within. Required. String. No Default value.
|
110
|
-
a. Note: (TODO) [Unknown usage](https://github.com/myoung34/vagrant-ovirt4/issues/26)
|
111
122
|
1. `template` => The name of the template to use for creation. Required. String. No Default value.
|
112
123
|
1. `cluster` => The name of the ovirt cluster to create within. Required. String. No Default value.
|
113
124
|
1. `console` => The type of remote viewing protocol to use. Required. String. No Default value.
|
114
|
-
a. Note: (TODO) Enforce this to be Spice, VNC, and RDP
|
115
125
|
1. `memory_size` => The physical size of the memory for the VM (in MB). Defaults to `256`
|
116
126
|
1. `memory_guaranteed` => The guaranteed size of the memory for the VM (in MB). Note: cannot be larger than `memory_size`. Defaults to `memory_size`
|
117
127
|
1. `cpu_cores` => The number of CPU cores. Defaults to `1`
|
118
128
|
1. `cpu_sockets` => The number of CPU cores. Defaults to `1`
|
119
129
|
1. `cpu_threads` => The number of CPU threads. Defaults to `1`
|
120
130
|
1. `cloud_init` => The cloud-init data to pass. Must be properly formatted as yaml. [Docs here](http://cloudinit.readthedocs.io/en/latest/topics/examples.html)
|
131
|
+
1. `affinity` => The affinity to use. [See this for possible uses](http://www.rubydoc.info/gems/ovirt-engine-sdk/OvirtSDK4/VmAffinity). Optional. Invalid will cause a `RuntimeError`
|
132
|
+
1. `placement_host` => The host to start the VM on. Optional.
|
133
|
+
1. `bios_serial` => The BIOS serial number to assign. Optional.
|
134
|
+
1. `optimized_for` => The "optimized for" setting. Can be one of 'Desktop' or 'Server' (case insensitive). Optional.
|
135
|
+
1. `storage` => adds a new storage disk to the VM
|
136
|
+
a. `size`: the size of the disk
|
137
|
+
a. `type`: the type of disk. It can be either `qcow2` or `raw`
|
138
|
+
a. `storage_domain`: the storage domain where the disk should be created
|
121
139
|
|
122
140
|
|
123
141
|
## Contributing
|
@@ -127,7 +145,3 @@ end
|
|
127
145
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
128
146
|
4. Push to the branch (`git push origin my-new-feature`)
|
129
147
|
5. Create new Pull Request
|
130
|
-
|
131
|
-
## Contributing Notes
|
132
|
-
|
133
|
-
1. You must comment out `gemspec` in the [Gemfile](Gemfile), uncomment `vagrant` and `plugins/vagrant-ovirt4` in order for `bundle install` to work and use live code. Not sure why. Too lazy to figure it out.
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
|
+
require 'rake/release'
|
3
4
|
require 'rspec/core/rake_task'
|
4
5
|
|
5
6
|
# Immediately sync all stdout so that tools like buildbot can
|
@@ -13,10 +14,3 @@ Dir.chdir(File.expand_path("../", __FILE__))
|
|
13
14
|
# This installs the tasks that help with gem creation and
|
14
15
|
# publishing.
|
15
16
|
Bundler::GemHelper.install_tasks
|
16
|
-
|
17
|
-
# Install the `spec` task so that we can run tests.
|
18
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
19
|
-
t.rspec_opts = "--order defined"
|
20
|
-
end
|
21
|
-
# Default task is to run the unit tests
|
22
|
-
task :default => :spec
|
@@ -9,11 +9,15 @@ module VagrantPlugins
|
|
9
9
|
# This action is called to bring the box up from nothing.
|
10
10
|
def self.action_up
|
11
11
|
Vagrant::Action::Builder.new.tap do |b|
|
12
|
+
b.use HandleBox
|
12
13
|
b.use ConfigValidate
|
13
14
|
b.use ConnectOVirt
|
14
15
|
b.use Call, ReadState do |env, b2|
|
16
|
+
# synced_folders defaults to NFS on linux. Make it default to rsync as before.
|
17
|
+
env[:machine].config.nfs.functional = false
|
15
18
|
if env[:machine_state_id] == :up
|
16
|
-
b2.use
|
19
|
+
b2.use SyncedFolderCleanup
|
20
|
+
b2.use SyncedFolders
|
17
21
|
b2.use MessageAlreadyUp
|
18
22
|
next
|
19
23
|
end
|
@@ -26,7 +30,7 @@ module VagrantPlugins
|
|
26
30
|
if env[:machine_state_id] == :not_created
|
27
31
|
b2.use SetNameOfDomain
|
28
32
|
b2.use CreateVM
|
29
|
-
|
33
|
+
b2.use ResizeDisk
|
30
34
|
|
31
35
|
b2.use Provision
|
32
36
|
b2.use CreateNetworkInterfaces
|
@@ -36,8 +40,10 @@ module VagrantPlugins
|
|
36
40
|
|
37
41
|
b2.use StartVM
|
38
42
|
b2.use WaitTillUp
|
39
|
-
b2.use
|
43
|
+
b2.use SyncedFolderCleanup
|
44
|
+
b2.use SyncedFolders
|
40
45
|
end
|
46
|
+
b.use DisconnectOVirt
|
41
47
|
end
|
42
48
|
end
|
43
49
|
|
@@ -52,9 +58,10 @@ module VagrantPlugins
|
|
52
58
|
|
53
59
|
b2.use ConnectOVirt
|
54
60
|
b2.use ProvisionerCleanup, :before if defined?(ProvisionerCleanup)
|
55
|
-
b2.use HaltVM
|
56
|
-
b2.use WaitTillDown
|
61
|
+
b2.use HaltVM unless env[:machine].state.id == :down
|
62
|
+
b2.use WaitTillDown unless env[:machine].state.id == :down
|
57
63
|
b2.use DestroyVM
|
64
|
+
b2.use DisconnectOVirt
|
58
65
|
end
|
59
66
|
end
|
60
67
|
end
|
@@ -63,12 +70,15 @@ module VagrantPlugins
|
|
63
70
|
Vagrant::Action::Builder.new.tap do |b|
|
64
71
|
b.use ConfigValidate
|
65
72
|
b.use Call, IsCreated do |env, b2|
|
73
|
+
# synced_folders defaults to NFS on linux. Make it default to rsync as before.
|
74
|
+
env[:machine].config.nfs.functional = false
|
66
75
|
if !env[:result]
|
67
76
|
b2.use MessageNotCreated
|
68
77
|
next
|
69
78
|
end
|
70
79
|
b2.use Provision
|
71
|
-
b2.use
|
80
|
+
b2.use SyncedFolderCleanup
|
81
|
+
b2.use SyncedFolders
|
72
82
|
end
|
73
83
|
end
|
74
84
|
end
|
@@ -77,9 +87,11 @@ module VagrantPlugins
|
|
77
87
|
# state is expected to be put into the `:machine_state_id` key.
|
78
88
|
def self.action_read_state
|
79
89
|
Vagrant::Action::Builder.new.tap do |b|
|
90
|
+
b.use HandleBox
|
80
91
|
b.use ConfigValidate
|
81
92
|
b.use ConnectOVirt
|
82
93
|
b.use ReadState
|
94
|
+
b.use DisconnectOVirt
|
83
95
|
end
|
84
96
|
end
|
85
97
|
|
@@ -91,6 +103,7 @@ module VagrantPlugins
|
|
91
103
|
b.use ConfigValidate
|
92
104
|
b.use ConnectOVirt
|
93
105
|
b.use ReadSSHInfo
|
106
|
+
b.use DisconnectOVirt
|
94
107
|
end
|
95
108
|
end
|
96
109
|
|
@@ -111,6 +124,7 @@ module VagrantPlugins
|
|
111
124
|
raise Errors::NoIPError if env[:ip_address].nil?
|
112
125
|
b2.use SSHExec
|
113
126
|
end
|
127
|
+
b.use DisconnectOVirt
|
114
128
|
end
|
115
129
|
end
|
116
130
|
|
@@ -131,6 +145,7 @@ module VagrantPlugins
|
|
131
145
|
raise Errors::NoIPError if env[:ip_address].nil?
|
132
146
|
b2.use SSHRun
|
133
147
|
end
|
148
|
+
b.use DisconnectOVirt
|
134
149
|
end
|
135
150
|
end
|
136
151
|
|
@@ -153,7 +168,7 @@ module VagrantPlugins
|
|
153
168
|
end
|
154
169
|
|
155
170
|
def self.action_reload
|
156
|
-
|
171
|
+
Vagrant::Action::Builder.new.tap do |b|
|
157
172
|
b.use action_halt
|
158
173
|
b.use action_up
|
159
174
|
end
|
@@ -186,7 +201,8 @@ module VagrantPlugins
|
|
186
201
|
b.use MessageNotSuspended
|
187
202
|
next
|
188
203
|
end
|
189
|
-
b.use
|
204
|
+
b.use StartVM
|
205
|
+
b.use WaitTillUp
|
190
206
|
end
|
191
207
|
end
|
192
208
|
|
@@ -210,6 +226,7 @@ module VagrantPlugins
|
|
210
226
|
|
211
227
|
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
212
228
|
autoload :ConnectOVirt, action_root.join("connect_ovirt")
|
229
|
+
autoload :DisconnectOVirt, action_root.join("disconnect_ovirt")
|
213
230
|
autoload :CreateNetworkInterfaces, action_root.join("create_network_interfaces")
|
214
231
|
autoload :CreateVM, action_root.join("create_vm")
|
215
232
|
autoload :DestroyVM, action_root.join("destroy_vm")
|
@@ -218,13 +235,15 @@ module VagrantPlugins
|
|
218
235
|
autoload :IsRunning, action_root.join("is_running")
|
219
236
|
autoload :ReadSSHInfo, action_root.join("read_ssh_info")
|
220
237
|
autoload :ReadState, action_root.join("read_state")
|
238
|
+
autoload :ResizeDisk, action_root.join("resize_disk")
|
221
239
|
autoload :SetNameOfDomain, action_root.join("set_name_of_domain")
|
222
240
|
autoload :SnapshotDelete, action_root.join("snapshot_delete")
|
223
241
|
autoload :SnapshotList, action_root.join("snapshot_list")
|
224
242
|
autoload :SnapshotSave, action_root.join("snapshot_save")
|
225
243
|
autoload :StartVM, action_root.join("start_vm")
|
226
244
|
autoload :SuspendVM, action_root.join("suspend_vm")
|
227
|
-
autoload :
|
245
|
+
autoload :SyncedFolders, 'vagrant/action/builtin/synced_folders'
|
246
|
+
autoload :SyncedFolderCleanup, 'vagrant/action/builtin/synced_folder_cleanup'
|
228
247
|
autoload :WaitTillDown, action_root.join("wait_till_down")
|
229
248
|
autoload :WaitTillUp, action_root.join("wait_till_up")
|
230
249
|
autoload :WaitTilSuspended, action_root.join("wait_til_suspended")
|
@@ -248,6 +267,7 @@ module VagrantPlugins
|
|
248
267
|
end
|
249
268
|
yield env, b2
|
250
269
|
end
|
270
|
+
b.use DisconnectOVirt
|
251
271
|
end
|
252
272
|
end
|
253
273
|
end
|
@@ -21,6 +21,7 @@ module VagrantPlugins
|
|
21
21
|
conn_attr[:password] = config.password if config.password
|
22
22
|
conn_attr[:debug] = config.debug if config.debug
|
23
23
|
conn_attr[:insecure] = true if config.insecure
|
24
|
+
conn_attr[:headers] = {'Filter' => true} if config.filtered_api
|
24
25
|
|
25
26
|
@logger.info("Connecting to oVirt (#{config.url}) ...")
|
26
27
|
OVirtProvider.ovirt_connection = OvirtSDK4::Connection.new(conn_attr)
|
@@ -16,36 +16,72 @@ module VagrantPlugins
|
|
16
16
|
|
17
17
|
def call(env)
|
18
18
|
|
19
|
-
|
20
|
-
iface_options = nil
|
21
|
-
env[:machine].config.vm.networks.each do |config|
|
22
|
-
type, options = config
|
23
|
-
# We support private and public networks only. They mean both the
|
24
|
-
# same right now.
|
25
|
-
next unless [:private_network].include? type
|
19
|
+
config = env[:machine].provider_config
|
26
20
|
|
27
|
-
|
21
|
+
# FIX MULTIPLE NETWORK INTERFACES
|
22
|
+
vagrantfile_networks = []
|
23
|
+
@logger.info("Found next configured networks in Vagrantfile:")
|
24
|
+
env[:machine].config.vm.networks.each do |network|
|
25
|
+
type, options = network
|
26
|
+
|
27
|
+
# We support private networks only
|
28
|
+
next unless type == :private_network
|
29
|
+
@logger.info("#{network}")
|
30
|
+
|
31
|
+
vagrantfile_networks << [type, options]
|
28
32
|
end
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
34
|
+
@logger.info("Processing each found configured network")
|
35
|
+
vagrantfile_networks.each do |network|
|
36
|
+
type, options = network
|
37
|
+
|
38
|
+
iface_options = scoped_hash_override(options, :ovirt)
|
39
|
+
@logger.info("Interface options: #{iface_options}")
|
40
|
+
|
41
|
+
begin
|
42
|
+
nics_service = env[:vms_service].vm_service(env[:machine].id).nics_service
|
43
|
+
if iface_options.nil?
|
44
|
+
# throw an error if they didn't provide any sort of information on interfaces _and_ the VM has none
|
45
|
+
raise Errors::NoNetworkError if nics_service.list.count == 0
|
46
|
+
else
|
47
|
+
# provided a network block of some sort. Search oVirt for the corresponding network_profile_ids
|
48
|
+
@logger.info("Finding network #{iface_options[:network_name]} for given cluster #{config.cluster}")
|
49
|
+
clusters_service = env[:connection].system_service.clusters_service
|
50
|
+
cluster = clusters_service.list(search: "name=#{config.cluster}").first
|
51
|
+
profiles_service = env[:connection].system_service.vnic_profiles_service
|
52
|
+
network_profile_ids = profiles_service.list.map do |profile|
|
53
|
+
if env[:connection].follow_link(profile.network).data_center.id == cluster.data_center.id and
|
54
|
+
profile.name == iface_options[:network_name]
|
55
|
+
profile.id
|
56
|
+
end
|
57
|
+
end
|
58
|
+
network_profile_id = network_profile_ids.compact.first
|
59
|
+
# error if they provided a 'network name' but it could not be located in the previous search
|
60
|
+
raise Errors::NetworkNotFoundError, :network_name => iface_options[:network_name] if network_profile_id.nil? and !iface_options[:network_name].nil?
|
61
|
+
|
62
|
+
# quick and dirty way to look for a 'nic#' that is not already attached to the machine
|
63
|
+
iface = (("nic1".."nic8").flat_map { |x| x } - env[:vms_service].vm_service(env[:machine].id).nics_service.list.map(&:name)).first rescue "vagrant_nic1"
|
64
|
+
@logger.info("Creating network interface #{iface}")
|
65
|
+
nics_service.add(
|
66
|
+
OvirtSDK4::Nic.new(
|
67
|
+
name: iface,
|
68
|
+
vnic_profile: {
|
69
|
+
id: network_profile_id
|
70
|
+
}
|
71
|
+
)
|
72
|
+
)
|
73
|
+
end
|
74
|
+
rescue => e
|
75
|
+
if config.debug
|
76
|
+
raise e
|
77
|
+
else
|
78
|
+
fault_message = /Fault detail is \"\[?(.+?)\]?\".*/.match(e.message)[1] rescue e.message
|
79
|
+
raise Errors::AddInterfaceError,
|
80
|
+
:error_message => fault_message
|
81
|
+
end
|
82
|
+
end
|
48
83
|
end
|
84
|
+
# END FIX MULTIPLE NETWORK INTERFACES
|
49
85
|
|
50
86
|
# Continue the middleware chain.
|
51
87
|
@app.call(env)
|