From ccbe267c74071fc8248567aba5cc352ed9279019 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 18 Mar 2010 11:27:28 +0000 Subject: [PATCH] Moving org.glite.yaim.lb to L&B subsystem. --- org.glite.lb.yaim/Makefile | 31 +++ org.glite.lb.yaim/config/defaults/glite-lb.pre | 3 + org.glite.lb.yaim/config/functions/config_gip_lb | 14 ++ org.glite.lb.yaim/config/functions/config_glite_lb | 253 +++++++++++++++++++++ .../config/functions/config_info_service_lb | 92 ++++++++ org.glite.lb.yaim/config/node-info.d/glite-lb | 14 ++ org.glite.lb.yaim/project/ChangeLog | 3 + org.glite.lb.yaim/project/package.description | 1 + org.glite.lb.yaim/project/package.summary | 1 + org.glite.lb.yaim/project/version.properties | 3 + 10 files changed, 415 insertions(+) create mode 100644 org.glite.lb.yaim/Makefile create mode 100644 org.glite.lb.yaim/config/defaults/glite-lb.pre create mode 100644 org.glite.lb.yaim/config/functions/config_gip_lb create mode 100644 org.glite.lb.yaim/config/functions/config_glite_lb create mode 100644 org.glite.lb.yaim/config/functions/config_info_service_lb create mode 100644 org.glite.lb.yaim/config/node-info.d/glite-lb create mode 100644 org.glite.lb.yaim/project/ChangeLog create mode 100644 org.glite.lb.yaim/project/package.description create mode 100644 org.glite.lb.yaim/project/package.summary create mode 100644 org.glite.lb.yaim/project/version.properties diff --git a/org.glite.lb.yaim/Makefile b/org.glite.lb.yaim/Makefile new file mode 100644 index 0000000..e51ba78 --- /dev/null +++ b/org.glite.lb.yaim/Makefile @@ -0,0 +1,31 @@ +top_srcdir=.. +stagedir=. +package=glite-lb-yaim +version=0.0.0 +PREFIX=/opt/glite + +-include Makefile.inc +-include ../project/version.properties + +all: + +install: + mkdir -p $(PREFIX)/yaim/functions/ + mkdir -p $(PREFIX)/yaim/node-info.d + mkdir -p $(PREFIX)/yaim/defaults + mkdir -p $(PREFIX)/yaim/etc/versions + install -m 0644 $(top_srcdir)/config/defaults/glite-lb.pre $(PREFIX)/yaim/defaults + for c in gip_lb glite_lb info_service_lb ; do \ + install -m 0644 $(top_srcdir)/config/functions/config_$$c $(PREFIX)/yaim/functions; \ + done + install -m 0644 $(top_srcdir)/config/node-info.d/glite-lb $(PREFIX)/yaim/node-info.d + echo "$(package) $(module.version)-$(module.age)" > $(PREFIX)/yaim/etc/versions/$(package) + +stage: + $(MAKE) install PREFIX=${stagedir} + +check: + +clean: + +.PHONY: default all check stage clean diff --git a/org.glite.lb.yaim/config/defaults/glite-lb.pre b/org.glite.lb.yaim/config/defaults/glite-lb.pre new file mode 100644 index 0000000..765eb59 --- /dev/null +++ b/org.glite.lb.yaim/config/defaults/glite-lb.pre @@ -0,0 +1,3 @@ +### Default values to some glite-LB variables +# backward compatible default location of GLITE_LOCATION_VAR +GLITE_LOCATION_VAR=/var/glite diff --git a/org.glite.lb.yaim/config/functions/config_gip_lb b/org.glite.lb.yaim/config/functions/config_gip_lb new file mode 100644 index 0000000..dde5c00 --- /dev/null +++ b/org.glite.lb.yaim/config/functions/config_gip_lb @@ -0,0 +1,14 @@ +function config_gip_lb_check () { + + yaimlog DEBUG "This function currently doesn't set any environment variables." + +} + +function config_gip_lb () { + + SERVICE_TYPE=org.glite.lb.Server + + rm -f $INSTALL_ROOT/glite/var/tmp/gip/service-${SERVICE_TYPE}.conf + rm -f $INSTALL_ROOT/glite/etc/gip/ldif/service-${SERVICE_TYPE}.ldif + +} diff --git a/org.glite.lb.yaim/config/functions/config_glite_lb b/org.glite.lb.yaim/config/functions/config_glite_lb new file mode 100644 index 0000000..d999714 --- /dev/null +++ b/org.glite.lb.yaim/config/functions/config_glite_lb @@ -0,0 +1,253 @@ +function config_glite_lb_check(){ + requires $1 MYSQL_PASSWORD INSTALL_ROOT GLITE_LOCATION GLITE_LOCATION_VAR GLITE_USER +} + +function config_glite_lb_setenv(){ + + yaimgridenv_set GLITE_USER ${GLITE_USER:-glite} + # Redefine GLITE_HOME_DIR to make sure we retrieve the correct HOME directory of user glite + GLITE_HOME_DIR=`getent passwd ${GLITE_USER} | cut -d: -f6` + if [ "x${GLITE_HOME_DIR}" = "x" ]; then + yaimlog ERROR "The home directory of ${GLITE_USER} doesn't exist. Check whether the user ${GLITE_USER} was properly created" + exit ${YEX_NOSUCHFILE} + fi + yaimgridenv_set GLITE_JP_LOCATION ${GLITE_JP_LOCATION:-} + yaimgridenv_set GLITE_WMS_QUERY_TIMEOUT ${GLITE_WMS_QUERY_TIMEOUT:-300} + yaimgridenv_set GLITE_HOST_CERT ${GLITE_HOME_DIR:-/home/glite}/.certs/hostcert.pem + yaimgridenv_set GLITE_HOST_KEY ${GLITE_HOME_DIR:-/home/glite}/.certs/hostkey.pem + yaimgridenv_set X509_CERT_DIR /etc/grid-security/certificates + yaimgridenv_set X509_VOMS_DIR /etc/grid-security/vomsdir + + yaimgridenv_set GLITE_LB_EXPORT_ENABLED ${GLITE_LB_EXPORT_ENABLED:-false} + yaimgridenv_set GLITE_LB_EXPORT_PURGE_ARGS "${GLITE_LB_EXPORT_PURGE_ARGS:---cleared 2d --aborted 15d --cancelled 15d --other 60d}" + yaimgridenv_set GLITE_LB_EXPORT_JPPS ${GLITE_LB_EXPORT_JPPS:-} + yaimgridenv_set GLITE_LB_RTM_ENABLED ${GLITE_LB_RTM_ENABLED:-false} + yaimgridenv_set GLITE_LB_RTM_DN "${GLITE_LB_RTM_DN:-/C=UK/O=eScience/OU=Imperial/L=Physics/CN=heppc24.hep.ph.ic.ac.uk/Email=janusz.martyniak@imperial.ac.uk}" + yaimgridenv_set GLITE_LB_SUPER_USERS "${GLITE_LB_SUPER_USERS:-}" + yaimgridenv_set GLITE_LB_HARVESTER_ENABLED ${GLITE_LB_HARVESTER_ENABLED:-false} + yaimgridenv_set GLITE_LB_HARVESTER_MSG_OPTIONS "${GLITE_LB_HARVESTER_MSG_OPTIONS:---wlcg}" + + yaimgridenv_set GLITE_LB_TYPE ${GLITE_LB_TYPE:-server} + + cares_prefix=${INSTALL_ROOT:-/opt}/c-ares + classads_prefix=${INSTALL_ROOT:-/opt}/classads + if [ x`uname -m` = xx86_64 ]; then + if [ -d "$cares_prefix/lib64" ]; then + cares_libarch=lib64 + fi + if [ -d "$classads_prefix/lib64" ]; then + classads_libarch=lib64 + fi + fi + yaimgridpath_append LD_LIBRARY_PATH $cares_prefix/${cares_libarch:-lib} + yaimgridpath_append LD_LIBRARY_PATH $classads_prefix/${classads_libarch:-lib} +} + +function config_glite_lb() { + + ############################################# + # Logging and Bookkeeping configuration # + ############################################# + + HOSTNAME=`hostname -f` + + # Redefine GLITE_HOME_DIR to make sure we retrieve the correct HOME directory of user glite + GLITE_HOME_DIR=`getent passwd ${GLITE_USER} | cut -d: -f6` + if [ "x${GLITE_HOME_DIR}" = "x" ]; then + yaimlog ERROR "The home directory of ${GLITE_USER} doesn't exist. Check whether the user ${GLITE_USER} was properly created" + exit ${YEX_NOSUCHFILE} + fi + + # Let Job Provenance Primary Storage as localhost:8901 in LB startup script. + # More strict check of GLITE_LB_EXPORT_JPPS variable only here. + if [ x"$GLITE_LB_EXPORT_ENABLED" = x"true" -a -z "$GLITE_LB_EXPORT_JPPS" ]; then + yaimlog ABORT "Job Provenance Primary Storage for export not set! (GLITE_LB_EXPORT_JPPS)" + return 1 + fi + + LB_PURGE="$GLITE_LOCATION/bin/glite-lb-purge" + if [ ! -x "$LB_PURGE" ]; then + LB_PURGE="$GLITE_LOCATION/sbin/glite-lb-purge" + fi + if [ ! -x "$LB_PURGE" ]; then + yaimlog ABORT "Purge utility not found! Install glite-lb-utils (or glite-lb-client in older version)" + return 1 + fi + + chmod og+rx /var/lib/mysql/ + chown mysql:mysql /var/run/mysqld/ + + # add option --max_allowed_packet=17M + if [ ! -f /etc/my.cnf ]; then + echo "[mysqld]" >> /etc/my.cnf + echo "max_allowed_packet=17M" >> /etc/my.cnf + else + grep "^[mysqld]" /etc/my.cnf > /dev/null + if [ ! $? = 0 ]; then + echo "[mysqld]" >> /etc/my.cnf + echo "max_allowed_packet=17M" >> /etc/my.cnf + fi + fi + + /sbin/chkconfig mysqld on + ps ax | grep -v grep |grep mysqld_safe > /dev/null 2>&1 + if [ ! $? = 0 ] ; then + /etc/init.d/mysqld start + sleep 1 + fi + + ls /tmp/mysql.sock > /dev/null 2>&1 + if [ ! $? = 0 ]; then + ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock + fi + + # set mysql password + set_mysql_passwd || return 1 # the function uses $MYSQL_PASSWORD + + # Check if database exist + mysqlshow --password="$MYSQL_PASSWORD" | grep "\" > /dev/null 2>&1 + + if [ ! $? = 0 ]; then + mysql -u root --password="$MYSQL_PASSWORD" -e "CREATE DATABASE lbserver20" + mysql --password="$MYSQL_PASSWORD" lbserver20 < ${INSTALL_ROOT}/glite/etc/glite-lb-dbsetup.sql + mysql -u root --password="$MYSQL_PASSWORD" -e "GRANT ALL PRIVILEGES on lbserver20.* to lbserver IDENTIFIED BY '' WITH GRANT OPTION;" + mysql -u root --password="$MYSQL_PASSWORD" -e "GRANT ALL PRIVILEGES on lbserver20.* to lbserver@'$HOSTNAME' IDENTIFIED BY '' WITH GRANT OPTION;" + mysql -u root --password="$MYSQL_PASSWORD" -e "GRANT ALL PRIVILEGES on lbserver20.* to lbserver@localhost IDENTIFIED BY '' WITH GRANT OPTION;" + mysql -u root --password="$MYSQL_PASSWORD" -e "ALTER TABLE short_fields MAX_ROWS=1000000000;" lbserver20 + mysql -u root --password="$MYSQL_PASSWORD" -e "ALTER TABLE long_fields MAX_ROWS=55000000;" lbserver20 + mysql -u root --password="$MYSQL_PASSWORD" -e "ALTER TABLE states MAX_ROWS=9500000;" lbserver20 + mysql -u root --password="$MYSQL_PASSWORD" -e "ALTER TABLE events MAX_ROWS=175000000;" lbserver20 + else + yaimlog WARNING "Database lbserver20 already exists" + fi + + # adjust indexes + # 1) if L&B with local harvester or L&B for Real Time Monitoring ==> lastUpdateTime needed + # 2) if GLITE_LB_INDEX_OWNER specified ==> create/destroy owner index + need_reindex=0 + $GLITE_LOCATION/bin/glite-lb-bkindex -d 2>/dev/null | tail -n +3 | head -n -2 | sed 's/\([^,]\)$/\1,/' > /var/tmp/glite-lb-bkindexes.txt + if [ x"$GLITE_LB_RTM_ENABLED" = x"true" -o x"GLITE_LB_HARVESTER_ENABLED" = x"true" ]; then + # index for querying older jobs by real time monitor + grep '\[ type = "system"; name = "lastUpdateTime" \]' /var/tmp/glite-lb-bkindexes.txt >/dev/null + if [ $? != 0 ]; then + need_reindex=1 + yaimlog INFO "Index 'lastUpdateTime' will be added" + echo '[ type = "system"; name = "lastUpdateTime" ],' >> /var/tmp/glite-lb-bkindexes.txt + fi + fi + if [ x"$GLITE_LB_INDEX_OWNER" = x"true" ]; then + grep 'name = "owner"' /var/tmp/glite-lb-bkindexes.txt >/dev/null + if [ $? != 0 ]; then + need_reindex=1 + yaimlog INFO "Index 'owner' will be added" + echo '[ type = "system"; name = "owner" ],' >> /var/tmp/glite-lb-bkindexes.txt + fi + elif [ x"$GLITE_LB_INDEX_OWNER" = x"false" ]; then + grep 'name = "owner"' /var/tmp/glite-lb-bkindexes.txt >/dev/null + if [ $? = 0 ]; then + need_reindex=1 + yaimlog INFO "Index 'owner' will be deleted" + mv /var/tmp/glite-lb-bkindexes.txt /var/tmp/glite-lb-bkindexes.txt.2 + grep -v 'name = "owner"' /var/tmp/glite-lb-bkindexes.txt.2 > /var/tmp/glite-lb-bkindexes.txt + rm -f /var/tmp/glite-lb-bkindexes.txt.2 + fi + fi + if [ $need_reindex = 1 ]; then + cat << EOF | $GLITE_LOCATION/bin/glite-lb-bkindex -rv +[ + JobIndices = { +`cat /var/tmp/glite-lb-bkindexes.txt` + } +] +EOF + fi + rm -f /var/tmp/glite-lb-bkindexes.txt + + mkdir -p $GLITE_LOCATION_VAR # Needed to store PID of LB server + + chown $GLITE_USER:$GLITE_USER $GLITE_LOCATION_VAR + chmod 0755 $GLITE_LOCATION_VAR + + mkdir -p $GLITE_HOME_DIR/.certs + chown $GLITE_USER:$GLITE_USER $GLITE_HOME_DIR/.certs + chmod 0755 $GLITE_HOME_DIR/.certs + cp -f /etc/grid-security/hostcert.pem /etc/grid-security/hostkey.pem $GLITE_HOME_DIR/.certs/ + if [ ! $? = 0 ] ; then + yaimlog WARNING "Please copy host certificate and key into /etc/grid-security and" + yaimlog WARNING " $GLITE_HOME_DIR/.certs/, change the owner of the ones in" + yaimlog WARNING " $GLITE_HOME_DIR/.certs/ to $GLITE_USER" + fi + chown $GLITE_USER:$GLITE_USER $GLITE_HOME_DIR/.certs/hostcert.pem $GLITE_HOME_DIR/.certs/hostkey.pem + chmod 0644 $GLITE_HOME_DIR/.certs/hostcert.pem + chmod 0400 $GLITE_HOME_DIR/.certs/hostkey.pem + + # Create cron for purging + mkdir -p /var/log/glite + logfile=/var/log/glite/glite-lb-purger.log + if $LB_PURGE --help 2>&1 | grep 'target-runtime' > /dev/null; then + purge_target_runtime_cmd='export GLITE_LB_PURGE_TARGET_RUNTIME=84600s; ' + fi + cat << EOF > /etc/cron.d/glite-lb-purge.cron +HOME=/ +MAILTO=$SITE_EMAIL + +1 1 * * * $GLITE_USER . /opt/glite/etc/profile.d/grid-env.sh ; export GLITE_LB_EXPORT_BKSERVER=$HOSTNAME; $purge_target_runtime_cmd/opt/glite/sbin/glite-lb-export.sh >> $logfile 2>&1 +EOF + + touch $logfile + chown $GLITE_USER:$GLITE_USER $logfile + + cat > /etc/logrotate.d/lb-purger < /dev/null + if [ ! $? = 0 ] ; then + echo "${GLITE_LOCATION}/etc/init.d/glite-lb-bkserverd" >> ${GLITE_LOCATION}/etc/gLiteservices + fi + + if [ -z "$GLITE_LB_SUPER_USERS" ]; then + touch ${GLITE_LOCATION}/etc/LB-super-users + else + echo "$GLITE_LB_SUPER_USERS" > ${GLITE_LOCATION}/etc/LB-super-users + fi + if [ x"$GLITE_LB_RTM_ENABLED" = x"true" ]; then + echo "$GLITE_LB_RTM_DN" >> ${GLITE_LOCATION}/etc/LB-super-users + fi + + if [ ! -f ${GLITE_LOCATION}/etc/glite-lb-harvester.conf ]; then + echo $HOSTNAME > ${GLITE_LOCATION}/etc/glite-lb-harvester.conf + fi + + . /opt/glite/etc/profile.d/grid-env.sh + ${GLITE_LOCATION}/etc/init.d/glite-lb-bkserverd stop + #Temporary workaround to kill glite-lb-*-interlogd + ps ax | grep -v grep | grep glite-lb-notif-interlogd > /dev/null + if [ $? = 0 ]; then + killall -9 /opt/glite/bin/glite-lb-notif-interlogd + fi + ps ax | grep -v grep | grep glite-lb-interlogd > /dev/null + if [ $? = 0 ]; then + killall -9 /opt/glite/bin/glite-lb-interlogd + fi + ${GLITE_LOCATION}/etc/init.d/glite-lb-bkserverd start + + if [ ! $? = 0 ] ; then + yaimlog ABORT "Service glite-lb-bkserverd failed to start!" + return 1 + fi + + return 0 + +} diff --git a/org.glite.lb.yaim/config/functions/config_info_service_lb b/org.glite.lb.yaim/config/functions/config_info_service_lb new file mode 100644 index 0000000..9154391 --- /dev/null +++ b/org.glite.lb.yaim/config/functions/config_info_service_lb @@ -0,0 +1,92 @@ +############################################################################## +# Copyright (c) Members of the EGEE Collaboration. 2004. +# See http://www.eu-egee.org/partners/ for details on the copyright +# holders. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################## +# +# NAME : config_info_service_lb +# +# DESCRIPTION : This function configures the dynamic service publisher +# for site LB server node. +# +# AUTHORS : Maria.Alandes.Pradillo@cern.ch +# salvet@ics.muni.cz +# +# NOTES : +# +# YAIM MODULE: glite-yaim-lb +# +############################################################################## + +config_info_service_lb_check () { + requires $1 SITE_NAME INSTALL_ROOT +} + +config_info_service_lb_setenv () { + yaimlog DEBUG "This function currently doesn't set any environment variables." +} + +config_info_service_lb () { + +INFO_SERVICE_CONFIG=${INFO_SERVICE_CONFIG:-${INSTALL_ROOT}/glite/etc} +INFO_SERVICE_SCRIPT=${INFO_SERVICE_SCRIPT:-${INSTALL_ROOT}/glite/libexec} +INFO_PROVIDER_PATH=${INFO_PROVIDER_PATH:-${INSTALL_ROOT}/glite/etc/gip/provider} + +SERVICE=LBSERVER +SERVICE_LC=lbserver + +SERVICE_HOST=`hostname -f` + +if [ ! -f ${INFO_SERVICE_CONFIG}/glite-info-service-${SERVICE_LC}.conf.template ]; then + yaimlog ERROR "The template file for glite-info-service-${SERVICE_LC}.conf.template was not found in ${INFO_SERVICE_CONFIG}." + exit 1 +fi + +if [ ! -f ${INFO_SERVICE_SCRIPT}/glite-info-service ]; then + yaimlog ERROR "The script file for glite-info-service was not found in ${INFO_SERVICE_SCRIPT}." + exit 1 +fi + +yaimlog DEBUG "Delete a previous version of the glite-info-service-${SERVICE_LC}.conf if it exists" +rm -rf ${INFO_SERVICE_CONFIG}/glite-info-service-${SERVICE_LC}.conf + +yaimlog DEBUG "Create the glite-info-service-${SERVICE_LC}.conf file out of the template file" +cp ${INFO_SERVICE_CONFIG}/glite-info-service-${SERVICE_LC}.conf.template ${INFO_SERVICE_CONFIG}/glite-info-service-${SERVICE_LC}.conf + +# Note: the configuration file may need to be altered if non standard values have been used. + +yaimlog DEBUG "Delete a previous version of the glite-info-provider-service-${SERVICE_LC}-wrapper if it exists" +rm -rf ${INFO_PROVIDER_PATH}/glite-info-provider-service-${SERVICE_LC}-wrapper + +yaimlog DEBUG "Create the ${INFO_PROVIDER_PATH} in case it doesn't exist" +mkdir -p ${INFO_PROVIDER_PATH} + +yaimlog DEBUG "Create the glite-info-provider-service-${SERVICE_LC}-wrapper file" +cat << EOF > ${INFO_PROVIDER_PATH}/glite-info-provider-service-${SERVICE_LC}-wrapper +#!/bin/sh +export PATH=$PATH:${INFO_SERVICE_SCRIPT} +export ${SERVICE}_HOST=${SERVICE_HOST} +${INFO_SERVICE_SCRIPT}/glite-info-service ${INFO_SERVICE_CONFIG}/glite-info-service-${SERVICE_LC}.conf $SITE_NAME +${INFO_SERVICE_SCRIPT}/glite-info-service-glue2 ${INFO_SERVICE_CONFIG}/glite-info-service-${SERVICE_LC}.conf $SITE_NAME +EOF + +chmod +x ${INFO_PROVIDER_PATH}/glite-info-provider-service-${SERVICE_LC}-wrapper + + +return 0 + +} + + diff --git a/org.glite.lb.yaim/config/node-info.d/glite-lb b/org.glite.lb.yaim/config/node-info.d/glite-lb new file mode 100644 index 0000000..4a44960 --- /dev/null +++ b/org.glite.lb.yaim/config/node-info.d/glite-lb @@ -0,0 +1,14 @@ +LB_FUNCTIONS=" +config_add_pool_env +config_crl +config_host_certs +config_edgusers +config_gip_only +config_gip_lb +config_info_service_lb +config_gip_service_release +config_globus_clients +config_glite_lb +config_glite_locallogger +config_bdii_only +config_glite_initd" diff --git a/org.glite.lb.yaim/project/ChangeLog b/org.glite.lb.yaim/project/ChangeLog new file mode 100644 index 0000000..5edc618 --- /dev/null +++ b/org.glite.lb.yaim/project/ChangeLog @@ -0,0 +1,3 @@ +4.2.2-2 +- Moved from org.glite.yaim.lb +- Cleanup diff --git a/org.glite.lb.yaim/project/package.description b/org.glite.lb.yaim/project/package.description new file mode 100644 index 0000000..0885cc3 --- /dev/null +++ b/org.glite.lb.yaim/project/package.description @@ -0,0 +1 @@ +This package contains the yaim functions to configuration of the LB node. diff --git a/org.glite.lb.yaim/project/package.summary b/org.glite.lb.yaim/project/package.summary new file mode 100644 index 0000000..9b56210 --- /dev/null +++ b/org.glite.lb.yaim/project/package.summary @@ -0,0 +1 @@ +YAIM initialization scripts for LB node diff --git a/org.glite.lb.yaim/project/version.properties b/org.glite.lb.yaim/project/version.properties new file mode 100644 index 0000000..608e174 --- /dev/null +++ b/org.glite.lb.yaim/project/version.properties @@ -0,0 +1,3 @@ +# $Header$ +module.version=1.0.0 +module.age=0 -- 1.8.2.3