OVirt

From Gentoo Wiki
Jump to: navigation, search

Contents

Background

oVirt project is a complete open sourced virtualization management platform working with kvm. More can be found here: [1]
Additional information (including presentations) from a Workshop held early this November is available here: [2]
The Project is made of:

Description

This article will try to explain how to install oVirt on Gentoo system, more specifically we'll set up the following:

Note
This manual is what I did on my Gentoo server. If you have different install, which you probably do, you might not strictly do copy/paste and some additional steps might be necessary. I will specify every error I encountered and a solution to it at the end of the document. Feel free to add any problem not noted

Install Java runtime

Ovirt manual is suggesting installing openJDK. My server has sun-jdk already set so I will point you to Gentoo Java guide for setting java environment. Make sure you are setting jdk version 1.6!!!

Install Java application server – JBoss

oVirt runs on JBoss application server, here is a quick guide to set up jboss for our needs. The plan is to have JBoss under /opt, make a jboss user and set the installation dir as the user's home dir (I did this because I wanted to have everything on a single place for portability and because it makes things easier with permissions etc). Then we 'll put ovirt inside this directory and set it up.

user $ cd /opt
root # tar xvzf jboss-as-7.1.0.CR1b.tar.gz
root # useradd -d /opt/jboss-as-7.1.0.CR1b -u 36 -g 36 -r jboss -Z user_u
root # chown -R jboss:jboss /opt/jboss-as-7.1.0.CR1b
root # su jboss
user $ cd ~
user $ bin/standalone.sh -b 0.0.0.0

Troubleshooting JBoss

If you're being attacked by exceptions, follow this list:

Codejboss.te
module jboss 1.0;

require {
        type user_tmp_t;
        type user_home_dir_t;
        type bin_t;
        type usr_t;
        type port_t;
        type node_t;
        type sysfs_t;
        type newrole_t;
        type java_t;
        class tcp_socket { name_bind listen accept node_bind };
        class fd use;
        class capability dac_override;
        class file{ read write getattr open create unlink };
        class dir { getattr read write open search add_name create remove_name };
}

#============= java_t ==============
allow java_t newrole_t:fd use;
allow java_t bin_t:file { getattr read open };
allow java_t self:capability dac_override;
allow java_t sysfs_t:dir { read search open };
allow java_t user_tmp_t:dir { read getattr open search write add_name create remove_name };
allow java_t user_home_dir_t:dir search;
allow java_t user_tmp_t:file { create read write open unlink };
allow java_t usr_t:dir { write add_name create remove_name };
allow java_t usr_t:file { create open write };
allow java_t port_t:tcp_socket name_bind;
allow java_t self:tcp_socket { listen accept };
allow java_t node_t:tcp_socket node_bind;
127.0.0.1 localhost engine-dev
user $ export JAVA_OPTS="-Xmx2048m"

Installing PostgreSQL

Ovirt Engine works with postgresql 8.4.x or 9.1.x

If you didn't already, specify default locale for your server (as root):

root # cat /etc/locale.gen

Output (may be different)

en_US ISO-8859-1
en_US.UTF-8 UTF-8
sr_RS UTF-8
sr_RS@latin UTF-8 
root # echo 'LANG="en_US.UTF-8"' > /etc/env.d/02locale
root # env-update && source /etc/profile

Now lets install PostgreSQL...

root # echo "dev-db/postgresql-server uuid" >> /etc/portage/package.use/monolithic
root # emerge -DuNavt dev-db/postgresql-server:9.1 jdbc-postgresql
root # usermod -a -G postgres jboss

Installing oVirt Engine Core

Now that our needed components are in place it's time to download and build the engine core. Sticking to the plan lets get ovirt engine's source code and place it inside ~jboss/ We 'll do the whole process as user jboss

root # su jboss
user $ cd ~
user $ wget http://www.ovirt.org/releases/stable/src/ovirt-engine-3.0.0_0001.tar.gz
user $ mkdir ovirt-engine
user $ tar xvzf ovirt-engine-3.0.0_0001.tar.gz -C ovirt-engine

Install maven

root # emerge --ask dev-java/maven-bin
root # emerge -DuNavt =dev-java/maven-bin-2.2.1
user $ mvn-2.2
File~/.m2/settings.xml
 
