aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuoyu <ruoyu.ying@intel.com>2018-11-22 07:11:51 +0000
committerRuoyu <ruoyu.ying@intel.com>2018-11-22 07:13:23 +0000
commit9e49959502c940149b73352f120f76273b1683cc (patch)
tree598e4e17c864e49ab7effeacdc4c2497bb092dee
parentd813aee2668461e08829f1ebcbb947492004b65d (diff)
Retrieve flavor id from OOF response
Retrieve flavor id from OOF response, and store it into db Change-Id: I6a0bb23e5e81784a0599f6095f9d9992f03ea10b Issue-ID: VFC-1193 Signed-off-by: Ruoyu <ruoyu.ying@intel.com>
-rw-r--r--lcm/ns_vnfs/biz/grant_vnf.py2
-rw-r--r--lcm/ns_vnfs/biz/place_vnfs.py2
-rw-r--r--lcm/ns_vnfs/tests/tests.py23
3 files changed, 16 insertions, 11 deletions
diff --git a/lcm/ns_vnfs/biz/grant_vnf.py b/lcm/ns_vnfs/biz/grant_vnf.py
index f16382e7..6891ee9d 100644
--- a/lcm/ns_vnfs/biz/grant_vnf.py
+++ b/lcm/ns_vnfs/biz/grant_vnf.py
@@ -123,7 +123,7 @@ class GrantVnf(object):
'vimConnectionId': offs[0].vim_id,
'resourceProviderId': vdu.get("vduName"),
'vnfdVirtualComputeDescId': None, # TODO: required
- 'vimFlavourId': vdu.get("flavorName")
+ 'vimFlavourId': vdu.get("flavorId")
})
# grant_resp['additionalparams'][off.vim_id] = off.directive
break
diff --git a/lcm/ns_vnfs/biz/place_vnfs.py b/lcm/ns_vnfs/biz/place_vnfs.py
index 6f858127..d63ee74e 100644
--- a/lcm/ns_vnfs/biz/place_vnfs.py
+++ b/lcm/ns_vnfs/biz/place_vnfs.py
@@ -127,7 +127,7 @@ class PlaceVnfs(object):
for item in directive.get("directives"):
if item.get("type") == "flavor_directives":
for attribute in item.get("attributes"):
- vdu['flavorName'] = attribute.get("attribute_value")
+ vdu[attribute.get("attribute_name")] = attribute.get("attribute_value")
else:
other_directives.append(item)
if other_directives:
diff --git a/lcm/ns_vnfs/tests/tests.py b/lcm/ns_vnfs/tests/tests.py
index 02fa2f82..50f380aa 100644
--- a/lcm/ns_vnfs/tests/tests.py
+++ b/lcm/ns_vnfs/tests/tests.py
@@ -729,14 +729,14 @@ class TestGetVimInfoViews(TestCase):
class TestPlaceVnfViews(TestCase):
def setUp(self):
self.vnf_inst_id = "1234"
- self.vnf_inst_name = "vG"
+ self.vnf_id = "vG"
self.client = Client()
OOFDataModel.objects.all().delete()
OOFDataModel.objects.create(
request_id="1234",
transaction_id="1234",
request_status="init",
- request_module_name=self.vnf_inst_name,
+ request_module_name=self.vnf_id,
service_resource_id=self.vnf_inst_id,
vim_id="",
cloud_owner="",
@@ -752,6 +752,7 @@ class TestPlaceVnfViews(TestCase):
vdu_info_json = [{
"vduName": "vG_0",
"flavorName": "HPA.flavor.1",
+ "flavorId": "12345",
"directive": []
}]
PlaceVnfs(vnf_place_request).extract()
@@ -772,7 +773,7 @@ class TestPlaceVnfViews(TestCase):
"placementSolutions": [
[
{
- "resourceModuleName": self.vnf_inst_name,
+ "resourceModuleName": self.vnf_id,
"serviceResourceId": self.vnf_inst_id,
"solution": {
"identifierType": "serviceInstanceId",
@@ -823,7 +824,7 @@ class TestPlaceVnfViews(TestCase):
"placementSolutions": [
[
{
- "resourceModuleName": self.vnf_inst_name,
+ "resourceModuleName": self.vnf_id,
"serviceResourceId": self.vnf_inst_id,
"solution": {
"identifierType": "serviceInstanceId",
@@ -873,7 +874,7 @@ class TestPlaceVnfViews(TestCase):
"placementSolutions": [
[
{
- "resourceModuleName": self.vnf_inst_name,
+ "resourceModuleName": self.vnf_id,
"serviceResourceId": self.vnf_inst_id,
"solution": {
"identifierType": "serviceInstanceId",
@@ -946,7 +947,7 @@ class TestGrantVnfViews(TestCase):
"vnfLcmOpOccId": "1234",
"operation": "INSTANTIATE"
}
- vdu_info_dict = [{"vduName": "vg", "flavorName": "flavor_1", "directive": []}]
+ vdu_info_dict = [{"vduName": "vg", "flavorName": "flavor_1", "flavorId": "12345", "directive": []}]
OOFDataModel(request_id='1234', transaction_id='1234', request_status='done', request_module_name='vg',
service_resource_id=self.vnf_inst_id, vim_id='cloudOwner_casa', cloud_owner='cloudOwner',
cloud_region_id='casa', vdu_info=json.dumps(vdu_info_dict)).save()
@@ -968,7 +969,7 @@ class TestGrantVnfViews(TestCase):
resp = GrantVnf(self.data).exec_grant()
self.assertEquals(resp['vimAssets']['computeResourceFlavours'][0]['vimConnectionId'], 'cloudOwner_casa')
self.assertEquals(resp['vimAssets']['computeResourceFlavours'][0]['resourceProviderId'], 'vg')
- self.assertEquals(resp['vimAssets']['computeResourceFlavours'][0]['vimFlavourId'], 'flavor_1')
+ self.assertEquals(resp['vimAssets']['computeResourceFlavours'][0]['vimFlavourId'], '12345')
vnfd_model_dict = {
@@ -1764,9 +1765,13 @@ vnf_place_request = {
"type": "flavor_directives",
"attributes": [
{
- "attribute_name": "flavor_name",
+ "attribute_name": "flavorName",
"attribute_value": "HPA.flavor.1"
- }
+ },
+ {
+ "attribute_name": "flavorId",
+ "attribute_value": "12345"
+ },
]
}
]