Omaha #3623 Created command line utilities to activate/deactivate sites

Change-Id: I2bc0a10caf51129af06aa4ae4cb1f0471bc49408

Former-commit-id: 670a9bd71874fbd6fecd0c9df5567ad342892333
This commit is contained in:
Ron Anderson 2014-09-16 16:03:08 -05:00
parent e0af8ad1be
commit b09244975e
15 changed files with 597 additions and 18 deletions

View file

@ -0,0 +1,50 @@
#!/bin/bash
##
# 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.
##
##############################################################################
# TODO: ADD DESCRIPTION
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 09/10/14 #3623 randerso Initial Creation.
##############################################################################
# this allows you to run this script from outside of ./bin
path_to_script=`readlink -f $0`
RUN_FROM_DIR=`dirname $path_to_script`
BASE_AWIPS_DIR=`dirname $RUN_FROM_DIR`
# get the base environment
source ${RUN_FROM_DIR}/setup.env
# setup the environment needed to run the the Python
export LD_LIBRARY_PATH=${BASE_AWIPS_DIR}/src/lib:${PYTHON_INSTALL}/lib
export PYTHONPATH=${RUN_FROM_DIR}/src:$PYTHONPATH
# execute the ifpInit Python module
_PYTHON="${PYTHON_INSTALL}/bin/python"
_MODULE="${RUN_FROM_DIR}/src/siteActivation/activateSite.py"
# quoting of '$@' is used to prevent command line interpretation
$_PYTHON $_MODULE "$@"

View file

@ -0,0 +1,50 @@
#!/bin/bash
##
# 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.
##
##############################################################################
# TODO: ADD DESCRIPTION
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 09/10/14 #3623 randerso Initial Creation.
##############################################################################
# this allows you to run this script from outside of ./bin
path_to_script=`readlink -f $0`
RUN_FROM_DIR=`dirname $path_to_script`
BASE_AWIPS_DIR=`dirname $RUN_FROM_DIR`
# get the base environment
source ${RUN_FROM_DIR}/setup.env
# setup the environment needed to run the the Python
export LD_LIBRARY_PATH=${BASE_AWIPS_DIR}/src/lib:${PYTHON_INSTALL}/lib
export PYTHONPATH=${RUN_FROM_DIR}/src:$PYTHONPATH
# execute the ifpInit Python module
_PYTHON="${PYTHON_INSTALL}/bin/python"
_MODULE="${RUN_FROM_DIR}/src/siteActivation/deactivateSite.py"
# quoting of '$@' is used to prevent command line interpretation
$_PYTHON $_MODULE "$@"

View file

@ -9,3 +9,9 @@ export OPERATIONAL_MODE=${OPERATIONAL_MODE:-TRUE}
# determine python path
export PYTHON_INSTALL="/awips2/python"
# host where edex is running
export JMS_HOST=${JMS_HOST:-localhost}
# port service is running on
export JMS_PORT=${JMS_PORT:-5672}

View file

@ -0,0 +1,64 @@
##
# 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.
##
#
# Listens for and prints site activation messages
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 09/10/14 #3623 randerso Initial Creation.
#
##
import threading
import datetime
import traceback
import dynamicserialize
from dynamicserialize.dstypes.com.raytheon.uf.common.site.notify import ClusterActivationNotification
from ufpy import QpidSubscriber
class ActivationTopicListener(threading.Thread):
def __init__(self, hostname='localHost', portNumber='5762', topicName="edex.alerts.siteActivate" ):
self.hostname = hostname
self.portNumber = portNumber
self.topicName = topicName
self.qs = None
threading.Thread.__init__(self)
def run(self):
self.qs = QpidSubscriber.QpidSubscriber(self.hostname, self.portNumber)
self.qs.topicSubscribe(self.topicName, self.receivedMessage)
def stop(self):
self.qs.close()
def receivedMessage(self, msg):
try:
obj = dynamicserialize.deserialize(msg)
print datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), obj
if type(obj) == ClusterActivationNotification:
self.stop()
except:
traceback.print_exc()

View file

