WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] xen domains

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] xen domains
From: devi thapa <devi.thapa@xxxxxxxxx>
Date: Mon, 17 Aug 2009 06:58:14 -0400
Delivery-date: Mon, 17 Aug 2009 03:58:52 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=/bpBrF0fmFEANmFC95rTc4p2imJWeGBe23DWTz/emjE=; b=KZHew3PNCV66AL8Z/HesuxUYecYfDpMVaMwnWC58gfw80gE5ayW7PvKt7mN/pN3NaL 3x/NBC9x9HTEaRwmyzNqDuctCYDCWX3u8SLP5nQsuObMy0nuOYyh09bgPIfTyKiERuqY XBZT96ALy4erTigXb3BuEpQ8yK/AJxQUrv/zE=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=Mh5TKDlBLAtVqFHaxPRrr/Ai32LgkUC8of61ougSqBR6sXSkwZntu0MKnvVfdcAL0S BscSWi44cINoX8giD2GJVeZRjfFq0OAQ4CuYHlqfFhbAqq20lD8muz22F/oSpSAz67XT 1D4fAOCPxoYrI1d/t4eXv2AeGmKNxiYXcknZg=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hi,

      I have found problems with xendomains service, when I wanted to start
    all the virtual machines.  So, I have written a service, which services
    the purpose of xendomains.  Hope, this may be useful.
    and here are few details
    if we want to run only one particular virtual machine
    then we will run as
    ./resourceagent vm1{virtual machine}
    and suppose if we want to run all the virtual machine,
    then simply
    ./resourceagent
    And also this code can be treated as ocf or lsb script
    I am attaching as well as copying the code.
    #!/bin/sh
    VMCONFIG="/etc/xen"
    vm=$2
    retval=0

