From 341b5bb2347c30344662675936b90b325efe5520 Mon Sep 17 00:00:00 2001 From: Vijay Venkatesh Kumar Date: Thu, 17 Nov 2022 14:51:38 -0500 Subject: Heartbeat code refactoring code optimization & test improvement Issue-ID: DCAEGEN2-2953 Signed-off-by: Vijay Venkatesh Kumar Change-Id: I99229d966c13ad666ac994ab5a582aeeaa306639 Signed-off-by: Vijay Venkatesh Kumar --- miss_htbt_service/mod/htbt_exit.py | 89 +++++++++ miss_htbt_service/mod/htbt_get_cbs_config.py | 112 ++++++++++++ miss_htbt_service/mod/htbt_http_session.py | 53 ++++++ miss_htbt_service/mod/htbt_io.py | 52 ++++++ miss_htbt_service/mod/htbt_runtime_pid.py | 82 +++++++++ miss_htbt_service/mod/htbt_settings.py | 165 +++++++++++++++++ miss_htbt_service/mod/htbt_vnf_table.py | 250 ++++++++++++++++++++++++++ miss_htbt_service/mod/trapd_exit.py | 89 --------- miss_htbt_service/mod/trapd_get_cbs_config.py | 112 ------------ miss_htbt_service/mod/trapd_http_session.py | 53 ------ miss_htbt_service/mod/trapd_io.py | 52 ------ miss_htbt_service/mod/trapd_runtime_pid.py | 82 --------- miss_htbt_service/mod/trapd_settings.py | 165 ----------------- miss_htbt_service/mod/trapd_vnf_table.py | 250 -------------------------- 14 files changed, 803 insertions(+), 803 deletions(-) create mode 100644 miss_htbt_service/mod/htbt_exit.py create mode 100644 miss_htbt_service/mod/htbt_get_cbs_config.py create mode 100644 miss_htbt_service/mod/htbt_http_session.py create mode 100644 miss_htbt_service/mod/htbt_io.py create mode 100644 miss_htbt_service/mod/htbt_runtime_pid.py create mode 100644 miss_htbt_service/mod/htbt_settings.py create mode 100644 miss_htbt_service/mod/htbt_vnf_table.py delete mode 100644 miss_htbt_service/mod/trapd_exit.py delete mode 100644 miss_htbt_service/mod/trapd_get_cbs_config.py delete mode 100644 miss_htbt_service/mod/trapd_http_session.py delete mode 100644 miss_htbt_service/mod/trapd_io.py delete mode 100644 miss_htbt_service/mod/trapd_runtime_pid.py delete mode 100644 miss_htbt_service/mod/trapd_settings.py delete mode 100644 miss_htbt_service/mod/trapd_vnf_table.py (limited to 'miss_htbt_service/mod') diff --git a/miss_htbt_service/mod/htbt_exit.py b/miss_htbt_service/mod/htbt_exit.py new file mode 100644 index 0000000..3779e15 --- /dev/null +++ b/miss_htbt_service/mod/htbt_exit.py @@ -0,0 +1,89 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2017-2023 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2019 Pantheon.tech. All rights reserved. +# Copyright (c) 2020 Deutsche Telekom. 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# ============LICENSE_END========================================================= + +""" +htbt_exit is responsible for removing any existing runtime PID +file, and exiting with the provided (param 1) exit code +""" + +__docformat__ = "restructuredtext" + +import sys +import os +from mod.htbt_runtime_pid import rm_pid + +prog_name = os.path.basename(__file__) + + +# # # # # # # # # # # # # +# fx: cleanup_and_exit +# - remove pid file +# - exit with supplied return code +# # # # # # # # # # # # # +def cleanup_and_exit(_loc_exit_code, _pid_file_name): + """ + Remove existing PID file, and exit with provided exit code + :Parameters: + _loc_exit_code + value to return to calling shell upon exit + _pid_file_name + name of file that contains current process ID (for + removal) + :Exceptions: + none + :Keywords: + runtime PID exit + :Variables: + _num_params + number of parameters passed to module + """ + + # _num_params = len(locals()) + + if _pid_file_name is not None: + rm_pid(_pid_file_name) + sys.exit(_loc_exit_code) + + +# # # # # # # # # # # # # +# fx: cleanup_and_exit +# - remove pid file +# - exit with supplied return code +# # # # # # # # # # # # # +def cleanup(_loc_exit_code, _pid_file_name): + """ + Remove existing PID file, and exit with provided exit code + :Parameters: + _loc_exit_code + value to return to calling shell upon exit + _pid_file_name + name of file that contains current process ID (for + removal) + :Exceptions: + none + :Keywords: + runtime PID exit + :Variables: + _num_params + number of parameters passed to module + """ + + # _num_params = len(locals()) + + if _pid_file_name is not None: + rm_pid(_pid_file_name) diff --git a/miss_htbt_service/mod/htbt_get_cbs_config.py b/miss_htbt_service/mod/htbt_get_cbs_config.py new file mode 100644 index 0000000..613b46f --- /dev/null +++ b/miss_htbt_service/mod/htbt_get_cbs_config.py @@ -0,0 +1,112 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2018-2023 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2019 Pantheon.tech. All rights reserved. +# Copyright (c) 2020 Deutsche Telekom. All rights reserved. +# Copyright (c) 2021 Samsung Electronics. 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# ============LICENSE_END========================================================= + +""" +Look for CBS broker and return application config; if not present, look for +env variable that specifies JSON equiv of CBS config (typically used for +testing purposes) +""" + +__docformat__ = "restructuredtext" + +import json +import os +from onap_dcae_cbs_docker_client.client import get_config +from mod import htbt_settings as tds +from mod.htbt_exit import cleanup, cleanup_and_exit +from mod.htbt_io import stdout_logger + +prog_name = os.path.basename(__file__) + + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# function: htbt_get_config_sim +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + + +def get_cbs_config(): + """ + Get config values from CBS or JSON file (fallback) + :Parameters: + none + :Exceptions: + """ + + tds.c_config = {} + + # See if we are in a config binding service (CBS) /controller environment + try: + msg = "Unable to fetch CBS config or it is erroneously empty - trying override/simulator config" + tds.c_config = get_config() + stdout_logger("CBS client lib response : " + str(tds.c_config)) + if tds.c_config == {}: + stdout_logger(msg) + + # if no CBS present, default to JSON config specified via CBS_HTBT_JSON env var + except Exception as e: + msg = "ONAP controller not present, trying json config override via CBS_HTBT_JSON env variableo, " + str(e) + stdout_logger(msg) + + try: + msg = "CBS_HTBT_JSON not defined - FATAL ERROR, exiting" + _cbs_sim_json_file = os.getenv("CBS_HTBT_JSON", "None") + except Exception: + stdout_logger(msg) + cleanup(1, None) + return False + + msg = "CBS_HTBT_JSON not defined - FATAL ERROR, exiting" + if _cbs_sim_json_file == "None": + stdout_logger(msg) + cleanup(1, None) + return False + else: + msg = "ONAP controller override specified via CBS_HTBT_JSON: %s" % _cbs_sim_json_file + stdout_logger(msg) + msg = "Unable to load CBS_HTBT_JSON " + _cbs_sim_json_file + " (invalid json?) - FATAL ERROR, exiting" + try: + tds.c_config = json.load(open(_cbs_sim_json_file)) + except Exception: + stdout_logger(msg) + cleanup_and_exit(0, None) + + # recalc timeout, set default if not present + try: + tds.timeout_seconds = tds.c_config["publisher.http_timeout_milliseconds"] / 1000.0 + except Exception: + tds.timeout_seconds = 1.5 + + # recalc seconds_between_retries, set default if not present + try: + tds.seconds_between_retries = tds.c_config["publisher.http_milliseconds_between_retries"] / 1000.0 + except Exception: + tds.seconds_between_retries = 0.750 + + # recalc min_severity_to_log, set default if not present + try: + tds.minimum_severity_to_log = tds.c_config["files.minimum_severity_to_log"] + except Exception: + tds.minimum_severity_to_log = 3 + + try: + tds.publisher_retries = tds.c_config["publisher.http_retries"] + except Exception: + tds.publisher_retries = 3 + + return True diff --git a/miss_htbt_service/mod/htbt_http_session.py b/miss_htbt_service/mod/htbt_http_session.py new file mode 100644 index 0000000..f0a409a --- /dev/null +++ b/miss_htbt_service/mod/htbt_http_session.py @@ -0,0 +1,53 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2017-2023 AT&T Intellectual Property. 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# ============LICENSE_END========================================================= + +""" +htbt_http_session establishes an http session for future use in publishing +messages to the dmaap cluster. +""" + +__docformat__ = "restructuredtext" + +import os +import requests + +prog_name = os.path.basename(__file__) + + +# # # # # # # # # # # # # +# fx: init_session_obj +# # # # # # # # # # # # # +def init_session_obj(): + """ + Initializes and returns a http request session object for later use + :Parameters: + none + :Exceptions: + session object creation + this function will throw an exception if unable to create + a new session object + :Keywords: + http request session + :Variables: + none + """ + + try: + _loc_session = requests.Session() + except Exception: + return None + + return _loc_session diff --git a/miss_htbt_service/mod/htbt_io.py b/miss_htbt_service/mod/htbt_io.py new file mode 100644 index 0000000..3f16a7b --- /dev/null +++ b/miss_htbt_service/mod/htbt_io.py @@ -0,0 +1,52 @@ +# ============LICENSE_START=======================================================) +# Copyright (c) 2018-2023 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2019 Pantheon.tech. All rights reserved. +# Copyright (c) 2020 Deutsche Telekom. 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# ============LICENSE_END========================================================= + +""" +""" + +__docformat__ = "restructuredtext" + +# basics +import datetime +import os + +prog_name = os.path.basename(__file__) + +# # # # # # # # # # # # # +# fx: stdout_logger +# # # # # # # # # # # # # + + +def stdout_logger(_msg): + """ + Log info/errors to stdout. This is done: + - for critical runtime issues + + :Parameters: + _msg + message to print + :Exceptions: + none + :Keywords: + log stdout + :Variables: + """ + + t_out = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S,%f")[:-3] + + print("%s %s" % (t_out, _msg)) diff --git a/miss_htbt_service/mod/htbt_runtime_pid.py b/miss_htbt_service/mod/htbt_runtime_pid.py new file mode 100644 index 0000000..d086ed2 --- /dev/null +++ b/miss_htbt_service/mod/htbt_runtime_pid.py @@ -0,0 +1,82 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2017-2023 AT&T Intellectual Property. 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# ============LICENSE_END========================================================= + +""" +htbt_runtime_pid maintains a 'PID file' (file that contains the +PID of currently running trap receiver) +""" + +__docformat__ = "restructuredtext" + +import os + +prog_name = os.path.basename(__file__) + + +# # # # # # # # # # # # # +# fx: save_pid - save PID of running process +# # # # # # # # # # # # # +def save_pid(_pid_file_name): + """ + Save the current process ID in a file for external + access. + :Parameters: + none + :Exceptions: + file open + this function will catch exception of unable to + open/create _pid_file_name + :Keywords: + pid /var/run + """ + + try: + pid_fd = open(_pid_file_name, "w") + pid_fd.write("%d" % os.getpid()) + pid_fd.close() + except IOError: + print("IOError saving PID file %s :" % _pid_file_name) + return False + else: + return True + + +# # # # # # # # # # # # # +# fx: rm_pid - remove PID of running process +# # # # # # # # # # # # # +def rm_pid(_pid_file_name): + """ + Remove the current process ID file before exiting. + :Parameters: + none + :Exceptions: + file open + this function will catch exception of unable to find or remove + _pid_file_name + :Keywords: + pid /var/run + """ + + try: + if os.path.isfile(_pid_file_name): + os.remove(_pid_file_name) + return True + else: + return False + + except IOError: + print("Error removing Runtime PID file: %s" % _pid_file_name) + return False diff --git a/miss_htbt_service/mod/htbt_settings.py b/miss_htbt_service/mod/htbt_settings.py new file mode 100644 index 0000000..b5b58cc --- /dev/null +++ b/miss_htbt_service/mod/htbt_settings.py @@ -0,0 +1,165 @@ +# ============LICENSE_START=======================================================) +# Copyright (c) 2018-2023 AT&T Intellectual Property. 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# ============LICENSE_END========================================================= + +""" +""" + +__docformat__ = "restructuredtext" + + +def init(): + + # + # consul config or simulated via json file + global c_config + c_config = None + # + + # + # + # dns_cache_ip_to_name + # key [ip address] -> fqdn + # dns_cache_ip_expires + # key [ip address] -> epoch time this entry expires and must + # be reloaded + global dns_cache_ip_to_name + dns_cache_ip_to_name = {} + global dns_cache_ip_expires + dns_cache_ip_expires = {} + # + + # + global eelf_error_file_name + eelf_error_file_name = "" + global eelf_error_fd + eelf_error_fd = None + + global eelf_debug_file_name + eelf_debug_file_name = "" + global eelf_debug_fd + eelf_debug_fd = None + + global eelf_audit_file_name + eelf_audit_file_name = "" + global eelf_audit_fd + eelf_audit_fd = None + + global eelf_metrics_file_name + eelf_metrics_file_name = "" + global eelf_metrics_fd + eelf_metrics_fd = None + + global last_minute + last_minute = 0 + global last_hour + last_hour = 0 + global last_day + last_day = 0 + # + + # + + # + global traps_in_minute + traps_in_minute = 0 + global last_epoch_second + last_epoch_second = 0 + global traps_since_last_publish + traps_since_last_publish = 0 + global last_pub_time + last_pub_time = 0 + global milliseconds_since_last_publish + milliseconds_since_last_publish = 0 + global timeout_seconds + timeout_seconds = 1.5 + global seconds_between_retries + seconds_between_retries = 2 + global publisher_retries + publisher_retries = 2 + # + + # + global http_requ_session + http_requ_session = None + # + + # + global json_traps_filename + json_traps_filename = "" + global json_traps_fd + json_traps_fd = None + # + + # + global arriving_traps_filename + arriving_traps_filename = "" + global arriving_traps_fd + arriving_traps_fd = None + # + + # + global pid_file_name + pid_file_name = "" + + # + global LOG_TYPES + global LOG_TYPE_NONE + global LOG_TYPE_ERROR + global LOG_TYPE_DEBUG + global LOG_TYPE_AUDIT + global LOG_TYPE_METRICS + LOG_TYPES = ["none", "ERROR", "DEBUG", "AUDIT", "METRICS"] + LOG_TYPE_NONE = 0 + LOG_TYPE_ERROR = 1 + LOG_TYPE_DEBUG = 2 + LOG_TYPE_AUDIT = 3 + LOG_TYPE_METRICS = 4 + + global SEV_TYPES + global SEV_NONE + global SEV_DETAILED + global SEV_INFO + global SEV_WARN + global SEV_CRIT + global SEV_FATAL + SEV_TYPES = ["none", "DETAILED", "INFO", "WARN", "CRITICAL", "FATAL"] + SEV_NONE = 0 + SEV_DETAILED = 1 + SEV_INFO = 2 + SEV_WARN = 3 + SEV_CRIT = 4 + SEV_FATAL = 5 + + global CODE_GENERAL + CODE_GENERAL = "100" + + global minimum_severity_to_log + minimum_severity_to_log = 3 + + # diff --git a/miss_htbt_service/mod/htbt_vnf_table.py b/miss_htbt_service/mod/htbt_vnf_table.py new file mode 100644 index 0000000..3396e80 --- /dev/null +++ b/miss_htbt_service/mod/htbt_vnf_table.py @@ -0,0 +1,250 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2017-2023 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2019 Pantheon.tech. All rights reserved. +# Copyright (c) 2020 Deutsche Telekom. All rights reserved. +# Copyright (c) 2021 Samsung Electronics. All rights reserved. +# Copyright (c) 2021 Fujitsu Ltd. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# ============LICENSE_END========================================================= +# +# Author Kiran Mandal (km386e) + +""" +htbt_vnf_table verifies the successful creation of DB Tables. +""" +import logging +import os +import yaml +import os.path as path +import time +import subprocess + +import db_monitoring as dbmon +import htbtworker as pm +import misshtbtd as db +import cbs_polling as cbs + +prog_name = os.path.basename(__file__) +hb_properties_file = path.abspath(path.join(__file__, "../../config/hbproperties.yaml")) +_logger = logging.getLogger(__name__) + + +def hb_properties(): + # Read the hbproperties.yaml for postgress and CBS related data + s = open(hb_properties_file, "r") + a = yaml.full_load(s) + ip_address = a["pg_ipAddress"] + port_num = a["pg_portNum"] + user_name = a["pg_userName"] + password = a["pg_passwd"] + db_name = a["pg_dbName"] + db_name = db_name.lower() + cbs_polling_required = a["CBS_polling_allowed"] + cbs_polling_interval = a["CBS_polling_interval"] + 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() + try: + _db_status = db.db_table_creation_check(connection_db, "vnf_table_1") + except Exception: + 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() + try: + _db_status = db.db_table_creation_check(connection_db, "vnf_table_2") + except Exception: + return None + + return _db_status + + +def verify_DB_creation_hb_common(): + + connection_db = pm.postgres_db_open() + try: + _db_status = db.db_table_creation_check(connection_db, "hb_common") + except Exception: + return None + + return _db_status + + +def verify_cbspolling(): + os.environ["pytest"] = "test" + os.environ["SERVICE_NAME"] = "mvp-dcaegen2-heartbeat-static" + cbs.poll_cbs(10) + os.unsetenv("pytest") + os.unsetenv("SERVICE_NAME") + + +def verify_fetch_json_file(): + os.environ["pytest"] = "test" + os.environ["SERVICE_NAME"] = "mvp-dcaegen2-heartbeat-static" + os.environ["CONSUL_HOST"] = "localhost" + os.environ["HOSTNAME"] = "mvp-dcaegen2-heartbeat-static" + try: + db.fetch_json_file() + result = True + except Exception: + result = False + print(result) + os.unsetenv("pytest") + os.unsetenv("SERVICE_NAME") + os.unsetenv("CONSUL_HOST") + os.unsetenv("HOSTNAME") + return result + + +def verify_misshtbtdmain(): + os.environ["pytest"] = "test" + os.environ["SERVICE_NAME"] = "mvp-dcaegen2-heartbeat-static" + os.environ["CONSUL_HOST"] = "localhost" + os.environ["HOSTNAME"] = "mvp-dcaegen2-heartbeat-static" + + try: + db.main() + result = True + except Exception: + result = False + print(result) + os.unsetenv("pytest") + os.unsetenv("SERVICE_NAME") + os.unsetenv("CONSUL_HOST") + os.unsetenv("HOSTNAME") + return result + + +def verify_dbmonitoring(): + os.environ["pytest"] = "test" + os.environ["SERVICE_NAME"] = "mvp-dcaegen2-heartbeat-static" + os.environ["CONSUL_HOST"] = "localhost" + os.environ["HOSTNAME"] = "mvp-dcaegen2-heartbeat-static" + try: + jsfile = db.fetch_json_file() + ip_address, port_num, user_name, password, db_name, cbs_polling_required, cbs_polling_interval = hb_properties() + hbc_pid, hbc_state, hbc_src_name, hbc_time = db.read_hb_common( + user_name, password, ip_address, port_num, db_name + ) + 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 - %s" % e) + result = False + print(result) + os.unsetenv("pytest") + os.unsetenv("SERVICE_NAME") + os.unsetenv("CONSUL_HOST") + os.unsetenv("HOSTNAME") + return result + + +def verify_dbmon_startup(): + try: + p = subprocess.Popen(["./miss_htbt_service/db_monitoring.py"], stdout=subprocess.PIPE, shell=True) + time.sleep(1) + except Exception: + return None + return True + + +def verify_sendControlLoop_VNF_ONSET(): + try: + 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: + return None + return _CL_return + + +def verify_sendControlLoop_VM_ONSET(): + try: + 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: + return None + return _CL_return + + +def verify_sendControlLoop_VNF_ABATED(): + try: + 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: + return None + return _CL_return + + +def verify_sendControlLoop_VM_ABATED(): + try: + 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: + return None + return _CL_return diff --git a/miss_htbt_service/mod/trapd_exit.py b/miss_htbt_service/mod/trapd_exit.py deleted file mode 100644 index 7791b31..0000000 --- a/miss_htbt_service/mod/trapd_exit.py +++ /dev/null @@ -1,89 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2017-2022 AT&T Intellectual Property. All rights reserved. -# Copyright (c) 2019 Pantheon.tech. All rights reserved. -# Copyright (c) 2020 Deutsche Telekom. 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# ============LICENSE_END========================================================= - -""" -trapc_exit_snmptrapd is responsible for removing any existing runtime PID -file, and exiting with the provided (param 1) exit code -""" - -__docformat__ = "restructuredtext" - -import sys -import os -from mod.trapd_runtime_pid import rm_pid - -prog_name = os.path.basename(__file__) - - -# # # # # # # # # # # # # -# fx: cleanup_and_exit -# - remove pid file -# - exit with supplied return code -# # # # # # # # # # # # # -def cleanup_and_exit(_loc_exit_code, _pid_file_name): - """ - Remove existing PID file, and exit with provided exit code - :Parameters: - _loc_exit_code - value to return to calling shell upon exit - _pid_file_name - name of file that contains current process ID (for - removal) - :Exceptions: - none - :Keywords: - runtime PID exit - :Variables: - _num_params - number of parameters passed to module - """ - - # _num_params = len(locals()) - - if _pid_file_name is not None: - rm_pid(_pid_file_name) - sys.exit(_loc_exit_code) - - -# # # # # # # # # # # # # -# fx: cleanup_and_exit -# - remove pid file -# - exit with supplied return code -# # # # # # # # # # # # # -def cleanup(_loc_exit_code, _pid_file_name): - """ - Remove existing PID file, and exit with provided exit code - :Parameters: - _loc_exit_code - value to return to calling shell upon exit - _pid_file_name - name of file that contains current process ID (for - removal) - :Exceptions: - none - :Keywords: - runtime PID exit - :Variables: - _num_params - number of parameters passed to module - """ - - # _num_params = len(locals()) - - if _pid_file_name is not None: - rm_pid(_pid_file_name) diff --git a/miss_htbt_service/mod/trapd_get_cbs_config.py b/miss_htbt_service/mod/trapd_get_cbs_config.py deleted file mode 100644 index 034b32b..0000000 --- a/miss_htbt_service/mod/trapd_get_cbs_config.py +++ /dev/null @@ -1,112 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2018-2022 AT&T Intellectual Property. All rights reserved. -# Copyright (c) 2019 Pantheon.tech. All rights reserved. -# Copyright (c) 2020 Deutsche Telekom. All rights reserved. -# Copyright (c) 2021 Samsung Electronics. 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# ============LICENSE_END========================================================= - -""" -Look for CBS broker and return application config; if not present, look for -env variable that specifies JSON equiv of CBS config (typically used for -testing purposes) -""" - -__docformat__ = "restructuredtext" - -import json -import os -from onap_dcae_cbs_docker_client.client import get_config -from mod import trapd_settings as tds -from mod.trapd_exit import cleanup, cleanup_and_exit -from mod.trapd_io import stdout_logger - -prog_name = os.path.basename(__file__) - - -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# function: trapd_get_config_sim -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - - -def get_cbs_config(): - """ - Get config values from CBS or JSON file (fallback) - :Parameters: - none - :Exceptions: - """ - - tds.c_config = {} - - # See if we are in a config binding service (CBS) /controller environment - try: - msg = "Unable to fetch CBS config or it is erroneously empty - trying override/simulator config" - tds.c_config = get_config() - stdout_logger("CBS client lib response : " + str(tds.c_config)) - if tds.c_config == {}: - stdout_logger(msg) - - # if no CBS present, default to JSON config specified via CBS_HTBT_JSON env var - except Exception as e: - msg = "ONAP controller not present, trying json config override via CBS_HTBT_JSON env variableo, " + str(e) - stdout_logger(msg) - - try: - msg = "CBS_HTBT_JSON not defined - FATAL ERROR, exiting" - _cbs_sim_json_file = os.getenv("CBS_HTBT_JSON", "None") - except Exception: - stdout_logger(msg) - cleanup(1, None) - return False - - msg = "CBS_HTBT_JSON not defined - FATAL ERROR, exiting" - if _cbs_sim_json_file == "None": - stdout_logger(msg) - cleanup(1, None) - return False - else: - msg = "ONAP controller override specified via CBS_HTBT_JSON: %s" % _cbs_sim_json_file - stdout_logger(msg) - msg = "Unable to load CBS_HTBT_JSON " + _cbs_sim_json_file + " (invalid json?) - FATAL ERROR, exiting" - try: - tds.c_config = json.load(open(_cbs_sim_json_file)) - except Exception: - stdout_logger(msg) - cleanup_and_exit(0, None) - - # recalc timeout, set default if not present - try: - tds.timeout_seconds = tds.c_config["publisher.http_timeout_milliseconds"] / 1000.0 - except Exception: - tds.timeout_seconds = 1.5 - - # recalc seconds_between_retries, set default if not present - try: - tds.seconds_between_retries = tds.c_config["publisher.http_milliseconds_between_retries"] / 1000.0 - except Exception: - tds.seconds_between_retries = 0.750 - - # recalc min_severity_to_log, set default if not present - try: - tds.minimum_severity_to_log = tds.c_config["files.minimum_severity_to_log"] - except Exception: - tds.minimum_severity_to_log = 3 - - try: - tds.publisher_retries = tds.c_config["publisher.http_retries"] - except Exception: - tds.publisher_retries = 3 - - return True diff --git a/miss_htbt_service/mod/trapd_http_session.py b/miss_htbt_service/mod/trapd_http_session.py deleted file mode 100644 index 17eb302..0000000 --- a/miss_htbt_service/mod/trapd_http_session.py +++ /dev/null @@ -1,53 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2017-2022 AT&T Intellectual Property. 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# ============LICENSE_END========================================================= - -""" -trapd_http_session establishes an http session for future use in publishing -messages to the dmaap cluster. -""" - -__docformat__ = "restructuredtext" - -import os -import requests - -prog_name = os.path.basename(__file__) - - -# # # # # # # # # # # # # -# fx: init_session_obj -# # # # # # # # # # # # # -def init_session_obj(): - """ - Initializes and returns a http request session object for later use - :Parameters: - none - :Exceptions: - session object creation - this function will throw an exception if unable to create - a new session object - :Keywords: - http request session - :Variables: - none - """ - - try: - _loc_session = requests.Session() - except Exception: - return None - - return _loc_session diff --git a/miss_htbt_service/mod/trapd_io.py b/miss_htbt_service/mod/trapd_io.py deleted file mode 100644 index 26445fc..0000000 --- a/miss_htbt_service/mod/trapd_io.py +++ /dev/null @@ -1,52 +0,0 @@ -# ============LICENSE_START=======================================================) -# Copyright (c) 2018-2022 AT&T Intellectual Property. All rights reserved. -# Copyright (c) 2019 Pantheon.tech. All rights reserved. -# Copyright (c) 2020 Deutsche Telekom. 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# ============LICENSE_END========================================================= - -""" -""" - -__docformat__ = "restructuredtext" - -# basics -import datetime -import os - -prog_name = os.path.basename(__file__) - -# # # # # # # # # # # # # -# fx: stdout_logger -# # # # # # # # # # # # # - - -def stdout_logger(_msg): - """ - Log info/errors to stdout. This is done: - - for critical runtime issues - - :Parameters: - _msg - message to print - :Exceptions: - none - :Keywords: - log stdout - :Variables: - """ - - t_out = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S,%f")[:-3] - - print("%s %s" % (t_out, _msg)) diff --git a/miss_htbt_service/mod/trapd_runtime_pid.py b/miss_htbt_service/mod/trapd_runtime_pid.py deleted file mode 100644 index 823d29f..0000000 --- a/miss_htbt_service/mod/trapd_runtime_pid.py +++ /dev/null @@ -1,82 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2017-2022 AT&T Intellectual Property. 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# ============LICENSE_END========================================================= - -""" -trapd_runtime_pid maintains a 'PID file' (file that contains the -PID of currently running trap receiver) -""" - -__docformat__ = "restructuredtext" - -import os - -prog_name = os.path.basename(__file__) - - -# # # # # # # # # # # # # -# fx: save_pid - save PID of running process -# # # # # # # # # # # # # -def save_pid(_pid_file_name): - """ - Save the current process ID in a file for external - access. - :Parameters: - none - :Exceptions: - file open - this function will catch exception of unable to - open/create _pid_file_name - :Keywords: - pid /var/run - """ - - try: - pid_fd = open(_pid_file_name, "w") - pid_fd.write("%d" % os.getpid()) - pid_fd.close() - except IOError: - print("IOError saving PID file %s :" % _pid_file_name) - return False - else: - return True - - -# # # # # # # # # # # # # -# fx: rm_pid - remove PID of running process -# # # # # # # # # # # # # -def rm_pid(_pid_file_name): - """ - Remove the current process ID file before exiting. - :Parameters: - none - :Exceptions: - file open - this function will catch exception of unable to find or remove - _pid_file_name - :Keywords: - pid /var/run - """ - - try: - if os.path.isfile(_pid_file_name): - os.remove(_pid_file_name) - return True - else: - return False - - except IOError: - print("Error removing Runtime PID file: %s" % _pid_file_name) - return False diff --git a/miss_htbt_service/mod/trapd_settings.py b/miss_htbt_service/mod/trapd_settings.py deleted file mode 100644 index 0f6a9a1..0000000 --- a/miss_htbt_service/mod/trapd_settings.py +++ /dev/null @@ -1,165 +0,0 @@ -# ============LICENSE_START=======================================================) -# Copyright (c) 2018-2022 AT&T Intellectual Property. 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# ============LICENSE_END========================================================= - -""" -""" - -__docformat__ = "restructuredtext" - - -def init(): - - # - # consul config or simulated via json file - global c_config - c_config = None - # - - # - # - # dns_cache_ip_to_name - # key [ip address] -> fqdn - # dns_cache_ip_expires - # key [ip address] -> epoch time this entry expires and must - # be reloaded - global dns_cache_ip_to_name - dns_cache_ip_to_name = {} - global dns_cache_ip_expires - dns_cache_ip_expires = {} - # - - # - global eelf_error_file_name - eelf_error_file_name = "" - global eelf_error_fd - eelf_error_fd = None - - global eelf_debug_file_name - eelf_debug_file_name = "" - global eelf_debug_fd - eelf_debug_fd = None - - global eelf_audit_file_name - eelf_audit_file_name = "" - global eelf_audit_fd - eelf_audit_fd = None - - global eelf_metrics_file_name - eelf_metrics_file_name = "" - global eelf_metrics_fd - eelf_metrics_fd = None - - global last_minute - last_minute = 0 - global last_hour - last_hour = 0 - global last_day - last_day = 0 - # - - # - - # - global traps_in_minute - traps_in_minute = 0 - global last_epoch_second - last_epoch_second = 0 - global traps_since_last_publish - traps_since_last_publish = 0 - global last_pub_time - last_pub_time = 0 - global milliseconds_since_last_publish - milliseconds_since_last_publish = 0 - global timeout_seconds - timeout_seconds = 1.5 - global seconds_between_retries - seconds_between_retries = 2 - global publisher_retries - publisher_retries = 2 - # - - # - global http_requ_session - http_requ_session = None - # - - # - global json_traps_filename - json_traps_filename = "" - global json_traps_fd - json_traps_fd = None - # - - # - global arriving_traps_filename - arriving_traps_filename = "" - global arriving_traps_fd - arriving_traps_fd = None - # - - # - global pid_file_name - pid_file_name = "" - - # - global LOG_TYPES - global LOG_TYPE_NONE - global LOG_TYPE_ERROR - global LOG_TYPE_DEBUG - global LOG_TYPE_AUDIT - global LOG_TYPE_METRICS - LOG_TYPES = ["none", "ERROR", "DEBUG", "AUDIT", "METRICS"] - LOG_TYPE_NONE = 0 - LOG_TYPE_ERROR = 1 - LOG_TYPE_DEBUG = 2 - LOG_TYPE_AUDIT = 3 - LOG_TYPE_METRICS = 4 - - global SEV_TYPES - global SEV_NONE - global SEV_DETAILED - global SEV_INFO - global SEV_WARN - global SEV_CRIT - global SEV_FATAL - SEV_TYPES = ["none", "DETAILED", "INFO", "WARN", "CRITICAL", "FATAL"] - SEV_NONE = 0 - SEV_DETAILED = 1 - SEV_INFO = 2 - SEV_WARN = 3 - SEV_CRIT = 4 - SEV_FATAL = 5 - - global CODE_GENERAL - CODE_GENERAL = "100" - - global minimum_severity_to_log - minimum_severity_to_log = 3 - - # diff --git a/miss_htbt_service/mod/trapd_vnf_table.py b/miss_htbt_service/mod/trapd_vnf_table.py deleted file mode 100644 index f9fecbb..0000000 --- a/miss_htbt_service/mod/trapd_vnf_table.py +++ /dev/null @@ -1,250 +0,0 @@ -# ============LICENSE_START======================================================= -# Copyright (c) 2017-2022 AT&T Intellectual Property. All rights reserved. -# Copyright (c) 2019 Pantheon.tech. All rights reserved. -# Copyright (c) 2020 Deutsche Telekom. All rights reserved. -# Copyright (c) 2021 Samsung Electronics. All rights reserved. -# Copyright (c) 2021 Fujitsu Ltd. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. -# ============LICENSE_END========================================================= -# -# Author Kiran Mandal (km386e) - -""" -trapd_vnf_table verifies the successful creation of DB Tables. -""" -import logging -import os -import yaml -import os.path as path -import time -import subprocess - -import db_monitoring as dbmon -import htbtworker as pm -import misshtbtd as db -import cbs_polling as cbs - -prog_name = os.path.basename(__file__) -hb_properties_file = path.abspath(path.join(__file__, "../../config/hbproperties.yaml")) -_logger = logging.getLogger(__name__) - - -def hb_properties(): - # Read the hbproperties.yaml for postgress and CBS related data - s = open(hb_properties_file, "r") - a = yaml.full_load(s) - ip_address = a["pg_ipAddress"] - port_num = a["pg_portNum"] - user_name = a["pg_userName"] - password = a["pg_passwd"] - db_name = a["pg_dbName"] - db_name = db_name.lower() - cbs_polling_required = a["CBS_polling_allowed"] - cbs_polling_interval = a["CBS_polling_interval"] - 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) - try: - _db_status = pm.db_table_creation_check(connection_db, "vnf_table_1") - except Exception: - 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) - try: - _db_status = pm.db_table_creation_check(connection_db, "vnf_table_2") - except Exception: - 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) - try: - _db_status = pm.db_table_creation_check(connection_db, "hb_common") - except Exception: - return None - - return _db_status - - -def verify_cbspolling(): - os.environ["pytest"] = "test" - os.environ["SERVICE_NAME"] = "mvp-dcaegen2-heartbeat-static" - cbs.poll_cbs(10) - os.unsetenv("pytest") - os.unsetenv("SERVICE_NAME") - - -def verify_fetch_json_file(): - os.environ["pytest"] = "test" - os.environ["SERVICE_NAME"] = "mvp-dcaegen2-heartbeat-static" - os.environ["CONSUL_HOST"] = "localhost" - os.environ["HOSTNAME"] = "mvp-dcaegen2-heartbeat-static" - try: - db.fetch_json_file() - result = True - except Exception: - result = False - print(result) - os.unsetenv("pytest") - os.unsetenv("SERVICE_NAME") - os.unsetenv("CONSUL_HOST") - os.unsetenv("HOSTNAME") - return result - - -def verify_misshtbtdmain(): - os.environ["pytest"] = "test" - os.environ["SERVICE_NAME"] = "mvp-dcaegen2-heartbeat-static" - os.environ["CONSUL_HOST"] = "localhost" - os.environ["HOSTNAME"] = "mvp-dcaegen2-heartbeat-static" - - try: - db.main() - result = True - except Exception: - result = False - print(result) - os.unsetenv("pytest") - os.unsetenv("SERVICE_NAME") - os.unsetenv("CONSUL_HOST") - os.unsetenv("HOSTNAME") - return result - - -def verify_dbmonitoring(): - os.environ["pytest"] = "test" - os.environ["SERVICE_NAME"] = "mvp-dcaegen2-heartbeat-static" - os.environ["CONSUL_HOST"] = "localhost" - os.environ["HOSTNAME"] = "mvp-dcaegen2-heartbeat-static" - try: - jsfile = db.fetch_json_file() - ip_address, port_num, user_name, password, db_name, cbs_polling_required, cbs_polling_interval = hb_properties() - hbc_pid, hbc_state, hbc_src_name, hbc_time = db.read_hb_common( - user_name, password, ip_address, port_num, db_name - ) - 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 - %s" % e) - result = False - print(result) - os.unsetenv("pytest") - os.unsetenv("SERVICE_NAME") - os.unsetenv("CONSUL_HOST") - os.unsetenv("HOSTNAME") - return result - - -def verify_dbmon_startup(): - try: - p = subprocess.Popen(["./miss_htbt_service/db_monitoring.py"], stdout=subprocess.PIPE, shell=True) - time.sleep(1) - except Exception: - return None - return True - - -def verify_sendControlLoop_VNF_ONSET(): - try: - 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: - return None - return _CL_return - - -def verify_sendControlLoop_VM_ONSET(): - try: - 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: - return None - return _CL_return - - -def verify_sendControlLoop_VNF_ABATED(): - try: - 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: - return None - return _CL_return - - -def verify_sendControlLoop_VM_ABATED(): - try: - 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: - return None - return _CL_return -- cgit 1.2.3-korg