|
|
|
|
|
|
|
|
|
|
xen-devel
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 <=
|
|
|
|
|