From: garciadeblas Date: Fri, 12 Jul 2024 12:44:11 +0000 (+0200) Subject: Revert "Feature 11039: Modification of Audit logs in NBI for password change and... X-Git-Tag: release-v16.0-start~14 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F88%2F14488%2F1;p=osm%2FNBI.git Revert "Feature 11039: Modification of Audit logs in NBI for password change and NS operations" This reverts commit e1f864e2c7b09348c5e2fa5a63e5dd32e89572f5. Change-Id: I23573d9f58c861bf9685184d6f6d62c390327af8 Signed-off-by: garciadeblas --- diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index 53f40e9..de0ad1f 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -1127,7 +1127,6 @@ class UserTopicAuth(UserTopic): "system_admin_id": indata.get("system_admin_id"), "unlock": indata.get("unlock"), "renew": indata.get("renew"), - "session_user": session.get("username"), } ) data_to_send = {"_id": _id, "changes": indata} diff --git a/osm_nbi/authconn_internal.py b/osm_nbi/authconn_internal.py index 94e6e47..8b94a4c 100644 --- a/osm_nbi/authconn_internal.py +++ b/osm_nbi/authconn_internal.py @@ -669,9 +669,7 @@ class AuthconnInternal(Authconn): { "name": "Change Password", "sourceUserName": user_data["username"], - "message": "User {} changing Password for user {}, Outcome=Success".format( - user_info.get("session_user"), user_data["username"] - ), + "message": "Changing Password for user, Outcome=Success", "severity": "2", }, ) diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index 115f433..9d2da99 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -2311,7 +2311,6 @@ class NsLcmOpTopic(BaseTopic): return ( None, None, - None, ) # a none in this case is used to indicate not instantiated. It can be removed if operation != "instantiate": raise EngineException( @@ -2400,7 +2399,6 @@ class NsLcmOpTopic(BaseTopic): indata["newVdur"] = vnfr_descriptor["vdur"] nslcmop_desc = self._create_nslcmop(nsInstanceId, operation, indata) _id = nslcmop_desc["_id"] - nsName = nsr.get("name") self.format_on_new( nslcmop_desc, session["project_id"], make_public=session["public"] ) @@ -2413,7 +2411,7 @@ class NsLcmOpTopic(BaseTopic): rollback.append({"topic": "nslcmops", "_id": _id}) if not slice_object: self.msg.write("ns", operation, nslcmop_desc) - return _id, nsName, None + return _id, None except ValidationError as e: # TODO remove try Except, it is captured at nbi.py raise EngineException(e, HTTPStatus.UNPROCESSABLE_ENTITY) # except DbException as e: diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index e4b7368..e1d3c11 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -1599,21 +1599,21 @@ class Server(object): # creates nslcmop indata["lcmOperationType"] = "instantiate" indata["nsInstanceId"] = _id - nslcmop_id, nsName, _ = self.engine.new_item( + nslcmop_id, _ = self.engine.new_item( rollback, engine_session, "nslcmops", indata, None ) self._set_location_header(main_topic, version, topic, _id) - outdata = {"id": _id, "nslcmop_id": nslcmop_id, "nsName": nsName} + outdata = {"id": _id, "nslcmop_id": nslcmop_id} elif topic == "ns_instances" and item: indata["lcmOperationType"] = item indata["nsInstanceId"] = _id - _id, nsName, _ = self.engine.new_item( + _id, _ = self.engine.new_item( rollback, engine_session, "nslcmops", indata, kwargs ) self._set_location_header( main_topic, version, "ns_lcm_op_occs", _id ) - outdata = {"id": _id, "nsName": nsName} + outdata = {"id": _id} cherrypy.response.status = HTTPStatus.ACCEPTED.value elif topic == "netslice_instances_content": # creates NetSlice_Instance_record (NSIR) @@ -1666,13 +1666,13 @@ class Server(object): elif topic == "vnf_instances" and item: indata["lcmOperationType"] = item indata["vnfInstanceId"] = _id - _id, nsName, _ = self.engine.new_item( + _id, _ = self.engine.new_item( rollback, engine_session, "vnflcmops", indata, kwargs ) self._set_location_header( main_topic, version, "vnf_lcm_op_occs", _id ) - outdata = {"id": _id, "nsName": nsName} + outdata = {"id": _id} cherrypy.response.status = HTTPStatus.ACCEPTED.value elif topic == "ns_lcm_op_occs" and item == "cancel": indata["nsLcmOpOccId"] = _id @@ -1712,11 +1712,11 @@ class Server(object): "nsInstanceId": _id, "autoremove": True, } - op_id, nsName, _ = self.engine.new_item( + op_id, _ = self.engine.new_item( rollback, engine_session, "nslcmops", nslcmop_desc, kwargs ) if op_id: - outdata = {"_id": op_id, "nsName": nsName} + outdata = {"_id": op_id} elif ( topic == "netslice_instances_content" and not engine_session["force"] @@ -1792,62 +1792,12 @@ class Server(object): ): self.authenticator.remove_token_from_cache() - cef_event( - cef_logger, - { - "name": "User Operation", - "sourceUserName": token_info.get("username"), - }, - ) - if topic == "ns_instances_content" and url_id: - nsName = ( - outdata.get("name") if method == "GET" else outdata.get("nsName") - ) - cef_event( - cef_logger, - { - "message": "{} {}, nsName={}, nsdId={}, Project={} Outcome=Success".format( - log_mapping[method], - topic, - nsName, - outdata.get("id"), - token_info.get("project_name"), - ), - }, - ) - cherrypy.log("{}".format(cef_logger)) - elif topic == "ns_instances_content" and method == "POST": - cef_event( - cef_logger, - { - "message": "{} {}, nsName={}, nsdId={}, Project={} Outcome=Success".format( - log_mapping[method], - topic, - outdata.get("nsName"), - outdata.get("id"), - token_info.get("project_name"), - ), - }, - ) - cherrypy.log("{}".format(cef_logger)) - elif topic in ("ns_instances", "vnf_instances") and item: - cef_event( - cef_logger, - { - "message": "{} {}, nsName={}, nsdId={}, Project={} Outcome=Success".format( - log_mapping[method], - topic, - outdata.get("nsName"), - url_id, - token_info.get("project_name"), - ), - }, - ) - cherrypy.log("{}".format(cef_logger)) - elif item is not None: + if item is not None: cef_event( cef_logger, { + "name": "User Operation", + "sourceUserName": token_info.get("username"), "message": "Performing {} operation on {} {}, Project={} Outcome=Success".format( item, topic, @@ -1861,6 +1811,8 @@ class Server(object): cef_event( cef_logger, { + "name": "User Operation", + "sourceUserName": token_info.get("username"), "message": "{} {} {}, Project={} Outcome=Success".format( log_mapping[method], topic, diff --git a/osm_nbi/osm_vnfm/vnf_instance_actions.py b/osm_nbi/osm_vnfm/vnf_instance_actions.py index 17825b5..b34d203 100644 --- a/osm_nbi/osm_vnfm/vnf_instance_actions.py +++ b/osm_nbi/osm_vnfm/vnf_instance_actions.py @@ -176,11 +176,9 @@ class NewVnfLcmOp(BaseMethod): vnfr = self.vnfrtopic.show(session, vnfInstanceId) indata["vnfInstanceId"] = vnfr.get("nsr-id-ref") indata = self.__get_formatted_indata(session, indata) - op_id, nsName, _ = self.nslcmoptopic.new( - rollback, session, indata, kwargs, headers - ) + op_id, _ = self.nslcmoptopic.new(rollback, session, indata, kwargs, headers) self.notify_operation(session, vnfInstanceId, lcm_operation, op_id) - return op_id, nsName, _ + return op_id, _ class ListVnfLcmOp(BaseMethod): diff --git a/osm_nbi/tests/test_instance_topics.py b/osm_nbi/tests/test_instance_topics.py index 112700f..b12a330 100644 --- a/osm_nbi/tests/test_instance_topics.py +++ b/osm_nbi/tests/test_instance_topics.py @@ -113,7 +113,7 @@ class TestNsLcmOpTopic(unittest.TestCase): rollback = [] headers = {} - nslcmop_id, nsName, _ = self.nslcmop_topic.new( + nslcmop_id, _ = self.nslcmop_topic.new( rollback, session, indata=deepcopy(indata), kwargs=None, headers=headers ) @@ -251,7 +251,7 @@ class TestNsLcmOpTopic(unittest.TestCase): rollback = [] headers = {} - nslcmop_id, nsName, _ = self.nslcmop_topic.new( + nslcmop_id, _ = self.nslcmop_topic.new( rollback, session, indata, kwargs=None, headers=headers ) @@ -305,7 +305,7 @@ class TestNsLcmOpTopic(unittest.TestCase): "vdu": {"vduCountIndex": 0, "vduId": "mgmtVM"}, "vnfInstanceId": "9e8006df-cdfa-4f63-bf6a-fce860d71c1f", } - nslcmop_id, nsName, _ = self.nslcmop_topic.new( + nslcmop_id, _ = self.nslcmop_topic.new( rollback, session, indata, kwargs=None, headers=headers ) @@ -334,7 +334,7 @@ class TestNsLcmOpTopic(unittest.TestCase): "nsInstanceId": self.nsr_id, "vnfInstanceId": "9e8006df-cdfa-4f63-bf6a-fce860d71c1f", } - nslcmop_id, nsName, _ = self.nslcmop_topic.new( + nslcmop_id, _ = self.nslcmop_topic.new( rollback, session, indata, kwargs=None, headers=headers ) @@ -367,7 +367,7 @@ class TestNsLcmOpTopic(unittest.TestCase): } with self.assertRaises(Exception) as e: - nslcmop_id, nsName, _ = self.nslcmop_topic.new( + nslcmop_id, _ = self.nslcmop_topic.new( rollback, session, indata, kwargs=None, headers=headers ) self.assertTrue( diff --git a/osm_nbi/tests/test_osm_vnfm.py b/osm_nbi/tests/test_osm_vnfm.py index 61615b9..f4e6e63 100644 --- a/osm_nbi/tests/test_osm_vnfm.py +++ b/osm_nbi/tests/test_osm_vnfm.py @@ -183,7 +183,7 @@ class TestVnfLcmOpTopic(unittest.TestCase): } rollback = [] headers = {} - vnflcmop_id, nsName, _ = self.vnflcmop_topic.new( + vnflcmop_id, _ = self.vnflcmop_topic.new( rollback, session, indata, kwargs=None, headers=headers ) vnflcmop_info = self.db.get_one("nslcmops")