forked from epics_driver_modules/require
delete what is not require
This commit is contained in:
@@ -1,120 +0,0 @@
|
||||
#!/bin/sh
|
||||
#File: bootinfo
|
||||
#Description: get info from the IOC_LASTBOOTED database table
|
||||
#Author: D.Zimoch
|
||||
#Parameters:
|
||||
|
||||
function help() {
|
||||
echo "usage: $(basename $0) [options] [pattern]"
|
||||
echo " Find boot information about %pattern% in database"
|
||||
echo "options are:"
|
||||
echo " -h, -?, --help : print this help and quit"
|
||||
echo " -v, --version : print cvs version info and quit"
|
||||
echo " -d : print BOOTDATE"
|
||||
echo " -t : print BOOTTIME"
|
||||
echo " -b : print BOOTPC"
|
||||
echo " -I : print INSTBASE"
|
||||
echo " -S : print INSTBASE (was SLSBASE before)"
|
||||
echo " -E : print EPICS version"
|
||||
echo " -V : print vxWorks version"
|
||||
echo " -i : print IP_ADDR"
|
||||
echo " -A : print ARCH"
|
||||
echo " -a : print a lot (= -dtbSEViA)"
|
||||
echo " -p : print PORT (soft IOCs) or processor number (VME IOCs)"
|
||||
echo " -L : log (print all reboots, not only last)"
|
||||
echo " -x : do exact query, i.e. do not append '%' to search pattern"
|
||||
echo " --noheader : don't print table header"
|
||||
echo " -- : treat next word as pattern, even if starting with -"
|
||||
exit 0
|
||||
}
|
||||
|
||||
function version() {
|
||||
echo 'Author: D. Zimoch'
|
||||
echo '$Date: 2011/11/14 14:31:23 $'
|
||||
echo '$Source: /cvs/G/DRV/misc/App/scripts/bootinfo,v $'
|
||||
exit 0
|
||||
}
|
||||
|
||||
HSEL="SYSTEM AS IOC"
|
||||
TABLE="IOC_LASTBOOTED"
|
||||
ORDER="1"
|
||||
JOKER="%"
|
||||
#ORDER="IOC,TO_DATE(BOOTDATE||' '||BOOTTIME,'DD-MM-YYYY HH24:MI:SS')"
|
||||
while true
|
||||
do
|
||||
case "$1" in
|
||||
--noheader) OPTS="SET HEADING OFF;" ;;
|
||||
-*h* | -*\?* | --help) help ;;
|
||||
-*v* | --version) version ;;
|
||||
--) shift; if [ -z "$SEL" ]; then set -- -a -- "$@"; continue; else break; fi ;;
|
||||
-*) OPTION=$1
|
||||
while true
|
||||
do
|
||||
OPTION=${OPTION:1}
|
||||
case "$OPTION" in
|
||||
t*) SEL="$SEL, BOOTTIME"; ORDER="BOOTDATE" ;;
|
||||
d*) SEL="$SEL, BOOTDATE"; ORDER="BOOTDATE" ;;
|
||||
b*) SEL="$SEL, BOOTPC" ;;
|
||||
E*) SEL="$SEL, EPICSVER AS EPICS" ;;
|
||||
V*) SEL="$SEL, VXWORKSVER AS VXWORKS";;
|
||||
i*) SEL="$SEL, IPADDR AS IP_ADDR" ;;
|
||||
e*) SEL="$SEL, ETHADDR AS ETH_ADDR" ;;
|
||||
p*) SEL="$SEL, PROCNUM as PORT" ;;
|
||||
[SI]*) SEL="$SEL, SLSBASE AS INSTBASE" ;;
|
||||
A*) SEL="$SEL, SUBSTR(VXWORKS,INSTR(VXWORKS,'/',-1,2)+1,
|
||||
INSTR(VXWORKS,'/',-1,1)-INSTR(VXWORKS,'/',-1,2)-1) AS ARCH" ;;
|
||||
f*) SEL="$SEL, VXWORKS AS FILENAME" ;;
|
||||
a*) OPTION=-dtbSEViA${OPTION:1} ;;
|
||||
L*) SEL="$SEL, BOOT_DT AS BOOTDATE, TO_CHAR(BOOT_DT,'HH24:MI:SS') AS BOOTTIME";
|
||||
ORDER="BOOTDATE";
|
||||
TABLE="IOC_BOOTLOG" ;;
|
||||
x*) JOKER="" ;;
|
||||
"") break ;;
|
||||
*) echo "Unknown option -${OPTION:0:1}. Try: --help"
|
||||
exit 1 ;;
|
||||
esac
|
||||
done ;;
|
||||
*) if [ -z "$SEL" ]; then set -- -a "$@"; continue; else break; fi ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$ORACLE_HOME" ]; then
|
||||
echo "ORACLE_HOME not defined" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eval $(resize 2>/dev/null)
|
||||
pattern="$JOKER$1$JOKER"
|
||||
sqlplus -s gfa_public/pub01@gfaprd << EOF
|
||||
SET PAGESIZE 10000;
|
||||
SET LINESIZE ${COLUMNS:-120};
|
||||
SET FEEDBACK OFF;
|
||||
$OPTS
|
||||
|
||||
COLUMN IOC FORMAT A20;
|
||||
COLUMN BOOTPC FORMAT A20;
|
||||
COLUMN INSTBASE FORMAT A15;
|
||||
COLUMN EPICS FORMAT A7;
|
||||
COLUMN VXWORKS FORMAT A7;
|
||||
COLUMN ARCH FORMAT A15;
|
||||
|
||||
SELECT ${HSEL} ${SEL}
|
||||
FROM EPICS.${TABLE}
|
||||
WHERE SYSTEM LIKE UPPER('$pattern') OR
|
||||
BOOTPC LIKE '$pattern' OR
|
||||
SLSBASE LIKE '$pattern' OR
|
||||
EPICSVER LIKE '$pattern' OR
|
||||
VXWORKSVER LIKE '$pattern' OR
|
||||
ETHADDR LIKE REPLACE(LOWER('$pattern'),'-',':') OR
|
||||
IPADDR LIKE '$pattern' OR
|
||||
LOWER(VXWORKS) LIKE LOWER('$pattern')
|
||||
ORDER BY ${ORDER};
|
||||
|
||||
EXIT
|
||||
EOF
|
||||
# $Name: $
|
||||
# $Id: bootinfo,v 1.26 2011/11/14 14:31:23 lutz_h Exp $
|
||||
# $Source: /cvs/G/DRV/misc/App/scripts/bootinfo,v $
|
||||
# $Revision: 1.26 $
|
||||
|
||||
@@ -1,386 +0,0 @@
|
||||
#!/bin/sh
|
||||
###############################################################################
|
||||
# $Author: krempaska $
|
||||
# $Date: 2009/03/10 17:46:43 $
|
||||
# $Id: bootlink,v 1.10 2009/03/10 17:46:43 krempaska Exp $
|
||||
# $Name: $
|
||||
# $Source: /cvs/G/DRV/misc/App/scripts/bootlink,v $
|
||||
# $Revision: 1.10 $
|
||||
###############################################################################
|
||||
# File name:
|
||||
# Description: creates a new link to the IOC booting directory
|
||||
# This script works only if yoa are located:
|
||||
# - on the boot pc or
|
||||
# - on a machine of the bootpc subnet or
|
||||
# - on office subnet and want to change boot link on machine.
|
||||
# Notes:
|
||||
# 1. This script does not jump between different facilities networks!
|
||||
# 2. If more IOCs are specified in the command line, they have to boot from
|
||||
# unique bootpc and the symbolic link of the specified targetbase will
|
||||
# be done for all this IOCs.
|
||||
###############################################################################
|
||||
#Note: this variables have to be don on bpc, (gw)
|
||||
#export INSTBASE=/psi-xfel/devl
|
||||
#export INSTBASELIST="/psi-xfel/devl /psi-xfel/work /psi-xfel/prod"
|
||||
|
||||
#---------------------------
|
||||
# This is supposed to be called only if running on a bootpc
|
||||
# It creates a new symbolic link of /ioc/$ioc to the boot directory
|
||||
#---------------------------
|
||||
function do_slink () {
|
||||
#echo "do_slink() params $*"
|
||||
targetbase=$1
|
||||
shift
|
||||
for ioc in $*
|
||||
do
|
||||
|
||||
if [ "-" = "$targetbase" ]
|
||||
then
|
||||
old=$(readlink /ioc/$ioc)
|
||||
echo "Link on $bootpc for $ioc is \"$old\""
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Changing symbolic link for /ioc/$ioc...";
|
||||
old=$(readlink /ioc/$ioc)
|
||||
new="$targetbase/iocBoot/ioc/$ioc"
|
||||
echo "Current link is to: $old"
|
||||
echo "Requested link is to: $new"
|
||||
if [ "$old" = "$new" ]
|
||||
then
|
||||
echo "No operation will be done, it already points to \"$old\"."
|
||||
continue
|
||||
fi
|
||||
if [ -d "$new" ]
|
||||
then
|
||||
rm -f /ioc/$ioc
|
||||
ln -s $new /ioc/$ioc
|
||||
chk=$(readlink /ioc/$ioc)
|
||||
if [ "$chk" = "$new" ]
|
||||
then
|
||||
echo "Changed on $bootpc";
|
||||
echo "from $old";
|
||||
echo "to $new"
|
||||
else
|
||||
echo "ERROR: change on $bootpc from \"$old\" to \"$new\" failed"
|
||||
echo "link points now to \"$chk\". Check permissions:"
|
||||
ls -l /ioc/$ioc
|
||||
fi
|
||||
else
|
||||
echo "Target directory \"$tdir\" does not exist, no link has been done."
|
||||
fi
|
||||
done
|
||||
return
|
||||
}
|
||||
|
||||
#---------------------------
|
||||
# Sets the ssh gateway name based on the bootpc value
|
||||
#---------------------------
|
||||
function get_gw () {
|
||||
case "$bootpc" in
|
||||
"slsbpc") #SLS machine
|
||||
ssh_gw="slsbridge"
|
||||
;;
|
||||
"x01dc-bpc")
|
||||
ssh_gw="x01dc-gw"
|
||||
;;
|
||||
"x02da-bpc")
|
||||
ssh_gw="x02da-gw"
|
||||
;;
|
||||
"x03ma-bpc")
|
||||
ssh_gw="x03ma-gw"
|
||||
;;
|
||||
"x04db-bpc")
|
||||
ssh_gw="x04db-gw"
|
||||
;;
|
||||
"x04sa-bpc")
|
||||
ssh_gw="x04sa-gw"
|
||||
;;
|
||||
"x05da-bpc")
|
||||
ssh_gw="x05da-gw"
|
||||
;;
|
||||
"x05la-bpc")
|
||||
ssh_gw="x05la-gw"
|
||||
;;
|
||||
"x06da-bpc")
|
||||
ssh_gw="x06da-gw"
|
||||
;;
|
||||
"x06sa-bpc")
|
||||
ssh_gw="x06sa-gw"
|
||||
;;
|
||||
"x07da-bpc")
|
||||
ssh_gw="x07da-gw"
|
||||
;;
|
||||
"x07db-bpc")
|
||||
ssh_gw="x07db-gw"
|
||||
;;
|
||||
"x07ma-bpc")
|
||||
ssh_gw="x07ma-gw"
|
||||
;;
|
||||
"x09la-bpc")
|
||||
ssh_gw="x09la-gw"
|
||||
;;
|
||||
"x10da-bpc")
|
||||
ssh_gw="x10da-gw"
|
||||
;;
|
||||
"x10sa-bpc")
|
||||
ssh_gw="x10sa-gw"
|
||||
;;
|
||||
"x11la-bpc")
|
||||
ssh_gw="x11la-gw"
|
||||
;;
|
||||
"x12sa-bpc")
|
||||
ssh_gw="x12sa-gw"
|
||||
;;
|
||||
"fin-cbpce"|"fin-cbpc01e")
|
||||
ssh_gw="fin-cgwe"
|
||||
;;
|
||||
"hipa-bpc01")
|
||||
ssh_gw="hipa-gw01"
|
||||
;;
|
||||
*)
|
||||
ssh_gw=""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [ "$1" = "-v" ];then echo "\$Header: /cvs/G/DRV/misc/App/scripts/bootlink,v 1.10 2009/03/10 17:46:43 krempaska Exp $";exit;fi
|
||||
|
||||
#calling from the script $1=action: do_slink, $2=target, $3=bootpc, $4=ioc1, $5=ioc2,...
|
||||
if [ $# > 3 ] && [ "$1" = "do_slink" ]
|
||||
then
|
||||
#echo "calling $0 with parameters: $@"
|
||||
#check if you are on the bootpc
|
||||
val=$(echo $(nslookup $(hostname).psi.ch ));
|
||||
hname=$(echo $val|awk '{print $6}')
|
||||
#cut the domain part of the hname
|
||||
hname=$(echo $hname|awk 'BEGIN {FS="."} {print $1}')
|
||||
bootpc=$2
|
||||
#echo $bootpc
|
||||
#for slsbpc (slsbpc1/2) cluster exception
|
||||
if [ $hname = "slsbpc2" ] || [ $hname = "slsbpc1" ];then hname="slsbpc";fi
|
||||
|
||||
if [ "$hname" != "$bootpc" ];then echo "I am not on the $bootpc but on $hname";exit;fi
|
||||
shift
|
||||
shift
|
||||
do_slink $@;
|
||||
exit;
|
||||
fi
|
||||
|
||||
if [ $# -lt 2 ] || [ "$1" = "-?" ]
|
||||
then
|
||||
echo "Usage: $0 (<newbase>|-) <IOC> [<IOC2> [...]]"
|
||||
echo "Description: Change boot path for list of IOCs."
|
||||
echo "If <newbase> = \"-\" it shows the current links."
|
||||
echo "Example: $0 /work X07DA-VME-OP1"
|
||||
exit
|
||||
fi
|
||||
if [ -z "$ORACLE_HOME" ] ; then
|
||||
echo "ORACLE_HOME not defined" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
targetbase=$1
|
||||
#chkslsbase.sh checks if the bootdirectory specified in the $1 argument is valid
|
||||
#it has to be one of $SLSBASELIST or $INSTBASELIST
|
||||
#check if the requested directory is defined in one of the environment
|
||||
#variables $*LIST
|
||||
in_list=$(awk -vb="${*%/}" -vl="$SLSBASELIST $INSTBASELIST $PSIXFELBASELIST" '
|
||||
BEGIN{
|
||||
split(b,s)
|
||||
for (j in s) {
|
||||
split(l,f)
|
||||
for (i in f) {
|
||||
if (f[i] == s[j]) {
|
||||
print f[i]
|
||||
exit
|
||||
}
|
||||
}
|
||||
}
|
||||
}')
|
||||
|
||||
#if [ "$(chkslsbase.sh $targetbase)" = "" ] && [ "$targetbase" != "-" ]
|
||||
if [ "$in_list" = "" ] && [ "$targetbase" != "-" ]
|
||||
then
|
||||
echo -ne "first argument (\"$targetbase\") has to be one out of\n$SLSBASELIST\t$INSTBASELIST\n"
|
||||
exit
|
||||
fi
|
||||
shift
|
||||
|
||||
#for the list of all IOCs specified in the command line arguments get bootpc
|
||||
#if it's not the same it exits
|
||||
#get bootpc for the first IOC
|
||||
bootpc=$(echo $(
|
||||
sqlplus -s gfa_public/pub01@GFAPRD << EOF
|
||||
SET HEADING OFF;
|
||||
SELECT DESTINATION FROM HOSTS.RELATIONS WHERE REL_TYPE_ID=3 AND HOST_NAME='$1';
|
||||
EXIT
|
||||
EOF
|
||||
))
|
||||
if [ "$bootpc" = "no rows selected" ]
|
||||
then
|
||||
echo "No bootpc for the $ioc found in the HOSTS database."
|
||||
exit
|
||||
fi
|
||||
bootpcprev=$bootpc
|
||||
|
||||
for ioc in $*
|
||||
do
|
||||
#get bootpc from HOSTS
|
||||
bootpcprev=$bootpc
|
||||
bootpc=$(echo $(
|
||||
sqlplus -s gfa_public/pub01@GFAPRD << EOF
|
||||
SET HEADING OFF;
|
||||
SELECT DESTINATION FROM HOSTS.RELATIONS WHERE REL_TYPE_ID=3 AND HOST_NAME='$ioc';
|
||||
EXIT
|
||||
EOF
|
||||
))
|
||||
if [ "$bootpc" = "no rows selected" ]
|
||||
then
|
||||
echo "No bootpc for the $ioc found in the HOSTS database."
|
||||
exit
|
||||
fi
|
||||
# if some bpc differs stop
|
||||
if [ "$bootpcprev" != "$bootpc" ]
|
||||
then
|
||||
echo "BootPC $bootpc for the IOC $ioc differs from other $bootpcprev!"
|
||||
exit
|
||||
fi
|
||||
done
|
||||
|
||||
#get instbase from last booted table
|
||||
slsbase=$(echo $(
|
||||
sqlplus -s gfa_public/pub01@GFAPRD << EOF
|
||||
SET HEADING OFF;
|
||||
SELECT SLSBASE FROM HOSTS.IOC_LASTBOOTED WHERE SYSTEM = '$ioc';
|
||||
EXIT
|
||||
EOF
|
||||
))
|
||||
if [ "$list" = "no rows selected" ]
|
||||
then
|
||||
echo "IOC $ioc not in bootinfo DB"
|
||||
exit
|
||||
fi
|
||||
slsbase=$(echo $list|awk '{print $2}');
|
||||
|
||||
#I need to go to the bootpc and do the sym. link operations directly there
|
||||
#1.get the subnet location of the currently used host
|
||||
#2.do the link depending on the location of your host and bootpc
|
||||
#2.a) if you are on the same subnet as your currently used host
|
||||
# and if you are on the bootpc, do the link (call function do_slink()),
|
||||
# otherwise do ssh to the bootpc and do the link
|
||||
# b) if you are on the other subnet (office), get the ssh gateway name
|
||||
# (by using naming convention), do ssh to the gw, ssh bootpc and do the link
|
||||
#Note: If you are on a facility subnet, i.e.SLSMACHINE, you cannot jump to FELOBLA!
|
||||
# So if you are on x07da-cons-1, the call "bootlink /work X09LA-VME-ES1" wan't work!
|
||||
|
||||
#get the bootpc IP -> from the HOSTS database
|
||||
bootpcIP=$(echo $(
|
||||
sqlplus -s gfa_public/pub01@GFAPRD << EOF
|
||||
SET HEADING OFF;
|
||||
SELECT IP FROM HOSTS.INTERFACES HI, HOSTS.IP_ADDRESSES HIP WHERE HI.INTERF_ID=HIP.INTERF_ID AND HI.HOST_NAME = '$bootpc';
|
||||
EXIT
|
||||
EOF
|
||||
))
|
||||
if [ "$slsbase" = "$targetbase" ]
|
||||
then
|
||||
echo "According to bootinfo, IOC $ioc has booted already from $slsbase"
|
||||
echo "continue anyway..."
|
||||
fi
|
||||
|
||||
#get the currently used host IP -> nslookup
|
||||
#added .psi.ch because on slsbpc in /etc/resolve.conf the line:
|
||||
#search psi.ch is missing
|
||||
val=$(echo $(nslookup $(hostname).psi.ch ));
|
||||
hname=$(echo $val|awk '{print $6}')
|
||||
currhostIP=$(echo $val|awk '{print $8}')
|
||||
|
||||
#on which subnet am I?
|
||||
NET=$(echo $currhostIP | awk 'BEGIN { FS = "." } ; { print $1"."$2"."$3"." }')
|
||||
case "$NET" in
|
||||
172.20.*.*)
|
||||
#SLS machine subnet
|
||||
echo "You are on the SLS machine subnet $NET";
|
||||
#tuto musim asi hardcoding of IP address
|
||||
#172.20.20.70.|69|71
|
||||
#if [ "$bootpcIP" = "$currhostIP" ]
|
||||
if [ "$currhostIP" = "172.20.20.70" ] || [ "$currhostIP" = "172.20.20.69" ] || [ "$currhostIP" = "172.20.20.71" ]
|
||||
then
|
||||
do_slink $targetbase $*
|
||||
else
|
||||
#echo "THis option is on work, please, login to the slsbpc directly."
|
||||
SCRPATH="$INSTBASE/sls/bin"
|
||||
echo "Logging to $bootpc and calling $SCRPATH/bootlink..."
|
||||
ssh $bootpc $SCRPATH/bootlink do_slink $bootpc $targetbase $*
|
||||
fi
|
||||
;;
|
||||
129.129.[01][0-9].*|129.129.12[0-2].*|129.129.[01][01][0-9].*)
|
||||
echo "You are on one of beamlines subnets $NET.";
|
||||
if [ "$bootpcIP" = "$currhostIP" ]
|
||||
then
|
||||
do_slink $targetbase $*
|
||||
else
|
||||
SCRPATH="$INSTBASE/sls/bin"
|
||||
echo "Logging to $bootpc..."
|
||||
ssh $bootpc $SCRPATH/bootlink do_slink $bootpc $targetbase $*
|
||||
fi
|
||||
;;
|
||||
172.21.70.*)
|
||||
echo "You are on FELOBLA subnet $NET";
|
||||
if [ "$bootpcIP" = "$currhostIP" ]
|
||||
then
|
||||
do_slink $targetbase $ioc
|
||||
else
|
||||
#ssh $bootpc /psi-xfel/devl/bin/bootlink do_slink $targetbase $ioc $bootpc
|
||||
ssh $bootpc /psi-xfel/devl/bin/bootlink do_slink $bootpc $targetbase $*
|
||||
fi
|
||||
;;
|
||||
129.129.151.*)
|
||||
echo "You are on HIPA subnet $NET";
|
||||
if [ "$bootpcIP" = "$currhostIP" ]
|
||||
then
|
||||
do_slink $targetbase $*
|
||||
else
|
||||
ssh $bootpc /hipa/prod/bin/bootlink do_slink $bootpc $targetbase $*
|
||||
fi
|
||||
;;
|
||||
129.129.153.*)
|
||||
echo "You are on PROSCAN subnet $NET";
|
||||
echo "on work!";
|
||||
;;
|
||||
*)
|
||||
echo "You are on OFFICE subnet $NET and you need to go to $bootpc";
|
||||
#get on which gw we have to go
|
||||
#ssh gateway name is defined according naming convention for each facility
|
||||
get_gw
|
||||
echo "Loging to $ssh_gw..."
|
||||
if [ "$CLIENT" = "sls" ]
|
||||
then
|
||||
SCRPATH="$INSTBASE/sls/bin"
|
||||
else
|
||||
SCRPATH="$INSTBASE/bin"
|
||||
fi
|
||||
ssh -t $ssh_gw ssh $bootpc $SCRPATH/bootlink do_slink $bootpc $targetbase $*
|
||||
;;
|
||||
esac
|
||||
exit
|
||||
###############################################################################
|
||||
#
|
||||
# $Log: bootlink,v $
|
||||
# Revision 1.10 2009/03/10 17:46:43 krempaska
|
||||
# a but in if statement fixed
|
||||
#
|
||||
# Revision 1.9 2009/03/10 17:25:45 krempaska
|
||||
# now it works also for hipa, the call of chkslsbase.sh script was replaced by the awk call which does exectly like this script
|
||||
#
|
||||
# Revision 1.8 2009/01/16 13:41:02 krempaska
|
||||
# fixed for SLS machine
|
||||
#
|
||||
# Revision 1.7 2009/01/16 13:00:32 krempaska
|
||||
# added psi.ch domain to hostname beacause of SLS netvork, which has not domain search in /etc/desolve.conf yet
|
||||
#
|
||||
# Revision 1.6 2009/01/13 16:34:07 krempaska
|
||||
# modified create link: It goes first on the bootpc and then reads/creates a link, adapted also for psi-xfel, prepared for hipa (and proscan)
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
@@ -1,184 +0,0 @@
|
||||
#! /usr/bin/env python
|
||||
#
|
||||
# $Source: /cvs/G/DRV/misc/App/scripts/call_ioc_ins,v $
|
||||
# $Revision: 1.7 $ $Date: 2004/10/07 12:08:26 $
|
||||
#
|
||||
# Obsolete Obsolete Obsolete Obsolete Obsolete Obsolete Obsolete Obsolete
|
||||
#
|
||||
# This script is obsolete. It may be of some interest as an example
|
||||
# of URL access from python.
|
||||
#
|
||||
# Obsolete Obsolete Obsolete Obsolete Obsolete Obsolete Obsolete Obsolete
|
||||
|
||||
'''
|
||||
Insert boot information about IOCs into the ssrm_public Oracle database.
|
||||
|
||||
Usage:
|
||||
-----
|
||||
call_ioc_ins [--help] [-v] [--debug] [-t=<secs>] \\
|
||||
<system> <ipadd> <procnum> \\
|
||||
<device> <bootpc> <slsbase> \\
|
||||
<bootfile> <script> <vxworks> \\
|
||||
<epicsver> <vxworksver> <ethaddr>
|
||||
|
||||
Default time-out (-t) = 10 secs.
|
||||
Example:
|
||||
-------
|
||||
call_ioc_ins X04SA-VME-PLD 172.19.151.29 0 \\
|
||||
dc pc3018 /work \\
|
||||
/ioc/X04SA-VME-PLD/vxWorks \\
|
||||
/ioc/X04SA-VME-PLD/startup.script \\
|
||||
/work/epics/base/bin/mv2306/vxWorks \\
|
||||
3.13.2 5.3.1 08:00:3e:2e:78:1d
|
||||
'''
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
import os, sys
|
||||
import commands
|
||||
import urllib
|
||||
import string
|
||||
import getopt
|
||||
import time
|
||||
import signal
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
def showVersion ():
|
||||
# ===========
|
||||
'''
|
||||
$Source: /cvs/G/DRV/misc/App/scripts/call_ioc_ins,v $
|
||||
$Revision: 1.7 $ $Date: 2004/10/07 12:08:26 $
|
||||
Installed Location: $SLSBASE/sls/bin
|
||||
'''
|
||||
print showVersion.__doc__
|
||||
return
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def showUsage ():
|
||||
# =========
|
||||
|
||||
print __doc__
|
||||
return
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# The program starts here!
|
||||
if __name__ == "__main__":
|
||||
|
||||
sys.stderr = sys.stdout
|
||||
#
|
||||
# Analyse the options
|
||||
#
|
||||
debug = 0
|
||||
timeout = 10
|
||||
try:
|
||||
(opts, items) = getopt.getopt (sys.argv[1:], "h?vt:", \
|
||||
("help", "debug"))
|
||||
for opt in opts:
|
||||
if opt[0] == "-h": raise "Help"
|
||||
if opt[0] == "-?": raise "Help"
|
||||
if opt[0] == "--help": raise "Help"
|
||||
if opt[0] == "-v": raise "Version"
|
||||
if opt[0] == "-t":
|
||||
timeout = int (opt[1])
|
||||
if timeout <= 0:
|
||||
print "\aTime-out must be a positive integer."
|
||||
raise
|
||||
#endif
|
||||
#endif
|
||||
if opt[0] == "--debug": debug = 1
|
||||
#endfor
|
||||
except "Help":
|
||||
showUsage ()
|
||||
sys.exit (0)
|
||||
except "Version":
|
||||
showVersion ()
|
||||
sys.exit (0)
|
||||
except:
|
||||
print "\aBad option. Specify \"-h\" for help."
|
||||
sys.exit (1)
|
||||
#endtry
|
||||
|
||||
if debug:
|
||||
print "Time-out = %d secs" % timeout
|
||||
print "Arguments:"
|
||||
for i in range (len (items)):
|
||||
print " ", items[i]
|
||||
#endfor
|
||||
#endif
|
||||
|
||||
if len (items) != 12:
|
||||
print "\aTwelve arguments are needed, not %d" % len (items)
|
||||
sys.exit (1)
|
||||
#endif
|
||||
|
||||
args = {}
|
||||
args["SYSTEM"] = items[ 0]
|
||||
args["IPADDR"] = items[ 1]
|
||||
args["PROCNUM"] = items[ 2]
|
||||
args["DEVICE"] = items[ 3]
|
||||
args["BOOTPC"] = items[ 4]
|
||||
args["SLSBASE"] = items[ 5]
|
||||
args["BOOTFILE"] = items[ 6]
|
||||
args["SCRIPT"] = items[ 7]
|
||||
args["VXWORKS"] = items[ 8]
|
||||
args["EPICSVER"] = items[ 9]
|
||||
args["VXWORKSVER"] = items[10]
|
||||
args["ETHADDR"] = items[11]
|
||||
|
||||
encArgs = urllib.urlencode (args)
|
||||
|
||||
url = "http://pc4860.psi.ch/testplan/IOC_INFOS/ioc_boot_ins.php?" + encArgs
|
||||
if debug:
|
||||
print "The URL is \"%s\"" % url
|
||||
print "Forking child process to do the work ..."
|
||||
#endif
|
||||
childPID = os.fork ()
|
||||
if childPID == 0:
|
||||
try:
|
||||
ufo = urllib.urlopen (url) # Query the database
|
||||
lines = ufo.readlines () # Get the result
|
||||
ufo.close ()
|
||||
except:
|
||||
print "Error inserting data into database!"
|
||||
raise
|
||||
#endtry
|
||||
sys.exit (0)
|
||||
else:
|
||||
if debug: print "Child's pid = %d" % childPID
|
||||
for i in range (int (timeout)):
|
||||
time.sleep (1)
|
||||
(pid, status) = os.waitpid (childPID, os.WNOHANG)
|
||||
if debug: print "waitpid return status = (%d, %d)" % (pid, status)
|
||||
if pid == childPID:
|
||||
if debug: print "Child has exited."
|
||||
sys.exit (0)
|
||||
#endif
|
||||
#endfor
|
||||
os.kill (childPID, signal.SIGKILL)
|
||||
print "Time-out inserting data into database!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#--------------------------------------------------#
|
||||
# emacs setup - force text mode to prevent emacs #
|
||||
# from helping with the indentation! #
|
||||
# Local Variables: #
|
||||
# mode:text #
|
||||
# indent-tabs-mode:nil #
|
||||
# End: #
|
||||
#--------------------------------------------------#
|
||||
#
|
||||
# $Log: call_ioc_ins,v $
|
||||
# Revision 1.7 2004/10/07 12:08:26 maden
|
||||
# Mark this file as obsolete
|
||||
#
|
||||
# Revision 1.6 2004/07/26 14:27:13 maden
|
||||
# No longer python2 dependent (there is no python2 on boot nodes yet).
|
||||
#
|
||||
# Revision 1.5 2004/07/26 11:39:38 maden
|
||||
# Add time-out
|
||||
#
|
||||
# Revision 1.4 2004/07/26 09:33:25 maden
|
||||
# Disable database update ... server is in trouble.
|
||||
#
|
||||
#
|
||||
#---------------------------------------------- End of $RCSfile: call_ioc_ins,v $
|
||||
@@ -1,116 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This script should only be called by the ioc at boot time.
|
||||
# The startup script should have the following line:
|
||||
# bootNotify SLSBASE,"sls/bin/iocBootNotify.sh"
|
||||
|
||||
PATH=$PATH:/bin:/usr/bin
|
||||
. /etc/profile
|
||||
|
||||
if [ "$1" = "-v" ]
|
||||
then
|
||||
echo '$Source: /cvs/G/DRV/misc/App/scripts/iocBootNotify.sh,v $'
|
||||
echo '$Author: lauk $'
|
||||
echo '$Date: 2015/03/25 08:57:14 $'
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" = "-h" ] || [ "$1" = "-?" ]
|
||||
then
|
||||
{
|
||||
echo "Usage:"
|
||||
echo " iocBootNotify.sh \\"
|
||||
echo " <system> \\"
|
||||
echo " <ipaddr> \\"
|
||||
echo " <procnum> \\"
|
||||
echo " <device> \\"
|
||||
echo " <bootfile> \\"
|
||||
echo " <script> \\"
|
||||
echo " <vxworksver> \\"
|
||||
echo " <epicsver> \\"
|
||||
echo " <ethaddr>"
|
||||
} >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SYSTEM=$1
|
||||
IPADDR=${2/-/$(hostname -i)}
|
||||
PROCNUM=${3#*:}
|
||||
DEVICE=${4/-/eth0}
|
||||
BOOTFILE=$5
|
||||
SCRIPT=$6
|
||||
VXWORKSVER=${7#VxWorks}
|
||||
EPICSVER=${8#R}
|
||||
ETHADDR=${9/-/$(/sbin/ifconfig eth0 | awk '/HWaddr/ {print $5}')}
|
||||
|
||||
if [ $# -lt 9 ]
|
||||
then
|
||||
{
|
||||
echo "This script should only be called by an IOC at boot time!"
|
||||
echo "It needs 9 arguments."
|
||||
echo "got: SYSTEM=\"$SYSTEM\""
|
||||
echo " IPADDR=\"$IPADDR\""
|
||||
echo " PROCNUM=\"$PROCNUM\""
|
||||
echo " DEVICE=\"$DEVICE\""
|
||||
echo " BOOTFILE=\"$BOOTFILE\""
|
||||
echo " SCRIPT=\"$SCRIPT\""
|
||||
echo " VXWORKSVER=\"$VXWORKSVER\""
|
||||
echo " EPICSVER=\"$EPICSVER\""
|
||||
echo " ETHADDR=\"$ETHADDR\""
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BOOTPC=$(hostname -s)
|
||||
|
||||
if [ ! -L /ioc/$SYSTEM ]
|
||||
then
|
||||
echo "ERROR: No symbolic link /ioc/$SYSTEM on $BOOTPC."
|
||||
echo "Rename 'target name' to your system name!"
|
||||
|
||||
# No link available, so the next best thing is to
|
||||
# extract SLSBASE from the path to the startup.script
|
||||
link=$(dirname $SCRIPT)
|
||||
else
|
||||
link=$(readlink /ioc/$SYSTEM)
|
||||
fi
|
||||
SLSBASE=${link%%/iocBoot*}
|
||||
if [ -L $BOOTFILE ]
|
||||
then
|
||||
link=$(readlink $BOOTFILE)
|
||||
tail=${link#../../}
|
||||
if [ $tail = $link ]
|
||||
then
|
||||
VXWORKS=$BOOTFILE
|
||||
else
|
||||
VXWORKS=$SLSBASE/iocBoot/$tail
|
||||
fi
|
||||
else
|
||||
VXWORKS=$BOOTFILE
|
||||
fi
|
||||
|
||||
if [ "$7" = "-" ]
|
||||
then
|
||||
VXWORKSVER=NULL
|
||||
VXWORKS=NULL
|
||||
OS=
|
||||
OSVERSION=
|
||||
else
|
||||
OS=$VXWORKS
|
||||
OSVERSION=$VXWORKSVER
|
||||
VXWORKSVER="'$VXWORKSVER'"
|
||||
VXWORKS="'$VXWORKS'"
|
||||
fi
|
||||
|
||||
|
||||
boot_info="--boot-device $DEVICE --boot-file $BOOTFILE --boot-pc $BOOTPC --epics-version $EPICSVER --ethernet-address $ETHADDR --ioc $SYSTEM --ip-address $IPADDR --port-number $PROCNUM --sls-base $SLSBASE --startup-script $SCRIPT"
|
||||
if [ -n "$OS" ]; then
|
||||
boot_info="$boot_info --os $OS --os-version $OSVERSION"
|
||||
fi
|
||||
echo "Uploading boot info to web service: $boot_info"
|
||||
$(dirname $0)/upload_bootinfo.py $boot_info &
|
||||
|
||||
# $Name: $
|
||||
# $Id: iocBootNotify.sh,v 1.27 2015/03/25 08:57:14 lauk Exp $
|
||||
# $Source: /cvs/G/DRV/misc/App/scripts/iocBootNotify.sh,v $
|
||||
# $Revision: 1.27 $
|
||||
@@ -1,135 +0,0 @@
|
||||
bootlink test scenarios/cases
|
||||
--------------------------------------------------------------------------------
|
||||
Facility: FELOBLA
|
||||
------------------------------------------------------------
|
||||
Called from: fin-cbpc01e
|
||||
Command:
|
||||
fin-cbpc01e:]bootlink /psi-xfel/devl FIN-M-CV10E
|
||||
/psi-xfel/devl/bin/bootlink: line 150: 3: Permission denied
|
||||
You are on FELOBLA subnet 172.21.70.
|
||||
Changing symbolic link for /ioc/FIN-M-CV10E...
|
||||
Current link is to:
|
||||
Requested link is to: /psi-xfel/devl/iocBoot/ioc/FIN-M-CV10E
|
||||
Changed on fin-cbpc01e
|
||||
from
|
||||
to /psi-xfel/devl/iocBoot/ioc/FIN-M-CV10E
|
||||
Results: link created
|
||||
------------------------------------------------------------
|
||||
Called from: fin-con01e (as afs user)
|
||||
Command:
|
||||
[fin-cbpc01e:]ssh fin-ccon01e
|
||||
krempaska@fin-ccon01e's password:
|
||||
Last login: Tue Jan 6 10:08:29 2009 from fin-cgwe.psi.ch
|
||||
[fin-ccon01e:]bootlink /psi-xfel/work FIN-M-CV10E
|
||||
You are on FELOBLA subnet 172.21.70.
|
||||
krempaska@fin-cbpc01e's password:
|
||||
Changing symbolic link for /ioc/FIN-M-CV10E...
|
||||
Current link is to: /psi-xfel/devl/iocBoot/ioc/FIN-M-CV10E
|
||||
Requested link is to: /psi-xfel/work/iocBoot/ioc/FIN-M-CV10E
|
||||
Changed on fin-cbpc01e
|
||||
from /psi-xfel/devl/iocBoot/ioc/FIN-M-CV10E
|
||||
to /psi-xfel/work/iocBoot/ioc/FIN-M-CV10E
|
||||
Results: link created
|
||||
------------------------------------------------------------
|
||||
Called from: xfellc
|
||||
Command:
|
||||
[xfellc:]bootlink /psi-xfel/devl/ FINLB-RLLE-CV10E
|
||||
You are on OFFICE subnet 129.129.145. and you need to go to fin-cbpc01e
|
||||
Loging to fin-cgwe...
|
||||
krempaska@fin-cgwe's password:
|
||||
krempaska@fin-cbpc01e's password:
|
||||
Changing symbolic link for /ioc/FINLB-RLLE-CV10E...
|
||||
Current link is to: /psi-xfel/devl/iocBoot/ioc/FINLB-RLLE-CV10E
|
||||
Requested link is to: /psi-xfel/devl//iocBoot/ioc/FINLB-RLLE-CV10E
|
||||
Changed on fin-cbpc01e
|
||||
from /psi-xfel/devl/iocBoot/ioc/FINLB-RLLE-CV10E
|
||||
to /psi-xfel/devl//iocBoot/ioc/FINLB-RLLE-CV10E
|
||||
Connection to fin-cgwe closed.
|
||||
Results: link created
|
||||
------------------------------------------------------------
|
||||
Notes:
|
||||
1. Do not use fin-cgwe for this operation it has no settings and not supposed to
|
||||
do any operations/.
|
||||
--------------------------------------------------------------------------------
|
||||
Facility: SLS Machine
|
||||
------------------------------------------------------------
|
||||
Called from: slsbpc
|
||||
Command:
|
||||
|
||||
Called from: slslc05 (when slsbridge is opened)
|
||||
Command:
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Facility: SLS Beamline
|
||||
Called from: x07da-bpc
|
||||
Command: !!called from devl
|
||||
cb /devl
|
||||
[x07da-bpc:/work]bootlink /devl X07DA-VME-OP1
|
||||
You are on one of beamlines subnets 129.129.113..
|
||||
Changing symbolic link for /ioc/X07DA-VME-OP1...
|
||||
Current link is to: /work/iocBoot/ioc/X07DA-VME-OP1
|
||||
Requested link is to: /devl/iocBoot/ioc/X07DA-VME-OP1
|
||||
Changed on x07da-bpc
|
||||
from /work/iocBoot/ioc/X07DA-VME-OP1
|
||||
to /devl/iocBoot/ioc/X07DA-VME-OP1
|
||||
Results: link created
|
||||
------------------------------------------------------------
|
||||
Called from: x07da-cons-1
|
||||
Command: !!call from /devl
|
||||
cb /devl
|
||||
[-bash SLSBASE=/devl]$ bootlink /devl X07DA-VME-OP1
|
||||
You are on one of beamlines subnets 129.129.113..
|
||||
x07da@x07da-bpc's password:
|
||||
|
||||
Results: CANNOT be used from console as this has no afs login possibility!
|
||||
------------------------------------------------------------
|
||||
Called from: slslc05
|
||||
Command:
|
||||
[gfalc05:/work]bootlink /devl X07DA-VME-OP1
|
||||
You are on OFFICE subnet 129.129.145. and you need to go to x07da-bpc
|
||||
Loging to x07da-gw...
|
||||
krempaska@x07da-gw's password:
|
||||
krempaska@x07da-bpc's password:
|
||||
Changing symbolic link for /ioc/X07DA-VME-OP1...
|
||||
Current link is to: /work/iocBoot/ioc/X07DA-VME-OP1
|
||||
Requested link is to: /devl/iocBoot/ioc/X07DA-VME-OP1
|
||||
Changed on x07da-bpc
|
||||
from /work/iocBoot/ioc/X07DA-VME-OP1
|
||||
to /devl/iocBoot/ioc/X07DA-VME-OP1
|
||||
Connection to x07da-gw closed.
|
||||
Results: link created
|
||||
--------------------------------------------------------------------------------
|
||||
Facility: HIPA
|
||||
------------------------------------------------------------
|
||||
Called from: hipa-bpc01
|
||||
|
||||
[hipa-bpc01:]./bootlink - ZPSAF28-VME
|
||||
You are on HIPA subnet 129.129.151.
|
||||
Link on hipa-bpc01 for ZPSAF28-VME is "/hipa/work/iocBoot/ioc/ZPSAF28-VME"
|
||||
[hipa-bpc01:]./bootlink /hipa/work ZPSAF28-VME
|
||||
You are on HIPA subnet 129.129.151.
|
||||
Changing symbolic link for /ioc/ZPSAF28-VME...
|
||||
Current link is to: /hipa/work/iocBoot/ioc/ZPSAF28-VME
|
||||
Requested link is to: /hipa/work/iocBoot/ioc/ZPSAF28-VME
|
||||
No operation will be done, it already points to "/hipa/work/iocBoot/ioc/ZPSAF28-VME".
|
||||
|
||||
Note: changing link to /hipa/prod was not tested yet because the directory
|
||||
doesn't exist yet:
|
||||
[hipa-bpc01:]./bootlink /hipa/prod ZPSAF28-VME
|
||||
You are on HIPA subnet 129.129.151.
|
||||
Changing symbolic link for /ioc/ZPSAF28-VME...
|
||||
Current link is to: /hipa/work/iocBoot/ioc/ZPSAF28-VME
|
||||
Requested link is to: /hipa/prod/iocBoot/ioc/ZPSAF28-VME
|
||||
Target directory "" does not exist, no link has been done.
|
||||
|
||||
Called from: hipa-lc01
|
||||
[hipa-lc01:]./bootlink /hipa/work ZPSAF28-VME
|
||||
You are on HIPA subnet 129.129.151.
|
||||
krempaska@hipa-bpc01's password:
|
||||
Changing symbolic link for /ioc/ZPSAF28-VME...
|
||||
Current link is to: /hipa/work/iocBoot/ioc/ZPSAF28-VME
|
||||
Requested link is to: /hipa/work/iocBoot/ioc/ZPSAF28-VME
|
||||
No operation will be done, it already points to "/hipa/work/iocBoot/ioc/ZPSAF28-VME".
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user