Add a subscription api on gvnfmdriver. 19/66319/4
authorlaili <lai.li@zte.com.cn>
Thu, 13 Sep 2018 12:07:52 +0000 (20:07 +0800)
committerLi Lai <lai.li@zte.com.cn>
Thu, 13 Sep 2018 12:19:51 +0000 (12:19 +0000)
Add serialiers for supscription.

Change-Id: Ib89857d1be7c02c4d0dda726bf8b29342e2cc903
Issue-ID: VFC-1118
Signed-off-by: laili <lai.li@zte.com.cn>
gvnfmadapter/driver/interfaces/serializers/lccn_filter.py [new file with mode: 0644]
gvnfmadapter/driver/interfaces/serializers/problem_details.py [new file with mode: 0644]
gvnfmadapter/driver/interfaces/serializers/serializers.py
gvnfmadapter/driver/interfaces/serializers/subscription_authentication.py [new file with mode: 0644]
gvnfmadapter/driver/interfaces/serializers/vnf_instance_subscription_filter.py [new file with mode: 0644]

diff --git a/gvnfmadapter/driver/interfaces/serializers/lccn_filter.py b/gvnfmadapter/driver/interfaces/serializers/lccn_filter.py
new file mode 100644 (file)
index 0000000..f4f3df2
--- /dev/null
@@ -0,0 +1,69 @@
+# Copyright 2018 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from rest_framework import serializers
+
+from driver.interfaces.serializers.vnf_instance_subscription_filter import VnfInstanceSubscriptionFilterSerializer
+
+NOTIFICATION_TYPES = [
+    "VnfLcmOperationOccurrenceNotification",
+    "VnfIdentifierCreationNotification",
+    "VnfIdentifierDeletionNotification"
+]
+
+OPERATION_TYPES = [
+    "INSTANTIATE",
+    "SCALE",
+    "SCALE_TO_LEVEL",
+    "CHANGE_FLAVOUR",
+    "TERMINATE",
+    "HEAL",
+    "OPERATE",
+    "CHANGE_EXT_CONN",
+    "MODIFY_INFO"
+]
+
+OPERATION_STATE_TYPES = [
+    "STARTING",
+    "PROCESSING",
+    "COMPLETED",
+    "FAILED_TEMP",
+    "FAILED",
+    "ROLLING_BACK",
+    "ROLLED_BACK"
+]
+
+
+class LifeCycleChangeNotificationsFilterSerializer(serializers.Serializer):
+    notificationTypes = serializers.ListField(
+        child=serializers.ChoiceField(required=True, choices=NOTIFICATION_TYPES),
+        help_text="Match particular notification types",
+        allow_null=False,
+        required=False)
+    operationTypes = serializers.ListField(
+        child=serializers.ChoiceField(required=True, choices=OPERATION_TYPES),
+        help_text="Match particular VNF lifecycle operation types for the " +
+                  "notification of type VnfLcmOperationOccurrenceNotification.",
+        allow_null=False,
+        required=False)
+    operationStates = serializers.ListField(
+        child=serializers.ChoiceField(required=True, choices=OPERATION_STATE_TYPES),
+        help_text="Match particular LCM operation state values as reported " +
+                  "in notifications of type VnfLcmOperationOccurrenceNotification.",
+        allow_null=False,
+        required=False)
+    vnfInstanceSubscriptionFilter = VnfInstanceSubscriptionFilterSerializer(
+        help_text="Filter criteria to select VNF instances about which to notify.",
+        required=False,
+        allow_null=False)
diff --git a/gvnfmadapter/driver/interfaces/serializers/problem_details.py b/gvnfmadapter/driver/interfaces/serializers/problem_details.py
new file mode 100644 (file)
index 0000000..fefc403
--- /dev/null
@@ -0,0 +1,45 @@
+# Copyright 2018 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from rest_framework import serializers
+
+class ProblemDetailsSerializer(serializers.Serializer):
+    type = serializers.CharField(
+        help_text='A URI reference according to IETF RFC 3986 [5] that identifies the problem type.',
+        required=False
+    )
+    title = serializers.CharField(
+        help_text='A short, human-readable summary of the problem type. \
+        It should not change from occurrence to occurrence of the problem, \
+        except for purposes of localization.',
+        required=False,
+    )
+    status = serializers.IntegerField(
+        help_text='The HTTP status code for this occurrence of the problem.',
+        required=True
+    )
+    detail = serializers.CharField(
+        help_text='A human-readable explanation specific to this occurrence of the problem.',
+        required=True
+    )
+    instance = serializers.CharField(
+        help_text='A URI reference that identifies the specific occurrence of the problem. \
+        It may yield further information if dereferenced.',
+        required=False
+    )
+    additional_details = serializers.ListField(
+        help_text='Any number of additional attributes, \
+        as defined in a specification or by an implementation.',
+        required=False,
+    )
index 4936d17..b9de78a 100644 (file)
@@ -14,6 +14,7 @@
 
 from driver.interfaces.serializers.link import LinkSerializer
 from driver.interfaces.serializers.resource_handle import ResourceHandleSerializer
+from driver.interfaces.serializers.problem_details import ProblemDetailsSerializer
 
 from rest_framework import serializers
 
@@ -221,19 +222,6 @@ class VimConnectionInfoSerializer(serializers.Serializer):
         allow_null=True)
 
 
