Omaha #4103: Move svcbu.properties into the localization store.

Change-Id: I95001ee02f06594b15a451f938736bc7cb93d8be

Former-commit-id: 4b201b0a5cee53f2ffd8427d08252f6d0c83f47c
This commit is contained in:
David Gillingham 2015-03-30 13:17:55 -05:00
parent f961e64ca4
commit 806583afd9
10 changed files with 85 additions and 36 deletions

View file

@ -20,7 +20,6 @@
package com.raytheon.edex.plugin.gfe.svcbackup;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
@ -37,9 +36,15 @@ import com.raytheon.uf.common.auth.exception.AuthorizationException;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.dataplugin.gfe.exception.GfeException;
import com.raytheon.uf.common.dataplugin.gfe.request.AbstractGfePrivilegedRequest;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.common.util.RunProcess;
import com.raytheon.uf.edex.auth.AuthManager;
import com.raytheon.uf.edex.auth.AuthManagerFactory;
@ -68,6 +73,7 @@ import com.raytheon.uf.edex.site.SiteAwareRegistry;
* Jul 10, 2014 2914 garmendariz Remove EnvProperties
* Feb 17, 2015 4103 dgilling Add getLockDir for specific site, code
* cleanup.
* Mar 27, 2015 4103 dgilling Support new location for svcbu.properties.
*
* </pre>
*
@ -84,6 +90,9 @@ public class SvcBackupUtil {
public static final String OPERATION_SUCCESS = "Success";
private static final String SVCBU_PROPS_PATH = FileUtil.join("config",
"gfe", "svcbu.properties");
/** The logger instance */
protected static transient Log logger = LogFactory
.getLog(SvcBackupUtil.class);
@ -203,26 +212,31 @@ public class SvcBackupUtil {
public static Properties getSvcBackupProperties() {
Properties svcbuProperties = new Properties();
FileInputStream fis = null;
try {
fis = new FileInputStream(
EDEXUtil.getEdexHome()
+ "/../GFESuite/ServiceBackup/configuration/svcbu.properties");
svcbuProperties.load(fis);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error reading svcbu.properties file!", e);
return null;
} finally {
if (fis != null) {
try {
fis.close();
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error reading svcbu.properties file!", e);
}
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationFile basePropsFile = pathMgr.getLocalizationFile(pathMgr
.getContext(LocalizationType.EDEX_STATIC,
LocalizationLevel.BASE), SVCBU_PROPS_PATH);
try (InputStream input = basePropsFile.openInputStream()) {
svcbuProperties.load(input);
} catch (IOException | LocalizationException e) {
statusHandler.error(
"Unable to load BASE level svcbu.properties file.", e);
}
LocalizationFile sitePropsFile = pathMgr.getLocalizationFile(pathMgr
.getContextForSite(LocalizationType.EDEX_STATIC,
EDEXUtil.getEdexSite()), SVCBU_PROPS_PATH);
if (sitePropsFile.exists()) {
try (InputStream input = sitePropsFile.openInputStream()) {
svcbuProperties.load(input);
} catch (IOException | LocalizationException e) {
statusHandler.error(
"Unable to load SITE level svcbu.properties file.", e);
}
}
return svcbuProperties;
}

View file

@ -2,7 +2,13 @@
export AWIPS_HOME=$(readlink -f $AWIPS_HOME)
. ${AWIPS_HOME}/GFESuite/ServiceBackup/configuration/svcbu.properties
. ${AWIPS_HOME}/edex/data/utility/edex_static/base/config/gfe/svcbu.properties
SITE_SVCBU_OVERRIDE=${AWIPS_HOME}/edex/data/utility/edex_static/site/${AW_SITE_IDENTIFIER}/config/gfe/svcbu.properties
if [[ -f ${SITE_SVCBU_OVERRIDE} ]]
then
. ${SITE_SVCBU_OVERRIDE}
fi
export PATH=$PATH:$GFESUITE_HOME/bin:$GFESUITE_HOME/ServiceBackup/scripts:/awips2/fxa/bin/
source /etc/profile.d/awips2Python.sh

View file

@ -28,6 +28,7 @@
# ------------ ---------- ----------- --------------------------
# 05/10/11 8688 dgilling Initial Creation.
# 02/12/15 4103 dgilling Pre-emptively determine site id.
# 03/30/15 4103 dgilling Support new location for svcbu.properties.
#
##############################################################################
@ -37,9 +38,17 @@ RUN_FROM_DIR=`dirname $path_to_script`
BASE_AWIPS_DIR=`dirname $RUN_FROM_DIR`
if [[ -z "${AWIPS_HOME}" ]]
then
AWIPS_HOME=$(dirname $(dirname $BASE_AWIPS_DIR))
fi
# get the base environment
source ${AWIPS_HOME}/edex/bin/setup.env
source /awips2/GFESuite/bin/setup.env
source /awips2/GFESuite/ServiceBackup/scripts/serviceBackupUtil.sh
export SVCBU_HOST
export CDSPORT
# setup the environment needed to run the the Python
export LD_LIBRARY_PATH=${PYTHON_INSTALL}/lib

View file

@ -37,6 +37,7 @@ from ufpy import ThriftClient, ConfigFileUtil
# ------------ ---------- ----------- --------------------------
# 08/04/11 bphillip Initial Creation.
# 02/12/15 #4103 dgilling Set site ID field.
# 03/27/15 #4103 dgilling Read connection values from environment.
#
#
#
@ -47,7 +48,7 @@ def main():
try:
receiveConfRequest = createRequest()
thriftClient = ThriftClient.ThriftClient(connectionParams["SVCBU_HOST"], int(connectionParams["CDSPORT"]), "/services")
thriftClient = ThriftClient.ThriftClient(connectionParams[0], connectionParams[1], "/services")
serverResponse = thriftClient.sendRequest(receiveConfRequest)
except Exception, e:
print "Unhandled exception thrown during receive_configuration processing: \n", str(e)
@ -58,7 +59,7 @@ def main():
sys.exit(1)
def getConnectionParams():
return ConfigFileUtil.parseKeyValueFile("/awips2/GFESuite/ServiceBackup/configuration/svcbu.properties")
return (str(os.environ["SVCBU_HOST"]), int(os.environ["CDSPORT"]))
def createRequest():
obj = ProcessReceivedConfRequest()

View file

@ -28,6 +28,7 @@
# ------------ ---------- ----------- --------------------------
# 05/10/11 8688 dgilling Initial Creation.
# 02/12/15 4103 dgilling Pre-emptively determine site id.
# 03/30/15 4103 dgilling Support new location for svcbu.properties.
#
##############################################################################
@ -37,9 +38,17 @@ RUN_FROM_DIR=`dirname $path_to_script`
BASE_AWIPS_DIR=`dirname $RUN_FROM_DIR`
if [[ -z "${AWIPS_HOME}" ]]
then
AWIPS_HOME=$(dirname $(dirname $BASE_AWIPS_DIR))
fi
# get the base environment
source ${AWIPS_HOME}/edex/bin/setup.env
source /awips2/GFESuite/bin/setup.env
source /awips2/GFESuite/ServiceBackup/scripts/serviceBackupUtil.sh
export SVCBU_HOST
export CDSPORT
# setup the environment needed to run the the Python
export LD_LIBRARY_PATH=${PYTHON_INSTALL}/lib

View file

@ -37,6 +37,7 @@ from ufpy import ThriftClient, ConfigFileUtil
# ------------ ---------- ----------- --------------------------
# 08/04/11 bphillip Initial Creation.
# 02/12/15 #4103 dgilling Set site ID field.
# 03/27/15 #4103 dgilling Read connection values from environment.
#
#
#
@ -47,7 +48,7 @@ def main():
try:
receiveGridsRequest = createRequest()
thriftClient = ThriftClient.ThriftClient(connectionParams["SVCBU_HOST"], int(connectionParams["CDSPORT"]), "/services")
thriftClient = ThriftClient.ThriftClient(connectionParams[0], connectionParams[1], "/services")
serverResponse = thriftClient.sendRequest(receiveGridsRequest)
except Exception, e:
print "Unhandled exception thrown during receive_grids processing: \n", str(e)
@ -58,7 +59,7 @@ def main():
sys.exit(1)
def getConnectionParams():
return ConfigFileUtil.parseKeyValueFile("/awips2/GFESuite/ServiceBackup/configuration/svcbu.properties")
return (str(os.environ["SVCBU_HOST"]), int(os.environ["CDSPORT"]))
def createRequest():
print sys.argv

View file

@ -29,15 +29,18 @@
# ------------ ---------- ----------- --------------------------
# 06/16/14 3276 randerso Added -T to iscMosaic call
# 02/12/15 4103 dgilling Support multiple service backup sites.
# 03/30/15 4103 dgilling Support new location for svcbu.properties.
#
##############################################################################
if [ ${#AWIPS_HOME} = 0 ]
if [[ -z "${AWIPS_HOME}" ]]
then
path_to_script=`readlink -f $0`
export AWIPS_HOME=$(dirname $(dirname $(dirname $(dirname $path_to_script))))
fi
. ${AWIPS_HOME}/GFESuite/ServiceBackup/configuration/svcbu.env
source ${AWIPS_HOME}/edex/bin/setup.env
source ${AWIPS_HOME}/GFESuite/ServiceBackup/configuration/svcbu.env
source ${AWIPS_HOME}/GFESuite/ServiceBackup/scripts/serviceBackupUtil.sh
# Create the log file

View file

@ -27,15 +27,22 @@
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# Feb 09, 2015 #4103 dgilling Initial Creation.
# Mar 27, 2015 #4103 dgilling Support new location for svcbu.properties.
#
##
if [ ${#AWIPS_HOME} = 0 ]
if [[ -z "${AWIPS_HOME}" ]]
then
path_to_script=`readlink -f $0`
AWIPS_HOME=$(dirname $(dirname $(dirname $(dirname $path_to_script))))
fi
. ${AWIPS_HOME}/GFESuite/ServiceBackup/configuration/svcbu.properties
. ${AWIPS_HOME}/edex/data/utility/edex_static/base/config/gfe/svcbu.properties
SITE_SVCBU_OVERRIDE=${AWIPS_HOME}/edex/data/utility/edex_static/site/${AW_SITE_IDENTIFIER}/config/gfe/svcbu.properties
if [[ -f ${SITE_SVCBU_OVERRIDE} ]]
then
. ${SITE_SVCBU_OVERRIDE}
fi
function configureLogging()

View file

@ -1,4 +1,3 @@
#!/usr/bin/env python
##
# This software was developed and / or modified by Raytheon Company,
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
@ -24,9 +23,7 @@ import os
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.request import IscDataRecRequest
from dynamicserialize.dstypes.com.raytheon.uf.common.message import WsId
from dynamicserialize import DynamicSerializationManager
from ufpy import ThriftClient, ConfigFileUtil
from ufpy import ThriftClient
#
# TODO: ADD DESCRIPTION
@ -37,6 +34,8 @@ from ufpy import ThriftClient, ConfigFileUtil
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 10/26/10 dgilling Initial Creation.
# 03/30/15 #4103 dgilling Use shell script to call this script
# to configure env. variables.
#
#
#
@ -47,9 +46,9 @@ def main():
try:
iscDataRequest = createRequest()
thriftClient = ThriftClient.ThriftClient(connectionParams["SVCBU_HOST"], int(connectionParams["CDSPORT"]), "/services")
thriftClient = ThriftClient.ThriftClient(connectionParams[0], connectionParams[1], "/services")
serverResponse = thriftClient.sendRequest(iscDataRequest)
except Exception, e:
except Exception as e:
print "Unhandled exception thrown during iscDataRec processing: \n", str(e)
sys.exit(1)
@ -58,7 +57,7 @@ def main():
sys.exit(1)
def getConnectionParams():
return ConfigFileUtil.parseKeyValueFile(os.path.join(sys.path[0], "../ServiceBackup/configuration/svcbu.properties"))
return (str(os.environ["SVCBU_HOST"]), int(os.environ["CDSPORT"]))
def createRequest():
obj = IscDataRecRequest()