Skip to content

Commit

Permalink
Merge pull request #131 from apel/release-3.0.0
Browse files Browse the repository at this point in the history
Release 3.0.0 to master
  • Loading branch information
tofu-rocketry authored Sep 23, 2020
2 parents 821bcf4 + d371855 commit 730e4f8
Show file tree
Hide file tree
Showing 24 changed files with 282 additions and 253 deletions.
13 changes: 3 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
os: linux
language: python
python:
- "2.6"
- "2.7"
- "nightly"
matrix:
allow_failures:
- python: "nightly"
fast_finish: true

# Pin Ubuntu to Trusty for the moment for Python 2.6 support
dist: trusty
- "3.7"

# Cache the dependencies installed by pip
cache: pip
Expand All @@ -29,7 +22,7 @@ before_script:
- export PYTHONPATH=$PYTHONPATH:`pwd -P`
- cd test

script: coverage run --branch --source=ssm,bin -m unittest2 discover --buffer
script: coverage run --branch --source=ssm,bin -m unittest discover --buffer

after_success:
- coveralls
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Changelog for 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.
- The argo-ams-library is now an optional module, depending on whether AMS is
used or not.
- Fixed how the use_ssl config option is retrieved to avoid "referenced before
assignment" errors leading to SSM failing to run.
- Changes made to messaging loops to avoid high CPU usage.

* Tue Sep 03 2019 Adrian Coveney <[email protected]> - 2.4.1-1
- Fixed handling of OpenSSL errors so that messages that have been tampered
with are now rejected.
Expand All @@ -18,7 +27,7 @@ Changelog for ssm
* Wed Nov 28 2018 Adrian Coveney <[email protected]> - 2.3.0-2
- Updated build and test files only.

* Wed Aug 16 2018 Adrian Coveney <[email protected]> - 2.3.0-1
* Thu Aug 16 2018 Adrian Coveney <[email protected]> - 2.3.0-1
- Added support for stomp.py versions from 3.1.6 onwards which allows for
builds on Ubuntu Trusty and should enable IPv6 support.
- Added script for creating Ubuntu (.deb) builds.
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ SSM is written in Python. Packages are available for RHEL 6 and 7, and

For more information about SSM, see the [EGI wiki](https://wiki.egi.eu/wiki/APEL/SSM).

## Acknowledgements

<span>
<img alt="STFC logo" src="https://github.com/GOCDB/gocdb/raw/dev/htdocs/web_portal/img/UKRI_STF_Council-Logo_Horiz-RGB_crop.png" height="57" />
<img alt="EU flag" src="https://github.com/GOCDB/gocdb/raw/dev/htdocs/web_portal/img/eu_flag_yellow_low_150.png" height="51" />
<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).

## Installing the RPM

Expand All @@ -24,12 +33,13 @@ The EPEL repository must be enabled. This can be done by installing
the RPM for your version of SL, which is available on this page:
http://fedoraproject.org/wiki/EPEL

The Python STOMP library (N.B. versions 3.1.1 and above are currently supported)
The Python STOMP library (N.B. versions between 3.1.1 (inclusive) and 5.0.0
(exclusive) are currently supported)
* `yum install stomppy`

The Python AMS library. See here for details on obtaining an RPM: https://github.com/ARGOeu/argo-ams-library/
The Python AMS library. This is only required if you want to use AMS. See here for details on obtaining an RPM: https://github.com/ARGOeu/argo-ams-library/

The Python daemon library (N.B. only versions below 2.2.0 are currently supported)
The Python daemon library
* `yum install python-daemon`

The Python ldap library
Expand Down Expand Up @@ -90,7 +100,7 @@ Install any missing system packages needed for the SSM:
* `apt-get -f install`

Install any missing Python requirements that don't have system packages:
* `pip install "stomp.py>=3.1.1" dirq`
* `pip install "stomp.py<5.0.0" dirq`

If you wish to run the SSM as a receiver, you will also need to install the python-daemon system package:
* `apt-get install python-daemon`
Expand Down
15 changes: 12 additions & 3 deletions apel-ssm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%endif

Name: apel-ssm
Version: 2.4.1
Version: 3.0.0
%define releasenumber 1
Release: %{releasenumber}%{?dist}
Summary: Secure stomp messenger
Expand All @@ -21,7 +21,7 @@ BuildArch: noarch
BuildRequires: python-devel
%endif

Requires: stomppy >= 3.1.1, python-daemon < 2.2.0, python-ldap, argo-ams-library
Requires: stomppy < 5.0.0, python-daemon, python-ldap
Requires(pre): shadow-utils

%define ssmconf %_sysconfdir/apel
Expand Down Expand Up @@ -100,6 +100,15 @@ rm -rf $RPM_BUILD_ROOT
%doc %_defaultdocdir/%{name}

%changelog
* 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.
- The argo-ams-library is now an optional module, depending on whether AMS is
used or not.
- Fixed how the use_ssl config option is retrieved to avoid "referenced before
assignment" errors leading to SSM failing to run.
- Changes made to messaging loops to avoid high CPU usage.

* Tue Sep 03 2019 Adrian Coveney <[email protected]> - 2.4.1-1
- Fixed handling of OpenSSL errors so that messages that have been tampered
with are now rejected.
Expand All @@ -118,7 +127,7 @@ rm -rf $RPM_BUILD_ROOT
* Wed Nov 28 2018 Adrian Coveney <[email protected]> - 2.3.0-2
- Updated build and test files only.

