aboutsummaryrefslogtreecommitdiffstats
path: root/miss_htbt_service
diff options
context:
space:
mode:
Diffstat (limited to 'miss_htbt_service')
-rw-r--r--miss_htbt_service/cbs_polling.py14
-rw-r--r--miss_htbt_service/config_notif.py29
-rw-r--r--miss_htbt_service/db_monitoring.py18
-rw-r--r--miss_htbt_service/htbtworker.py29
-rw-r--r--miss_htbt_service/misshtbtd.py46
-rw-r--r--miss_htbt_service/mod/trapd_exit.py3
-rw-r--r--miss_htbt_service/mod/trapd_get_cbs_config.py7
-rw-r--r--miss_htbt_service/mod/trapd_io.py5
-rw-r--r--miss_htbt_service/mod/trapd_vnf_table.py50
9 files changed, 106 insertions, 95 deletions
diff --git a/miss_htbt_service/cbs_polling.py b/miss_htbt_service/cbs_polling.py
index 233cdb5..01f30bb 100644
--- a/miss_htbt_service/cbs_polling.py
+++ b/miss_htbt_service/cbs_polling.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# Copyright 2018 AT&T Intellectual Property, Inc. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,7 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-#
+#
# Author Prakash Hosangady(ph553f@att.com)
# CBS Polling
# Set the hb_common table with state="RECONFIGURATION" periodically
@@ -24,12 +25,13 @@ import string
import sys
import os
import socket
-import htbtworker as pm
-import misshtbtd as db
import logging
-import get_logger
+from . import htbtworker as pm
+from . import misshtbtd as db
+from . import get_logger
+
_logger = get_logger.get_logger(__name__)
-
+
def pollCBS(current_pid):
jsfile = db.fetch_json_file()
@@ -58,7 +60,7 @@ def pollCBS(current_pid):
db.create_update_hb_common(update_flg, hbc_pid, state, user_name,password,ip_address,port_num,db_name)
else:
_logger.info("CBSP:Inactive instance or hb_common state is not RUNNING")
- return result
+ return result
if __name__ == "__main__":
current_pid = sys.argv[1]
while(True):
diff --git a/miss_htbt_service/config_notif.py b/miss_htbt_service/config_notif.py
index 8a10a15..a1d2d8b 100644
--- a/miss_htbt_service/config_notif.py
+++ b/miss_htbt_service/config_notif.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# Copyright 2018 AT&T Intellectual Property, Inc. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,7 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-#
+#
# Author Prakash Hosangady (ph553f)
# Read the hb_common table
# Update the state to RECONFIGURATION and save the hb_common table
@@ -27,8 +28,8 @@ import json
import psycopg2
from pathlib import Path
import os.path as path
-from mod.trapd_get_cbs_config import get_cbs_config
-import mod.trapd_settings as tds
+from .mod import trapd_settings as tds
+from .mod.trapd_get_cbs_config import get_cbs_config
hb_properties_file = path.abspath(path.join(__file__, "../config/hbproperties.yaml"))
@@ -39,7 +40,7 @@ def postgres_db_open(username,password,host,port,database_name):
try: #pragma: no cover
connection = psycopg2.connect(database=database_name, user = username, password = password, host = host, port =port)
except Exception as e:
- print("HB_Notif::postgress connect error:", e)
+ print("HB_Notif::postgress connect error: %s" % e)
connection = True
return connection
@@ -54,12 +55,12 @@ def db_table_creation_check(connection_db,table_name):
database_names = cur.fetchone()
if(database_names is not None):
if(table_name in database_names):
- print("HB_Notif::Postgres has already has table -", table_name)
+ print("HB_Notif::Postgres already has table - %s" % table_name)
return True
else:
- print("HB_Notif::Postgres does not have table - ", table_name)
+ print("HB_Notif::Postgres does not have table - %s" % table_name)
return False
- except (psycopg2.DatabaseError, e):
+ except psycopg2.DatabaseError as e:
print('COMMON:Error %s' % e)
finally:
cur.close()
@@ -72,7 +73,7 @@ def commit_and_close_db(connection_db):
connection_db.commit() # <--- makes sure the change is shown in the database
connection_db.close()
return True
- except(psycopg2.DatabaseError, e):
+ except psycopg2.DatabaseError as e:
return False
def read_hb_properties_default():
@@ -102,7 +103,7 @@ def read_hb_properties(jsfile):
with open(jsfile, 'r') as outfile:
cfg = json.load(outfile)
except(Exception) as err:
- print("Json file read error - %s",err)
+ print("Json file read error - %s" % err)
return read_hb_properties_default()
try:
ip_address = str(cfg['pg_ipAddress'])
@@ -113,10 +114,10 @@ def read_hb_properties(jsfile):
db_name = dbName.lower()
cbs_polling_required = str(cfg['CBS_polling_allowed'])
cbs_polling_interval = str(cfg['CBS_polling_interval'])
- if("SERVICE_NAME" in cfg.keys()):
+ if "SERVICE_NAME" in cfg:
os.environ['SERVICE_NAME'] = str(cfg['SERVICE_NAME'])
except(Exception) as err:
- print("Json file read parameter error -%s ",err)
+ print("Json file read parameter error - %s" % err)
return read_hb_properties_default()
return ip_address, port_num, user_name, password, db_name, cbs_polling_required, cbs_polling_interval
@@ -133,7 +134,7 @@ def read_hb_common(user_name,password,ip_address,port_num,db_name):
query_value = "SELECT process_id,source_name,last_accessed_time,current_state FROM hb_common;"
cur.execute(query_value)
rows = cur.fetchall()
- print("HB_Notif::hb_common contents - ", rows)
+ print("HB_Notif::hb_common contents - %s" % rows)
hbc_pid = rows[0][0]
hbc_srcName = rows[0][1]
hbc_time = rows[0][2]
@@ -171,7 +172,7 @@ def fetch_json_file():
else:
print("MSHBD:CBS Config not available, using local config")
jsfile = "../etc/config.json"
- print("Config_N: The json file is - %s", jsfile)
+ print("Config_N: The json file is - %s" % jsfile)
return jsfile
#if __name__ == "__main__":
@@ -199,5 +200,5 @@ def config_notif_run():
print("HB_Notif::Failure updating hb_common table")
commit_and_close_db(connection_db)
return False
-
+
cur.close()
diff --git a/miss_htbt_service/db_monitoring.py b/miss_htbt_service/db_monitoring.py
index fd00f8a..95b2dbe 100644
--- a/miss_htbt_service/db_monitoring.py
+++ b/miss_htbt_service/db_monitoring.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# Copyright 2018 AT&T Intellectual Property, Inc. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,25 +13,24 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-#
+#
# Author Prakash Hosangady(ph553f)
# DB Monitoring
# Tracks Heartbeat messages on each of the VNFs stored in postgres DB
# and generates Missing Heartbeat signal for Policy Engine
-import requests
import math
import sched, datetime, time
import json
import string
import sys
import os
+import logging
import socket
import requests
-import htbtworker as pm
-import misshtbtd as db
-import logging
-import get_logger
+from . import htbtworker as pm
+from . import misshtbtd as db
+from . import get_logger
_logger = get_logger.get_logger(__name__)
@@ -206,11 +206,11 @@ def db_monitoring(current_pid,json_file,user_name,password,ip_address,port_num,d
update_query = "UPDATE vnf_table_2 SET CL_FLAG=%d where EVENT_NAME ='%s' and source_name_key=%d" %(cl_flag,event_name,(source_name_key+1))
cur.execute(update_query)
connection_db.commit()
-
+
else: #pragma: no cover
msg="DBM:DB Monitoring is ignored for %s since validity flag is 0" %(event_name)
_logger.info(msg)
-
+
delete_query_table2 = "DELETE FROM vnf_table_2 WHERE EVENT_NAME = '%s';" %(event_name)
cur.execute(delete_query_table2)
delete_query = "DELETE FROM vnf_table_1 WHERE EVENT_NAME = '%s';" %(event_name)
@@ -225,7 +225,7 @@ def db_monitoring(current_pid,json_file,user_name,password,ip_address,port_num,d
pm.commit_and_close_db(connection_db)
cur.close()
break;
-
+
if __name__ == "__main__":
_logger.info("DBM: DBM Process started")
current_pid = sys.argv[1]
diff --git a/miss_htbt_service/htbtworker.py b/miss_htbt_service/htbtworker.py
index 2c206ce..c02f817 100644
--- a/miss_htbt_service/htbtworker.py
+++ b/miss_htbt_service/htbtworker.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# Copyright 2018 AT&T Intellectual Property, Inc. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,7 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-#
+#
# Author Prakash Hosangady(ph553f@att.com)
# Simple Microservice
# Tracks Heartbeat messages on input topic in DMaaP
@@ -21,11 +22,11 @@
import psycopg2
import requests
import os
+import os.path as path
import json,sys,time
-import misshtbtd as db
import logging
-import get_logger
-import os.path as path
+from . import misshtbtd as db
+from . import get_logger
_logger = get_logger.get_logger(__name__)
@@ -58,7 +59,7 @@ def process_msg(jsfile,user_name, password, ip_address, port_num, db_name):
time.sleep(10)
else:
break
-
+
if(os.getenv('pytest', "") == 'test'):
eventnameList = ["Heartbeat_vDNS","Heartbeat_vFW","Heartbeat_xx"]
connection_db = 0
@@ -66,7 +67,7 @@ def process_msg(jsfile,user_name, password, ip_address, port_num, db_name):
connection_db = postgres_db_open(user_name, password, ip_address, port_num, db_name)
cur = connection_db.cursor()
db_query = "Select event_name from vnf_table_1"
- cur.execute(db_query)
+ cur.execute(db_query)
eventnameList = [item[0] for item in cur.fetchall()]
msg="\n\nHBT:eventnameList values ", eventnameList
_logger.info(msg)
@@ -131,7 +132,7 @@ def process_msg(jsfile,user_name, password, ip_address, port_num, db_name):
_logger.info(msg)
cur.execute("CREATE TABLE vnf_table_2 (EVENT_NAME varchar , SOURCE_NAME_KEY integer , PRIMARY KEY(EVENT_NAME,SOURCE_NAME_KEY),LAST_EPO_TIME BIGINT, SOURCE_NAME varchar, CL_FLAG integer);")
else:
- msg="HBT:vnf_table_2 is already there"
+ msg="HBT:vnf_table_2 is already there"
_logger.info(msg)
if(eventName in eventnameList): #pragma: no cover
db_query = "Select source_name_count from vnf_table_1 where event_name='%s'" %(eventName)
@@ -188,9 +189,9 @@ def process_msg(jsfile,user_name, password, ip_address, port_num, db_name):
commit_and_close_db(connection_db)
if(os.getenv('pytest', "") != 'test'):
cur.close()
-
+
def postgres_db_open(username,password,host,port,database_name):
-
+
if(os.getenv('pytest', "") == 'test'):
return True
connection = psycopg2.connect(database=database_name, user = username, password = password, host = host, port =port)
@@ -209,9 +210,9 @@ def db_table_creation_check(connection_db,table_name):
return True
else:
return False
-
-
- except (psycopg2.DatabaseError, e):
+
+
+ except psycopg2.DatabaseError as e:
msg = 'COMMON:Error %s' % e
_logger.error(msg)
finally:
@@ -223,7 +224,7 @@ def commit_db(connection_db):
try:
connection_db.commit() # <--- makes sure the change is shown in the database
return True
- except(psycopg2.DatabaseError, e):
+ except psycopg2.DatabaseError as e:
msg = 'COMMON:Error %s' % e
_logger.error(msg)
return False
@@ -235,7 +236,7 @@ def commit_and_close_db(connection_db):
connection_db.commit() # <--- makes sure the change is shown in the database
connection_db.close()
return True
- except(psycopg2.DatabaseError, e):
+ except psycopg2.DatabaseError as e:
msg = 'COMMON:Error %s' % e
_logger.error(msg)
return False
diff --git a/miss_htbt_service/misshtbtd.py b/miss_htbt_service/misshtbtd.py
index f1a8688..790ab6a 100644
--- a/miss_htbt_service/misshtbtd.py
+++ b/miss_htbt_service/misshtbtd.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# ============LICENSE_START=======================================================
# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -21,7 +22,7 @@
# configuration file from CBS
# - Creates heartbeat worker process that receives the Heartbeat messages from VNF
# - Creates DB Monitoring process that generates Control loop event
-# - Download the CBS configuration and populate the DB
+# - Download the CBS configuration and populate the DB
#
# Author Prakash Hosangady(ph553f@att.com)
import traceback
@@ -36,17 +37,18 @@ import logging
import subprocess
import yaml
import socket
-import get_logger
-from pathlib import Path
-import mod.trapd_settings as tds
-import htbtworker as heartbeat
import os.path as path
+from pathlib import Path
+
+from . import htbtworker as heartbeat
+from . import get_logger
+from .mod import trapd_settings as tds
+from .mod.trapd_runtime_pid import save_pid, rm_pid
+from .mod.trapd_get_cbs_config import get_cbs_config
+from .mod.trapd_exit import cleanup_and_exit
+from .mod.trapd_http_session import init_session_obj
hb_properties_file = path.abspath(path.join(__file__, "../config/hbproperties.yaml"))
-from mod.trapd_runtime_pid import save_pid, rm_pid
-from mod.trapd_get_cbs_config import get_cbs_config
-from mod.trapd_exit import cleanup_and_exit
-from mod.trapd_http_session import init_session_obj
ip_address = "localhost"
port_num = 5432
user_name = "postgres"
@@ -144,7 +146,7 @@ def create_update_hb_common(update_flg, process_id, state, user_name,password,ip
cur.execute(query_value)
heartbeat.commit_and_close_db(connection_db)
cur.close()
-
+
def create_update_vnf_table_1(jsfile,update_db,connection_db):
with open(jsfile, 'r') as outfile:
cfg = json.load(outfile)
@@ -171,7 +173,7 @@ def create_update_vnf_table_1(jsfile,update_db,connection_db):
#_logger.error("MSHBT:",nfc)
validity_flag = 1
source_name_count = 0
- missed = vnf['heartbeatcountmissed']
+ missed = vnf['heartbeatcountmissed']
intvl = vnf['heartbeatinterval']
clloop = vnf['closedLoopControlName']
policyVersion = vnf['policyVersion']
@@ -180,11 +182,11 @@ def create_update_vnf_table_1(jsfile,update_db,connection_db):
target_type = vnf['target_type']
target = vnf['target']
version = vnf['version']
-
- if(nfc not in vnf_list):
+
+ if(nfc not in vnf_list):
query_value = "INSERT INTO vnf_table_1 VALUES('%s',%d,%d,'%s','%s','%s','%s','%s','%s','%s',%d,%d);" %(nfc,missed,intvl,clloop,policyVersion,policyName,policyScope,target_type, target,version,source_name_count,validity_flag)
else:
- query_value = "UPDATE vnf_table_1 SET HEARTBEAT_MISSED_COUNT='%d',HEARTBEAT_INTERVAL='%d', CLOSED_CONTROL_LOOP_NAME='%s',POLICY_VERSION='%s',POLICY_NAME='%s', POLICY_SCOPE='%s',TARGET_TYPE='%s', TARGET='%s',VERSION='%s',VALIDITY_FLAG='%d' where EVENT_NAME='%s'" %(missed,intvl,clloop,policyVersion,policyName,policyScope,target_type,target,version,validity_flag,nfc)
+ query_value = "UPDATE vnf_table_1 SET HEARTBEAT_MISSED_COUNT='%d',HEARTBEAT_INTERVAL='%d', CLOSED_CONTROL_LOOP_NAME='%s',POLICY_VERSION='%s',POLICY_NAME='%s', POLICY_SCOPE='%s',TARGET_TYPE='%s', TARGET='%s',VERSION='%s',VALIDITY_FLAG='%d' where EVENT_NAME='%s'" %(missed,intvl,clloop,policyVersion,policyName,policyScope,target_type,target,version,validity_flag,nfc)
if (envPytest != 'test'):
cur.execute(query_value)
#heartbeat.commit_and_close_db(connection_db)
@@ -200,7 +202,7 @@ def hb_cbs_polling_process(pid_current):
# subprocess.call(["python3.6",ABSOLUTE_PATH4 , str(pid_current) ])
sys.stdout.flush()
_logger.info("MSHBT:Creaated CBS polling process")
- return
+ return
def hb_worker_process(config_file_path):
my_file = Path("./miss_htbt_service/htbtworker.py")
# if my_file.is_file():
@@ -251,8 +253,8 @@ def read_hb_properties(jsfile):
msg = "CBS Json file load error - ",err
_logger.error(msg)
return read_hb_properties_default()
-
- try:
+
+ try:
ip_address = str(cfg['pg_ipAddress'])
port_num = str(cfg['pg_portNum'])
user_name = str(cfg['pg_userName'])
@@ -265,7 +267,7 @@ def read_hb_properties(jsfile):
group_id = str(cfg['groupID'])
os.environ['consumerID'] = consumer_id
os.environ['groupID'] = group_id
- if("SERVICE_NAME" in cfg.keys()):
+ if "SERVICE_NAME" in cfg:
os.environ['SERVICE_NAME'] = str(cfg['SERVICE_NAME'])
except(Exception) as err:
msg = "CBS Json file read parameter error - ",err
@@ -343,7 +345,7 @@ def main():
job_list = []
pid_current = os.getpid()
jsfile = fetch_json_file()
- ip_address, port_num, user_name, password, db_name, cbs_polling_required, cbs_polling_interval = read_hb_properties(jsfile)
+ ip_address, port_num, user_name, password, db_name, cbs_polling_required, cbs_polling_interval = read_hb_properties(jsfile)
msg = "MSHBT:HB Properties -", ip_address, port_num, user_name, password, db_name, cbs_polling_required, cbs_polling_interval
_logger.info(msg)
if(cbs_polling_required == 'True'):
@@ -397,7 +399,7 @@ def main():
state = "RUNNING"
update_flg = 1
create_update_hb_common(update_flg, pid_current, state, user_name,password,ip_address,port_num,db_name)
-
+
else:
_logger.info("MSHBD:Inactive Instance: Process IDs are different, Keep Looping")
if(len(job_list)>=2):
@@ -442,12 +444,12 @@ def main():
job_list[0].join()
job_list.remove(job_list[0])
break
-
+
except (Exception) as e:
msg = "MSHBD:Exception as %s" %(str(traceback.format_exc()))
_logger.error(msg)
- msg = "Fatal error. Could not start missing heartbeat service due to: {0}".format(e)
+ msg = "Fatal error. Could not start missing heartbeat service due to: {0}".format(e)
_logger.error(msg)
if __name__ == '__main__':
diff --git a/miss_htbt_service/mod/trapd_exit.py b/miss_htbt_service/mod/trapd_exit.py
index 6247f4b..80ed1b0 100644
--- a/miss_htbt_service/mod/trapd_exit.py
+++ b/miss_htbt_service/mod/trapd_exit.py
@@ -2,6 +2,7 @@
# org.onap.dcae
# ================================================================================
# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -28,7 +29,7 @@ __docformat__ = 'restructuredtext'
import sys
import os
import string
-from mod.trapd_runtime_pid import save_pid, rm_pid
+from .trapd_runtime_pid import save_pid, rm_pid
prog_name = os.path.basename(__file__)
diff --git a/miss_htbt_service/mod/trapd_get_cbs_config.py b/miss_htbt_service/mod/trapd_get_cbs_config.py
index 47ba223..86e621f 100644
--- a/miss_htbt_service/mod/trapd_get_cbs_config.py
+++ b/miss_htbt_service/mod/trapd_get_cbs_config.py
@@ -2,6 +2,7 @@
# org.onap.dcae
# ================================================================================
# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -33,10 +34,10 @@ import string
import time
import traceback
import collections
-import mod.trapd_settings as tds
from onap_dcae_cbs_docker_client.client import get_config
-from mod.trapd_exit import cleanup,cleanup_and_exit
-from mod.trapd_io import stdout_logger
+from . import trapd_settings as tds
+from .trapd_exit import cleanup,cleanup_and_exit
+from .trapd_io import stdout_logger
prog_name = os.path.basename(__file__)
diff --git a/miss_htbt_service/mod/trapd_io.py b/miss_htbt_service/mod/trapd_io.py
index 1c40346..063f3ee 100644
--- a/miss_htbt_service/mod/trapd_io.py
+++ b/miss_htbt_service/mod/trapd_io.py
@@ -2,6 +2,7 @@
# org.onap.dcae
# ================================================================================
# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -37,8 +38,8 @@ import time
import traceback
import unicodedata
# dcae_snmptrap
-import mod.trapd_settings as tds
-from mod.trapd_exit import cleanup_and_exit
+from . import trapd_settings as tds
+from .trapd_exit import cleanup_and_exit
prog_name = os.path.basename(__file__)
diff --git a/miss_htbt_service/mod/trapd_vnf_table.py b/miss_htbt_service/mod/trapd_vnf_table.py
index b180bf5..56aedbb 100644
--- a/miss_htbt_service/mod/trapd_vnf_table.py
+++ b/miss_htbt_service/mod/trapd_vnf_table.py
@@ -2,6 +2,7 @@
# org.onap.dcae
# ================================================================================
# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -27,20 +28,21 @@ trapd_vnf_table verifies the successful creation of DB Tables.
import psycopg2
import os
import sys
-import htbtworker as pm
-import misshtbtd as db
-import config_notif as cf
-import cbs_polling as cbs
import logging
-import get_logger
import yaml
import os.path as path
-import db_monitoring as dbmon
import json
-from onap_dcae_cbs_docker_client.client import get_config
-import unittest
import time
import subprocess
+from onap_dcae_cbs_docker_client.client import get_config
+
+from .. import get_logger
+from .. import db_monitoring as dbmon
+from .. import htbtworker as pm
+from .. import misshtbtd as db
+from .. import config_notif as cf
+from .. import cbs_polling as cbs
+
prog_name = os.path.basename(__file__)
hb_properties_file = path.abspath(path.join(__file__, "../../config/hbproperties.yaml"))
@@ -52,8 +54,8 @@ def hb_properties():
a=yaml.load(s)
ip_address = a['pg_ipAddress']
port_num = a['pg_portNum']
- user_name = a['pg_userName']
- password = a['pg_passwd']
+ user_name = a['pg_userName']
+ password = a['pg_passwd']
dbName = a['pg_dbName']
db_name = dbName.lower()
cbs_polling_required = a['CBS_polling_allowed']
@@ -61,7 +63,7 @@ def hb_properties():
s.close()
return ip_address, port_num, user_name, password, db_name, cbs_polling_required, cbs_polling_interval
-
+
def verify_DB_creation_1(user_name,password,ip_address,port_num,db_name):
connection_db = pm.postgres_db_open(user_name,password,ip_address,port_num,db_name)
# cur = connection_db.cursor()
@@ -69,9 +71,9 @@ def verify_DB_creation_1(user_name,password,ip_address,port_num,db_name):
_db_status=pm.db_table_creation_check(connection_db,"vnf_table_1")
except Exception as e:
return None
-
+
return _db_status
-
+
def verify_DB_creation_2(user_name,password,ip_address,port_num,db_name):
connection_db = pm.postgres_db_open(user_name,password,ip_address,port_num,db_name)
@@ -80,9 +82,9 @@ def verify_DB_creation_2(user_name,password,ip_address,port_num,db_name):
_db_status=pm.db_table_creation_check(connection_db,"vnf_table_2")
except Exception as e:
return None
-
+
return _db_status
-
+
def verify_DB_creation_hb_common(user_name,password,ip_address,port_num,db_name):
connection_db = pm.postgres_db_open(user_name,password,ip_address,port_num,db_name)
@@ -91,10 +93,10 @@ def verify_DB_creation_hb_common(user_name,password,ip_address,port_num,db_name)
_db_status=pm.db_table_creation_check(connection_db,"hb_common")
except Exception as e:
return None
-
+
return _db_status
-
-
+
+
def verify_cbsPolling_required():
_cbspolling_status = True
os.environ['pytest']='test'
@@ -104,9 +106,9 @@ def verify_cbsPolling_required():
try:
_cbspolling_status=cf.config_notif_run()
except Exception as e:
- print("Config_notify error - ",e)
+ print("Config_notify error - %s" % e)
#return None
-
+
os.unsetenv('pytest')
os.unsetenv('CONSUL_HOST')
os.unsetenv('SERVICE_NAME')
@@ -118,9 +120,9 @@ def verify_cbspolling():
try:
_cbspolling=cbs.pollCBS(10)
except Exception as e:
- #print("CBSP error - ",e)
+ #print("CBSP error - %s" % e)
return None
-
+
os.unsetenv('pytest')
os.unsetenv('SERVICE_NAME')
return _cbspolling
@@ -175,7 +177,7 @@ def verify_dbmonitoring():
dbmon.db_monitoring(hbc_pid,jsfile,user_name,password,ip_address,port_num,db_name)
result = True
except Exception as e:
- print("Message process error - ",e)
+ print("Message process error - %s" % e)
result = False
print(result)
os.unsetenv('pytest')
@@ -189,7 +191,7 @@ def verify_dbmon_startup():
p = subprocess.Popen(['./miss_htbt_service/db_monitoring.py'], stdout=subprocess.PIPE,shell=True)
time.sleep(1)
except Exception as e:
- #print( "Message process error - ",e)
+ #print("Message process error - %s" % e)
return None
return True