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
                 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
 
 
     )
     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
     )
     )
     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(
     )
     _links = GrantRequestLinksSerializer(
         help_text="Links to resources related to this request.",
-        required=False
+        required=False  # TODO required
     )
 
 
     )
     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
     )
         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
 
 
     # 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()),
 ]