Bug 1830 fixed: maps completed operations to original operation types
[osm/NBI.git] / osm_nbi / engine.py
index e9b1549..c4c8eb2 100644 (file)
@@ -205,7 +205,7 @@ class Engine(object):
             #                 "resources_to_operations file missing")
             #
             #     with open(resources_to_operations_file, 'r') as f:
-            #         resources_to_operations = yaml.load(f, Loader=yaml.Loader)
+            #         resources_to_operations = yaml.safeload(f)
             #
             #     self.operations = []
             #
@@ -380,6 +380,26 @@ class Engine(object):
         with self.write_lock:
             return self.map_topic[topic].edit(session, _id, indata, kwargs)
 
+    def cancel_item(
+        self, rollback, session, topic, indata=None, kwargs=None, headers=None
+    ):
+        """
+        Cancels an item
+        :param rollback: list to append created items at database in case a rollback must to be done
+        :param session: contains the used login username and working project, force to avoid checkins, public
+        :param topic: it can be: users, projects, vim_accounts, sdns, nsrs, nsds, vnfds
+        :param indata: data to be inserted
+        :param kwargs: used to override the indata descriptor
+        :param headers: http request headers
+        :return: _id: identity of the inserted data.
+        """
+        if topic not in self.map_topic:
+            raise EngineException(
+                "Unknown topic {}!!!".format(topic), HTTPStatus.INTERNAL_SERVER_ERROR
+            )
+        with self.write_lock:
+            self.map_topic[topic].cancel(rollback, session, indata, kwargs, headers)
+
     def upgrade_db(self, current_version, target_version):
         if target_version not in self.map_target_version_to_int.keys():
             raise EngineException(