Fix Typo and bug inside place vnf 03/73503/1
authorRuoyu <ruoyu.ying@intel.com>
Mon, 26 Nov 2018 08:48:35 +0000 (08:48 +0000)
committerRuoyu <ruoyu.ying@intel.com>
Mon, 26 Nov 2018 08:50:17 +0000 (08:50 +0000)
Fix Typo and bug

Change-Id: Idf5bf61e5854c8e7eda5a4e9a7fc4766e2dd757b
Issue-ID: VFC-941
Signed-off-by: Ruoyu <ruoyu.ying@intel.com>
lcm/ns_vnfs/biz/place_vnfs.py
lcm/ns_vnfs/tests/tests.py

index d63ee74..5b1d88b 100644 (file)
@@ -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"):
index 50f380a..f0ecc8f 100644 (file)
@@ -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",