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.py2
-rw-r--r--miss_htbt_service/check_health.py1
-rw-r--r--miss_htbt_service/config_notif.py1
-rw-r--r--miss_htbt_service/db_monitoring.py1
-rw-r--r--miss_htbt_service/get_logger.py5
-rw-r--r--miss_htbt_service/misshtbtd.py17
-rw-r--r--miss_htbt_service/mod/trapd_runtime_pid.py4
-rw-r--r--miss_htbt_service/mod/trapd_vnf_table.py21
8 files changed, 0 insertions, 52 deletions
diff --git a/miss_htbt_service/cbs_polling.py b/miss_htbt_service/cbs_polling.py
index d1253c0..d2be0d9 100644
--- a/miss_htbt_service/cbs_polling.py
+++ b/miss_htbt_service/cbs_polling.py
@@ -48,8 +48,6 @@ def pollCBS(current_pid):
cbs_polling_interval = "30"
time.sleep(int(cbs_polling_interval))
hbc_pid, hbc_state, hbc_srcName, hbc_time = db.read_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)
- # cur = connection_db.cursor()
source_name = socket.gethostname()
source_name = source_name + "-" + str(os.getenv('SERVICE_NAME', ""))
result = True
diff --git a/miss_htbt_service/check_health.py b/miss_htbt_service/check_health.py
index 739cd2b..a010b31 100644
--- a/miss_htbt_service/check_health.py
+++ b/miss_htbt_service/check_health.py
@@ -60,7 +60,6 @@ class GetHandler(BaseHTTPRequestHandler):
if __name__ == '__main__':
from http.server import HTTPServer
- # from BaseHTTPServer import HTTPServer
server = HTTPServer(("", 10002), GetHandler)
print('Starting server at http://localhost:10002')
server.serve_forever()
diff --git a/miss_htbt_service/config_notif.py b/miss_htbt_service/config_notif.py
index 087315d..cba898d 100644
--- a/miss_htbt_service/config_notif.py
+++ b/miss_htbt_service/config_notif.py
@@ -199,7 +199,6 @@ def fetch_json_file(download_json="../etc/download1.json", config_json="../etc/c
return jsfile
-# if __name__ == "__main__":
def config_notif_run():
jsfile = fetch_json_file()
ip_address, port_num, user_name, password, db_name, cbs_polling_required, cbs_polling_interval = read_hb_properties(
diff --git a/miss_htbt_service/db_monitoring.py b/miss_htbt_service/db_monitoring.py
index 708a2bd..8704966 100644
--- a/miss_htbt_service/db_monitoring.py
+++ b/miss_htbt_service/db_monitoring.py
@@ -118,7 +118,6 @@ def sendControlLoopEvent(CLType, pol_url, policy_version, policy_name, policy_sc
payload = json_object
msg = "DBM: CL Json object is", json_object
_logger.info(msg)
- # psend_url = pol_url+'DefaultGroup/1?timeout=15000'
psend_url = pol_url
msg = "DBM:", psend_url
_logger.info(msg)
diff --git a/miss_htbt_service/get_logger.py b/miss_htbt_service/get_logger.py
index bc8fea0..c58a945 100644
--- a/miss_htbt_service/get_logger.py
+++ b/miss_htbt_service/get_logger.py
@@ -20,7 +20,6 @@ import logging.handlers
'''Configures the module root logger'''
root = logging.getLogger()
if root.handlers:
- # root.handlers.clear()
del root.handlers[:]
formatter = logging.Formatter('%(asctime)s | %(name)s | %(module)s | %(funcName)s | %(lineno)d | %(levelname)s | %(message)s')
handler = logging.StreamHandler()
@@ -32,10 +31,6 @@ root.addHandler(fhandler)
root.setLevel("DEBUG")
-class BadEnviornmentENVNotFound(Exception):
- pass
-
-
def get_logger(module=None):
'''Returns a module-specific logger or global logger if the module is None'''
return root if module is None else root.getChild(module)
diff --git a/miss_htbt_service/misshtbtd.py b/miss_htbt_service/misshtbtd.py
index 12d439a..1808439 100644
--- a/miss_htbt_service/misshtbtd.py
+++ b/miss_htbt_service/misshtbtd.py
@@ -71,14 +71,6 @@ def create_database(update_db, jsfile, ip_address, port_num, user_name, password
cur.execute(query_value)
else:
_logger.info("MSHBD:Database already exists")
- '''
- con = None
- con = connect(user=user_name, host = ip_address, password=password)
- database_name = db_name
- con.autocommit = True
- cur = con.cursor()
- cur.execute('CREATE DATABASE %s IF NOT EXISTS %s' %(database_name,database_name))
- '''
cur.close()
con.close()
except(Exception) as err:
@@ -86,12 +78,6 @@ def create_database(update_db, jsfile, ip_address, port_num, user_name, password
_logger.error(msg)
-# def get_pol_and_mr_urls(jsfile, pol_url, mr_url):
-# with open(jsfile, 'r') as outfile:
-# cfg = json.load(outfile)
-# mr_url = str(cfg['streams_subscribes']['ves-heartbeat']['dmaap_info']['topic_url'])
-# pol_url = str(cfg['streams_publishes']['dcae_cl_out']['dmaap_info']['topic_url'])
-
def read_hb_common(user_name, password, ip_address, port_num, db_name):
envPytest = os.getenv('pytest', "")
if (envPytest == 'test'):
@@ -158,7 +144,6 @@ def create_update_vnf_table_1(jsfile, update_db, connection_db):
vnf_list = [item[0] for item in cur.fetchall()]
for vnf in (jhbcfg['vnfs']):
nfc = vnf['eventName']
- # _logger.error("MSHBT:",nfc)
validity_flag = 1
source_name_count = 0
missed = vnf['heartbeatcountmissed']
@@ -177,7 +162,6 @@ def create_update_vnf_table_1(jsfile, update_db, connection_db):
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)
if (envPytest != 'test'):
cur.close()
_logger.info("MSHBT:Updated vnf_table_1 as per the json configuration file")
@@ -261,7 +245,6 @@ def read_hb_properties(jsfile):
def fetch_json_file():
if get_cbs_config():
- # current_runtime_config_file_name = tds.c_config['files.runtime_base_dir'] + "../etc/download.json"
envPytest = os.getenv('pytest', "")
if (envPytest == 'test'):
current_runtime_config_file_name = "/tmp/opt/app/miss_htbt_service/etc/config.json"
diff --git a/miss_htbt_service/mod/trapd_runtime_pid.py b/miss_htbt_service/mod/trapd_runtime_pid.py
index 7194b8f..d2db83d 100644
--- a/miss_htbt_service/mod/trapd_runtime_pid.py
+++ b/miss_htbt_service/mod/trapd_runtime_pid.py
@@ -56,11 +56,7 @@ def save_pid(_pid_file_name):
except IOError:
print("IOError saving PID file %s :" % _pid_file_name)
return False
- # except:
- # print("Error saving PID file %s :" % _pid_file_name)
- # return False
else:
- # print("Runtime PID file: %s" % _pid_file_name)
return True
diff --git a/miss_htbt_service/mod/trapd_vnf_table.py b/miss_htbt_service/mod/trapd_vnf_table.py
index 001b566..81f1f3b 100644
--- a/miss_htbt_service/mod/trapd_vnf_table.py
+++ b/miss_htbt_service/mod/trapd_vnf_table.py
@@ -61,7 +61,6 @@ def hb_properties():
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()
try:
_db_status=pm.db_table_creation_check(connection_db,"vnf_table_1")
except Exception as e:
@@ -72,7 +71,6 @@ def verify_DB_creation_1(user_name,password,ip_address,port_num,db_name):
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)
- # cur = connection_db.cursor()
try:
_db_status=pm.db_table_creation_check(connection_db,"vnf_table_2")
except Exception as e:
@@ -83,7 +81,6 @@ def verify_DB_creation_2(user_name,password,ip_address,port_num,db_name):
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)
- #cur = connection_db.cursor()
try:
_db_status=pm.db_table_creation_check(connection_db,"hb_common")
except Exception as e:
@@ -95,14 +92,12 @@ def verify_DB_creation_hb_common(user_name,password,ip_address,port_num,db_name)
def verify_cbsPolling_required():
_cbspolling_status = True
os.environ['pytest']='test'
- #os.environ['CONSUL_HOST']='10.12.6.50' # Used this IP during testing
os.environ['CONSUL_HOST']='localhost'
os.environ['SERVICE_NAME']='mvp-dcaegen2-heartbeat-static'
try:
_cbspolling_status=cf.config_notif_run()
except Exception as e:
print("Config_notify error - %s" % e)
- #return None
os.unsetenv('pytest')
os.unsetenv('CONSUL_HOST')
@@ -115,9 +110,6 @@ def verify_cbspolling():
try:
_cbspolling=cbs.pollCBS(10)
except Exception as e:
- # print("CBSP error - %s" % e)
- # print("CBSP error - %s" % e, file=sys.stderr)
- # print("Stack: {0}".format(traceback.format_exc()), file=sys.stderr)
return None
os.unsetenv('pytest')
@@ -127,7 +119,6 @@ def verify_cbspolling():
def verify_fetch_json_file():
os.environ['pytest']='test'
os.environ['SERVICE_NAME']='mvp-dcaegen2-heartbeat-static'
- #os.environ['CONSUL_HOST']='10.12.6.50' # Used this IP during testing
os.environ['CONSUL_HOST']='localhost'
os.environ['HOSTNAME']='mvp-dcaegen2-heartbeat-static'
try:
@@ -145,7 +136,6 @@ def verify_fetch_json_file():
def verify_misshtbtdmain():
os.environ['pytest']='test'
os.environ['SERVICE_NAME']='mvp-dcaegen2-heartbeat-static'
- #os.environ['CONSUL_HOST']='10.12.6.50'
os.environ['CONSUL_HOST']='localhost'
os.environ['HOSTNAME']='mvp-dcaegen2-heartbeat-static'
@@ -164,7 +154,6 @@ def verify_misshtbtdmain():
def verify_dbmonitoring():
os.environ['pytest']='test'
os.environ['SERVICE_NAME']='mvp-dcaegen2-heartbeat-static'
- #os.environ['CONSUL_HOST']='10.12.6.50'
os.environ['CONSUL_HOST']='localhost'
os.environ['HOSTNAME']='mvp-dcaegen2-heartbeat-static'
try:
@@ -188,18 +177,14 @@ 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 - %s" % e)
return None
return True
def verify_sendControlLoop_VNF_ONSET():
try:
-# _CL_return = sendControlLoopEvent(CLType, pol_url, policy_version, policy_name, policy_scope, target_type, srcName, epoc_time, closed_control_loop_name, version, target)
pol_url = "http://10.12.5.252:3904/events/unauthenticated.DCAE_CL_OUTPUT/"
_CL_return = dbmon.sendControlLoopEvent("ONSET", pol_url, "1.0", "vFireWall", "pscope", "VNF", "srcname1", 1541234567, "SampleCLName", "1.0", "genVnfName")
except Exception as e:
- #msg = "Message process error - ",err
- #_logger.error(msg)
return None
return _CL_return
@@ -208,8 +193,6 @@ def verify_sendControlLoop_VM_ONSET():
pol_url = "http://10.12.5.252:3904/events/unauthenticated.DCAE_CL_OUTPUT/"
_CL_return = dbmon.sendControlLoopEvent("ONSET", pol_url, "1.0", "vFireWall", "pscope", "VM", "srcname1", 1541234567, "SampleCLName", "1.0", "genVnfName")
except Exception as e:
- #msg = "Message process error - ",err
- #_logger.error(msg)
return None
return _CL_return
@@ -218,8 +201,6 @@ def verify_sendControlLoop_VNF_ABATED():
pol_url = "http://10.12.5.252:3904/events/unauthenticated.DCAE_CL_OUTPUT/"
_CL_return = dbmon.sendControlLoopEvent("ABATED", pol_url, "1.0", "vFireWall", "pscope", "VNF", "srcname1", 1541234567, "SampleCLName", "1.0", "genVnfName")
except Exception as e:
- #msg = "Message process error - ",err
- #_logger.error(msg)
return None
return _CL_return
@@ -228,7 +209,5 @@ def verify_sendControlLoop_VM_ABATED():
pol_url = "http://10.12.5.252:3904/events/unauthenticated.DCAE_CL_OUTPUT/"
_CL_return = dbmon.sendControlLoopEvent("ABATED", pol_url, "1.0", "vFireWall", "pscope", "VM", "srcname1", 1541234567, "SampleCLName", "1.0", "genVnfName")
except Exception as e:
-# msg = "Message process error - ",err
-# _logger.error(msg)
return None
return _CL_return