-class ProblemDetailsSerializer(serializers.Serializer):
-    type = serializers.CharField(help_text="Type", required=False, allow_null=True)
-    title = serializers.CharField(help_text="Title", required=False, allow_null=True)
-    status = serializers.IntegerField(help_text="Status", required=True)
-    detail = serializers.CharField(help_text="Detail", required=True, allow_null=True)
-    instance = serializers.CharField(help_text="Instance", required=False, allow_null=True)
-    additional_details = serializers.ListField(
-        help_text="Any number of additional attributes, as defined in a " +
-        "specification or by an implementation.",
-        required=False,
-        allow_null=True)
-
-
 class ExtlinkPortInfoSerializer(serializers.Serializer):
     id = serializers.CharField(
         help_text="Identifier of this link port as provided by the entity that has created the link port.",
diff --git a/gvnfmadapter/driver/interfaces/serializers/subscription_authentication.py b/gvnfmadapter/driver/interfaces/serializers/subscription_authentication.py
new file mode 100644 (file)
index 0000000..d9129ed
--- /dev/null
@@ -0,0 +1,74 @@
+# Copyright (C) 2018 Verizon. All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from rest_framework import serializers
+
+AUTH_TYPES = [
+    "BASIC",
+    "OAUTH2_CLIENT_CREDENTIALS",
+    "TLS_CERT"
+]
+
+
+class OAuthCredentialsSerializer(serializers.Serializer):
+    clientId = serializers.CharField(
+        help_text="Client identifier to be used in the access token \
+        request of the OAuth 2.0 client credentials grant type.",
+        max_length=255,
+        required=False
+    )
+    clientPassword = serializers.CharField(
+        help_text="Client password to be used in the access token \
+        request of the OAuth 2.0 client credentials grant type.",
+        max_length=255,
+        required=False
+    )
+    tokenEndpoint = serializers.CharField(
+        help_text="The token endpoint \
+        from which the access token can be obtained.",
+        max_length=255,
+        required=False
+    )
+
+
+class BasicAuthSerializer(serializers.Serializer):
+    userName = serializers.CharField(
+        help_text="Username to be used in HTTP Basic authentication.",
+        max_length=255,
+        required=False
+    )
+    password = serializers.CharField(
+        help_text="Password to be used in HTTP Basic authentication.",
+        max_length=255,
+        required=False
+    )
+
+
+class SubscriptionAuthenticationSerializer(serializers.Serializer):
+    authType = serializers.ListField(
+        child=serializers.ChoiceField(required=True, choices=AUTH_TYPES),
+        help_text="Defines the types of Authentication / Authorization \
+        which the API consumer is willing to accept \
+        when receiving a notification.",
+        required=True
+    )
+    paramsBasic = BasicAuthSerializer(
+        help_text="Parameters for authentication/authorization using BASIC.",
+        required=False
+    )
+    paramsOauth2ClientCredentials = OAuthCredentialsSerializer(
+        help_text="Parameters for authentication/authorization \
+        using OAUTH2_CLIENT_CREDENTIALS.",
+        required=False
+    )
diff --git a/gvnfmadapter/driver/interfaces/serializers/vnf_instance_subscription_filter.py b/gvnfmadapter/driver/interfaces/serializers/vnf_instance_subscription_filter.py
new file mode 100644 (file)
index 0000000..c46dc50
--- /dev/null
@@ -0,0 +1,80 @@
+# Copyright (C) 2018 Verizon. All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from rest_framework import serializers
+
+
+class VersionsSerializer(serializers.Serializer):
+    vnfSoftwareVersion = serializers.CharField(
+        help_text="Software version to match.",
+        max_length=255,
+        required=True
+    )
+    vnfdVersions = serializers.ListField(
+        help_text="Match VNF instances \
+        that belong to VNF products with certain VNFD versions",
+        child=serializers.CharField(max_length=255, required=True),
+        required=False
+    )
+
+
+class VnfProductsSerializer(serializers.Serializer):
+    vnfProductName = serializers.CharField(
+        help_text="Name of the VNF product to match.",
+        max_length=255,
+        required=True
+    )
+    versions = VersionsSerializer(
+        help_text="Match VNF instances \
+        that belong to VNF products with certain versions \
+        and a certain product name, from one particular provider.",
+        required=False
+    )
+
+
+class VnfProductsProvidersSerializer(serializers.Serializer):
+    vnfProvider = serializers.CharField(
+        help_text="Name of the VNF provider to match.",
+        max_length=255,
+        required=True
+    )
+    vnfProducts = VnfProductsSerializer(
+        help_text="match VNF instances that belong to VNF products " +
+        "with certain product names, from one particular provider",
+        required=False
+    )
+
+
+class VnfInstanceSubscriptionFilterSerializer(serializers.Serializer):
+    vnfdIds = serializers.ListField(
+        help_text="VNF instances that were created \
+        based on a VNFD identified by one of the vnfdId values",
+        child=serializers.UUIDField(),
+        required=False
+    )
+    vnfInstanceIds = serializers.ListField(
+        help_text="VNF instance IDs that has to be matched",
+        child=serializers.UUIDField(),
+        required=False
+    )
+    vnfInstanceNames = serializers.ListField(
+        help_text="VNF Instance names that has to be matched",
+        child=serializers.CharField(max_length=255, required=True),
+        required=False
+    )
+    vnfProductsFromProviders = VnfProductsProvidersSerializer(
+        help_text="match VNF instances \
+        that belong to VNF products from certain providers.",
+        required=False
+    )