summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuoyu Ying <ruoyu.ying@intel.com>2018-11-02 14:24:24 +0800
committerRuoyu Ying <ruoyu.ying@intel.com>2018-11-02 15:42:24 +0800
commit7a6fcd55d8f0a451d5fc2462fd26c9f463959913 (patch)
tree9c16d0003484db502d25774c9771226fc5bb5791
parentb6f1ca9aaa49086a7b3304a828c8fedadf5e3800 (diff)
Refine place_vnf logic
Refine place_vnf logic Change-Id: Iee9dbad6c4ed978de280bee9f1fd5de07ef6116b Issue-ID: VFC-1085 Signed-off-by: Ruoyu Ying <ruoyu.ying@intel.com>
-rw-r--r--lcm/ns_vnfs/biz/place_vnfs.py17
-rw-r--r--lcm/ns_vnfs/tests/tests.py8
2 files changed, 16 insertions, 9 deletions
diff --git a/lcm/ns_vnfs/biz/place_vnfs.py b/lcm/ns_vnfs/biz/place_vnfs.py
index a63c04e3..e288f9dd 100644
--- a/lcm/ns_vnfs/biz/place_vnfs.py
+++ b/lcm/ns_vnfs/biz/place_vnfs.py
@@ -64,14 +64,14 @@ class PlaceVnfs(object):
if self.placements == [] or self.placements == [[]]:
logger.debug("No solution found for request %s " % self.request_id)
self.update_response_to_db(self.request_id, self.transaction_id,
- self.data.get("requestStatus"), "no-solution", "no-solution",
- "no-solution", "no-solution")
+ self.data.get("requestStatus"), "none", "none",
+ "none", "none")
return
for item in self.placements:
if not isinstance(item, list):
self.update_response_to_db(self.request_id, self.transaction_id,
- self.data.get("requestStatus"), "no-solution", "no-solution",
- "no-solution", "no-solution")
+ self.data.get("requestStatus"), "none", "none",
+ "none", "none")
continue
for placement in item:
assignmentInfo = placement.get("assignmentInfo")
@@ -106,8 +106,15 @@ class PlaceVnfs(object):
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.transaction_id,
+ self.data.get("requestStatus"), "none", "none",
+ "none", "none")
+ return
vim_id = vim_info['vimId'] if vim_info.get('vimId') \
- else cloud_owner + "_" + vim_info.get("locationId")
+ else cloud_owner + "_" + location_id
self.update_response_to_db(requestId=self.request_id,
transactionId=self.transaction_id,
requestStatus=self.data.get("requestStatus"),
diff --git a/lcm/ns_vnfs/tests/tests.py b/lcm/ns_vnfs/tests/tests.py
index db5931e9..b6c5a1be 100644
--- a/lcm/ns_vnfs/tests/tests.py
+++ b/lcm/ns_vnfs/tests/tests.py
@@ -930,10 +930,10 @@ class TestPlaceVnfViews(TestCase):
PlaceVnfs(resp).extract()
db_info = OOFDataModel.objects.filter(request_id=resp.get("requestId"), transaction_id=resp.get("transactionId"))
self.assertEqual(db_info[0].request_status, "completed")
- self.assertEqual(db_info[0].vim_id, "no-solution")
- self.assertEqual(db_info[0].cloud_owner, "no-solution")
- self.assertEqual(db_info[0].cloud_region_id, "no-solution")
- self.assertEqual(db_info[0].vdu_info, "no-solution")
+ self.assertEqual(db_info[0].vim_id, "none")
+ self.assertEqual(db_info[0].cloud_owner, "none")
+ self.assertEqual(db_info[0].cloud_region_id, "none")
+ self.assertEqual(db_info[0].vdu_info, "none")
vnfd_model_dict = {