- Ignored:


    usage()
    {
            echo "The valid options are"
            echo "start|stop|status|monitor|meta-data"
    }

    virtualmachine_meta_data()
    {
            cat <<END
            <?xml version="1.0"?>
            <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
            <resource-agent name="ResourceAgent">
            <version>1.0</version>

            <longdesc lang="en">
             This is meta-data about ResourceAgent
            </longdesc>

            <actions>
            <action name="start" timeout="60" />
            <action name="stop" timeout="40" />
            <action name="status" depth="0" timeout="30" interval="10"
    start-delay="120" />
            <action name="monitor" depth="0" timeout="30" interval="10"
    start-delay="120" />
            <action name="meta-data" timeout="5" />
            <action name="validate-all" timeout="5" />
            </actions>

            </resource-agent>
    END
    }

    virtualmachine_monitor()
    {
            if Checkforvm
            then
                    xm list $vm
                    if [ $? -eq 0 ]
                    then
                            echo $vm is running
                            retval=0
                    else
                            echo $vm is stopped
                            retval=7
                    fi
            else
                     ls /etc/xen1 >> tempfile
                     var=`cat tempfile`
                     for vm in $var
                     do
                           xm list $vm
                           if [ $? -eq 0 ]
                           then
                                  echo $vm is running
                                  retval=0
                                  else
                                          echo $vm is not running
                                          retval=7
                            fi
                      done
                    rm tempfile
            fi

    }

    Checkforvm()
    {
           if [ "${vm}" = "${null}" ] ; then
                    return 1
            else
                    return 0
            fi
    }

    virtualmachine_status()
    {
    if
         Checkforvm
    then
             xm list $vm
             rc=$?
             if
               [ $rc -ne 0 ]
             then
                   echo  \ "$vm is Stopped"
                   retval=11
             else
                   echo \ "$vm is Running"
                   retval=00
            fi

    else
            ls /etc/xen1 >> tempfile
            var=`cat tempfile`
            for vm in $var
            do
                    if [ "${vm}" = "${null}" ]
                    then
                           return  1
                    else
                            retval=2
                    fi
            done
            rm tempfile
    fi
    echo $i
    return $retval
    }

    virtualmachine_start()
    {
            virtualmachine_status
            if [ "$retval" =  "11" ]
            then
                    xm create /etc/xen1/$vm
                    rc=$?
                    if [ $rc -eq 0 ]
                    then
                            echo $vm is started successfully
                            retval=0
                    else
                            echo $vm is not started
                            return 1
                    fi

            elif    [ "$retval" =  "00" ]
                    then
                            echo $vm is already started
                            retval=0

            elif     [ "$retval" =  "1" ]
                    then
                            echo There are no vms to start
                            retval=1
            else
                           if [ "$retval" -eq 2 ]
                            then
                                    ls /etc/xen1 >> tempfile
                                    var=`cat tempfile`
                                    for vm in $var
                                    do

                                           xm list $vm
                                           if [ $? -eq 0 ]
                                            then
                                                    echo $vm is already
    running
                                                    retval=0
                                            else
                                                    xm create /etc/xen1/$vm
                                                    rc=$?
                                                    if [ $rc -ne 0 ]
                                                    then
                                                            echo $vm is not
    started
                                                            retval=1
                                                    else
                                                            echo $vm is
    started successfully
                                                            retval=0
                                                    fi
                                            fi

                                    done

                            fi

            fi
    }

    virtualmachine_stop()
    {
            virtualmachine_status
            if [ "$retval" = 11 ]
            then
                    echo $vm already stopped
                    retval=0
            elif [ "$retval" = 00 ]
            then
                    xm shutdown $vm
                    rc=$?
                    if [ $rc -ne 0 ]
                    then
                            echo $vm is not stopped successfully
                            retval=1
                    else
                            echo $vm is stopped successfully
                            retval=0
                    fi
            elif [ "$retval" = 0 ]
            then
                    echo No vms to stop
                    retval=1
            elif [ "$retval" = 2 ]
                    then
                            ls /etc/xen1 >> tempfile
                            var=`cat tempfile`
                            for vm in $var
                            do
                                    xm list $vm
                                    if [ $? -ne 0 ]
                                    then
                                            echo $vm is already stopped
                                            retval=0
                                    else
                                            xm shutdown $vm
                                            rc=$?
                                            if [ $rc -ne 0 ]

                                            then
                                                    echo $vm is not stopped
    successfully
                                                    retval=1
                                            else
                                                    echo $vm is stopped
    successfully
                                                    retval=0
                                            fi
                                    fi
                            done
            fi
    }

    case $1 in

    status )  virtualmachine_status
                    ;;

    start  )  virtualmachine_start
                    ;;

    stop   )  virtualmachine_stop
                    ;;

    monitor)  virtualmachine_monitor
                    ;;

    meta-data) virtualmachine_meta_data
                    exit 0
                    ;;


    *)         usage
                    exit 0
                    ;;

    esac
    exit $retval





    Regards,
    Devi.



- Done.



                        email message attachment

From:   devi <devi@xxxxxxxxxxx>
To:     linux-ha-request@xxxxxxxxxxxxxxxxxx
Subject:        ResourceAgent
Date:   Tue, 04 Aug 2009 13:38:43 -0400

        Hi All,

                I have found problems with xendomains service, when I
