Hi,

By coincidence I was thinking about VM startup order myself a few days ago. 
Unless we have a compelling reason to deviate, I think we should follow the OVF 
spec, have a look here:

http://www.dmtf.org/sites/default/files/standards/documents/DSP0243_1.1.0.pdf

search for "StartupSection". I think if we follow the standard then it will be 
much easier to export/ import OVF appliances in future.

I've got some notes on how we might be able to do this incrementally: I'll tidy 
them up and email them to the list :)

BTW I was also thinking about the current xapi-autostart-vms script. When this 
was first written we didn't have multi-host resource pools, so it made sense to 
restart VMs on host bootup. Now that we have pools, it would probably make more 
sense to restart VMs on other hosts when the host fails - what do you think?

Cheers,
Dave


From: [email protected] 
[mailto:[email protected]] On Behalf Of Alberto González 
Rodríguez
Sent: 21 December 2010 11:10
To: [email protected]
Subject: [Xen-API] REQUEST - Power on after another VM was started

Hello,

I would like know about your opinion about implement startup order on 
xenserver/xcp

I did a little modification on "xapi-autostart-vms" file, idea is the next:
- other_config:auto_poweron now is false or true, for any reason seems not 
boolean, then i can use "false" as value
- a two new fields on VM's other_config
     - auto_poweron_after: contains a vm uuid, if this value has a vm uuid, 
then is started when vm on auto_poweron_after field is in state "running"
     - auto_poweron_after_tools, contains a vm uuid, if this value has a vm 
uuid, then is started when vm on auto_poweron_after field has the field "live" 
in true

An example:

xe vm-param-set uuid=df81d848-e246-8958-125e-ad53d72b32de 
other-config:auto_poweron=after
xe vm-param-set uuid=df81d848-e246-8958-125e-ad53d72b32de 
other-config:auto_poweron_after=b2e6f6e0-c981-372e-10c0-a51bbc7164ec (or xe 
vm-param-set uuid=df81d848-e246-8958-125e-ad53d72b32de 
other-config:auto_poweron_after_tools=b2e6f6e0-c981-372e-10c0-a51bbc7164ec)

script modified is:

#!/bin/sh
#
# Copyright (c) Citrix Systems 2008. All rights reserved.
#
# wait for xapi initialisation to complete.
# Then, if initialisation did complete,  attempt to start all vms
# with "auto_poweron" in their other-config
#

[ -e /proc/xen ] || exit 0

XAPI_START_TIMEOUT_SECONDS=240

# wait for xapi to complete initialisation for a max 4 minutes
/opt/xensource/bin/xapi-wait-init-complete ${XAPI_START_TIMEOUT_SECONDS}
if [ $? -eq 0 ]; then
    # if xapi init completed then start vms (best effort, don't report errors)
    xe vm-start other-config:auto_poweron=true power-state=halted --multiple 
>/dev/null 2>/dev/null || true

    # 120 seconds should be a generous time
    for i in `/usr/bin/seq 1 24`;
    do
            UUIDS=$(/opt/xensource/bin/xe vm-list 
other-config:auto_poweron=after power-state=halted | /bin/grep ^uuid | /bin/awk 
'{print $5}')
            # If there are not vm with power state halted and 
auto_poweron=after, exit with 0
            if [ -z "$UUIDS" ]; then
               exit 0
            fi
            for uuid in $UUIDS
            do
                # Fields are "auto_poweron_after" and 
"auto_poweron_after_tools" and contains vm uuid
                AFTER=$(/opt/xensource/bin/xe vm-param-get uuid=${uuid} 
param-name=other-config param-key=auto_poweron_after 2>/dev/null)
                AFTERTOOLS=$(/opt/xensource/bin/xe vm-param-get uuid=${uuid}   
param-name=other-config param-key=auto_poweron_after_tools 2>/dev/null)

                if [ "x$AFTER" != "x" ];        then
                        STATE=$(/opt/xensource/bin/xe vm-param-get 
uuid=${AFTER} param-name=power-state 2>/dev/null)
                        # Start if vm is running
                        if [ "$STATE" == "running" ]; then
                            /opt/xensource/bin/xe vm-start uuid=${uuid}
                        fi

                elif [ "x$AFTERTOOLS" != "x" ]; then
                        STATE=$(/opt/xensource/bin/xe vm-param-get 
uuid=${AFTERTOOLS} param-name=live 2>/dev/null)
                        # Start xen tools are running
                        if [ "$STATE" == "true" ]; then
                            /opt/xensource/bin/xe vm-start uuid=${uuid}
                        fi
                fi
            done
            sleep 5
     done

fi


sorry my english
_______________________________________________
xen-api mailing list
[email protected]
http://lists.xensource.com/mailman/listinfo/xen-api

Reply via email to