diff options
author | 2018-09-10 20:42:26 +0800 | |
---|---|---|
committer | 2018-09-10 20:42:26 +0800 | |
commit | 040b4afd4e863f466b2e9a57006e7d14345ebc21 (patch) | |
tree | 3c32c5eea67c661be5250ae201d37c3ba721f99c | |
parent | f2c8a6137235d8f9664b36cce49aa3cbe061a5e5 (diff) |
Support functional requirements
- Modify grant vnf
Change-Id: Icd9ff1996ae42a536ed0a610ccb46680147f57f5
Issue-ID: VFC-1106
Signed-off-by: laili <lai.li@zte.com.cn>
-rw-r--r-- | lcm/ns_vnfs/biz/grant_vnf.py | 15 | ||||
-rw-r--r-- | lcm/ns_vnfs/serializers/grant_vnf_serializer.py | 17 | ||||
-rw-r--r-- | lcm/ns_vnfs/urls.py | 2 |
3 files changed, 27 insertions, 7 deletions
diff --git a/lcm/ns_vnfs/biz/grant_vnf.py b/lcm/ns_vnfs/biz/grant_vnf.py index 47348500..d812d957 100644 --- a/lcm/ns_vnfs/biz/grant_vnf.py +++ b/lcm/ns_vnfs/biz/grant_vnf.py @@ -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 diff --git a/lcm/ns_vnfs/serializers/grant_vnf_serializer.py b/lcm/ns_vnfs/serializers/grant_vnf_serializer.py index d1b865b5..f140e666 100644 --- a/lcm/ns_vnfs/serializers/grant_vnf_serializer.py +++ b/lcm/ns_vnfs/serializers/grant_vnf_serializer.py @@ -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 diff --git a/lcm/ns_vnfs/urls.py b/lcm/ns_vnfs/urls.py index 49a2229a..f3f2e3e5 100644 --- a/lcm/ns_vnfs/urls.py +++ b/lcm/ns_vnfs/urls.py @@ -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()), ] |