@ -0,0 +1,100 @@
##
# 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.
##
#
# Provides a command-line utility to activate a site
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 09/10/14 #3623 randerso Initial Creation.
#
##
import os
import sys
import time
from dynamicserialize.dstypes.com.raytheon.uf.common.site.requests import ActivateSiteRequest
from ufpy import ThriftClient
from ufpy import UsageArgumentParser
from ActivationTopicListener import ActivationTopicListener
def main():
args = validateArgs()
request = ActivateSiteRequest(args.site, args.plugin)
thriftClient = ThriftClient.ThriftClient(args.host, args.port, "/services")
thread = ActivationTopicListener(args.jmsHost, args.jmsPort)
try:
thread.start()
time.sleep(1) # sleep to allow thread to connect to JMS broker
print "\nSending site activation request for "+args.site
thriftClient.sendRequest(request)
print "\nMonitoring site activation messages."
thread.join()
except KeyboardInterrupt:
pass
except Exception, ex:
import traceback
traceback.print_exc()
sys.exit(1)
finally:
thread.stop()
def validateArgs():
parser = UsageArgumentParser.UsageArgumentParser(conflict_handler="resolve", prog='activateSite')
parser.add_argument("-h", action="store", dest="host",
help="host name of edex request server",
default=str(os.getenv("DEFAULT_HOST", "localhost")),
metavar="hostname")
parser.add_argument("-r", action="store", type=int, dest="port",
help="port number of edex request server",
default=int(os.getenv("DEFAULT_PORT", "9581")),
metavar="port")
parser.add_argument("-j", action="store", dest="jmsHost",
help="host name of JMS broker",
default=str(os.getenv("JMS_HOST", "localhost")),
metavar="jmsHost")
parser.add_argument("-q", action="store", type=int, dest="jmsPort",
help="port number of JMS broker",
default=int(os.getenv("JMS_PORT", "5672")),
metavar="jmsPort")
parser.add_argument("-p", action="store", dest="plugin", required=False,
help="plugin",
default="gfe",
metavar="plugin")
parser.add_argument("-s", action="store", dest="site", required=True,
help="site to activate",
metavar="site")
args = parser.parse_args()
return args
if __name__ == '__main__':
main()

View file

@ -0,0 +1,100 @@
##
# 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.
##
#
# Provides a command-line utility to deactivate a site
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 09/10/14 #3623 randerso Initial Creation.
#
##
import os
import sys
import time
from dynamicserialize.dstypes.com.raytheon.uf.common.site.requests import DeactivateSiteRequest
from ufpy import ThriftClient
from ufpy import UsageArgumentParser
from ActivationTopicListener import ActivationTopicListener
def main():
args = validateArgs()
request = DeactivateSiteRequest(args.site, args.plugin)
thriftClient = ThriftClient.ThriftClient(args.host, args.port, "/services")
thread = ActivationTopicListener(args.jmsHost, args.jmsPort)
try:
thread.start()
time.sleep(1) # sleep to allow thread to connect to JMS broker
print "\nSending site deactivation request for "+args.site
thriftClient.sendRequest(request)
print "\nMonitoring site activation messages."
thread.join()
except KeyboardInterrupt:
pass
except Exception, ex:
import traceback
traceback.print_exc()
finally:
thread.stop()
def validateArgs():
parser = UsageArgumentParser.UsageArgumentParser(conflict_handler="resolve", prog='deactivateSite')
parser.add_argument("-h", action="store", dest="host",
help="host name of edex request server",
default=str(os.getenv("DEFAULT_HOST", "localhost")),
metavar="hostname")
parser.add_argument("-r", action="store", type=int, dest="port",
help="port number of edex request server",
default=int(os.getenv("DEFAULT_PORT", "9581")),
metavar="port")
parser.add_argument("-j", action="store", dest="jmsHost",
help="host name of JMS broker",
default=str(os.getenv("JMS_HOST", "localhost")),
metavar="jmsHost")
parser.add_argument("-q", action="store", type=int, dest="jmsPort",
help="port number of JMS broker",
default=int(os.getenv("JMS_PORT", "5672")),
metavar="jmsPort")
parser.add_argument("-p", action="store", dest="plugin", required=False,
help="plugin",
default="gfe",
metavar="plugin")
parser.add_argument("-s", action="store", dest="site", required=True,
help="site to deactivate",
metavar="site")
args = parser.parse_args()
return args
if __name__ == '__main__':
main()

View file

@ -2,6 +2,6 @@
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.5</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>

View file

@ -25,7 +25,6 @@ __all__ = [
'GfeNotification',
'GridUpdateNotification',
'LockNotification',
'SiteActivationNotification',
'UserMessageNotification'
]
@ -33,6 +32,5 @@ from DBInvChangeNotification import DBInvChangeNotification
from GfeNotification import GfeNotification
from GridUpdateNotification import GridUpdateNotification
from LockNotification import LockNotification
from SiteActivationNotification import SiteActivationNotification
from UserMessageNotification import UserMessageNotification

