Skip to content
Mo Morsi edited this page Jan 4, 2013 · 4 revisions

title: Setting_up_oVirt
updated_on: Thu Sep 20 12:23:41 ~~0400 2012\

\
h1. Setting up oVirt
\
![](>http://www.redhat.com/g/magazine/video_stills/ovirt_demo2.png)
\
] to presentations / demo portal
\
These are complete end-to-end instruction on how to setup oVirt on a
Fresh Fedora 17 system, for use in demoing Aeolus
\
h2. Prereqs
\
oVirt cannot be run in a vm or off a live cd. It must be run on a
baremetal / installed system
\
oVirt requires 3GB of memory, and sufficient diskspace to store and
manipulate images
\
h3. Installation:
\
yum localinstall
[http://ovirt.org/releases/ovirt-release-fedora.noarch.rpm](http://ovirt.org/releases/ovirt-release-fedora.noarch.rpm)\
yum install ovirt-engine
\
h4. Setup host:
\
echo “192.168.122.218 ovirt” \>\> /etc/hosts
\
Set hostname in /etc/sysconfig/network
\
h4. Configure prereqs:
\
dnsmasq~~~~bind-interfaces~~-listen-address=127.0.0.1\
echo “PermitRootLogin yes” \>\> /etc/ssh/sshd\_config\
service sshd restart

#### Setup oVirt:

engine-setup

#### Setup nfs:

copy the following to /etc/exports:\
 /ext/ovirt31storage **\

/ext/ovirt31export**(rw,async,no\_subtree\_check,all\_squash,anonuid=36,anongid=36)\
 /ext/ovirt31isos **\
mkdir nfs dirs\
chown / set perms on nfs dirs to vdsm.kvm 775

\
h4. Import an initial image
\
engine-iso-uploader -i is1 upload
Downloads/Fedora-17-x86\_64-Live-Desktop.iso
\
h4. Add storage domains to the web ui
\
Open up web browser, navigate to [http://ovirt](http://ovirt)
\
Click on Administrative Interface and login
\
Click at storage domains at the top and then create / new storage domain
\
Fill in nfs details of storage domain,****note****!
\
** add and activate the ‘ovirt31storage’ domain before the isos or
export\
\* make sure to specify a mount point that is externally accessible (eg
ovirt:/ovirt31storage), this will need to be the EXACT SAME mountpoint
you moint on the Aeolus side\
\* make sure to select the ‘iso’ and ‘export’ types for the other
domains\
\* each time your machine reboots you will need to make sure the domains
start off as umounted before activating them in the oVirt web interface

#### Add localhost as a oVirt node to the web ui

In the same admin interface click on hosts, then ‘new host’. Fill in the
details for the local host. No need to configure power management.

This most likely will reboot the machine as the node is added to ovirt

#### Launch instance

Create new server in ui, add disk image, and click ‘run once’. Select
the cd image you uploaded before (this may take a few minutes after the
iso domain comes online to be available) and ‘run’

##### Helper python script to start storage domains

    <code class="python">
    #! /usr/bin/python
    from time import sleep
    from ovirtsdk.api import API
    from ovirtsdk.xml import params

    VERSION = params.Version(major='3', minor='0')

    URL =           'https://192.168.1.7:8443/api'
    USERNAME =      'admin@internal'
    PASSWORD =      'cloudpass'

    DC_NAME =       'Default'
    CLUSTER_NAME =  'Default'
    HOST_NAME =     'l2'
    STORAGE_NAME =  'os1'
    ISO_NAME     =  'is1'
    EXPORT_NAME =   'es1'

    STORAGE_ADDRESS = '192.168.1.7'
    #ISO_PATH = '/ext/ovirt31isos/'

    api = API(url=URL, username=USERNAME, password=PASSWORD)

    try:
        #if api.datacenters.get(DC_NAME).storagedomains.add(api.storagedomains.get(ISO_NAME)):
        #    print 'ISO Domain was attached successfully'
        if api.datacenters.get(DC_NAME).storagedomains.get(STORAGE_NAME).activate():
            print 'Storage Domain was activated successfully'
        if api.datacenters.get(DC_NAME).storagedomains.get(ISO_NAME).activate():
            print 'ISO Domain was activated successfully'
        if api.datacenters.get(DC_NAME).storagedomains.get(EXPORT_NAME).activate():
            print 'Export Domain was activated successfully'
    except Exception as e:
        print 'Failed to add domain:\n%s' % str(e)
    </code>

##### Helper python script to start instance

    <code class="python">
    #! /usr/bin/python
    from time import sleep
    from ovirtsdk.api import API
    from ovirtsdk.xml import params

    VERSION = params.Version(major='3', minor='0')

    URL =           'https://192.168.1.7:8443/api'
    USERNAME =      'admin@internal'
    PASSWORD =      'cloudpass'

    DC_NAME =       'Default'
    CLUSTER_NAME =  'Default'
    HOST_NAME =     'l2'
    STORAGE_NAME =  'os1'
    EXPORT_NAME =   'es1'
    VM_NAME =       'demo7'

    api = API(url=URL, username=USERNAME, password=PASSWORD)

    MB = 1024*1024
    GB = 1024*MB

    try:
        api.vms.add(params.VM(name=VM_NAME, memory=2*GB, cluster=api.clusters.get(CLUSTER_NAME), template=api.templates.get('Blank')))
        print 'VM created'

        api.vms.get(VM_NAME).nics.add(params.NIC(name='eth0', network=params.Network(name='ovirtmgmt'), interface='virtio'))
        print 'NIC added to VM'

        api.vms.get(VM_NAME).disks.add(params.Disk(storage_domains=params.StorageDomains(storage_domain=[api.storagedomains.get(STORAGE_NAME)]),
                                                    size=512*MB,
                                                    status=None,
                                                    interface='virtio',
                                                    format='cow',
                                                    sparse=True,
                                                    bootable=True))
        print 'Disk added to VM'
        print 'Waiting for VM to reach Down status'
        while api.vms.get(VM_NAME).status.state != 'down':
            sleep(1)

    except Exception as e:
        print 'Failed to create VM with disk and NIC\n%s' % str(e)

    sleep(10)

    try:
        if api.vms.get(VM_NAME).status.state != 'up':
            print 'Starting VM'
            api.vms.get(VM_NAME).start()
            print 'Waiting for VM to reach Up status'
            while api.vms.get(VM_NAME).status.state != 'up':
                sleep(1)
        else:
            print 'VM already up'
    except Exception as e:
        print 'Failed to Start VM:\n%s' % str(e)
    </code>
Clone this wiki locally