X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fengine.py;h=37f1fb27503281a06db3117c95c91b8bcc3fc9c1;hp=e9b154947c3d0673ad2a947003514360856bd286;hb=HEAD;hpb=f2af4a100d308e07f355d61b94fb27d1ccc97aa2 diff --git a/osm_nbi/engine.py b/osm_nbi/engine.py index e9b1549..c4c8eb2 100644 --- a/osm_nbi/engine.py +++ b/osm_nbi/engine.py @@ -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(