From f62f54267fd968708685216237fcf163e5ab5b48 Mon Sep 17 00:00:00 2001 From: Ruoyu Date: Mon, 26 Nov 2018 08:48:35 +0000 Subject: Fix Typo and bug inside place vnf Fix Typo and bug Change-Id: Idf5bf61e5854c8e7eda5a4e9a7fc4766e2dd757b Issue-ID: VFC-941 Signed-off-by: Ruoyu (cherry picked from commit 53c4988ba241c442693d870babc9a3bf65447f2d) --- lcm/ns_vnfs/biz/place_vnfs.py | 64 +++++++++++++++++++++---------------------- lcm/ns_vnfs/tests/tests.py | 2 +- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/lcm/ns_vnfs/biz/place_vnfs.py b/lcm/ns_vnfs/biz/place_vnfs.py index d63ee74e..5b1d88bf 100644 --- a/lcm/ns_vnfs/biz/place_vnfs.py +++ b/lcm/ns_vnfs/biz/place_vnfs.py @@ -81,47 +81,45 @@ class PlaceVnfs(object): for info in assignmentInfo: if info.get("key") in params: vim_info[info.get("key")] = info.get("value") - if not vim_info.get("oof_directives"): - logger.warn("Missing flavor info as no directive found in response") - self.update_response_to_db(self.request_id, - self.data.get("requestStatus"), "none", "none", - "none", "none") - continue - vduinfo = self.get_info_from_directives( - vim_info['oof_directives']) - if not vduinfo: + if not vim_info.get("oof_directives"): + logger.warn("Missing flavor info as no directive found in response") + self.update_response_to_db(self.request_id, + self.data.get("requestStatus"), "none", "none", + "none", "none") + continue + vduinfo = self.get_info_from_directives( + vim_info['oof_directives']) + if not vduinfo: + self.update_response_to_db(self.request_id, + self.data.get("requestStatus"), "none", "none", + "none", "none") + return + else: + cloud_owner = placement.get("solution").get("cloudOwner") \ + if placement.get("solution").get("cloudOwner") \ + else vim_info.get("cloudOwner") + location_id = vim_info.get("locationId") + if not cloud_owner or not location_id: self.update_response_to_db(self.request_id, self.data.get("requestStatus"), "none", "none", "none", "none") return - else: - cloud_owner = placement.get("solution").get("cloudOwner") \ - if placement.get("solution").get("cloudOwner") \ - else vim_info.get("cloudOwner") - location_id = vim_info.get("locationId") - if not cloud_owner or not location_id: - self.update_response_to_db(self.request_id, - self.data.get("requestStatus"), "none", "none", - "none", "none") - return - vim_id = vim_info['vimId'] if vim_info.get('vimId') \ - else cloud_owner + "_" + location_id - self.update_response_to_db(requestId=self.request_id, - requestStatus=self.data.get("requestStatus"), - vimId=vim_id, - cloudOwner=cloud_owner, - cloudRegionId=values.ignore_case_get(vim_info, "locationId"), - vduInfo=vduinfo - ) - logger.debug( - "Placement solution has been stored for request %s " - % self.request_id) - return "Done" + vim_id = vim_info['vimId'] if vim_info.get('vimId') \ + else cloud_owner + "_" + location_id + self.update_response_to_db(requestId=self.request_id, + requestStatus=self.data.get("requestStatus"), + vimId=vim_id, + cloudOwner=cloud_owner, + cloudRegionId=values.ignore_case_get(vim_info, "locationId"), + vduInfo=vduinfo) + logger.debug( + "Placement solution has been stored for request %s " % self.request_id) + return "Done" def get_info_from_directives(self, directives): vduinfo = [] for directive in directives.get("directives"): - if directive.get("type") == "tocsa.nodes.nfv.Vdu.Compute": + if directive.get("type") == "tosca.nodes.nfv.Vdu.Compute": vdu = {"vduName": directive.get("id")} other_directives = [] for item in directive.get("directives"): diff --git a/lcm/ns_vnfs/tests/tests.py b/lcm/ns_vnfs/tests/tests.py index 50f380aa..f0ecc8f4 100644 --- a/lcm/ns_vnfs/tests/tests.py +++ b/lcm/ns_vnfs/tests/tests.py @@ -1759,7 +1759,7 @@ vnf_place_request = { "directives": [ { "id": "vG_0", - "type": "tocsa.nodes.nfv.Vdu.Compute", + "type": "tosca.nodes.nfv.Vdu.Compute", "directives": [ { "type": "flavor_directives", -- cgit 1.2.3-korg