Support functional requirements 37/65537/1
authorlaili <lai.li@zte.com.cn>
Mon, 10 Sep 2018 12:42:26 +0000 (20:42 +0800)
committerlaili <lai.li@zte.com.cn>
Mon, 10 Sep 2018 12:42:26 +0000 (20:42 +0800)
- Modify grant vnf

Change-Id: Icd9ff1996ae42a536ed0a610ccb46680147f57f5
Issue-ID: VFC-1106
Signed-off-by: laili <lai.li@zte.com.cn>
lcm/ns_vnfs/biz/grant_vnf.py
lcm/ns_vnfs/serializers/grant_vnf_serializer.py
lcm/ns_vnfs/urls.py

index 4734850..d812d95 100644 (file)
@@ -15,7 +15,7 @@
 import json
 import logging
 import uuid
-from lcm.pub.database.models import NfInstModel
+from lcm.pub.database.models import NfInstModel, OOFDataModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.msapi.sdc_run_catalog import query_vnfpackage_by_id
 from lcm.pub.utils.values import ignore_case_get
@@ -85,12 +85,25 @@ class GrantVnf(object):
                 req_param[grant_type].append(grant_res)
             self.data = req_param
         vimConnections.append(resmgr.grant_vnf(self.data))
+
         grant_resp = {
             "id": str(uuid.uuid4()),
             "vnfInstanceId": ignore_case_get(self.data, 'vnfInstanceId'),
             "vnfLcmOpOccId": ignore_case_get(self.data, "vnfLcmOpOccId"),
             "vimConnections": vimConnections
         }
+
+        offs = OOFDataModel.objects.filter(service_resource_id=ignore_case_get(self.data, "vnfInstanceId"))
+        if offs.exists():
+            for off in offs:
+                grant_resp['vimAssets']['computeResourceFlavours'].append({
+                    'vimConnectionId': off.vim_id,
+                    'resourceProviderId': off.vdu_name,
+                    'vnfdVirtualComputeDescId': None,  # TODO: required
+                    'vimFlavourId': off.flavor_name
+                })
+                grant_resp['additionalparams'][off.vim_id] = off.directive
+
         logger.debug("grant_resp=%s", grant_resp)
         return grant_resp
 
index d1b865b..f140e66 100644 (file)
@@ -148,13 +148,13 @@ class GrantRequestSerializer(serializers.Serializer):
     )
     vnfLcmOpOccId = serializers.CharField(
         help_text="The identifier of the VNF lifecycle management operation occurrence associated to the GrantRequest.",
-        required=False,
+        required=False,  # TODO required
         allow_null=True,
         allow_blank=True
     )
     vnfdId = serializers.CharField(
         help_text="Identifier of the VNFD that defines the VNF for which the LCM operation is to be granted.",
-        required=False,
+        required=False,  # TODO required
         allow_null=True,
         allow_blank=True
     )
@@ -166,7 +166,7 @@ class GrantRequestSerializer(serializers.Serializer):
     )
     operation = serializers.ChoiceField(
         help_text="The lifecycle management operation for which granting is requested.",
-        choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"],
+        choices=["INSTANTIATE", "SCALE", "SCALE_TO_LEVEL", "CHANGE_FLAVOUR", "TERMINATE", "HEAL", "OPERATE", "CHANGE_EXT_CONN", "MODIFY_INFO"],
         required=True
     )
     isAutomaticInvocation = serializers.BooleanField(
@@ -217,7 +217,7 @@ class GrantRequestSerializer(serializers.Serializer):
     )
     _links = GrantRequestLinksSerializer(
         help_text="Links to resources related to this request.",
-        required=False
+        required=False  # TODO required
     )
 
 
@@ -592,7 +592,7 @@ class GrantSerializer(serializers.Serializer):
     )
     vnfLcmOpOccId = serializers.CharField(
         help_text="Identifier of the related VNF lifecycle management operation occurrence.",
-        required=False,
+        required=False,  # TODO required
         allow_null=True,
         allow_blank=True
     )
@@ -664,6 +664,13 @@ class GrantSerializer(serializers.Serializer):
         many=True,
         required=False
     )
+    additionalParams = serializers.DictField(
+        help_text="Additional parameters passed by the NFVO, \
+        specific to the VNF and the LCM operation.",
+        child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True),
+        required=False,
+        allow_null=True
+    )
     _links = GrantLinksSerializer(
         help_text="Links to resources related to this resource.",
         required=False
index 49a2229..f3f2e3e 100644 (file)
@@ -33,7 +33,7 @@ urlpatterns = [
 
     # move form v2
     url(r'^api/nslcm/v2/grants$', VnfGrantView.as_view()),
-    url(r'^api/nslcm/v2/ns/(?P<vnfmId>[0-9a-zA-Z_-]+)/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z_-]+)/Notify$',
+    url(r'^api/nslcm/v2/ns/(?P<vnfmId>[0-9a-zA-Z_-]+)/ns_vnfs/(?P<vnfInstanceId>[0-9a-zA-Z_-]+)/Notify$',
         VnfNotifyView.as_view()),
 ]