X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fengine.py;h=c4c8eb29784df8669c1e35e04d195059a3b7f2b9;hp=1bc9171c0d8740e02ca6644ec41cb82a0274523c;hb=HEAD;hpb=4568a372eb5a204e04d917213de03ec51f9110c1 diff --git a/osm_nbi/engine.py b/osm_nbi/engine.py index 1bc9171..c4c8eb2 100644 --- a/osm_nbi/engine.py +++ b/osm_nbi/engine.py @@ -52,8 +52,10 @@ from osm_nbi.instance_topics import ( NsiTopic, NsiLcmOpTopic, ) +from osm_nbi.vnf_instance_topics import VnfInstances, VnfLcmOpTopic from osm_nbi.pmjobs_topics import PmJobsTopic from osm_nbi.subscription_topics import NslcmSubscriptionsTopic +from osm_nbi.osm_vnfm.vnf_subscription import VnflcmSubscriptionsTopic from base64 import b64encode from os import urandom # , path from threading import Lock @@ -85,6 +87,9 @@ class Engine(object): "nsilcmops": NsiLcmOpTopic, "vnfpkgops": VnfPkgOpTopic, "nslcm_subscriptions": NslcmSubscriptionsTopic, + "vnf_instances": VnfInstances, + "vnflcmops": VnfLcmOpTopic, + "vnflcm_subscriptions": VnflcmSubscriptionsTopic, # [NEW_TOPIC]: add an entry here # "pm_jobs": PmJobsTopic will be added manually because it needs other parameters } @@ -200,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 = [] # @@ -293,12 +298,13 @@ class Engine(object): ) return self.map_topic[topic].list(session, filter_q, api_req) - def get_item(self, session, topic, _id, api_req=False): + def get_item(self, session, topic, _id, filter_q=None, api_req=False): """ Get complete information on an item :param session: contains the used login username and working project :param topic: it can be: users, projects, vnfds, nsds, :param _id: server id of the item + :param filter_q: other arguments :param api_req: True if this call is serving an external API request. False if serving internal request. :return: dictionary, raise exception if not found. """ @@ -306,7 +312,7 @@ class Engine(object): raise EngineException( "Unknown topic {}!!!".format(topic), HTTPStatus.INTERNAL_SERVER_ERROR ) - return self.map_topic[topic].show(session, _id, api_req) + return self.map_topic[topic].show(session, _id, filter_q, api_req) def get_file(self, session, topic, _id, path=None, accept_header=None): """ @@ -374,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(