From: bhangare Date: Wed, 11 Oct 2017 10:37:06 +0000 (-0700) Subject: Changes in vROPs Plugin webservice & install script to use fqdn X-Git-Tag: v4.0.0~62^2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=cea9af8fa73e2442415b31ef6dcd6ac45d80fe86;p=osm%2FMON.git Changes in vROPs Plugin webservice & install script to use fqdn Change-Id: If2d35c5c7ab874ca4671d90871f6b60aa1ad6850 Signed-off-by: bhangare --- diff --git a/plugins/vRealiseOps/mon_plugin_vrops.py b/plugins/vRealiseOps/mon_plugin_vrops.py index 986376b..309cec9 100644 --- a/plugins/vRealiseOps/mon_plugin_vrops.py +++ b/plugins/vRealiseOps/mon_plugin_vrops.py @@ -35,7 +35,7 @@ import json from OpenSSL.crypto import load_certificate, FILETYPE_PEM import os import datetime -from socket import gethostname +from socket import getfqdn from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) @@ -48,8 +48,8 @@ PERIOD_MSEC = {'HR':3600000,'DAY':86400000,'WEEK':604800000,'MONTH':2678400000,' #To Do - Add actual webhook url & certificate #SSL_CERTIFICATE_FILE_NAME = 'vROPs_Webservice/SSL_certificate/www.vrops_webservice.com.cert' #webhook_url = "https://mano-dev-1:8080/notify/" #for testing -webhook_url = "https://" + gethostname() + ":8080/notify/" -SSL_CERTIFICATE_FILE_NAME = ('vROPs_Webservice/SSL_certificate/' + gethostname() + ".cert") +webhook_url = "https://" + getfqdn() + ":8080/notify/" +SSL_CERTIFICATE_FILE_NAME = ('vROPs_Webservice/SSL_certificate/' + getfqdn() + ".cert") #SSL_CERTIFICATE_FILE_NAME = 'vROPs_Webservice/SSL_certificate/10.172.137.214.cert' #for testing MODULE_DIR = os.path.dirname(__file__) diff --git a/plugins/vRealiseOps/vROPs_Webservice/install.sh b/plugins/vRealiseOps/vROPs_Webservice/install.sh index 258abf4..e81344b 100755 --- a/plugins/vRealiseOps/vROPs_Webservice/install.sh +++ b/plugins/vRealiseOps/vROPs_Webservice/install.sh @@ -23,7 +23,7 @@ BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SSL_Cert_Dir="${BASEDIR}/SSL_certificate" -THISHOST=$(hostname) +THISHOST=$(hostname -f) Domain_Name="${THISHOST}" #Domain_Name="www.vrops_webservice.com" WebServiceFile="${BASEDIR}/vrops_webservice" @@ -36,7 +36,7 @@ echo ' #Function to install packages using apt-get function install_packages(){ [ -x /usr/bin/apt-get ] && apt-get install -y $* - + #check properly installed for PACKAGE in $* do @@ -49,7 +49,7 @@ function install_packages(){ fi done } - + apt-get update # To get the latest package lists [ "$_DISTRO" == "Ubuntu" ] && install_packages "python-yaml python-bottle python-jsonschema python-requests libxml2-dev libxslt-dev python-dev python-pip openssl" @@ -78,8 +78,9 @@ echo ' nohup python "${WebServiceFile}" & -echo ' +echo ' ################################################################# ##### Done ##### #################################################################' + diff --git a/plugins/vRealiseOps/vROPs_Webservice/vrops_webservice b/plugins/vRealiseOps/vROPs_Webservice/vrops_webservice index 547f4ff..98533f1 100755 --- a/plugins/vRealiseOps/vROPs_Webservice/vrops_webservice +++ b/plugins/vRealiseOps/vROPs_Webservice/vrops_webservice @@ -33,7 +33,7 @@ __version__ = '0.1' from bottle import (ServerAdapter, route, run, server_names, redirect, default_app, request, response, template, debug, TEMPLATE_PATH , static_file) -from socket import gethostname +from socket import getfqdn from datetime import datetime from xml.etree import ElementTree as ET import logging @@ -55,8 +55,8 @@ except ImportError: #Set Constants BASE_DIR = os.path.dirname(os.path.dirname(__file__)) CERT_DIR = os.path.join(BASE_DIR, "SSL_certificate") -certificate_name = gethostname() + ".cert" -key_name = gethostname() + ".key" +certificate_name = getfqdn() + ".cert" +key_name = getfqdn() + ".key" CERTIFICATE = os.path.join(CERT_DIR, certificate_name) KEY = os.path.join(CERT_DIR, key_name) #CERTIFICATE = os.path.join(CERT_DIR, "www.vrops_webservice.com.cert") @@ -225,17 +225,18 @@ class SSLWebServer(ServerAdapter): try: server.start() - logger.info("Started vROPs Web Serverice") + logger.info("Started vROPs Web Service") except Exception as exp: server.stop() - logger.error("Exception: {} Stopped vROPs Web Serverice".format(exp)) + logger.error("Exception: {} Stopped vROPs Web Service".format(exp)) if __name__ == "__main__": #Start SSL Web Service - logger.info("Start vROPs Web Serverice") + logger.info("Start vROPs Web Service") app = default_app() server_names['sslwebserver'] = SSLWebServer - run(app=app,host=gethostname(), port=8080, server='sslwebserver') + run(app=app,host=getfqdn(), port=8080, server='sslwebserver') +