View file

@ -21,7 +21,8 @@
# File auto-generated by PythonFileGenerator
__all__ = [
'requests'
'notify',
'requests',
]

View file

@ -0,0 +1,58 @@
##
# 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.
##
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 09/10/14 #3623 randerso Manually created, do not regenerate
#
##
# File auto-generated against equivalent DynamicSerialize Java class
from SiteActivationNotification import SiteActivationNotification
class ClusterActivationNotification(SiteActivationNotification):
def __init__(self):
self.clusterActive = False
SiteActivationNotification.__init__(self)
def isClusterActive(self):
return self.clusterActive
def setClusterActive(self, clusterActive):
self.clusterActive = clusterActive
def __str__(self):
s = self.modifiedSite
if self.type == 'ACTIVATE':
if self.status == 'FAILURE':
s += " has failed to activate on some or all cluster members. See logs for details"
else:
s += " has been successfully activated on all cluster members"
else:
if self.status == 'FAILURE':
s += " has failed to deactivate on some or all cluster members. See logs for details"
else:
s += " has been successfully deactivated on all cluster members"
return s

View file

@ -17,23 +17,43 @@
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
# further licensing information.
##
# File auto-generated against equivalent DynamicSerialize Java class
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 09/10/14 #3623 randerso Manually created, do not regenerate
#
##
class SiteActivationNotification(object):
def __init__(self):
self.active = None
self.type = None
self.status = None
self.primarySite = None
self.modifiedSite = None
self.runMode = None
self.serverName = None
self.siteID = None
self.pluginName = None
def getActive(self):
return self.active
def getType(self):
return self.type
def setActive(self, active):
self.active = active
def setType(self, type):
self.type = type
def getStatus(self):
return self.status
def setStatus(self, status):
self.status = status
def getPrimarySite(self):
return self.primarysite
def setPrimarySite(self, primarysite):
self.primarysite = primarysite
def getModifiedSite(self):
return self.modifiedSite
@ -53,9 +73,17 @@ class SiteActivationNotification(object):
def setServerName(self, serverName):
self.serverName = serverName
def getSiteID(self):
return self.siteID
def setSiteID(self, siteID):
self.siteID = siteID
def getPluginName(self):
return self.pluginName
def setPluginName(self, pluginName):
self.pluginName = pluginName
def __str__(self):
return self.pluginName.upper() + ":" \
+ self.status + ":" \
+ self.type + " " \
+ self.modifiedSite.upper() + " on " \
+ self.serverName + ":" \
+ self.runMode

View file

@ -0,0 +1,30 @@
##
# 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.
##
# File auto-generated by PythonFileGenerator
__all__ = [
'ClusterActivationNotification',
'SiteActivationNotification',
]
from ClusterActivationNotification import ClusterActivationNotification
from SiteActivationNotification import SiteActivationNotification

View file

@ -0,0 +1,45 @@
##
# 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.
##
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 09/10/14 #3623 randerso Manually created, do not regenerate
#
##
class ActivateSiteRequest(object):
def __init__(self, siteID=None, plugin=None):
self.siteID = siteID
self.plugin = plugin
def getSiteID(self):
return self.siteID
def setSiteID(self, siteID):
self.siteID = siteID
def getPlugin(self):
return self.plugin
def setPlugin(self, plugin):
self.plugin = plugin

View file

@ -0,0 +1,45 @@
##
# 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.
##
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 09/10/14 #3623 randerso Manually created, do not regenerate
#
##
class DeactivateSiteRequest(object):
def __init__(self, siteID=None, plugin=None):
self.siteID = siteID
self.plugin = plugin
def getSiteID(self):
return self.siteID
def setSiteID(self, siteID):
self.siteID = siteID
def getPlugin(self):
return self.plugin
def setPlugin(self, plugin):
self.plugin = plugin

View file

@ -21,8 +21,12 @@
# File auto-generated by PythonFileGenerator
__all__ = [
'GetActiveSitesRequest'
'ActivateSiteRequest',
'DeactivateSiteRequest',
'GetActiveSitesRequest',
]
from ActivateSiteRequest import ActivateSiteRequest
from DeactivateSiteRequest import DeactivateSiteRequest
from GetActiveSitesRequest import GetActiveSitesRequest