* Wed Aug 16 2018 Adrian Coveney <[email protected]> - 2.3.0-1
* Thu Aug 16 2018 Adrian Coveney <[email protected]> - 2.3.0-1
- Added support for stomp.py versions from 3.1.6 onwards which allows for
builds on Ubuntu Trusty and should enable IPv6 support.
- Added script for creating Ubuntu (.deb) builds.
Expand Down
56 changes: 34 additions & 22 deletions bin/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@
Script to run a receiving SSM.
@author: Will Rogers
'''
from __future__ import print_function

from ssm.brokers import StompBrokerGetter, STOMP_SERVICE, STOMP_SSL_SERVICE
from ssm.ssm2 import Ssm2, Ssm2Exception
from ssm import __version__, set_up_logging, LOG_BREAK

from stomp.exception import NotConnectedException
from argo_ams_library import AmsConnectionException
try:
from argo_ams_library import AmsConnectionException
except ImportError:
# ImportError is raised when Ssm2 initialised if AMS is requested but lib
# not installed.
AmsConnectionException = None

import time
import logging.config
Expand All @@ -33,12 +39,17 @@
import sys
from optparse import OptionParser
from daemon import DaemonContext
import ConfigParser

try:
import ConfigParser
except ImportError:
import configparser as ConfigParser

# How often (in seconds) to read the list of valid DNs.
REFRESH_DNS = 600
log = None


def get_dns(dn_file):
'''
Retrieve a list of DNs from a file.
Expand Down Expand Up @@ -83,13 +94,13 @@ def main():

(options, unused_args) = op.parse_args()

cp = ConfigParser.ConfigParser()
cp = ConfigParser.ConfigParser({'use_ssl': 'true'})
cp.read(options.config)

# Check for pidfile
pidfile = cp.get('daemon', 'pidfile')
if os.path.exists(pidfile):
print 'Cannot start SSM. Pidfile %s already exists.' % pidfile
print('Cannot start SSM. Pidfile %s already exists.' % pidfile)
sys.exit(1)

# set up logging
Expand All @@ -100,9 +111,9 @@ def main():
set_up_logging(cp.get('logging', 'logfile'),
cp.get('logging', 'level'),
cp.getboolean('logging', 'console'))
except (ConfigParser.Error, ValueError, IOError), err:
print 'Error configuring logging: %s' % str(err)
print 'SSM will exit.'
except (ConfigParser.Error, ValueError, IOError) as err:
print('Error configuring logging: %s' % err)
print('SSM will exit.')
sys.exit(1)

global log
Expand All @@ -128,17 +139,18 @@ def main():
project = None
token = ''

use_ssl = cp.getboolean('broker', 'use_ssl')
if use_ssl:
service = STOMP_SSL_SERVICE
else:
service = STOMP_SERVICE

# If we can't get a broker to connect to, we have to give up.
try:
bg = StompBrokerGetter(cp.get('broker', 'bdii'))
use_ssl = cp.getboolean('broker', 'use_ssl')
if use_ssl:
service = STOMP_SSL_SERVICE
else:
service = STOMP_SERVICE
brokers = bg.get_broker_hosts_and_ports(service, cp.get('broker',
'network'))
except ConfigParser.NoOptionError, e:
except ConfigParser.NoOptionError as e:
try:
host = cp.get('broker', 'host')
port = cp.get('broker', 'port')
Expand All @@ -150,7 +162,7 @@ def main():
log.error('System will exit.')
log.info(LOG_BREAK)
sys.exit(1)
except ldap.SERVER_DOWN, e:
except ldap.SERVER_DOWN as e:
log.error('Could not connect to LDAP server: %s', e)
log.error('System will exit.')
log.info(LOG_BREAK)
Expand All @@ -174,20 +186,20 @@ def main():
'please check your configuration')
log.error('System will exit.')
log.info(LOG_BREAK)
print 'SSM failed to start. See log file for details.'
print('SSM failed to start. See log file for details.')
sys.exit(1)

# Attempt to configure AMS specific variables.
try:
token = cp.get('messaging', 'token')
project = cp.get('messaging', 'ams_project')

except (ConfigParser.Error, ValueError, IOError), err:
except (ConfigParser.Error, ValueError, IOError) as err:
# A token and project are needed to successfully receive from an
# AMS instance, so log and then exit on an error.
log.error('Error configuring AMS values: %s', err)
log.error('SSM will exit.')
print 'SSM failed to start. See log file for details.'
print('SSM failed to start. See log file for details.')
sys.exit(1)

if len(brokers) == 0:
Expand Down Expand Up @@ -221,7 +233,7 @@ def main():
dns = get_dns(options.dn_file)
ssm.set_dns(dns)

except Exception, e:
except Exception as e:
log.fatal('Failed to initialise SSM: %s', e)
log.info(LOG_BREAK)
sys.exit(1)
Expand All @@ -237,13 +249,13 @@ def main():
# The message listening loop.
while True:
try:
time.sleep(1)
time.sleep(0.1)
if protocol == Ssm2.AMS_MESSAGING:
# We need to pull down messages as part of
# this loop when using AMS.
ssm.pull_msg_ams()

if i % REFRESH_DNS == 0:
if i % (REFRESH_DNS * 10) == 0:
log.info('Refreshing valid DNs and then sending ping.')
dns = get_dns(options.dn_file)
ssm.set_dns(dns)
Expand All @@ -264,11 +276,11 @@ def main():

i += 1

except SystemExit, e:
except SystemExit as e:
log.info('Received the shutdown signal: %s', e)
ssm.shutdown()
dc.close()
except Exception, e:
except Exception as e:
log.error('Unexpected exception: %s', e)
log.error('Exception type: %s', e.__class__)
log.error('The SSM will exit.')
Expand Down
Loading

0 comments on commit 730e4f8

Please sign in to comment.