remove unused scripts

This commit is contained in:
anthony 2010-08-29 18:39:15 -07:00
parent e270011aed
commit afd8052203
8 changed files with 2 additions and 449 deletions

View File

@ -1,58 +0,0 @@
#!/bin/bash
#set -x
usage() {
printf "Usage: %s [uuid of this host] [interval in seconds]\n" $(basename $0) >&2
}
if [ -z $1 ]; then
usage
exit 2
fi
if [ -z $2 ]; then
usage
exit 3
fi
date=`date +%s`
hbs=`lvscan | grep hb-$1 | awk '{print $2}'`
for hb in $hbs
do
hb=${hb:1:`expr ${#hb} - 2`}
active=`lvscan | grep $hb | awk '{print $1}'`
if [ "$active" == "inactive" ]; then
lvchange -ay $hb
if [ ! -L $hb ]; then
continue;
fi
fi
ping=`dd if=$hb bs=1 count=100`
if [ $? -ne 0 ]; then
continue;
fi
diff=`expr $date - $ping`
if [ $diff -lt $2 ]; then
echo "=====> ALIVE <====="
exit 0;
fi
done
hbs=`ls -l /var/run/sr-mount/*/hb-$1 | awk '{print $9}'`
for hb in $hbs
do
ping=`cat $hb`
if [ $? -ne 0 ]; then
continue;
fi
diff=`expr $date - $ping`
if [ $diff -lt $2 ]; then
echo "=====> ALIVE <====="
exit 0;
fi
done
echo "=====> DEAD <======"

View File

