From 6e280452e4eb527435589b70d10c1cbc337f96e7 Mon Sep 17 00:00:00 2001 From: Nikolay Stanchev <ns17@it-innovation.soton.ac.uk> Date: Fri, 5 Oct 2018 12:08:32 +0100 Subject: [PATCH] Updates clmc-service to read SFEMC FQDN from the environment when installing --- scripts/clmc-service/install-clmc-service.sh | 1 + scripts/clmc-service/install.sh | 5 +++++ scripts/test/fixture.sh | 2 +- src/service/clmcservice/__init__.py | 3 +++ src/service/development.ini | 3 --- src/service/production.ini | 3 --- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/clmc-service/install-clmc-service.sh b/scripts/clmc-service/install-clmc-service.sh index c6ba51b..126ea5f 100755 --- a/scripts/clmc-service/install-clmc-service.sh +++ b/scripts/clmc-service/install-clmc-service.sh @@ -102,6 +102,7 @@ mkdir -p /opt/flame/clmc start_script_file="/opt/flame/clmc/start.sh" echo "#!/bin/bash" > $start_script_file echo "export WORKON_HOME=${HOME}/.virtualenvs" >> $start_script_file +echo "export SFEMC_FQDN=${SFEMC_FQDN}" >> $start_script_file echo "source /usr/local/bin/virtualenvwrapper.sh" >> $start_script_file echo "workon CLMC" >> $start_script_file echo "pserve ${REPO_ROOT}/src/service/production.ini &" >> $start_script_file diff --git a/scripts/clmc-service/install.sh b/scripts/clmc-service/install.sh index 9003943..f1a7aa1 100755 --- a/scripts/clmc-service/install.sh +++ b/scripts/clmc-service/install.sh @@ -27,6 +27,11 @@ # Force fail on command fail (off for now as virtualenvwrapper install fails) set -euo pipefail +if [[ -z "${SFEMC_FQDN}" ]]; then + echo "Failed: cannot find SFEMC_FQDN environment variable." + exit 1 +fi + # Ensure everything runs in directory of the parent script cd `dirname $0` diff --git a/scripts/test/fixture.sh b/scripts/test/fixture.sh index 725e21d..8c568ff 100755 --- a/scripts/test/fixture.sh +++ b/scripts/test/fixture.sh @@ -52,7 +52,7 @@ create() { if [ ${service_name} == "clmc-service" ]; then cmd="/vagrant/scripts/clmc-service/install.sh" echo "Provisioning command ${cmd}" - lxc exec ${service_name} --env REPO_ROOT="/vagrant" -- ${cmd} + lxc exec ${service_name} --env REPO_ROOT="/vagrant" --env SFEMC_FQDN="sfemc.localhost" -- ${cmd} exit_code=$? if [ $exit_code != 0 ]; then echo "clmc-service installation failed with exit code ${exit_code}" diff --git a/src/service/clmcservice/__init__.py b/src/service/clmcservice/__init__.py index b710578..70c6e76 100644 --- a/src/service/clmcservice/__init__.py +++ b/src/service/clmcservice/__init__.py @@ -26,6 +26,7 @@ # Python standard libs from json import load from os.path import dirname, abspath +import os # PIP installed libs from pyramid.config import Configurator @@ -47,6 +48,8 @@ def main(global_config, **settings): DBSession.configure(bind=engine) # bind the engine to a DB session Base.metadata.bind = engine # bind the engine to the Base class metadata + settings['sfemc_fqdn'] = os.environ['SFEMC_FQDN'] # read the SFEMC FQDN from the OS environment + settings['influx_port'] = int(settings['influx_port']) # the influx port setting must be converted to integer instead of a string settings['kapacitor_port'] = int(settings['kapacitor_port']) # the kapacitor port setting must be converted to integer instead of a string diff --git a/src/service/development.ini b/src/service/development.ini index d459d20..cbc930b 100644 --- a/src/service/development.ini +++ b/src/service/development.ini @@ -20,9 +20,6 @@ network_configuration_path = /vagrant/src/service/resources/GraphAPI/network_con # PostgreSQL connection url sqlalchemy.url = postgresql://clmc:clmc_service@localhost:5432/whoamidb -# SFEMC FQDN -sfemc_fqdn = sfemc.localhost - # Influx connection influx_host = localhost influx_port = 8086 diff --git a/src/service/production.ini b/src/service/production.ini index 94a0071..5acb36a 100644 --- a/src/service/production.ini +++ b/src/service/production.ini @@ -20,9 +20,6 @@ network_configuration_path = /vagrant/src/service/resources/GraphAPI/network_con # PostgreSQL connection url sqlalchemy.url = postgresql://clmc:clmc_service@localhost:5432/whoamidb -# SFEMC FQDN -sfemc_fqdn = sfemc.localhost - # Influx connection influx_host = localhost influx_port = 8086 -- GitLab