Skip to content

Commit

Permalink
Merge pull request #137 from tofu-rocketry/release-3.1.0
Browse files Browse the repository at this point in the history
Release 3.1.0 to master
  • Loading branch information
tofu-rocketry authored Dec 2, 2020
2 parents 730e4f8 + 5bc5ef8 commit 269239e
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 201 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changelog for ssm
=================
* Tue Dev 01 2020 Adrian Coveney <[email protected]> - 3.1.0-1
- Enabled retries for all AMS communication methods to avoid timeouts from
crashing SSM.

* Wed Sep 23 2020 Adrian Coveney <[email protected]> - 3.0.0-1
- As part of the migration to Python 3, this release removes support for
Python 2.6.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For more information about SSM, see the [EGI wiki](https://wiki.egi.eu/wiki/APEL
<img alt="EOSC-hub logo" src="https://github.com/GOCDB/gocdb/raw/dev/htdocs/web_portal/img/eosc-hub-v-web_150.png" height="57" />
</span>

SSM is provided by [STFC](https://stfc.ukri.org/), a part of [UK Research and Innovation](www.ukri.org), and is co-funded by the [EOSC-hub](https://www.eosc-hub.eu/) project (Horizon 2020) under Grant number 777536. Licensed under the [Apache 2 License](http://www.apache.org/licenses/LICENSE-2.0).
SSM is provided by [STFC](https://stfc.ukri.org/), a part of [UK Research and Innovation](https://www.ukri.org/), and is co-funded by the [EOSC-hub](https://www.eosc-hub.eu/) project (Horizon 2020) under Grant number 777536. Licensed under the [Apache 2 License](http://www.apache.org/licenses/LICENSE-2.0).

## Installing the RPM

Expand Down
6 changes: 5 additions & 1 deletion apel-ssm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%endif

Name: apel-ssm
Version: 3.0.0
Version: 3.1.0
%define releasenumber 1
Release: %{releasenumber}%{?dist}
Summary: Secure stomp messenger
Expand Down Expand Up @@ -100,6 +100,10 @@ rm -rf $RPM_BUILD_ROOT
%doc %_defaultdocdir/%{name}

%changelog
* Tue Dev 01 2020 Adrian Coveney <[email protected]> - 3.1.0-1
- Enabled retries for all AMS communication methods to avoid timeouts from
crashing SSM.

* Wed Sep 23 2020 Adrian Coveney <[email protected]> - 3.0.0-1
- As part of the migration to Python 3, this release removes support for
Python 2.6.
Expand Down
22 changes: 8 additions & 14 deletions bin/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

'''
Script to run a receiving SSM.
@author: Will Rogers
'''
"""Script to run a receiving SSM."""

from __future__ import print_function

from ssm.brokers import StompBrokerGetter, STOMP_SERVICE, STOMP_SSL_SERVICE
Expand Down Expand Up @@ -51,9 +49,7 @@


def get_dns(dn_file):
'''
Retrieve a list of DNs from a file.
'''
"""Retrieve a list of DNs from a file."""
dns = []
f = None
try:
Expand All @@ -78,9 +74,7 @@ def get_dns(dn_file):


def main():
'''
Set up connection, and listen for messages.
'''
"""Set up connection, and listen for messages."""
ver = "SSM %s.%s.%s" % __version__
op = OptionParser(description=__doc__, version=ver)
op.add_option('-c', '--config', help='location of config file',
Expand Down Expand Up @@ -217,10 +211,10 @@ def main():

try:
ssm = Ssm2(brokers,
cp.get('messaging','path'),
cert=cp.get('certificates','certificate'),
key=cp.get('certificates','key'),
listen=cp.get('messaging','destination'),
cp.get('messaging', 'path'),
cert=cp.get('certificates', 'certificate'),
key=cp.get('certificates', 'key'),
listen=cp.get('messaging', 'destination'),
use_ssl=use_ssl,
capath=cp.get('certificates', 'capath'),
check_crls=cp.getboolean('certificates', 'check_crls'),
Expand Down
14 changes: 5 additions & 9 deletions bin/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

'''
Script to run a sending SSM.
@author: Will Rogers
'''
"""Script to run a sending SSM."""

from __future__ import print_function

from ssm import __version__, set_up_logging, LOG_BREAK
Expand All @@ -38,13 +36,11 @@


def main():
'''
Set up connection, send all messages and quit.
'''
"""Set up connection, send all messages and quit."""
ver = "SSM %s.%s.%s" % __version__
op = OptionParser(description=__doc__, version=ver)
op.add_option('-c', '--config', help='location of config file',
default='/etc/apel/sender.cfg')
default='/etc/apel/sender.cfg')
op.add_option('-l', '--log_config',
help='location of logging config file (optional)',
default='/etc/apel/logging.cfg')
Expand Down Expand Up @@ -174,7 +170,7 @@ def main():
server_cert = None
verify_server_cert = True
try:
server_cert = cp.get('certificates','server_cert')
server_cert = cp.get('certificates', 'server_cert')
try:
verify_server_cert = cp.getboolean('certificates', 'verify_server_cert')
except ConfigParser.NoOptionError:
Expand Down
2 changes: 1 addition & 1 deletion scripts/ssm-build-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

set -eu

TAG=3.0.0-1
TAG=3.1.0-1

SOURCE_DIR=~/debbuild/source
BUILD_DIR=~/debbuild/build
Expand Down
2 changes: 1 addition & 1 deletion scripts/ssm-build-rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
rpmdev-setuptree

RPMDIR=/home/rpmb/rpmbuild
VERSION=3.0.0-1
VERSION=3.1.0-1
SSMDIR=apel-ssm-$VERSION

# Remove old sources and RPMS
Expand Down
11 changes: 5 additions & 6 deletions ssm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
Copyright (C) 2012 STFC.
Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,19 +14,18 @@
limitations under the License.
@author: Will Rogers
'''
"""

import logging
import sys

__version__ = (3, 0, 0)
__version__ = (3, 1, 0)

LOG_BREAK = '========================================'


def set_up_logging(logfile, level, console):
'''
Programmatically initialise logging system.
'''
"""Programmatically initialise logging system."""
levels = {'DEBUG': logging.DEBUG,
'INFO': logging.INFO,
'WARN': logging.WARN,
Expand Down
64 changes: 32 additions & 32 deletions ssm/brokers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
"""
Copyright (C) 2012 STFC.
Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,7 +17,7 @@
Class to interact with a BDII LDAP server to retrieve information about
the stomp brokers specified in a network.
'''
"""
from __future__ import print_function

import ldap
Expand All @@ -32,32 +32,31 @@
STOMP_PREFIX = 'stomp'
STOMP_SSL_PREFIX = 'stomp+ssl'


class StompBrokerGetter(object):
'''
"""Class for seaching a BDII for message brokers.
Given the URL of a BDII, searches for all the STOMP
brokers listed that are part of the specified network.
'''
"""

def __init__(self, bdii_url):
'''
Set up the LDAP connection and strings which are re-used.
'''
"""Set up the LDAP connection and strings which are re-used."""
# Set up the LDAP connection
log.debug('Connecting to %s...', bdii_url)
self._ldap_conn = ldap.initialize(bdii_url)

self._base_dn = 'o=grid'
self._service_id_key = 'GlueServiceUniqueID'
self._endpoint_key = 'GlueServiceEndpoint'
self._endpoint_key = 'GlueServiceEndpoint'
self._service_data_value_key = 'GlueServiceDataValue'

def get_broker_urls(self, service_type, network):
'''
Gets the list of all the stomp brokers in the BDII, then
checks them to see if they are part of the network. The network
is supplied as a string.
Returns a list of URLs.
'''
"""Get a list stomp broker URLs in a specified network from a BDII.
Checks them to see if they are part of the network. The network is
supplied as a string. Returns a list of URLs.
"""
prod_broker_urls = []

broker_details = self._get_broker_details(service_type)
Expand All @@ -69,23 +68,23 @@ def get_broker_urls(self, service_type, network):
return prod_broker_urls

def get_broker_hosts_and_ports(self, service_type, network):
'''
Gets the list of all the stomp brokers in the BDII, then
checks them to see if they are part of the network. The network
is supplied as a string.
Returns a list of (host, port) tuples.
'''
"""Get a list of stomp broker (host, port) tuples from a BDII.
Gets the list of all the stomp brokers in the BDII, then checks them to
see if they are part of the network. The network is supplied as a
string.Returns a list of (host, port) tuples.
"""
urls = self.get_broker_urls(service_type, network)
hosts_and_ports = []
for url in urls:
hosts_and_ports.append(parse_stomp_url(url))
return hosts_and_ports

def _get_broker_details(self, service_type):
'''
Searches the BDII for all STOMP message brokers. Returns a list of
tuples: (<GlueServiceUniqueID>, <URL>).
'''
"""Search the BDII for all STOMP message brokers.
Returns a list of tuples: (<GlueServiceUniqueID>, <URL>).
"""
broker_details = []

ldap_filter = '(&(objectClass=GlueService)(GlueServiceType=%s))' % service_type
Expand All @@ -100,26 +99,26 @@ def _get_broker_details(self, service_type):
return broker_details

def _broker_in_network(self, broker_id, network):
'''
Given a GlueServiceUniqueID for a message broker, check that it is
part of the specified network.
'''
"""Check that a GlueServiceUniqueID is part of a specified netowrk."""
ldap_filter = '(&(GlueServiceDataKey=cluster)(GlueChunkKey=GlueServiceUniqueID=%s))' \
% broker_id
attrs = [self._service_data_value_key]
results = self._ldap_conn.search_s(self._base_dn, ldap.SCOPE_SUBTREE, ldap_filter, attrs)
results = self._ldap_conn.search_s(self._base_dn, ldap.SCOPE_SUBTREE,
ldap_filter, attrs)

try:
unused_dn, attrs2 = results[0]
return network in attrs2[self._service_data_value_key]
except IndexError: # no results from the query
except IndexError: # no results from the query
return False


def parse_stomp_url(stomp_url):
'''
"""Parse a stomp scheme URL.
Given a URL of the form stomp://stomp.cern.ch:6262/,
return a tuple containing (stomp.cern.ch, 6262).
'''
"""
parts = stomp_url.split(':')

protocols = [STOMP_PREFIX, STOMP_SSL_PREFIX]
Expand All @@ -140,6 +139,7 @@ def parse_stomp_url(stomp_url):
BG = StompBrokerGetter(BDII)

def print_brokers(text, service, network):
"""Pretty print a list of brokers."""
brokers = BG.get_broker_hosts_and_ports(service, network)
# Print section heading
print('==', text, '==')
Expand Down
Loading

0 comments on commit 269239e

Please sign in to comment.