vagrant-ovirt 0.0.1 → 0.0.2
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.
- data/CHANGELOG.md +10 -0
- data/README.md +43 -24
- data/example_box/Vagrantfile +2 -2
- data/lib/vagrant-ovirt/action.rb +3 -2
- data/lib/vagrant-ovirt/action/create_network_interfaces.rb +63 -16
- data/lib/vagrant-ovirt/action/timed_provision.rb +1 -1
- data/lib/vagrant-ovirt/version.rb +1 -1
- data/tools/prepare_redhat_for_box.sh +4 -3
- data/vagrant-ovirt.gemspec +2 -2
- metadata +5 -4
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -5,18 +5,26 @@ This is a [Vagrant](http://www.vagrantup.com) 1.1+ plugin that adds an
|
|
5
5
|
[rhev](http://www.redhat.com/products/virtualization/) provider to Vagrant,
|
6
6
|
allowing Vagrant to control and provision machines in oVirt and RHEV.
|
7
7
|
|
8
|
-
|
8
|
+
In this document, both oVirt and RHEV names are used interchangeably and
|
9
|
+
represent the same platform on top of which this provider should work.
|
9
10
|
|
10
|
-
|
11
|
+
**Note:** Actual version (0.0.2) is still a development one. It was developed
|
12
|
+
and tested on RHEV 3.1 only.
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
## Features (Version 0.0.2)
|
15
|
+
|
16
|
+
* Vagrant `up` and `destroy` commands.
|
17
|
+
* Create and boot oVirt machines from templates.
|
14
18
|
* SSH into domains.
|
15
19
|
* Provision domains with any built-in Vagrant provisioner.
|
16
20
|
* Minimal synced folder support via `rsync`.
|
17
21
|
|
18
22
|
## Future work
|
19
23
|
|
24
|
+
* Validation of configuration parameters.
|
25
|
+
* Test it on other versions of oVirt and RHEV.
|
26
|
+
* Template preparation scripts for other distros than RHEL.
|
27
|
+
* Vagrant commands `halt`, `resume`, `ssh`, `provision`, `suspend` and `resume`.
|
20
28
|
* Take a look at [open issues](https://github.com/pradels/vagrant-ovirt/issues?state=open).
|
21
29
|
|
22
30
|
## Installation
|
@@ -46,19 +54,23 @@ your information where necessary.
|
|
46
54
|
Vagrant.configure("2") do |config|
|
47
55
|
config.vm.define :test_vm do |test_vm|
|
48
56
|
test_vm.vm.box = "ovirt"
|
57
|
+
test_vm.vm.network :private_network,
|
58
|
+
:ip => '10.20.30.40',
|
59
|
+
:ovirt__network_name => 'ovirt_network',
|
60
|
+
|
49
61
|
test_vm.vm.provider :ovirt do |ovirt|
|
50
|
-
ovirt.template = "
|
51
|
-
ovirt.quota = "
|
62
|
+
ovirt.template = "Template name"
|
63
|
+
ovirt.quota = "Quota name"
|
52
64
|
ovirt.cpus = 1
|
53
65
|
ovirt.memory = 1024
|
54
66
|
end
|
55
67
|
end
|
56
68
|
|
57
69
|
config.vm.provider :ovirt do |ovirt|
|
58
|
-
ovirt.url = "https://
|
59
|
-
ovirt.username = "
|
60
|
-
ovirt.password = "
|
61
|
-
ovirt.datacenter = "
|
70
|
+
ovirt.url = "https://ovirt.example.com:443"
|
71
|
+
ovirt.username = "Username"
|
72
|
+
ovirt.password = "Secret"
|
73
|
+
ovirt.datacenter = "Datacenter name"
|
62
74
|
end
|
63
75
|
end
|
64
76
|
|
@@ -73,16 +85,17 @@ This provider exposes quite a few provider-specific configuration options:
|
|
73
85
|
* `password` - Password to access oVirt.
|
74
86
|
* `datacenter` - oVirt datacenter name, where machines will be created.
|
75
87
|
* `cluster` - oVirt cluster name. Defaults to first cluster found.
|
76
|
-
*
|
77
|
-
MAC address specified in
|
78
|
-
searches in local arp table.
|
88
|
+
* `ip_command` - Shell command, which shoud return IP address string for
|
89
|
+
MAC address specified in environment variable named $MAC. By default, this
|
90
|
+
command searches IP in local arp table.
|
79
91
|
|
80
92
|
### Domain Specific Options
|
81
93
|
|
82
94
|
* `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
|
83
95
|
* `cpus` - Number of virtual cpus. Defaults to 1 if not set.
|
84
96
|
* `template` - Name of template from which new VM should be created.
|
85
|
-
* `quota` - Name of oVirt quota for VM. Defaults to first quota found
|
97
|
+
* `quota` - Name of oVirt quota for VM. Defaults to first quota found in
|
98
|
+
datacenter.
|
86
99
|
|
87
100
|
Specific domain settings can be set for each domain separately in multi-VM
|
88
101
|
environment. Example below shows a part of Vagrantfile, where specific options
|
@@ -122,27 +135,33 @@ Vagrant goes through steps below when creating new project:
|
|
122
135
|
1. Connect to oVirt via REST API on every REST query.
|
123
136
|
2. Create new oVirt machine from template with additional network interfaces.
|
124
137
|
3. Start oVirt machine.
|
125
|
-
4. Check for IP address of VM with ip_command
|
138
|
+
4. Check for IP address of VM with `ip_command`.
|
126
139
|
5. Wait till SSH is available.
|
127
140
|
6. Sync folders via `rsync` and run Vagrant provisioner on new domain if
|
128
141
|
setup in Vagrantfile.
|
129
142
|
|
130
|
-
##
|
143
|
+
## Network Interfaces
|
131
144
|
|
132
|
-
Networking features in the form of `config.vm.network`
|
133
|
-
|
134
|
-
provider.
|
145
|
+
Networking features in the form of `config.vm.network` support private networks
|
146
|
+
concept. No public network or port forwarding are supported in current version
|
147
|
+
of provider.
|
135
148
|
|
136
|
-
|
149
|
+
An examples of network interface definitions:
|
137
150
|
|
138
151
|
```ruby
|
139
|
-
config.vm.define :
|
140
|
-
|
152
|
+
config.vm.define :test_vm1 do |test_vm1|
|
153
|
+
test_vm1.vm.network :private_network,
|
154
|
+
:ip => "10.20.30.40",
|
155
|
+
:netmask => "255.255.255.0",
|
156
|
+
:ovirt__network_name => "ovirt_networkname"
|
141
157
|
end
|
142
158
|
```
|
143
159
|
|
144
|
-
In example
|
145
|
-
|
160
|
+
In example below, one additional network interface is created for VM test_vm1.
|
161
|
+
Interface is connected to `ovirt_networkname` network and configured to ip
|
162
|
+
address `10.20.30.40/24`. If you omit ip address, interface will be configured
|
163
|
+
dynamicaly via dhcp.
|
164
|
+
|
146
165
|
|
147
166
|
## Obtaining Domain IP Address
|
148
167
|
|
data/example_box/Vagrantfile
CHANGED
@@ -15,8 +15,8 @@ Vagrant.configure("2") do |config|
|
|
15
15
|
|
16
16
|
#config.vm.provider :ovirt do |ovirt|
|
17
17
|
# ovirt.url = "https://ovirt.example.com:443"
|
18
|
-
# ovirt.username = "
|
19
|
-
# ovirt.password = "
|
18
|
+
# ovirt.username = "Username"
|
19
|
+
# ovirt.password = "Secret"
|
20
20
|
# ovirt.datacenter = "Datacenter name"
|
21
21
|
#end
|
22
22
|
end
|
data/lib/vagrant-ovirt/action.rb
CHANGED
@@ -17,12 +17,13 @@ module VagrantPlugins
|
|
17
17
|
next
|
18
18
|
end
|
19
19
|
|
20
|
-
# Create and start VM if not yet created.
|
21
20
|
b2.use SetNameOfDomain
|
22
21
|
b2.use CreateVM
|
23
|
-
b2.use CreateNetworkInterfaces
|
24
22
|
|
25
23
|
b2.use TimedProvision
|
24
|
+
b2.use CreateNetworkInterfaces
|
25
|
+
|
26
|
+
b2.use SetHostname
|
26
27
|
b2.use StartVM
|
27
28
|
b2.use WaitTillUp
|
28
29
|
b2.use SyncFolders
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'log4r'
|
2
|
+
require 'vagrant/util/scoped_hash_override'
|
2
3
|
|
3
4
|
module VagrantPlugins
|
4
5
|
module OVirtProvider
|
5
6
|
module Action
|
6
7
|
# Create network interfaces for machine, before VM is running.
|
7
8
|
class CreateNetworkInterfaces
|
9
|
+
include Vagrant::Util::ScopedHashOverride
|
8
10
|
|
9
11
|
def initialize(app, env)
|
10
12
|
@logger = Log4r::Logger.new("vagrant_ovirt::action::create_network_interfaces")
|
@@ -26,41 +28,53 @@ module VagrantPlugins
|
|
26
28
|
|
27
29
|
# First interface is for provisioning, so this slot is not usable.
|
28
30
|
# This interface should be available already from template.
|
29
|
-
adapters[0] =
|
31
|
+
adapters[0] = {
|
32
|
+
:network_name => 'rhevm'
|
33
|
+
}
|
30
34
|
|
31
35
|
env[:machine].config.vm.networks.each do |type, options|
|
32
|
-
#
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
# We support private and public networks only. They mean both the
|
37
|
+
# same right now.
|
38
|
+
next if type != :private_network and type != :public_network
|
39
|
+
|
40
|
+
# Get options for this interface. Options can be specified in
|
41
|
+
# Vagrantfile in short format (:ip => ...), or provider format
|
42
|
+
# (:ovirt__network_name => ...).
|
43
|
+
options = scoped_hash_override(options, :ovirt)
|
44
|
+
options = {
|
45
|
+
:netmask => '255.255.255.0',
|
46
|
+
:network_name => 'rhevm'
|
47
|
+
}.merge(options)
|
37
48
|
|
38
49
|
if options[:adapter]
|
39
50
|
if adapters[options[:adapter]]
|
40
51
|
raise Errors::InterfaceSlotNotAvailable
|
41
52
|
end
|
42
53
|
|
43
|
-
|
54
|
+
free_slot = options[:adapter].to_i
|
44
55
|
else
|
45
|
-
|
46
|
-
raise Errors::InterfaceSlotNotAvailable if
|
56
|
+
free_slot = find_empty(adapters, start=1)
|
57
|
+
raise Errors::InterfaceSlotNotAvailable if free_slot == nil
|
58
|
+
end
|
47
59
|
|
48
|
-
|
49
|
-
end
|
60
|
+
adapters[free_slot] = options
|
50
61
|
end
|
51
62
|
|
52
63
|
# Create each interface as new domain device
|
53
|
-
adapters.each_with_index do |
|
54
|
-
next if
|
64
|
+
adapters.each_with_index do |opts, slot_number|
|
65
|
+
next if slot_number == 0
|
55
66
|
iface_number = slot_number + 1
|
56
67
|
|
68
|
+
#require 'pp'
|
69
|
+
#pp env[:ovirt_client].networks(:cluster => env[:ovirt_cluster].id)
|
70
|
+
|
57
71
|
# Get network id
|
58
72
|
network = OVirtProvider::Util::Collection.find_matching(
|
59
|
-
env[:ovirt_client].networks(:
|
60
|
-
network_name)
|
73
|
+
env[:ovirt_client].networks(:cluster_id => env[:ovirt_cluster].id),
|
74
|
+
opts[:network_name])
|
61
75
|
if network == nil
|
62
76
|
raise Errors::NoNetworkError,
|
63
|
-
:network_name => network_name
|
77
|
+
:network_name => opts[:network_name]
|
64
78
|
end
|
65
79
|
|
66
80
|
@logger.info("Creating network interface nic#{iface_number}")
|
@@ -78,7 +92,40 @@ module VagrantPlugins
|
|
78
92
|
end
|
79
93
|
end
|
80
94
|
|
95
|
+
# Continue the middleware chain.
|
81
96
|
@app.call(env)
|
97
|
+
|
98
|
+
# Configure interfaces that user requested. Machine should be up and
|
99
|
+
# running now.
|
100
|
+
networks_to_configure = []
|
101
|
+
|
102
|
+
adapters.each_with_index do |opts, slot_number|
|
103
|
+
# Skip configuring first interface. It's used for provisioning and
|
104
|
+
# it has to be available during provisioning - ifdown command is
|
105
|
+
# not acceptable here.
|
106
|
+
next if slot_number == 0
|
107
|
+
|
108
|
+
network = {
|
109
|
+
:interface => slot_number,
|
110
|
+
#:mac => ...,
|
111
|
+
}
|
112
|
+
|
113
|
+
if opts[:ip]
|
114
|
+
network = {
|
115
|
+
:type => :static,
|
116
|
+
:ip => opts[:ip],
|
117
|
+
:netmask => opts[:netmask],
|
118
|
+
}.merge(network)
|
119
|
+
else
|
120
|
+
network[:type] = :dhcp
|
121
|
+
end
|
122
|
+
|
123
|
+
networks_to_configure << network
|
124
|
+
end
|
125
|
+
|
126
|
+
env[:ui].info I18n.t("vagrant.actions.vm.network.configuring")
|
127
|
+
env[:machine].guest.capability(
|
128
|
+
:configure_networks, networks_to_configure)
|
82
129
|
end
|
83
130
|
|
84
131
|
private
|
@@ -6,7 +6,7 @@ module VagrantPlugins
|
|
6
6
|
# This is the same as the builtin provision except it times the
|
7
7
|
# provisioner runs.
|
8
8
|
class TimedProvision < Vagrant::Action::Builtin::Provision
|
9
|
-
def run_provisioner(env, p)
|
9
|
+
def run_provisioner(env, name, p)
|
10
10
|
timer = Util::Timer.time do
|
11
11
|
super
|
12
12
|
end
|
@@ -89,7 +89,7 @@ chmod 600 ~root/.ssh/authorized_keys
|
|
89
89
|
chkconfig iptables off
|
90
90
|
chkconfig ip6tables off
|
91
91
|
sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/sysconfig/selinux
|
92
|
-
sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
|
92
|
+
[ -f /etc/selinux/config ] && sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
|
93
93
|
|
94
94
|
|
95
95
|
# Networking setup..
|
@@ -113,16 +113,17 @@ set_sysctl 'net.ipv4.conf.all.arp_ignore' 1
|
|
113
113
|
set_sysctl 'net.ipv4.conf.all.arp_announce' 2
|
114
114
|
set_sysctl 'net.ipv4.conf.all.rp_filter' 3
|
115
115
|
|
116
|
+
# Ok, this is not very clean solution. Should be replaced in future. It allows
|
117
|
+
# all machines on local network to have arp record about new VM.
|
116
118
|
echo 'for NETWORK in $(ip a | grep -w inet | grep -v "127.0.0.1" | awk "{ print \$2 }"); do nmap -sP $NETWORK; done' > /etc/rc3.d/S99ping_broadcast
|
117
119
|
chmod +x /etc/rc3.d/S99ping_broadcast
|
118
120
|
|
119
|
-
|
120
121
|
# Don't fix ethX names to hw address.
|
121
122
|
rm -f /etc/udev/rules.d/*persistent-net.rules
|
122
123
|
rm -f /etc/udev/rules.d/*-net.rules
|
123
124
|
rm -fr /var/lib/dhclient/*
|
124
125
|
|
125
|
-
# Interface eth0 should get IP address via dhcp.
|
126
|
+
# Interface eth0 should always get IP address via dhcp.
|
126
127
|
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
|
127
128
|
DEVICE="eth0"
|
128
129
|
BOOTPROTO="dhcp"
|
data/vagrant-ovirt.gemspec
CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/vagrant-ovirt/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Lukas Stanek"]
|
6
6
|
gem.email = ["ls@elostech.cz"]
|
7
|
-
gem.description = %q{Vagrant provider for oVirt.}
|
8
|
-
gem.summary = %q{Vagrant provider for oVirt.}
|
7
|
+
gem.description = %q{Vagrant provider for oVirt and RHEV.}
|
8
|
+
gem.summary = %q{Vagrant provider for oVirt and RHEV.}
|
9
9
|
gem.homepage = "https://github.com/pradels/vagrant-ovirt"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-ovirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
description: Vagrant provider for oVirt.
|
62
|
+
description: Vagrant provider for oVirt and RHEV.
|
63
63
|
email:
|
64
64
|
- ls@elostech.cz
|
65
65
|
executables: []
|
@@ -67,6 +67,7 @@ extensions: []
|
|
67
67
|
extra_rdoc_files: []
|
68
68
|
files:
|
69
69
|
- .gitignore
|
70
|
+
- CHANGELOG.md
|
70
71
|
- Gemfile
|
71
72
|
- LICENSE
|
72
73
|
- README.md
|
@@ -124,5 +125,5 @@ rubyforge_project:
|
|
124
125
|
rubygems_version: 1.8.25
|
125
126
|
signing_key:
|
126
127
|
specification_version: 3
|
127
|
-
summary: Vagrant provider for oVirt.
|
128
|
+
summary: Vagrant provider for oVirt and RHEV.
|
128
129
|
test_files: []
|