@ -1,111 +0,0 @@
#!/bin/sh
# $Id: find_bond.sh 10510 2010-07-11 10:10:03Z alex $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/vm/hypervisor/xenserver/find_bond.sh $
#set -x
cleanup_vlan() {
for vlan in `xe vlan-list | grep uuid | awk '{print $NF}'`; do
untagged=$(xe vlan-param-list uuid=$vlan | grep untagged | awk '{print $NF}')
network=$(xe pif-param-get param-name=network-uuid uuid=$untagged)
xe vlan-destroy uuid=$vlan
xe network-destroy uuid=$network
done
}
usage() {
echo "$0 device"
exit 1
}
sflag=
dflag=
while getopts 'sd' OPTION
do
case $OPTION in
d) dflag=1
;;
s) sflag=1
;;
?) usage
exit 1
;;
esac
done
shift $(($OPTIND - 1))
nic=$1
[ -z "$nic" ] && usage
addr=$(ip addr | grep $nic | grep inet | awk '{print $2}')
addr=${addr%/*}
bridges=$(brctl show | grep -v bridge | awk '{print $1}')
host_uuid=$(xe host-list hostname=$(hostname) | grep uuid | awk '{print $NF}')
if [ -z "$host_uuid" ]; then
printf "Unable to find host uuid using $(hostname)\n" >&2
exit 2
fi
if [ -z "$addr" ]; then
printf "Unable to find an ip address for $nic\n" >&2
exit 3
fi
current=$(brctl show | grep $nic | awk '{print $NF}')
for dev in `ip addr | grep mtu | grep -v -E "\.[0-9]*@|lo|$nic|$current" | awk '{print $2}'`
do
dev=${dev%:}
echo $bridges | grep $dev >/dev/null 2>&1
br=$?
ifconfig $dev | grep UP >/dev/null 2>&1
rc=$?
if [ $rc -eq 1 ]; then
ifconfig $dev up
sleep 4
fi
arping -q -c 1 -w 2 -D -I $dev $addr >/dev/null 2>&1
rc=$?
if [ $rc -ne 1 ]; then
continue;
fi
if [ $br -ne 0 ]; then
# What we've found is the naked nic.
pif_uuid=$(xe pif-list device=$dev host-uuid=$host_uuid | grep -B 3 "( RO): -1" | grep uuid | awk '{print $NF}')
if [ -z "$pif_uuid" ]; then
mac=$(ifconfig $dev | grep HWaddr | awk '{print $NF}')
pif_uuid=$(xe pif-introduce host-uuid=$host_uuid device=$dev mac=$mac)
fi
if [ -z $pif_uuid ]; then
continue;
fi
bridge=$(xe network-list PIF-uuids=$pif_uuid | grep bridge | awk '{print $NF}')
if [ -z $bridge ]; then
continue;
fi
xe pif-plug uuid=$pif_uuid
echo ">>>$dev<<<"
exit 0
else
# What we've found is the bridge
network_uuid=`xe network-list bridge=$dev | grep uuid | awk '{print $NF}'`
if [ -z "$network_uuid" ]; then
continue;
fi
pif=`xe pif-list network-uuid=$network_uuid host-uuid=$host_uuid VLAN=-1 | grep device | awk '{print $NF}'`
if [ -z "$pif" ]; then
continue;
fi
echo ">>>$pif<<<"
exit 0
fi
done
exit 4

View File

@ -1,30 +0,0 @@
#!/bin/bash
#set -x
usage() {
printf "Usage: %s [uuid of this host] [interval in seconds]\n" $(basename $0)
}
if [ -z $1 ]; then
usage
exit 2
fi
if [ -z $2 ]; then
usage
exit 3
fi
if [ ! -f /opt/xensource/bin/xenheartbeat.sh ]; then
printf "Error: Unable to find xenheartbeat.sh to launch\n"
exit 4
fi
for psid in `ps -ef | grep xenheartbeat | grep -v grep | awk '{print $2}'`; do
kill $psid
done
nohup /opt/xensource/bin/xenheartbeat.sh $1 $2 >/var/log/heartbeat.log 2>&1 &
echo "======> DONE <======"

View File

@ -1,83 +0,0 @@
#!/bin/bash
#set -x
usage() {
printf "Usage: %s [uuid of this host] [uuid of the sr to place the heartbeat]\n" $(basename $0) >&2
}
if [ -z $1 ]; then
usage
exit 2
fi
if [ -z $2 ]; then
usage
exit 3
fi
if [ `xe host-list | grep $1 | wc -l` -ne 1 ]; then
printf "Error: Unable to find the host uuid: $1\n" >&2
usage
exit 4
fi
if [ `xe sr-list uuid=$2 | wc -l` -eq 0 ]; then
printf "Error: Unable to find SR with uuid: $2\n" >&2
usage
exit 5
fi
if [ `xe pbd-list sr-uuid=$2 | grep -B 1 $1 | wc -l` -eq 0 ]; then
printf "Error: Unable to find a pbd for the SR: $2\n" >&2
usage
exit 6
fi
srtype=`xe sr-param-get param-name=type uuid=$2`
if [ "$srtype" == "nfs" ];then
filename=/var/run/sr-mount/$2/hb-$1
files=`ls /var/run/sr-mount/$2 | grep "hb-$1"`
if [ -z "$files" ]; then
date=`date +%s`
echo "$date" > $filename
fi
else
link=/dev/VG_XenStorage-$2/hb-$1
lv=`lvscan | grep $link`
if [ -z "$lv" ]; then
lvcreate VG_XenStorage-$2 -n hb-$1 --size 1M
if [ $? -ne 0 ]; then
printf "Error: Unable to create heartbeat SR\n" >&2
exit 7
fi
lv=`lvscan | grep $link`
if [ -z "$lv" ]; then
printf "Error: Unable to create heartbeat SR\n" >&2
exit 8
fi
fi
if [ `echo $lv | awk '{print $1}'` == "inactive" ]; then
lvchange -ay $link
if [ $? -ne 0 ]; then
printf "Error: Unable to make the heartbeat SR active\n" >&2
exit 8
fi
fi
if [ ! -L $link ]; then
printf "Error: Unable to find the soft link $link\n" >&2
exit 9
fi
dd if=/dev/zero of=$link bs=1 count=100
fi
echo "======> DONE <======"
exit 0

View File

@ -52,17 +52,7 @@ def gethostvmstats(session, args):
result = hostvmstats.get_stats(session, collect_host_stats, consolidation_function, interval, start_time)
return result
@echo
def find_bond(session, args):
nic = args['arg1']
try:
cmd = ["bash", "/opt/xensource/bin/find_bond.sh", nic]
txt = util.pread2(cmd)
except:
txt = ''
return txt
@echo
def setup_iscsi(session, args):
uuid=args['uuid']
@ -428,40 +418,6 @@ def networkUsage(session, args):
return txt
@echo
def setup_heartbeat_sr(session, args):
host = args['host']
sr = args['sr']
try:
cmd = ["bash", "/opt/xensource/bin/setup_heartbeat_sr.sh", host, sr]
txt = util.pread2(cmd)
except:
txt = ''
return txt
@echo
def check_heartbeat(session, args):
host = args['host']
interval = args['interval']
try:
cmd = ["bash", "/opt/xensource/bin/check_heartbeat.sh", host, interval]
txt = util.pread2(cmd)
except:
txt=''
return txt
@echo
def heartbeat(session, args):
host = args['host']
interval = args['interval']
try:
cmd = ["/bin/bash", "/opt/xensource/bin/launch_hb.sh", host, interval]
txt = util.pread2(cmd)
except:
txt='fail'
return txt
def get_private_nic( args):
session = get_xapi_session()
vms = session.xenapi.VM.get_all()
@ -1132,5 +1088,5 @@ def network_rules(session, args):
if __name__ == "__main__":
XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_heartbeat_sr":setup_heartbeat_sr, "check_heartbeat":check_heartbeat, "heartbeat": heartbeat, "setup_iscsi":setup_iscsi, "find_bond": find_bond, "gethostvmstats": gethostvmstats, "getvncport": getvncport, "getgateway": getgateway, "getnetwork": getnetwork, "preparemigration": preparemigration, "setIptables": setIptables, "patchdomr": patchdomr, "pingdomr": pingdomr, "pingxenserver": pingxenserver, "ipassoc": ipassoc, "vm_data": vm_data, "savePassword": savePassword, "saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule, "setLoadBalancerRule": setLoadBalancerRule, "createFile": createFile, "deleteFile": deleteFile, "checkMount": checkMount, "checkIscsi": checkIscsi, "networkUsage": networkUsage, "network_rules":network_rules, "can_bridge_firewall":can_bridge_firewall, "default_network_rules":default_network_rules, "destroy_network_rules_for_vm":destroy_network_rules_for_vm, "default_network_rules_systemvm":default_network_rules_systemvm, "get_rule_logs_for_vms":get_rule_logs_for_vms, "setLinkLocalIP":setLinkLocalIP})
XenAPIPlugin.dispatch({"pingtest": pingtest, "setup_iscsi":setup_iscsi, "gethostvmstats": gethostvmstats, "getvncport": getvncport, "getgateway": getgateway, "getnetwork": getnetwork, "preparemigration": preparemigration, "setIptables": setIptables, "patchdomr": patchdomr, "pingdomr": pingdomr, "pingxenserver": pingxenserver, "ipassoc": ipassoc, "vm_data": vm_data, "savePassword": savePassword, "saveDhcpEntry": saveDhcpEntry, "setFirewallRule": setFirewallRule, "setLoadBalancerRule": setLoadBalancerRule, "createFile": createFile, "deleteFile": deleteFile, "checkMount": checkMount, "checkIscsi": checkIscsi, "networkUsage": networkUsage, "network_rules":network_rules, "can_bridge_firewall":can_bridge_firewall, "default_network_rules":default_network_rules, "destroy_network_rules_for_vm":destroy_network_rules_for_vm, "default_network_rules_systemvm":default_network_rules_systemvm, "get_rule_logs_for_vms":get_rule_logs_for_vms, "setLinkLocalIP":setLinkLocalIP})

View File

@ -1,62 +0,0 @@
#!/bin/bash
# Version @VERSION@
#set -x
usage() {
printf "Usage: %s [uuid of this host] [interval in seconds]\n" $(basename $0) >&2
}
if [ -z $1 ]; then
usage
exit 2
fi
if [ -z $2 ]; then
usage
exit 3
fi
hbs=
while true
do
sleep $2
date=`date +%s`
lvscan
hbs=`ls -l /dev/VG*/hb-$1 | awk '{print $9}'`
for hb in $hbs
do
echo $date | dd of=$hb count=100 bs=1
if [ $? -ne 0 ]; then
reboot -f
echo "Problem with $hb";
fi
done
dirs=`ls /var/run/sr-mount`
if [ "$dirs" == "" ]; then
continue
fi
ls /var/run/sr-mount/* >/dev/null 2>&1
if [ $? -ne 0 ]; then
reboot -f
echo "Problem with ls";
fi
hbs=`ls -l /var/run/sr-mount/*/hb-$1 | awk '{print $9}'`
for hb in $hbs
do
echo $date > $hb
if [ $? -ne 0 ]; then
reboot -f
echo "Problem with $hb";
fi
done
done

View File

@ -29,13 +29,8 @@ prepsystemvm.sh=..,0755,/opt/xensource/bin
setupxenserver.sh=..,0755,/opt/xensource/bin
make_migratable.sh=..,0755,/opt/xensource/bin
networkUsage.sh=..,0755,/opt/xensource/bin
find_bond.sh=..,0755,/opt/xensource/bin
setup_iscsi.sh=..,0755,/opt/xensource/bin
version=..,0755,/opt/xensource/bin
setup_heartbeat_sr.sh=..,0755,/opt/xensource/bin
check_heartbeat.sh=..,0755,/opt/xensource/bin
xenheartbeat.sh=..,0755,/opt/xensource/bin
launch_hb.sh=..,0755,/opt/xensource/bin
pingtest.sh=../../..,0755,/opt/xensource/bin
dhcp_entry.sh=../../../../network/domr/,0755,/opt/xensource/bin
ipassoc.sh=../../../../network/domr/,0755,/opt/xensource/bin

View File

@ -1,54 +0,0 @@
#!/bin/bash
#set -x
usage() {
printf "Usage: %s \n" $(basename $0) >&2
}
# remove device which is in xenstore but not in xapi
remove_device() {
be=$1
xenstore-write /local/domain/0/backend/tap/0/$be/online 0 &>/dev/null
xenstore-write /local/domain/0/backend/tap/0/$be/shutdown-request normal &>/dev/null
for i in $(seq 20)
do
sleep 1
xenstore-exists /local/domain/0/backend/tap/0/$be/shutdown-done &>/dev/null
if [ $? -eq 0 ] ; then
xenstore-rm /local/domain/0/device/vbd/$be &>/dev/null
xenstore-rm /local/domain/0/backend/tap/0/$be &>/dev/null
xenstore-rm /local/domain/0/error/backend/tap/0/$be &>/dev/null
xenstore-rm /local/domain/0/error/device/vbd/$be &>/dev/null
return
fi
xenstore-exists /local/domain/0/backend/tap/0/$be &>/dev/null
if [ $? -ne 0 ] ; then
return
fi
done
echo "unplug device $be failed"
exit 2
}
bes=`xenstore-list /local/domain/0/backend/tap/0`
if [ -z "$bes" ]; then
exit 0
fi
for be in $bes
do
device=`xenstore-read /local/domain/0/backend/tap/0/$be/dev`
ls $device >/dev/null 2>&1
if [ $? -ne 0 ]; then
remove_device $be
fi
done
echo "======> DONE <======"
exit 0