wanted to start
        all the virtual machines.  So, I have written a service, which services
        the purpose of xendomains.  Hope, this may be useful.

        and here are few details
        if we want to run only one particular virtual machine
        then we will run as

        ./resourceagent vm1{virtual machine}

        and suppose if we want to run all the virtual machine,
        then simply

        ./resourceagent

        And also this code can be treated as ocf or lsb script

        I am attaching as well as copying the code.

        #!/bin/sh
        VMCONFIG="/etc/xen"
        vm=$2
        retval=0


        usage()
        {
                echo "The valid options are"
                echo "start|stop|status|monitor|meta-data"
        }

        virtualmachine_meta_data()
        {
                cat <<END
                <?xml version="1.0"?>
                <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
                <resource-agent name="ResourceAgent">
                <version>1.0</version>

                <longdesc lang="en">
                 This is meta-data about ResourceAgent
                </longdesc>

                <actions>
                <action name="start" timeout="60" />
                <action name="stop" timeout="40" />
                <action name="status" depth="0" timeout="30" interval="10"
        start-delay="120" />
                <action name="monitor" depth="0" timeout="30" interval="10"
        start-delay="120" />
                <action name="meta-data" timeout="5" />
                <action name="validate-all" timeout="5" />
                </actions>

                </resource-agent>
        END
        }

        virtualmachine_monitor()
        {
                if Checkforvm
                then
                        xm list $vm
                        if [ $? -eq 0 ]
                        then
                                echo $vm is running
                                retval=0
                        else
                                echo $vm is stopped
                                retval=7
                        fi
                else
                         ls /etc/xen1 >> tempfile
                         var=`cat tempfile`
                         for vm in $var
                         do
                               xm list $vm
                               if [ $? -eq 0 ]
                               then
                                      echo $vm is running
                                      retval=0
                                      else
                                              echo $vm is not running
                                              retval=7
                                fi
                          done
                        rm tempfile
                fi

        }

        Checkforvm()
        {
               if [ "${vm}" = "${null}" ] ; then
                        return 1
                else
                        return 0
                fi
        }

        virtualmachine_status()
        {
        if
             Checkforvm
        then
                 xm list $vm
                 rc=$?
                 if
                   [ $rc -ne 0 ]
                 then
                       echo  \ "$vm is Stopped"
                       retval=11
                 else
                       echo \ "$vm is Running"
                       retval=00
                fi

        else
                ls /etc/xen1 >> tempfile
                var=`cat tempfile`
                for vm in $var
                do
                        if [ "${vm}" = "${null}" ]
                        then
                               return  1
                        else
                                retval=2
                        fi
                done
                rm tempfile
        fi
        echo $i
        return $retval
        }

        virtualmachine_start()
        {
                virtualmachine_status
                if [ "$retval" =  "11" ]
                then
                        xm create /etc/xen1/$vm
                        rc=$?
                        if [ $rc -eq 0 ]
                        then
                                echo $vm is started successfully
                                retval=0
                        else
                                echo $vm is not started
                                return 1
                        fi

                elif    [ "$retval" =  "00" ]
                        then
                                echo $vm is already started
                                retval=0

                elif     [ "$retval" =  "1" ]
                        then
                                echo There are no vms to start
                                retval=1
                else
                               if [ "$retval" -eq 2 ]
                                then
                                        ls /etc/xen1 >> tempfile
                                        var=`cat tempfile`
                                        for vm in $var
                                        do

                                               xm list $vm
                                               if [ $? -eq 0 ]
                                                then
                                                        echo $vm is already
        running
                                                        retval=0
                                                else
                                                        xm create /etc/xen1/$vm
                                                        rc=$?
                                                        if [ $rc -ne 0 ]
                                                        then
                                                                echo $vm is not
        started
                                                                retval=1
                                                        else
                                                                echo $vm is
        started successfully
                                                                retval=0
                                                        fi
                                                fi

                                        done

                                fi

                fi
        }

        virtualmachine_stop()
        {
                virtualmachine_status
                if [ "$retval" = 11 ]
                then
                        echo $vm already stopped
                        retval=0
                elif [ "$retval" = 00 ]
                then
                        xm shutdown $vm
                        rc=$?
                        if [ $rc -ne 0 ]
                        then
                                echo $vm is not stopped successfully
                                retval=1
                        else
                                echo $vm is stopped successfully
                                retval=0
                        fi
                elif [ "$retval" = 0 ]
                then
                        echo No vms to stop
                        retval=1
                elif [ "$retval" = 2 ]
                        then
                                ls /etc/xen1 >> tempfile
                                var=`cat tempfile`
                                for vm in $var
                                do
                                        xm list $vm
                                        if [ $? -ne 0 ]
                                        then
                                                echo $vm is already stopped
                                                retval=0
                                        else
                                                xm shutdown $vm
                                                rc=$?
                                                if [ $rc -ne 0 ]

                                                then
                                                        echo $vm is not stopped
        successfully
                                                        retval=1
                                                else
                                                        echo $vm is stopped
        successfully
                                                        retval=0
                                                fi
                                        fi
                                done
                fi
        }

        case $1 in

        status )  virtualmachine_status
                        ;;

        start  )  virtualmachine_start
                        ;;

        stop   )  virtualmachine_stop
                        ;;

        monitor)  virtualmachine_monitor
                        ;;

        meta-data) virtualmachine_meta_data
                        exit 0
                        ;;


        *)         usage
                        exit 0
                        ;;

        esac
        exit $retval





        Regards,
        Devi.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] xen domains, devi thapa <=