vagrant-ovirt4 1.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 +7 -0
- data/.gitignore +8 -0
- data/.rspec +1 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +54 -0
- data/README.md +110 -0
- data/Rakefile +22 -0
- data/example_box/README.md +13 -0
- data/example_box/Vagrantfile +14 -0
- data/example_box/metadata.json +4 -0
- data/lib/vagrant-ovirt4/action/connect_ovirt.rb +38 -0
- data/lib/vagrant-ovirt4/action/create_network_interfaces.rb +58 -0
- data/lib/vagrant-ovirt4/action/create_vm.rb +92 -0
- data/lib/vagrant-ovirt4/action/destroy_vm.rb +25 -0
- data/lib/vagrant-ovirt4/action/halt_vm.rb +23 -0
- data/lib/vagrant-ovirt4/action/is_created.rb +19 -0
- data/lib/vagrant-ovirt4/action/is_running.rb +19 -0
- data/lib/vagrant-ovirt4/action/message_already_up.rb +16 -0
- data/lib/vagrant-ovirt4/action/message_not_created.rb +16 -0
- data/lib/vagrant-ovirt4/action/message_not_suspended.rb +16 -0
- data/lib/vagrant-ovirt4/action/message_not_up.rb +16 -0
- data/lib/vagrant-ovirt4/action/message_powering_up.rb +16 -0
- data/lib/vagrant-ovirt4/action/message_saving_state.rb +16 -0
- data/lib/vagrant-ovirt4/action/read_ssh_info.rb +56 -0
- data/lib/vagrant-ovirt4/action/read_state.rb +47 -0
- data/lib/vagrant-ovirt4/action/set_name_of_domain.rb +24 -0
- data/lib/vagrant-ovirt4/action/snapshot_delete.rb +37 -0
- data/lib/vagrant-ovirt4/action/snapshot_list.rb +58 -0
- data/lib/vagrant-ovirt4/action/snapshot_save.rb +28 -0
- data/lib/vagrant-ovirt4/action/start_vm.rb +80 -0
- data/lib/vagrant-ovirt4/action/suspend_vm.rb +24 -0
- data/lib/vagrant-ovirt4/action/sync_folders.rb +69 -0
- data/lib/vagrant-ovirt4/action/wait_til_suspended.rb +44 -0
- data/lib/vagrant-ovirt4/action/wait_till_down.rb +47 -0
- data/lib/vagrant-ovirt4/action/wait_till_up.rb +83 -0
- data/lib/vagrant-ovirt4/action.rb +255 -0
- data/lib/vagrant-ovirt4/cap/snapshot_list.rb +12 -0
- data/lib/vagrant-ovirt4/cap/snapshot_save.rb +12 -0
- data/lib/vagrant-ovirt4/config.rb +49 -0
- data/lib/vagrant-ovirt4/errors.rb +48 -0
- data/lib/vagrant-ovirt4/plugin.rb +80 -0
- data/lib/vagrant-ovirt4/provider.rb +76 -0
- data/lib/vagrant-ovirt4/util/collection.rb +21 -0
- data/lib/vagrant-ovirt4/util/timer.rb +17 -0
- data/lib/vagrant-ovirt4/util.rb +9 -0
- data/lib/vagrant-ovirt4/version.rb +6 -0
- data/lib/vagrant-ovirt4.rb +38 -0
- data/locales/en.yml +74 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/vagrant-ovirt4/action/is_created_spec.rb +40 -0
- data/spec/vagrant-ovirt4/action/is_running_spec.rb +40 -0
- data/spec/vagrant-ovirt4/action/message_already_up_spec.rb +20 -0
- data/spec/vagrant-ovirt4/action/message_not_created_spec.rb +20 -0
- data/spec/vagrant-ovirt4/action/message_not_suspended_spec.rb +20 -0
- data/spec/vagrant-ovirt4/action/message_not_up_spec.rb +20 -0
- data/spec/vagrant-ovirt4/action/message_powering_up_spec.rb +20 -0
- data/spec/vagrant-ovirt4/action/message_saving_state_spec.rb +20 -0
- data/spec/vagrant-ovirt4/action/read_ssh_info_spec.rb +73 -0
- data/spec/vagrant-ovirt4/action/read_state_spec.rb +68 -0
- data/spec/vagrant-ovirt4/config_spec.rb +55 -0
- data/tools/prepare_redhat_for_box.sh +113 -0
- data/vagrant-ovirt4.gemspec +26 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b5342f00fbaebdf678cce7ea4125f40cc213d140
|
4
|
+
data.tar.gz: 385cdb34732539203b0bbd03d7ff414dffa79a7a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 582d275b8b01fb98e8997b3defb9a79b68ea1f01122c54771439afdc14c8bacdd7b6876cc48c921d6df7f90b3bc025112d328222b8ebb6c8e5f3a216ae3d0335
|
7
|
+
data.tar.gz: 23b28cef56c3423fca1f70cd956e507afa650d1b015acdb75d0d95d0c4a314b39ac9c7a907d44ba4a54cff346660bd0057b60ff407c3a63aa992bad8fcdb6a7d
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format doc --order random --color #--fail-fast
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
#gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git'
|
7
|
+
gem 'pry'
|
8
|
+
gem 'byebug'
|
9
|
+
gem 'pry-byebug'
|
10
|
+
end
|
11
|
+
|
12
|
+
group :testing do
|
13
|
+
gem 'rspec-its'
|
14
|
+
end
|
15
|
+
|
16
|
+
group :plugins do
|
17
|
+
gem 'vagrant-ovirt4', :path => '.'
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
vagrant-ovirt4 (0.0.1)
|
5
|
+
ovirt-engine-sdk (~> 4.0, >= 4.0.6)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
byebug (9.0.6)
|
11
|
+
coderay (1.1.1)
|
12
|
+
diff-lcs (1.2.5)
|
13
|
+
method_source (0.8.2)
|
14
|
+
ovirt-engine-sdk (4.0.6)
|
15
|
+
pry (0.10.4)
|
16
|
+
coderay (~> 1.1.0)
|
17
|
+
method_source (~> 0.8.1)
|
18
|
+
slop (~> 3.4)
|
19
|
+
pry-byebug (3.4.0)
|
20
|
+
byebug (~> 9.0)
|
21
|
+
pry (~> 0.10)
|
22
|
+
rake (0.9.6)
|
23
|
+
rspec (3.5.0)
|
24
|
+
rspec-core (~> 3.5.0)
|
25
|
+
rspec-expectations (~> 3.5.0)
|
26
|
+
rspec-mocks (~> 3.5.0)
|
27
|
+
rspec-core (3.5.4)
|
28
|
+
rspec-support (~> 3.5.0)
|
29
|
+
rspec-expectations (3.5.0)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.5.0)
|
32
|
+
rspec-its (1.2.0)
|
33
|
+
rspec-core (>= 3.0.0)
|
34
|
+
rspec-expectations (>= 3.0.0)
|
35
|
+
rspec-mocks (3.5.0)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.5.0)
|
38
|
+
rspec-support (3.5.0)
|
39
|
+
slop (3.6.0)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
byebug
|
46
|
+
pry
|
47
|
+
pry-byebug
|
48
|
+
rake (~> 0)
|
49
|
+
rspec (~> 3.4)
|
50
|
+
rspec-its
|
51
|
+
vagrant-ovirt4!
|
52
|
+
|
53
|
+
BUNDLED WITH
|
54
|
+
1.12.5
|
data/README.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# Vagrant oVirt v4 Provider
|
2
|
+
|
3
|
+
This is a [Vagrant](http://www.vagrantup.com) 1.1+ plugin that adds an
|
4
|
+
[oVirt v4](http://ovirt.org) and
|
5
|
+
allowing Vagrant to control and provision machines in oVirt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
```
|
10
|
+
$ vagrant plugin install vagrant-ovirt4
|
11
|
+
$ vagrant up --provider=ovirt4
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
### Prerequisites
|
17
|
+
|
18
|
+
#### Configuration
|
19
|
+
|
20
|
+
1. [ovirt-guest-agent](https://github.com/oVirt/ovirt-guest-agent)
|
21
|
+
1. [cloud-init](https://cloudinit.readthedocs.io/en/latest/)
|
22
|
+
1. User 'vagrant'
|
23
|
+
1. password 'vagrant'
|
24
|
+
1. Public key [from here](https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub)
|
25
|
+
1. add to group with sudo no password
|
26
|
+
1. set `!requiretty` in sudoers
|
27
|
+
1. firewall off and ssh enabled
|
28
|
+
|
29
|
+
#### Example creation steps
|
30
|
+
|
31
|
+
1. Create a base template
|
32
|
+
1. Centos Example
|
33
|
+
1. Spin up a virtual machine using the Centos 7 Generic Cloud Image from the ovirt Glance provider
|
34
|
+
1. Once it is up and running, run [the example script](tools/prepare_redhat_for_box.sh) from inside the VM
|
35
|
+
1. Power down the virtual machine
|
36
|
+
1. Remove all Network Interfaces from the VM (so that the template does not have it)
|
37
|
+
1. Right click the virtual machine and click 'Make Template'
|
38
|
+
|
39
|
+
### Supported Commands (tested)
|
40
|
+
|
41
|
+
1. `vagrant up`
|
42
|
+
1. `vagrant destroy`
|
43
|
+
1. `vagrant ssh [-c '#command']`
|
44
|
+
1. `vagrant ssh-config`
|
45
|
+
1. `vagrant halt`
|
46
|
+
1. `vagrant reload`
|
47
|
+
1. `vagrant status`
|
48
|
+
1. `vagrant suspend`
|
49
|
+
1. `vagrant resume`
|
50
|
+
|
51
|
+
### Configuration example
|
52
|
+
|
53
|
+
```
|
54
|
+
Vagrant.configure("2") do |config|
|
55
|
+
config.vm.box = 'ovirt4'
|
56
|
+
config.vm.hostname = "foo"
|
57
|
+
config.vm.box_url = 'https://github.com/myoung34/vagrant-ovirt4/blob/master/example_box/dummy.box?raw=true'
|
58
|
+
|
59
|
+
config.vm.network :private_network,
|
60
|
+
:ip => '192.168.56.100', :nictype => 'virtio', :netmask => '255.255.255.0', #normal network configuration
|
61
|
+
:ovirt__ip => '192.168.2.198', :ovirt__network_name => 'ovirtmgmt', :ovirt__gateway => '192.168.2.125' # oVirt specific information, overwrites previous on oVirt provider
|
62
|
+
|
63
|
+
config.vm.provider :ovirt4 do |ovirt|
|
64
|
+
ovirt.url = 'https://server/ovirt-engine/api'
|
65
|
+
ovirt.username = "admin@internal"
|
66
|
+
ovirt.password = "password"
|
67
|
+
ovirt.insecure = true
|
68
|
+
ovirt.debug = true
|
69
|
+
ovirt.cluster = 'Default'
|
70
|
+
ovirt.template = 'Vagrant-Centos7-test'
|
71
|
+
ovirt.console = 'vnc'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
### Configuration options
|
77
|
+
|
78
|
+
1. Vagrant specific
|
79
|
+
1. `config.vm.hostname` => Sets the hostname of the VM
|
80
|
+
a. Is the 'name' in the Virtual Machine tab of the UI
|
81
|
+
a. Is the 'hostname' of the VM configured by `cloud-init`
|
82
|
+
1. `config.vm.network` => Sets the network information of the VM.
|
83
|
+
a. Note: `:ip` => is ignored, but `:ovirt__ip` is used and merged with `:ip`
|
84
|
+
1. Provider specific
|
85
|
+
1. `config.vm.network` => Sets the network information of the VM.
|
86
|
+
a. Note: Only `:private_network` is currently supported.
|
87
|
+
a. If `:ovirt__ip` is provided, then the network type is assumed 'STATIC' and `gateway` is also used.
|
88
|
+
1. `url` => The URL for the API. Required. String. No default value.
|
89
|
+
1. `username` => The username for the API. Required. String. No default value.
|
90
|
+
1. `password` => The password for the API. Required. String. No default value.
|
91
|
+
1. `insecure` => Allow connecting to SSL sites without certificates. Optional. Bool. Default is `false`
|
92
|
+
1. `debug` => Turn on additional log statements. Optional. Bool. Default is `false`.
|
93
|
+
1. `cpus` => Number of CPUs to use for the VM. Optional. Integer. Default is `1`.
|
94
|
+
a. Note: (TODO) [Unknown usage](https://github.com/myoung34/vagrant-ovirt4/issues/26)
|
95
|
+
1. `datacenter` => The name of the ovirt datacenter to create within. Required. String. No Default value.
|
96
|
+
a. Note: (TODO) [Unknown usage](https://github.com/myoung34/vagrant-ovirt4/issues/26)
|
97
|
+
1. `template` => The name of the template to use for creation. Required. String. No Default value.
|
98
|
+
1. `memory` => The amount of RAM to use.
|
99
|
+
a. Note: (TODO) [Unknown usage/defaults](https://github.com/myoung34/vagrant-ovirt4/issues/26)
|
100
|
+
1. `cluster` => The name of the ovirt cluster to create within. Required. String. No Default value.
|
101
|
+
1. `console` => The type of remote viewing protocol to use. Required. String. No Default value.
|
102
|
+
a. Note: (TODO) Enforce this to be Spice, VNC, and RDP
|
103
|
+
|
104
|
+
## Contributing
|
105
|
+
|
106
|
+
1. Fork it
|
107
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
108
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
109
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
110
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
# Immediately sync all stdout so that tools like buildbot can
|
6
|
+
# immediately load in the output.
|
7
|
+
$stdout.sync = true
|
8
|
+
$stderr.sync = true
|
9
|
+
|
10
|
+
# Change to the directory of this file.
|
11
|
+
Dir.chdir(File.expand_path("../", __FILE__))
|
12
|
+
|
13
|
+
# This installs the tasks that help with gem creation and
|
14
|
+
# publishing.
|
15
|
+
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
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Vagrant oVirt4 Example Box
|
2
|
+
|
3
|
+
Vagrant providers each require a custom provider-specific box format.
|
4
|
+
This folder shows the example contents of a box for the `ovirt4` provider.
|
5
|
+
To turn this into a box:
|
6
|
+
|
7
|
+
```
|
8
|
+
$ tar cvzf dummy.box ./metadata.json ./Vagrantfile
|
9
|
+
```
|
10
|
+
|
11
|
+
This box works by using Vagrant's built-in Vagrantfile merging to setup
|
12
|
+
defaults for oVirt. These defaults can easily be overwritten by higher-level
|
13
|
+
Vagrantfiles (such as project root Vagrantfiles).
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
Vagrant.configure("2") do |config|
|
4
|
+
config.vm.box = 'ovirt4'
|
5
|
+
#config.vm.box_url = 'https://github.com/myoung34/vagrant-ovirt4/blob/master/example_box/dummy.box?raw=true'
|
6
|
+
|
7
|
+
config.vm.provider :ovirt4 do |ovirt|
|
8
|
+
ovirt.url = 'https://server/ovirt-engine/api'
|
9
|
+
ovirt.username = "admin@internal"
|
10
|
+
ovirt.password = "password"
|
11
|
+
ovirt.insecure = true
|
12
|
+
ovirt.debug = true
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
require 'ovirtsdk4'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module OVirtProvider
|
6
|
+
module Action
|
7
|
+
class ConnectOVirt
|
8
|
+
def initialize(app, env)
|
9
|
+
@logger = Log4r::Logger.new("vagrant_ovirt4::action::connect_ovirt")
|
10
|
+
@app = app
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
|
15
|
+
# Get config options for ovirt provider.
|
16
|
+
config = env[:machine].provider_config
|
17
|
+
|
18
|
+
conn_attr = {}
|
19
|
+
conn_attr[:url] = "#{config.url}"
|
20
|
+
conn_attr[:username] = config.username if config.username
|
21
|
+
conn_attr[:password] = config.password if config.password
|
22
|
+
conn_attr[:debug] = config.debug if config.debug
|
23
|
+
conn_attr[:insecure] = true if config.insecure
|
24
|
+
|
25
|
+
@logger.info("Connecting to oVirt (#{config.url}) ...")
|
26
|
+
OVirtProvider.ovirt_connection = OvirtSDK4::Connection.new(conn_attr)
|
27
|
+
OVirtProvider.vms_service = OVirtProvider.ovirt_connection.system_service.vms_service
|
28
|
+
env[:connection] = OVirtProvider.ovirt_connection
|
29
|
+
env[:vms_service] = OVirtProvider.vms_service
|
30
|
+
|
31
|
+
@app.call(env)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
require 'vagrant/util/scoped_hash_override'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module OVirtProvider
|
6
|
+
module Action
|
7
|
+
|
8
|
+
# Create network interfaces for machine, before VM is running.
|
9
|
+
class CreateNetworkInterfaces
|
10
|
+
include Vagrant::Util::ScopedHashOverride
|
11
|
+
|
12
|
+
def initialize(app, env)
|
13
|
+
@logger = Log4r::Logger.new("vagrant_ovirt4::action::create_network_interfaces")
|
14
|
+
@app = app
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
|
19
|
+
iface = "nic1"
|
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
|
26
|
+
|
27
|
+
iface_options = scoped_hash_override(options, :ovirt)
|
28
|
+
end
|
29
|
+
|
30
|
+
profiles_service = env[:connection].system_service.vnic_profiles_service
|
31
|
+
network_profile_id = profiles_service.list.map { |p| p.id if p.name == iface_options[:network_name] }.first
|
32
|
+
raise Errors::NoNetworkError, :network_name => iface_options[:network_name] if network_profile_id.nil?
|
33
|
+
|
34
|
+
@logger.info("Creating network interface #{iface}")
|
35
|
+
begin
|
36
|
+
nics_service = env[:vms_service].vm_service(env[:machine].id).nics_service
|
37
|
+
nics_service.add(
|
38
|
+
OvirtSDK4::Nic.new(
|
39
|
+
name: iface,
|
40
|
+
vnic_profile: {
|
41
|
+
id: network_profile_id
|
42
|
+
}
|
43
|
+
)
|
44
|
+
)
|
45
|
+
rescue => e
|
46
|
+
raise Errors::AddInterfaceError,
|
47
|
+
:error_message => e.message
|
48
|
+
end
|
49
|
+
|
50
|
+
# Continue the middleware chain.
|
51
|
+
@app.call(env)
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
require 'vagrant/util/retryable'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module OVirtProvider
|
6
|
+
module Action
|
7
|
+
class CreateVM
|
8
|
+
include Vagrant::Util::Retryable
|
9
|
+
|
10
|
+
def initialize(app, env)
|
11
|
+
@logger = Log4r::Logger.new("vagrant_ovirt4::action::create_vm")
|
12
|
+
@app = app
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
# Get config.
|
17
|
+
config = env[:machine].provider_config
|
18
|
+
|
19
|
+
hostname = env[:machine].config.vm.hostname
|
20
|
+
hostname = 'vagrant' if hostname.nil?
|
21
|
+
|
22
|
+
# Output the settings we're going to use to the user
|
23
|
+
env[:ui].info(I18n.t("vagrant_ovirt4.creating_vm"))
|
24
|
+
env[:ui].info(" -- Name: #{hostname}")
|
25
|
+
env[:ui].info(" -- Cluster: #{config.cluster}")
|
26
|
+
env[:ui].info(" -- Template: #{config.template}")
|
27
|
+
env[:ui].info(" -- Console Type: #{config.console}")
|
28
|
+
|
29
|
+
# Create oVirt VM.
|
30
|
+
attr = {
|
31
|
+
:name => hostname,
|
32
|
+
:cluster => {
|
33
|
+
:name => config.cluster,
|
34
|
+
},
|
35
|
+
:template => {
|
36
|
+
:name => config.template,
|
37
|
+
},
|
38
|
+
:display => {
|
39
|
+
:type => config.console,
|
40
|
+
},
|
41
|
+
}
|
42
|
+
|
43
|
+
begin
|
44
|
+
server = env[:vms_service].add(attr)
|
45
|
+
rescue OvirtSDK4::Error => e
|
46
|
+
raise Errors::CreateVMError,
|
47
|
+
:error_message => /Fault detail is \"\[(.*)\]\".*/.match(e.message)[1]
|
48
|
+
end
|
49
|
+
|
50
|
+
# Immediately save the ID since it is created at this point.
|
51
|
+
env[:machine].id = server.id
|
52
|
+
|
53
|
+
# Wait till all volumes are ready.
|
54
|
+
env[:ui].info(I18n.t("vagrant_ovirt4.wait_for_ready_vm"))
|
55
|
+
for i in 0..300
|
56
|
+
ready = true
|
57
|
+
vm_service = env[:vms_service].vm_service(env[:machine].id)
|
58
|
+
disk_attachments_service = vm_service.disk_attachments_service
|
59
|
+
disk_attachments = disk_attachments_service.list
|
60
|
+
disk_attachments.each do |disk_attachment|
|
61
|
+
disk = env[:connection].follow_link(disk_attachment.disk)
|
62
|
+
if disk.status != 'ok'
|
63
|
+
ready = false
|
64
|
+
break
|
65
|
+
end
|
66
|
+
end
|
67
|
+
break if ready
|
68
|
+
sleep 2
|
69
|
+
end
|
70
|
+
|
71
|
+
if not ready
|
72
|
+
raise Errors::WaitForReadyVmTimeout
|
73
|
+
end
|
74
|
+
|
75
|
+
@app.call(env)
|
76
|
+
end
|
77
|
+
|
78
|
+
def recover(env)
|
79
|
+
return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError)
|
80
|
+
|
81
|
+
# Undo the import
|
82
|
+
env[:ui].info(I18n.t("vagrant_ovirt4.error_recovering"))
|
83
|
+
destroy_env = env.dup
|
84
|
+
destroy_env.delete(:interrupted)
|
85
|
+
destroy_env[:config_validate] = false
|
86
|
+
destroy_env[:force_confirm_destroy] = true
|
87
|
+
env[:action_runner].run(Action.action_destroy, destroy_env)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module OVirtProvider
|
5
|
+
module Action
|
6
|
+
class DestroyVM
|
7
|
+
def initialize(app, env)
|
8
|
+
@logger = Log4r::Logger.new("vagrant_ovirt4::action::destroy_vm")
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
# Destroy the server, remove the tracking ID
|
14
|
+
env[:ui].info(I18n.t("vagrant_ovirt4.destroy_vm"))
|
15
|
+
|
16
|
+
vm_service = env[:vms_service].vm_service(env[:machine].id)
|
17
|
+
vm_service.remove
|
18
|
+
env[:machine].id = nil
|
19
|
+
|
20
|
+
@app.call(env)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module OVirtProvider
|
5
|
+
module Action
|
6
|
+
class HaltVM
|
7
|
+
def initialize(app, env)
|
8
|
+
@logger = Log4r::Logger.new("vagrant_ovirt4::action::halt_vm")
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
env[:ui].info(I18n.t("vagrant_ovirt4.halt_vm"))
|
14
|
+
|
15
|
+
machine = env[:vms_service].vm_service(env[:machine].id)
|
16
|
+
machine.stop rescue nil #todo dont rescue
|
17
|
+
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module OVirtProvider
|
5
|
+
module Action
|
6
|
+
class IsCreated
|
7
|
+
def initialize(app, env)
|
8
|
+
@app = app
|
9
|
+
@logger = Log4r::Logger.new("vagrant_ovirt4::action::is_created")
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
env[:result] = env[:machine].state.id != :not_created
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module OVirtProvider
|
5
|
+
module Action
|
6
|
+
class IsRunning
|
7
|
+
def initialize(app, env)
|
8
|
+
@app = app
|
9
|
+
@logger = Log4r::Logger.new("vagrant_ovirt4::action::is_created")
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
env[:result] = env[:machine].state.id == :up
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OVirtProvider
|
3
|
+
module Action
|
4
|
+
class MessageAlreadyUp
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env[:ui].info(I18n.t("vagrant_ovirt4.already_up"))
|
11
|
+
@app.call(env)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OVirtProvider
|
3
|
+
module Action
|
4
|
+
class MessageNotCreated
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env[:ui].info(I18n.t("vagrant_ovirt4.not_created"))
|
11
|
+
@app.call(env)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OVirtProvider
|
3
|
+
module Action
|
4
|
+
class MessageNotSuspended
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env[:ui].info(I18n.t("vagrant_ovirt4.not_suspended"))
|
11
|
+
@app.call(env)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OVirtProvider
|
3
|
+
module Action
|
4
|
+
class MessagePoweringUp
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env[:ui].info(I18n.t("vagrant_ovirt4.powering_up"))
|
11
|
+
@app.call(env)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OVirtProvider
|
3
|
+
module Action
|
4
|
+
class MessageSavingState
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env[:ui].info(I18n.t("vagrant_ovirt4.saving_state"))
|
11
|
+
@app.call(env)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|