<?xml version="1.0"?>
<settings xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
          http://maven.apache.org/xsd/settings-1.0.0.xsd">

<!--**************************** PROFILES ****************************-->

        <activeProfiles>
                <activeProfile>oVirtEnvSettings</activeProfile>
        </activeProfiles>

        <profiles>
                <profile>
                        <id>oVirtEnvSettings</id>
                        <properties>
                                <jbossHome>/opt/jboss-as-7.1.0.CR1b</jbossHome>
                                <JAVA_1_6_HOME>/opt/sun-jdk-1.6.0.26</JAVA_1_6_HOME>
                                <forkTests>always</forkTests>
                        </properties>
                </profile>
        </profiles>
</settings>

Build oVirt-engine

Prepare build environment

export MAVEN_OPTS="-Xmx2048M -XX:MaxPermSize=2048M"

by adding the lines:

<!-- Reduce the number of permutations to compile, just for tests: -->
<set-property name="user.agent" value="gecko1_8"/>

Building ovirt-engine and REST api

user $ cd ~/ovirt-engine/
user $ mvn-2.2 -e -DskipTests=true clean install

Compile web-admin and user-portal

user $ cd ~/ovirt-engine/
user $ mvn-2.2 -e -DskipTests=true clean install -Pgwt-admin,gwt-user

Application deployment

Time to put oVirt Engine Core and its components to JBoss

user $ cd ~/ovirt-engine/ear
user $ mvn-2.2 -e -DskipTests=true clean install -Pdep,setup
user $ cd ~jboss/ovirt-engine/ear
user $ mvn-2.2 -e -DskipTests=true clean install -Pdep
user $ cd $OVIRT_HOME/ear
user $ mvn-2.2 -e -DskipTests=true clean install -Pdep

New ROOT container deployment

We need to replace the JBoss's root container (what you see under http://engine-dev:8080/) with oVirt's ROOT.war since it'll hold the Engine Core's certificate and public ssh key, used by oVirt nodes.

user $ cp -a ~/ovirt-engine/packaging/fedora/setup/resources/jboss/ROOT.war ~/standalone/deployments/
File~/standalone/configuration/standalone.xml
[...]
<virtual-server name="default-host" enable-welcome-root="false">
[...]
user $ touch ~/standalone/deployments/ROOT.war.dodeploy

Creating the database schema

Finally it's time to create the database schema for Engine Core

user $ cd ~/ovirt-engine/backend/manager/dbscripts
user $ ./create_db_devel.sh -u postgres

Create the oVirt Engine Core's Certificate Authority and keys

Now we need to create the Engine Core's CA certificate that 'll be used to sign the certificate of each Hypervisor and its public ssh key, needed for engine <-> Hypervisor communication. The plan is to put everything under ~/pki (on Fedora /etc/pki is used) and put the needed values on the database.

