[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Fwd: [Linux-cluster] Fence VirtualIron - i have the script but...



it seems that i lost the mailing list address...then i forward the
answer to Nuno Fernandes.

And Nuno, please, write after this thread if you make some
improvments, i'll be glad to discuss bugs/improvements/ideas.

Bye!

---------- Forwarded message ----------
From: Maurizio Rottin <maurizio rottin gmail com>
Date: 2008/11/14
Subject: Re: [Linux-cluster] Fence VirtualIron - i have the script but...
To: Nuno Fernandes <npf-mlists eurotux com>


2008/11/14 Nuno Fernandes <npf-mlists eurotux com>:
> We also use virtual iron. Could you please post your script?
>
> Thanks,
>
> Nuno Fernandes

first of all you must have a working java>1.5.0

than (mind that my scripts are little "temporary")

vim /sbin/fence_vivm
#!/bin/bash
# Maurizio Rottin 2008-11-11
#
# fence a VirtualIron VirtualServer
#
###############################################################################
#
# Copyright (C) 2008 Maurizio Rottin.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# or visit http://www.gnu.org/licenses/gpl.txt
#
###############################################################################

#must parse arguments passed from stdin
#in format name=param
#must ignore #name=param
#there should not be two name=param string passed, as the xml should
be considered bad!
name=""
vm=""
while read param;do
       if [ `expr index $param \# ` -ne 0 ];then
               continue
       elif expr match $param 'ip=.*' >/dev/null ;then
               ip=${param#ip=}
       elif expr match $param 'name=.*'  >/dev/null ;then
               name=${param#name=}
       elif expr match $param 'vm=.*'  >/dev/null ;then
               vm=${param#vm=}
       fi
done
#end parsing
if [ "$vm" == "" ];then
       echo "$$: No name provided!"
       exit 1
fi
basedir="/root/vso"

if [ -d $basedir ];then
       cd /root/vso
       sh ./runner --vivmgr=http://youripaddress:80  --username=admin
--password='yourpassword' --inputfile=vsOperations.py --action=fence
--vs="${vm}"
       retval=$?
else
       retval=1
fi
exit $retval
->>>>end of script

of course you can pass also password, ip and so on, depending on your needs.


then you must copy this files from VirtualIron directory into
/root/vso (if you change /root/vso, then change it also in the
fence_vivm)


./system
./system/resources
./system/resources/lib
./system/resources/lib/myoocomClient.jar
./system/resources/lib/MgmtAPI.jar
./system/resources/lib/MgmtUtil.jar
./system/resources/lib/runner.jar
./system/resources/lib/jython.jar
./system/resources/lib/log4j.jar
./system/resources/lib/MgmtControl.jar
./system/resources/lib/jline.jar
./system/resources/lib/MgmtTools.jar
./system/resources/lib/myoodbClient.jar
./etc
./etc/runner.properties


ok, now we need two more scripts

This is taken from VirtualIron so i don't know if some licences are involved.

vim /root/vso/runner
#!/bin/bash
export INS_PATH=`pwd`

#
# run in the context of the install
#
cd "$INS_PATH"

#
#   usage: runner.sh --mode=<jython|sql>
#
#          --mode      : default is <jython>
#          --vivmgr    : default is <tcp://localhost:54321>
#          --username  : default is <admin>
#          --password  : default is <admin>
#          --inputfile : default is <interactive>
#
#          --help      : print usage
#

java -Xmx512m -Dpython.inclusive.packages="java,javax,org.python" -jar
"system/resources/lib/runner.jar" $*
exit $?
->>> end script
chmod 700 /root/vso/runner

AND

taken from VirtualIron scripts and modified for our needs:

vim /root/vso/vsOperations.py
#
# vsOperations: perform start/stop/shutdown/restart action on VirtualServer
#
from com.virtualiron.vce.mgmt.api import VirtualizationManager
from com.virtualiron.vce.mgmt.api.virtual import VirtualServer
import java.lang
import java.util
import os
import string
import sys
import traceback

def Usage():
       if os.name == 'nt':
               command = 'runner.bat'
       else:
               command = 'runner.sh'
       print 'Usage: %s --inputfile=vsOperations.py --vs="Virtual
Server" --action=[start,stop,shutdown,restart]' % (command)
       print 'or Usage: %s --vivmgr=http://192.168.0.48:80
--username=admin --password=\'dba iron\' --inputfile=vsOperations.py
--action=[start,stop,shutdown,restart,reboot]' % (command)
       sys.exit(1)

#
# parse command line arguments
#
vsName = None
action = None
for arg in sys.argv[1:]:
       if string.find(arg, "--vs=") != -1:
               tokens = string.splitfields(arg, "=")
               vsName = tokens[1]

       elif string.find(arg, "--action=") != -1:
               tokens = string.splitfields(arg, "=")
               action = tokens[1]

#
# check if required arguments were specified
#
if vsName is None or action is None:
       Usage()

#
# get connection to Database
#
configurationManager = VirtualizationManager.getConfigurationManager()

#
# find virtual server object
#
vs = configurationManager.findObject(VirtualServer, vsName)
if vs is None:
       print 'FAIL to find VirtualServer %s' % (vsName)
       sys.exit(1)

#
# wrap VS action in job control
#
error = 0
try:
       jobName = java.lang.Long.toString(configurationManager.getLocalTime())
       job = configurationManager.createJob(jobName)
       job.begin()

       if action == 'start':
               vs.start()
               job.addOperationDescription("Start VirtualServer", vs, vs, vs)
       elif action == 'stop':
               vs.stop()
               job.addOperationDescription("Stop VirtualServer", vs, vs, vs)
       elif action == 'shutdown':
               vs.shutdown()
               job.addOperationDescription("Shutdown VirtualServer",
vs, vs, vs)
       elif action == 'restart':
               vs.restart()
               job.addOperationDescription("Restart VirtualServer", vs, vs, vs)
       elif action == 'reboot':
               vs.reboot()
               job.addOperationDescription("Hard reset and boot
VirtualServer", vs, vs, vs)
       elif action == 'fence':
               statusEvent = vs.getStatusEvent().toString()
               if string.find(statusEvent, 'VirtualServerStoppedEvent') == 0:
                       print "fence: starting"
                       vs.start()
                       job.addOperationDescription("Fence Start
VirtualServer", vs, vs, vs)
               elif string.find(statusEvent, 'VirtualServerRunningEvent') == 0:
                       print "fence: rebooting"
                       vs.reboot()
                       job.addOperationDescription("Fence reboot
VirtualServer", vs, vs, vs)
               elif string.find(statusEvent,
'VirtualServerStartingEvent') == 0:
                       print "wait 60 sec reboot()? or do nothing?"
               else:
                       print "Unknown status %s " % (statusEvent)
       else:
               error = 1
               print 'Unknown action:', action
               job.abort()

       if not error:
               job.commit()            # commit job

except java.lang.Throwable, throw:
       job.abort()             # if job fails, rollback
       throw.printStackTrace()
except:
       job.abort()             # if job fails, rollback
       traceback.print_exc()

if error:
       Usage()

->>> end script

chmod 700 /root/vso/vsOperations.py


Last thing is to modify the cluster.conf
copy your cluster.conf somewhere
add plus 1 to "config_version=number"

the beginning should look like this:
<------begin
<?xml version="1.0"?>
<cluster alias="VironLab" config_version="33" name="VironLab">
       <fence_daemon clean_start="0" post_fail_delay="0" post_join_delay="3"/>
       <clusternodes>
               <clusternode name="bend02.viron.local" nodeid="1" votes="1">
                       <fence>
                               <method name="1">
                                       <device name="bend02"/>
                               </method>
                       </fence>
               </clusternode>
               <clusternode name="bend01.viron.local" nodeid="2" votes="1">
                       <fence>
                               <method name="1">
                                       <device name="bend01"/>
                               </method>
                       </fence>
               </clusternode>
       </clusternodes>
       <cman expected_votes="1" two_node="1"/>
       <fencedevices>
               <fencedevice agent="fence_vivm" name="bend02" vm="bend_02"/>
               <fencedevice agent="fence_vivm" name="bend01" vm="bend_01"/>
       </fencedevices>
       <rm>
--------->cut<-------

where "bend_02" and "bend_01" are the real names in the VirtualIron manager!

update the cluste.conf while the cluster is running:
ccs_tool update cluster.conf


enjoy it!

--
mr



-- 
mr


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]