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)
#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__)
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"
#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
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"
nohup python "${WebServiceFile}" &
-echo '
+echo '
#################################################################
##### Done #####
#################################################################'
+
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
#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")
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')
+