user $ mkdir ~/pki
user $ mkdir ~/pki/vps-ca
user $ mkdir ~/pki/vps-ca/ca
user $ cd ~/pki/vps-ca/ca
user $ gcc ~/ovirt-engine/backend/manager/3rdparty/pub2ssh/src/pubkey2ssh.c -o pubkey2ssh -lcrypto
user $ cd ~/ovirt-engine/backend/manager/conf/ca
user $ ./installCA_dev.sh `pwd` ~/pki/vps-ca
user $ cd ~/pki/vps-ca/ca
user $ ./exportK2SSH.sh ~/pki/vps-ca/ca/.keystore engine engine.pub NoSoup4U
user $ ./pubkey2ssh keys/engine.pub engine > keys/engine.ssh.key.txt
user $ rm keys/engine.pub
Warning
"NoSoup4U" is the default password for the keystore and the certificate defined inside ~/pki/vps-ca/ca/* files and scripts, you should change it !
user $ cd ~/pki/vps-ca/ca
user $ cp keys/engine.ssh.key.txt ~/standalone/deployments/ROOT.war/
user $ cp ca.pem ~/standalone/deployments/ROOT.war/ca.crt
Note
SignReq.sh script found inside ~/pki/vps-ca/ca will try to write to /var/lock, in case your jboss user is not allowed to write there -or you don't want to- just edit that script like this
FileSignReq.sh
#lock_file=$7
if [ -z "$lock_file" ]; then
        lock_file=/tmp/.openssl.exclusivelock
fi
If you don't then you'll hit an error each time you try to add a Hypervisor to the system

Time to add our new CA to the database, this script will do the trick...

Fileca_db.sh
#!/bin/bash

CA_DIR=/opt/jboss-as-7.1.0.CR1b/pki/vps-ca/ca

psql engine postgres -c "update vdc_options set option_value = '$CA_DIR/certs/engine.cer' where option_name = 'CertificateFileName';"
psql engine postgres -c "update vdc_options set option_value = '$CA_DIR/.keystore' where option_name = 'TruststoreUrl';"
psql engine postgres -c "update vdc_options set option_value = '$CA_DIR' where option_name = 'CABaseDirectory';"
psql engine postgres -c "update vdc_options set option_value = 'ca.pem' where option_name  = 'CACertificatePath';"
psql engine postgres -c "update vdc_options set option_value = '$CA_DIR/.keystore' where option_name = 'keystoreUrl';"
psql engine postgres -c "update vdc_options set option_value = '$CA_DIR/private/ca.pem' where option_name = 'CAEngineKey';"

Testing

user $ cd ~
user $ bin/standalone.sh -b 0.0.0.0
http://engine-dev:8080/
 http://engine-dev:8080/webadmin
 http://engine-dev:8080/UserPortal
user $ wget -O - --debug --auth-no-challenge --http-user=admin@internal --http-password='letmein!' head='Accept: application/xml' http://engine-dev:8080/api/
http://engine-dev:8080/api

Install vdsm

Warning
VDSM for now is mostly Fedora/Redhat oriented, trying to set up VDSM on a non-Fedora node takes more than you think. If you succeed however please update this part of the article and notify upstream. Until then I suggest you use an oVirt-node image for your Hypervisors from here [3]
root # emerge --ask dev-python/pyflakes
user $ rpm2tgz vdsm-4.9.0-0.200.g2fc4e63.fc16.src.rpm
user $ tar zxvf vdsm-4.9.0-0.200.g2fc4e63.fc16.src.tgz
root # cd vdsm-4.9.0-0.200.g2fc4e63.fc16
root # ./configure --prefix=/path/to/install/directory && make && make install

How to contribute

Errors & Solutions

Error: When compiling projects, getting errors about unmappable characters.

Solution: My install is UTF8, but default locale was not set. So default locale by Maven/JBoss (not sure which one) was US_ASCII. Set default locale and errors are history.

Error: Compile process dies with PermGenSpace error.

Solution: This error means that no more memory is available to java compiler. This is fixed by setting MAVEN_OPTS with higher values for mx and MaxPermSize parameters. Another trick that helped was choosing only one browser to compile GWT for by modifying above mentioned files.

Error: Compile process dies with error code 137.

Solution: This one I'm not quite sure about. The only info I could google out was a suggestion to try change the java compiler (oVirt wiki uses openJDK, me sun-jdk). The solution for me was to add -e -DskipTests=true options to maven. Again, I'm not sure how this is relevant as I don't know what error 137 means or how it is caused.

Error: Message: JBAS014724: Missing required attribute(s): cache-ref

Solution:

user $ diff ovirt-engine/backend/manager/conf/standalone.xml standalone/configuration/standalone.xml
165c158
<                 <stateful default-access-timeout="5000"/>
---
>                 <stateful default-access-timeout="5000" cache-ref="simple"/>
Error: Message: JBAS014788: Unexpected attribute 'show-model' encountered

Solution:

user $ diff ovirt-engine/backend/manager/conf/standalone.xml standalone/configuration/standalone.xml
222c215
<         <subsystem xmlns="urn:jboss:domain:jmx:1.1" show-model="true"/>
---
>         <subsystem xmlns="urn:jboss:domain:jmx:1.1"/>

Advanced features

oVirt Node integration

Personal tools
Namespaces
Variants
Actions
Gentoo Websites logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki new! Get Gentoo!
Navigation
Toolbox
Categories