Issue #1762: Remove NATIONAL_CENTER setting from svcbu.properties,
all code that used that setting will now use new CheckServiceBackupPrimarySiteRequest. Change-Id: I0f9ebe68ba73a6aaf1882ae361327d7681449e31 Former-commit-id: 1b2c23abda7ed0a296bf1ffb1f3e8e27dc02555e
This commit is contained in:
parent
d66d7b5968
commit
0259bb6672
9 changed files with 326 additions and 147 deletions
|
@ -21,18 +21,16 @@ package com.raytheon.viz.gfe.dialogs.sbu;
|
|||
|
||||
import com.raytheon.uf.common.auth.user.IUser;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.CheckPermissionsRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.NcCheckRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.CheckServiceBackupPrimarySiteRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.site.requests.GetPrimarySiteRequest;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.core.auth.UserController;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* A utility class for the Service Backup GUI to do permissions checks.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -42,6 +40,8 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 11, 2011 bphillip Initial creation
|
||||
* Nov 14, 2012 jdynina Added check for national center
|
||||
* May 02, 2013 #1762 dgilling Replace national center check with
|
||||
* a svcbu PRIMARY_SITES check.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -54,6 +54,16 @@ public class CheckPermissions {
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ServiceBackupDlg.class);
|
||||
|
||||
/**
|
||||
* A private constructor so that Java does not attempt to create one for us.
|
||||
* As this class should not be instantiated, do not attempt to ever call
|
||||
* this constructor; it will simply throw an AssertionError.
|
||||
*
|
||||
*/
|
||||
private CheckPermissions() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static boolean getAuthorization() {
|
||||
boolean authorized = false;
|
||||
|
@ -74,39 +84,18 @@ public class CheckPermissions {
|
|||
}
|
||||
return authorized;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static boolean isNationalCenter() {
|
||||
boolean isNationalCenter = false;
|
||||
NcCheckRequest request = new NcCheckRequest();
|
||||
try {
|
||||
ServerResponse<String> obj = (ServerResponse<String>) ThriftClient
|
||||
.sendRequest(request);
|
||||
if (obj.isOkay()) {
|
||||
isNationalCenter = true;
|
||||
} else {
|
||||
isNationalCenter = false;
|
||||
}
|
||||
} catch (VizException e) {
|
||||
statusHandler.error("Error checking site type!", e);
|
||||
isNationalCenter = false;
|
||||
}
|
||||
return isNationalCenter;
|
||||
}
|
||||
|
||||
public static boolean runningAsPrimary() {
|
||||
boolean isPrimary = false;
|
||||
|
||||
GetPrimarySiteRequest request = new GetPrimarySiteRequest();
|
||||
CheckServiceBackupPrimarySiteRequest request = new CheckServiceBackupPrimarySiteRequest();
|
||||
try {
|
||||
String obj = (String)ThriftClient
|
||||
@SuppressWarnings("unchecked")
|
||||
ServerResponse<Boolean> sr = (ServerResponse<Boolean>) ThriftClient
|
||||
.sendRequest(request);
|
||||
return LocalizationManager.getInstance().getCurrentSite()
|
||||
.equalsIgnoreCase(obj);
|
||||
return sr.getPayload();
|
||||
} catch (VizException e) {
|
||||
statusHandler
|
||||
.error("Error checking if running as primary site!", e);
|
||||
}
|
||||
return isPrimary;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
|||
* Nov 15, 2012 15614 jdynina Added check for national center
|
||||
* Mar 20, 2013 1447 dgilling Port troubleshooting mode changes
|
||||
* from A1 DR 21404, some code cleanup.
|
||||
* May 01, 2013 1762 dgilling Remove national center check.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -158,8 +159,6 @@ public class ServiceBackupDlg extends CaveJFACEDialog {
|
|||
|
||||
private boolean authorized;
|
||||
|
||||
private boolean nationalCenter;
|
||||
|
||||
private SVCBU_OP currentOperation = SVCBU_OP.no_backup;
|
||||
|
||||
/**
|
||||
|
@ -169,7 +168,6 @@ public class ServiceBackupDlg extends CaveJFACEDialog {
|
|||
super(parentShell);
|
||||
authorized = CheckPermissions.getAuthorization();
|
||||
this.site = LocalizationManager.getInstance().getCurrentSite();
|
||||
this.nationalCenter = CheckPermissions.isNationalCenter();
|
||||
this.runningAsPrimary = CheckPermissions.runningAsPrimary();
|
||||
if (!ServiceBackupJobManager.getInstance().isRunning()) {
|
||||
ServiceBackupJobManager.getInstance().start();
|
||||
|
@ -1194,7 +1192,7 @@ public class ServiceBackupDlg extends CaveJFACEDialog {
|
|||
+ UserController.getUserObject().uniqueId());
|
||||
}
|
||||
|
||||
if ((!runningAsPrimary) & (!nationalCenter)) {
|
||||
if (!runningAsPrimary) {
|
||||
doExCon.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
|
203
deltaScripts/13.5.1/update_svcbu_props.sh
Normal file
203
deltaScripts/13.5.1/update_svcbu_props.sh
Normal file
|
@ -0,0 +1,203 @@
|
|||
#!/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.
|
||||
#
|
||||
# U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
# This software product contains export-restricted data whose
|
||||
# export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
# to non-U.S. persons whether in the United States or abroad requires
|
||||
# an export license or other authorization.
|
||||
#
|
||||
# Contractor Name: Raytheon Company
|
||||
# Contractor Address: 6825 Pine Street, Suite 340
|
||||
# Mail Stop B8
|
||||
# Omaha, NE 68106
|
||||
# 402.291.0100
|
||||
#
|
||||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
# further licensing information.
|
||||
##
|
||||
|
||||
import logging
|
||||
import shutil
|
||||
import sys
|
||||
from ufpy import ConfigFileUtil
|
||||
|
||||
|
||||
logging.basicConfig(format="%(asctime)s %(levelname)s: %(message)s",
|
||||
datefmt="%H:%M:%S",
|
||||
level=logging.INFO)
|
||||
|
||||
|
||||
SVCBU_CONFIG_FILENAME = "/awips2/GFESuite/ServiceBackup/configuration/svcbu.properties"
|
||||
SVCBU_CONFIG_BACKUP_FILENAME = SVCBU_CONFIG_FILENAME + ".bak"
|
||||
SVCBU_CONFIG_MIGRATE = ['SVCBU_HOST', 'MSG_SEND_COMMAND', 'CDSPORT', 'SVCBU_DB',
|
||||
'SVCBU_TRIM_ELEMS', 'SVCBU_FAILED_SITE_PORT',
|
||||
'SVCBU_GRIDAREA', 'SVCBU_ADDRESSEE', 'SVCBU_WMO_HEADER',
|
||||
'SVCBU_USER', 'SVCBU_USER_ID', 'EXPORT_GRID']
|
||||
STATIC_CONFIG_DATA = """
|
||||
#Variables used by service backup:
|
||||
#
|
||||
# AWIPS_HOME: The AWIPS II installation directory.
|
||||
#
|
||||
# GFESUITE_HOME: The server directory containing files and programs
|
||||
# used by GFE during Service Backup
|
||||
#
|
||||
# GFESUITE_BIN: Directory containing GFE server side utility
|
||||
# programs including ifpnetCDF and iscMosaic
|
||||
#
|
||||
# SVCBU_HOME: Directory used by service backup as a sandbox for
|
||||
# constructing files to be sent and for processing
|
||||
# received files.
|
||||
#
|
||||
# LOCALIZATION_PATH: This is the path to the root of the localization
|
||||
# directory. This path is used for properly importing
|
||||
# and exporting configuration data
|
||||
#
|
||||
# IFPS_LOG: Directory containing logs for the service backup
|
||||
# operations.
|
||||
#
|
||||
# IFPS_DATA: Directory containing the svcbu_export_elements file.
|
||||
# This file is used to specify which weather elements are
|
||||
# packaged and sent when exporting digital data for a
|
||||
# site.
|
||||
#
|
||||
# LOCK_DIR: Directory used for lock files. Each Service Backup
|
||||
# operation maintains a lock file during its execution.
|
||||
# The lock remains for the duration of the operation and
|
||||
# is erased upon completion to prevent simultaneous
|
||||
# operations from occurring.
|
||||
#
|
||||
# SCRIPTS_DIR: Directory containing the scripts used by service
|
||||
# backup
|
||||
#
|
||||
# CAVE_LAUNCH_SCRIPT: This path points to the script which starts GFE. This
|
||||
# variable is read when the user hits the 'Enable' button
|
||||
# On the service backup GUI.
|
||||
#
|
||||
# SVCBU_HOST: Server where the service backup scripts will be
|
||||
# executed.
|
||||
#
|
||||
# MSG_SEND_COMMAND: The command executed to send a message via the message handling
|
||||
# system. This value will usually be msg_send. But, it can be
|
||||
# changed to a different command in a test environment.
|
||||
#
|
||||
# CDSPORT: This is the port on which the Thrift Client listens
|
||||
# for script execution events.
|
||||
#
|
||||
# SVCBU_DB: Defines which database to use for exporting
|
||||
# grids to central server for service backup.
|
||||
# VALID VALUES: Fcst
|
||||
# Official (default)
|
||||
#
|
||||
# SVCBU_TRIM_ELEMS: Indication of whether ifpnetCDF needs to trim
|
||||
# off elements while exporting grids to central
|
||||
# server.
|
||||
# VALID VALUES: 1 - To do element trimming
|
||||
# 0 - To disable element trimming
|
||||
# Note: ${IFPS_DATA}/svcbu_export_elements.ccc
|
||||
# file has to be present for this to work. This file
|
||||
# will contain list of elements to include in the
|
||||
# netcdf file that's being sent over to central srv.
|
||||
#
|
||||
# SVCBU_FAILED_SITE_PORT: Unused
|
||||
#
|
||||
# SVCBU_GRIDAREA: The name of the edit area used when exporting grids
|
||||
# to the central server for service backup and
|
||||
# imported to the Restore databse after service backup.
|
||||
# DEFUALT VALUE: ISC_Send_Area
|
||||
#
|
||||
# SVCBU_ADDRESSEE: The name of the msg_send addressee. Will be used to
|
||||
# pass with -a flag of msg_send. (NCF use only).
|
||||
#
|
||||
# SVCBU_WMO_HEADER: The WMO header that will be used to pass in calls to
|
||||
# msg_send with -i argument. This will be empty to
|
||||
# begin with. Should not be changed. (NCF use only)
|
||||
#
|
||||
# EXPORT_GRID Indicate the ways of grid being exported
|
||||
# VALID VALUES: 0 = do not export grids
|
||||
# 1 = grids are exported by quartz timer
|
||||
# at 15 after each hour, the service
|
||||
# backup GUI, and from GFE via the
|
||||
# 'Send Grids to NDFD...' script
|
||||
# 2 = grids are exported only by the service backup GUI and from GFE via the 'Send
|
||||
# Grids to NDFD...' script'
|
||||
#
|
||||
# SVCBU_USER Indicates that the site can configure a special user to
|
||||
# run GFE when in service backup
|
||||
# VALID VALUES: 0 = do not use a designated user to run
|
||||
# GFE when in service backup
|
||||
# 1 = use a designated user to run GFE
|
||||
# when in service backup
|
||||
#
|
||||
# SVCBU_USER_ID The user id of the designated user to run GFE when
|
||||
# in service backup
|
||||
#
|
||||
# PRIMARY_SITES (Optional) For dual-domain sites, a comma-separated
|
||||
# list of sites for the export grids cron to run for
|
||||
# instead of the site defined as AW_SITE_IDENTIFIER. If
|
||||
# this setting is empty or not defined, cron will only
|
||||
# export grids for site set as AW_SITE_IDENTIFIER.
|
||||
#
|
||||
#
|
||||
# Directories used by Service Backup
|
||||
GFESUITE_HOME=/awips2/GFESuite
|
||||
GFESUITE_BIN=/awips2/GFESuite/bin
|
||||
SVCBU_HOME=/awips2/GFESuite/ServiceBackup/svcbu
|
||||
LOCALIZATION_PATH=/awips2/edex/data/utility
|
||||
IFPS_LOG=/awips2/GFESuite/ServiceBackup/logs
|
||||
IFPS_DATA=/awips2/GFESuite/ServiceBackup/data
|
||||
LOCK_DIR=/awips2/GFESuite/ServiceBackup/locks
|
||||
SCRIPTS_DIR=/awips2/GFESuite/ServiceBackup/scripts
|
||||
CAVE_LAUNCH_SCRIPT=/awips2/cave/cave.sh
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
def get_old_config():
|
||||
return ConfigFileUtil.parseKeyValueFile(SVCBU_CONFIG_FILENAME)
|
||||
|
||||
def backup_old_config():
|
||||
shutil.move(SVCBU_CONFIG_FILENAME, SVCBU_CONFIG_BACKUP_FILENAME)
|
||||
|
||||
def write_new_config(old_vals):
|
||||
with open(SVCBU_CONFIG_FILENAME, 'w') as configOut:
|
||||
configOut.write(STATIC_CONFIG_DATA)
|
||||
for entry in SVCBU_CONFIG_MIGRATE:
|
||||
oldValue = old_vals[entry]
|
||||
configOut.write(entry + "=" + oldValue + "\n")
|
||||
configOut.write("PRIMARY_SITES=")
|
||||
if "NATIONAL_CENTER" in old_vals and old_vals["NATIONAL_CENTER"] == '1':
|
||||
logging.warning("Since this system was previously configured as a " +
|
||||
"national center, please configure the " +
|
||||
"PRIMARY_SITES setting with your GFE sites after " +
|
||||
"this script is complete.")
|
||||
|
||||
def main():
|
||||
logging.info("Migrating svcbu.properties for 13.5.1.")
|
||||
|
||||
try:
|
||||
oldConfig = get_old_config()
|
||||
except:
|
||||
logging.exception("Could not read old configuration from " + SVCBU_CONFIG_FILENAME)
|
||||
|
||||
try:
|
||||
backup_old_config()
|
||||
except:
|
||||
logging.exception("Could not backup previous svcbu.properties.")
|
||||
|
||||
try:
|
||||
write_new_config(oldConfig)
|
||||
except:
|
||||
logging.exception("Could not write new svcbu.properties.")
|
||||
|
||||
logging.info("Migration complete.")
|
||||
logging.info("After you have verified that svcbu.properties was properly migrated, " +
|
||||
"please delete the file " + SVCBU_CONFIG_BACKUP_FILENAME + ".")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -347,6 +347,14 @@
|
|||
<constructor-arg ref="CheckPermissionsRequestHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="CheckPrimarySiteHandler"
|
||||
class="com.raytheon.edex.plugin.gfe.server.handler.svcbu.CheckServiceBackupPrimarySiteHandler" />
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg
|
||||
value="com.raytheon.uf.common.dataplugin.gfe.request.CheckServiceBackupPrimarySiteRequest" />
|
||||
<constructor-arg ref="CheckPrimarySiteHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="CleanupSvcBuLogRequestHandler"
|
||||
class="com.raytheon.edex.plugin.gfe.server.handler.svcbu.CleanupSvcBuLogRequestHandler" />
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
|
@ -354,14 +362,6 @@
|
|||
value="com.raytheon.uf.common.dataplugin.gfe.request.CleaunpSvcBuLogRequest" />
|
||||
<constructor-arg ref="CleanupSvcBuLogRequestHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="NcCheckRequestHandler"
|
||||
class="com.raytheon.edex.plugin.gfe.server.handler.svcbu.NcCheckRequestHandler" />
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg
|
||||
value="com.raytheon.uf.common.dataplugin.gfe.request.NcCheckRequest" />
|
||||
<constructor-arg ref="NcCheckRequestHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="ExportConfRequestHandler"
|
||||
class="com.raytheon.edex.plugin.gfe.server.handler.svcbu.ExportConfRequestHandler" />
|
||||
|
|
|
@ -20,12 +20,14 @@
|
|||
package com.raytheon.edex.plugin.gfe.server.handler.svcbu;
|
||||
|
||||
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.NcCheckRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.CheckServiceBackupPrimarySiteRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
|
||||
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Handler for <code>CheckServiceBackupPrimarySiteRequest</code>. Determines
|
||||
* whether the specified site id has been configured as one of service backup's
|
||||
* primary sites.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -33,26 +35,31 @@ import com.raytheon.uf.common.serialization.comm.IRequestHandler;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 14, 2012 jdynina Initial creation
|
||||
* May 02, 2013 dgilling Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author jdynina
|
||||
* @author dgilling
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class NcCheckRequestHandler implements IRequestHandler<NcCheckRequest>{
|
||||
public class CheckServiceBackupPrimarySiteHandler implements
|
||||
IRequestHandler<CheckServiceBackupPrimarySiteRequest> {
|
||||
|
||||
public Object handleRequest(NcCheckRequest request)
|
||||
throws Exception {
|
||||
ServerResponse<String> sr = new ServerResponse<String>();
|
||||
if (!isNationalCenter()) {
|
||||
sr.addMessage("Site is not a national center.");
|
||||
}
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
|
||||
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
|
||||
*/
|
||||
@Override
|
||||
public ServerResponse<Boolean> handleRequest(
|
||||
CheckServiceBackupPrimarySiteRequest request) throws Exception {
|
||||
ServerResponse<Boolean> sr = new ServerResponse<Boolean>();
|
||||
boolean isPrimarySite = SvcBackupUtil.getPrimarySites().contains(
|
||||
request.getSiteID());
|
||||
sr.setPayload(isPrimarySite);
|
||||
return sr;
|
||||
}
|
||||
|
||||
public boolean isNationalCenter() {
|
||||
return SvcBackupUtil.ncCheck();
|
||||
}
|
||||
}
|
|
@ -19,24 +19,17 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.gfe.svcbackup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.raytheon.edex.plugin.gfe.server.handler.svcbu.ExportGridsRequestHandler;
|
||||
import com.raytheon.edex.site.SiteUtil;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.ExportGridsRequest;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.request.ExportGridsRequest.ExportGridsMode;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.edex.site.SiteAwareRegistry;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Cron job that exports GFE's primary sites' grids. Primary sites are
|
||||
* determined by a combination of the env. variable AW_SITE_IDENTIFIER and the
|
||||
* PRIMARY_SITES entry in svcbu.properties.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -47,6 +40,8 @@ import com.raytheon.uf.edex.site.SiteAwareRegistry;
|
|||
* Aug 03, 2011 bphillip Initial creation
|
||||
* Apr 30, 2013 #1761 dgilling Read list of sites to export grids
|
||||
* for from svcbu.properties.
|
||||
* May 02, 2013 #1762 dgilling Move code to read PRIMARY_SITES setting
|
||||
* to SvcBackupUtil.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -56,9 +51,6 @@ import com.raytheon.uf.edex.site.SiteAwareRegistry;
|
|||
|
||||
public class ExportGridsTask extends TimerTask {
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ExportGridsTask.class);
|
||||
|
||||
public ExportGridsTask(Date executionTime) {
|
||||
ServiceBackupNotificationManager
|
||||
.sendMessageNotification("Export grids cron scheduled for execution at: "
|
||||
|
@ -74,7 +66,7 @@ public class ExportGridsTask extends TimerTask {
|
|||
public void run() {
|
||||
final ExportGridsRequestHandler reqHandler = new ExportGridsRequestHandler();
|
||||
|
||||
for (String site : getSites()) {
|
||||
for (String site : SvcBackupUtil.getPrimarySites()) {
|
||||
ServiceBackupNotificationManager
|
||||
.sendMessageNotification("Export Grids to central server cron started for site "
|
||||
+ site + ".");
|
||||
|
@ -88,35 +80,4 @@ public class ExportGridsTask extends TimerTask {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<String> getSites() {
|
||||
Properties svcbuProps = SvcBackupUtil.getSvcBackupProperties();
|
||||
String siteList = SiteUtil.getSite();
|
||||
if (svcbuProps != null) {
|
||||
String propVal = svcbuProps.getProperty("PRIMARY_SITES", "").trim();
|
||||
if (!propVal.isEmpty()) {
|
||||
siteList = propVal;
|
||||
}
|
||||
}
|
||||
|
||||
String[] sites = siteList.split(",");
|
||||
Collection<String> retVal = new ArrayList<String>(sites.length);
|
||||
Set<String> validSites = Sets.newHashSet(SiteAwareRegistry
|
||||
.getInstance().getActiveSites());
|
||||
for (String site : sites) {
|
||||
final String siteId = site.trim().toUpperCase();
|
||||
if (!siteId.isEmpty()) {
|
||||
if (validSites.contains(siteId)) {
|
||||
retVal.add(siteId);
|
||||
} else {
|
||||
statusHandler
|
||||
.warn("Site "
|
||||
+ siteId
|
||||
+ " is not a currently activated site. Grids will not be exported for this site. Check the PRIMARY_SITES setting in svcbu.properties.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,11 +24,15 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.raytheon.edex.site.SiteUtil;
|
||||
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;
|
||||
|
@ -43,6 +47,7 @@ import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
|
|||
import com.raytheon.uf.edex.auth.roles.IRoleStorage;
|
||||
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||
import com.raytheon.uf.edex.core.props.PropertiesFactory;
|
||||
import com.raytheon.uf.edex.site.SiteAwareRegistry;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -56,8 +61,11 @@ import com.raytheon.uf.edex.core.props.PropertiesFactory;
|
|||
* Oct 09, 2009 bphillip Initial creation
|
||||
* Sep 19, 2011 10955 rferrel make sure process destroy is called.
|
||||
* Jun 12, 2012 00609 djohnson Use EDEXUtil for EDEX_HOME.
|
||||
* Nov 15, 2012 15614 jdynina Added check for national center
|
||||
*
|
||||
* Nov 15, 2012 15614 jdynina Added check for national center
|
||||
* May 02, 2013 #1762 dgilling Remove check for national center, add
|
||||
* method to retrieve list of svcbu
|
||||
* sites.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -77,6 +85,16 @@ public class SvcBackupUtil {
|
|||
protected static transient Log logger = LogFactory
|
||||
.getLog(SvcBackupUtil.class);
|
||||
|
||||
/**
|
||||
* A private constructor so that Java does not attempt to create one for us.
|
||||
* As this class should not be instantiated, do not attempt to ever call
|
||||
* this constructor; it will simply throw an AssertionError.
|
||||
*
|
||||
*/
|
||||
private SvcBackupUtil() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static String execute(String... args) throws Exception {
|
||||
String[] newArgs = new String[args.length + 1];
|
||||
newArgs[0] = "sh";
|
||||
|
@ -240,17 +258,11 @@ public class SvcBackupUtil {
|
|||
String lockDir = SvcBackupUtil.getSvcBackupProperties().getProperty(
|
||||
"LOCK_DIR")
|
||||
+ File.separator;
|
||||
lockDir = lockDir.replace("${GFESUITE_HOME}",
|
||||
EDEXUtil.EDEX_HOME + "/../GFESuite"
|
||||
+ File.separator);
|
||||
|
||||
return lockDir;
|
||||
}
|
||||
|
||||
public static AuthorizationResponse authorizeWithLocalization(
|
||||
IUser user,
|
||||
AbstractGfePrivilegedRequest request)
|
||||
throws AuthorizationException {
|
||||
public static AuthorizationResponse authorizeWithLocalization(IUser user,
|
||||
AbstractGfePrivilegedRequest request) throws AuthorizationException {
|
||||
AuthManager manager = AuthManagerFactory.getInstance().getManager();
|
||||
IRoleStorage roles = manager.getRoleStorage();
|
||||
String roleId = request.getRoleId();
|
||||
|
@ -264,13 +276,34 @@ IUser user,
|
|||
+ roleId);
|
||||
}
|
||||
|
||||
|
||||
public static boolean ncCheck() {
|
||||
String nationalCenter = SvcBackupUtil.getSvcBackupProperties()
|
||||
.getProperty("NATIONAL_CENTER");
|
||||
if (nationalCenter.equals("1")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
public static Set<String> getPrimarySites() {
|
||||
Properties svcbuProps = SvcBackupUtil.getSvcBackupProperties();
|
||||
String siteList = SiteUtil.getSite();
|
||||
if (svcbuProps != null) {
|
||||
String propVal = svcbuProps.getProperty("PRIMARY_SITES", "").trim();
|
||||
if (!propVal.isEmpty()) {
|
||||
siteList = propVal;
|
||||
}
|
||||
}
|
||||
|
||||
String[] sites = siteList.split(",");
|
||||
Set<String> retVal = new HashSet<String>(sites.length, 1.0f);
|
||||
Set<String> validSites = Sets.newHashSet(SiteAwareRegistry
|
||||
.getInstance().getActiveSites());
|
||||
for (String site : sites) {
|
||||
String siteId = site.trim().toUpperCase();
|
||||
if (!siteId.isEmpty()) {
|
||||
if (validSites.contains(siteId)) {
|
||||
retVal.add(siteId);
|
||||
} else {
|
||||
final String msg = "Service backup primary site "
|
||||
+ site
|
||||
+ " is not a currently activated site. Service backup and export grids tasks cannot be run for this site. Check the PRIMARY_SITES setting in svcbu.properties.";
|
||||
statusHandler.warn(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.dataplugin.gfe.request;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Request to determine whether specified site id is one of the server's
|
||||
* configured primary sites for service backup.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -30,18 +29,14 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 14, 2012 jdynina Initial creation
|
||||
* May 02, 2013 dgilling Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author jdynina
|
||||
* @author dgilling
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@DynamicSerialize
|
||||
public class NcCheckRequest extends AbstractGfeRequest {
|
||||
|
||||
public NcCheckRequest() {
|
||||
}
|
||||
public class CheckServiceBackupPrimarySiteRequest extends AbstractGfeRequest {
|
||||
|
||||
}
|
|
@ -86,13 +86,6 @@
|
|||
# 2 = grids are exported only by the service backup GUI and from GFE via the 'Send
|
||||
# Grids to NDFD...' script'
|
||||
#
|
||||
# NATIONAL_CENTER Indicates that the site is a national center
|
||||
# This will allow for special treatment of national centers
|
||||
# when determining site id's. For crons these come from AW_SITE_IDENTIFIER at regular sites.
|
||||
# At national centers the values will come from activeSites.txt
|
||||
# VALID VALUES: 0 = this site is not a national center
|
||||
# 1 = this site is a national center
|
||||
#
|
||||
# SVCBU_USER Indicates that the site can configure a special user to
|
||||
# run GFE when in service backup
|
||||
# VALID VALUES: 0 = do not use a designated user to run
|
||||
|
@ -111,15 +104,15 @@
|
|||
#
|
||||
#
|
||||
# Directories used by Service Backup
|
||||
GFESUITE_HOME=${AWIPS_HOME}/GFESuite
|
||||
GFESUITE_BIN=${GFESUITE_HOME}/bin
|
||||
SVCBU_HOME=${GFESUITE_HOME}/ServiceBackup/svcbu
|
||||
LOCALIZATION_PATH=${AWIPS_HOME}/edex/data/utility
|
||||
IFPS_LOG=${GFESUITE_HOME}/ServiceBackup/logs
|
||||
IFPS_DATA=${GFESUITE_HOME}/ServiceBackup/data
|
||||
LOCK_DIR=${GFESUITE_HOME}/ServiceBackup/locks
|
||||
SCRIPTS_DIR=${GFESUITE_HOME}/ServiceBackup/scripts
|
||||
CAVE_LAUNCH_SCRIPT=${AWIPS_HOME}/cave/cave.sh
|
||||
GFESUITE_HOME=/awips2/GFESuite
|
||||
GFESUITE_BIN=/awips2/GFESuite/bin
|
||||
SVCBU_HOME=/awips2/GFESuite/ServiceBackup/svcbu
|
||||
LOCALIZATION_PATH=/awips2/edex/data/utility
|
||||
IFPS_LOG=/awips2/GFESuite/ServiceBackup/logs
|
||||
IFPS_DATA=/awips2/GFESuite/ServiceBackup/data
|
||||
LOCK_DIR=/awips2/GFESuite/ServiceBackup/locks
|
||||
SCRIPTS_DIR=/awips2/GFESuite/ServiceBackup/scripts
|
||||
CAVE_LAUNCH_SCRIPT=/awips2/cave/cave.sh
|
||||
|
||||
SVCBU_HOST=ec
|
||||
MSG_SEND_COMMAND=msg_send
|
||||
|
@ -133,4 +126,4 @@ SVCBU_WMO_HEADER=SVCBKPIFP
|
|||
SVCBU_USER=0
|
||||
SVCBU_USER_ID=""
|
||||
EXPORT_GRID=1
|
||||
NATIONAL_CENTER=0
|
||||
PRIMARY_SITES=
|
||||
|
|
Loading…
Add table
Reference in a new issue