[ovirt-users] Autostart vm's at host boot on local storage

Blaster Blaster at 556nato.com
Tue Dec 23 10:51:42 EST 2014


There was a discussion on this list a year or so ago about this.  I 
believe one of the developers responded that oVirt has no facility to 
start VMs on a boot, and explained why....

I use the following 2 scripts to start VMs automatically when my AIO 
host reboots for whatever reason.  The Python script was grabbed from 
somewhere on the net, I don't remember where anymore.
I run the first script out of cron every 15 minutes.

#!/bin/bash

VMSTART="vm1 vm2 vm...."

for vm in ${VMSTART}
do
echo "Do I need to start  ${vm}"
/root/bin/vm_up ${vm}
if [ $? -eq 1 ]; then
TEXT="VM ${vm} needed starting"
echo "${TEXT}"
echo "${TEXT}" | mailx -s "${TEXT}" root at domain.com
fi
done

#!/usr/bin/python

import sys, string
from time import sleep

from ovirtsdk.api import API
from ovirtsdk.xml import params

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

URL =           'https://host.domain/api'
USERNAME =      'admin at internal'
PASSWORD =      'passwd'
CA_FILE = '/etc/pki/ovirt-engine/ca.pem'

VM_NAME = sys.argv[1]

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


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)
          sys,exit(1)
      else:
          print 'VM already up'
      sys.exit(0)
except Exception as e:
      print 'Failed to Start VM:\n%s' % str(e)



On 12/22/2014 10:53 PM, Brent Hartzell wrote:
> Can this be done? We hit a road block with gluster and will be using 
> local storage while testing gluster. Only problem, if a host reboots, 
> the vm's on that host do not. Is there a way to have ovirt/libvirt 
> start all vm's residing on the local storage?
>
>
> _______________________________________________
> Users mailing list
> Users at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20141223/2a82c841/attachment.html>


More information about the Users mailing list