Update nf_pm serializer in vnflcm 14/98914/3
authoryangyan <yangyanyj@chinamobile.com>
Thu, 28 Nov 2019 01:56:33 +0000 (09:56 +0800)
committeryangyan <yangyanyj@chinamobile.com>
Thu, 28 Nov 2019 02:26:31 +0000 (10:26 +0800)
Change-Id: Icaa588d6a9f72274b65e258ab23c19d0c4f74773
Issue-ID: VFC-1590
Signed-off-by: yangyan <yangyanyj@chinamobile.com>
lcm/lcm/nf_pm/counst.py
lcm/lcm/nf_pm/serializers/Link.py [new file with mode: 0644]
lcm/lcm/nf_pm/serializers/create_pm_job_request.py [new file with mode: 0644]
lcm/lcm/nf_pm/serializers/create_thresho_id_request.py [new file with mode: 0644]
lcm/lcm/nf_pm/serializers/performance_information_available_aotification.py [new file with mode: 0644]
lcm/lcm/nf_pm/serializers/performance_report.py [new file with mode: 0644]
lcm/lcm/nf_pm/serializers/pm_job.py [new file with mode: 0644]
lcm/lcm/nf_pm/serializers/pm_subscription.py [new file with mode: 0644]
lcm/lcm/nf_pm/serializers/threshold.py [new file with mode: 0644]
lcm/lcm/nf_pm/serializers/threshold_crossed_notification.py [new file with mode: 0644]

index 3d3ce50..f8c39a8 100644 (file)
@@ -24,3 +24,12 @@ AUTH_TYPE = enum(
     OAUTH2_CLIENT_CREDENTIALS="OAUTH2_CLIENT_CREDENTIALS",
     TLS_CERT="TLS_CERT"
 )
+
+CrossingDirectionType = enum(
+    UP="UP",
+    DOWN="DOWN"
+)
+
+THRESHOLDTYPE = enum(
+    SIMPLE="SIMPLE"
+)
diff --git a/lcm/lcm/nf_pm/serializers/Link.py b/lcm/lcm/nf_pm/serializers/Link.py
new file mode 100644 (file)
index 0000000..bc9a1d1
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (c) 2019, CMCC Technologies Co., Ltd.
+#
+# 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 linkSerializer(serializers.Serializer):
+    href = serializers.CharField(
+        help_text="URI of the referenced resource.",
+        required=True,
+        allow_null=False,
+        allow_blank=False)
+
+
+class LinkSerializer(serializers.Serializer):
+    self = linkSerializer(
+        help_text="URI of this resource.",
+        required=True,
+        allow_null=False)
diff --git a/lcm/lcm/nf_pm/serializers/create_pm_job_request.py b/lcm/lcm/nf_pm/serializers/create_pm_job_request.py
new file mode 100644 (file)
index 0000000..3e7ca19
--- /dev/null
@@ -0,0 +1,40 @@
+# Copyright (c) 2019, CMCC Technologies Co., Ltd.
+#
+# 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 PmJobCriteriaSerializer(serializers.Serializer):
+    performanceMetric = serializers.ListField(help_text="This defines the types of performance metrics "
+                                                        "for the specified object instances, as specified "
+                                                        "in an external measurement specification",
+                                              required=False, allow_null=True)
+    performanceMetricGroup = serializers.ListField(help_text="Group of performance metrics",
+                                                   required=False, allow_null=True)
+    collectionPeriod = serializers.CharField(help_text="Specifies the periodicity at which the producer "
+                                                       "will collect performance information",
+                                             required=True, allow_null=False)
+    reportingPeriod = serializers.CharField(help_text="Specifies the periodicity at which the producer "
+                                                      "will report to the consumer",
+                                            required=True, allow_null=False)
+    reportingBoundary = serializers.DateField(help_text="dentifies a time boundary after which the reporting "
+                                                        "will stop.", required=False, allow_null=True)
+
+
+class CreatePmJobRequestSerializer(serializers.Serializer):
+    objectInstanceIds = serializers.ListField(help_text="Identifiers of the VNF instances for which "
+                                                        "performance information is requested to be "
+                                                        "collected.", required=True, allow_null=False)
+    criteria = PmJobCriteriaSerializer(help_text="Criteria of the collection of performance information",
+                                       required=True, allow_null=False)
diff --git a/lcm/lcm/nf_pm/serializers/create_thresho_id_request.py b/lcm/lcm/nf_pm/serializers/create_thresho_id_request.py
new file mode 100644 (file)
index 0000000..84c03be
--- /dev/null
@@ -0,0 +1,34 @@
+# Copyright (c) 2019, CMCC Technologies Co., Ltd.
+#
+# 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 lcm.nf_pm.counst import THRESHOLDTYPE
+
+
+class ThresholdCriteriaSerializer(serializers.Serializer):
+    performanceMetric = serializers.CharField(help_text="Defines the performance metric associated with the"
+                                                        "threshold, as specified in an external measurement"
+                                                        "specification.", required=True, allow_null=False)
+    thresholdType = serializers.ChoiceField(help_text="Type of threshold", required=True, allow_null=False,
+                                            choices=THRESHOLDTYPE)
+    simpleThresholdDetails = serializers.CharField(help_text="Details of a simple threshold",
+                                                   required=False, allow_null=True)
+
+
+class CreateThresholdRequestSerializer(serializers.Serializer):
+    objectInstanceId = serializers.CharField(help_text="Identifier of the VNF instance associated with this "
+                                                       "threshold.", required=True, allow_null=False)
+    criteria = ThresholdCriteriaSerializer(help_text="Criteria that define this threshold.",
+                                           required=True, allow_null=False)
diff --git a/lcm/lcm/nf_pm/serializers/performance_information_available_aotification.py b/lcm/lcm/nf_pm/serializers/performance_information_available_aotification.py
new file mode 100644 (file)
index 0000000..276e1d0
--- /dev/null
@@ -0,0 +1,31 @@
+# Copyright (c) 2019, CMCC Technologies Co., Ltd.
+#
+# 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 lcm.nf_pm.serializers.Link import LinkSerializer
+
+
+class PerformanceInformationAvailableNotificationSerializer(serializers.Serializer):
+    id = serializers.CharField(help_text="Identifier of this notification.", required=True, allow_null=False)
+    notificationType = serializers.CharField(help_text="Discriminator for the different notification types.",
+                                             required=True, allow_null=False)
+    subscriptionId = serializers.CharField(help_text="Identifier of the subscription that this notification "
+                                                     "relates to.", required=True, allow_null=False)
+    timeStamp = serializers.DateField(help_text="Date and time of the generation of thenotification.",
+                                      required=True, allow_null=False)
+    objectInstanceId = serializers.CharField(help_text="Identifier that identifies a VNF instance.",
+                                             required=True, allow_null=False)
+    _links = LinkSerializer(help_text="Links to resources related to this notification",
+                            required=True, allow_null=False)
diff --git a/lcm/lcm/nf_pm/serializers/performance_report.py b/lcm/lcm/nf_pm/serializers/performance_report.py
new file mode 100644 (file)
index 0000000..e79756e
--- /dev/null
@@ -0,0 +1,20 @@
+# Copyright (c) 2019, CMCC Technologies Co., Ltd.
+#
+# 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 PerformanceReportSerializer(serializers.Serializer):
+    entries = serializers.ListField(help_text="List of performance information entries",
+                                    required=True, allow_null=False)
diff --git a/lcm/lcm/nf_pm/serializers/pm_job.py b/lcm/lcm/nf_pm/serializers/pm_job.py
new file mode 100644 (file)
index 0000000..a9006b7
--- /dev/null
@@ -0,0 +1,28 @@
+# Copyright (c) 2019, CMCC Technologies Co., Ltd.
+#
+# 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 lcm.nf_pm.serializers.create_pm_job_request import PmJobCriteriaSerializer
+
+
+class PmJob(serializers.Serializer):
+    id = serializers.CharField(help_text="Identifier of this PM job.", required=True, allow_null=False)
+    objectInstanceIds = serializers.ListField(help_text="Identifiers of the VNF instances for which "
+                                                        "performance information is collected",
+                                              required=True, allow_null=False)
+    criteria = PmJobCriteriaSerializer(help_text="Criteria of the collection of performance information.",
+                                       required=True, allow_null=False)
+    reports = serializers.ListField(help_text="Information about available reports collected by this PM job.",
+                                    required=False, allow_null=True)
diff --git a/lcm/lcm/nf_pm/serializers/pm_subscription.py b/lcm/lcm/nf_pm/serializers/pm_subscription.py
new file mode 100644 (file)
index 0000000..e330dbc
--- /dev/null
@@ -0,0 +1,32 @@
+# Copyright (c) 2019, CMCC Technologies Co., Ltd.
+#
+# 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 lcm.nf_pm.serializers.Link import LinkSerializer
+from lcm.nf_pm.serializers.pm_subscription_request import PmNotificationsFilterSerializer
+
+
+class PmSubscriptionSerializer(serializers.Serializer):
+    id = serializers.CharField(help_text="Identifier that identifies the subscription",
+                               required=True, allow_null=False)
+    filter = PmNotificationsFilterSerializer(help_text="Filter settings for this subscription, to define the"
+                                                       " subset of all notifications this subscription "
+                                                       "relates to.", required=False, allow_null=True)
+    callbackUri = serializers.CharField(help_text="The URI of the endpoint to send the notification to",
+                                        required=True, allow_null=False)
+    _links = LinkSerializer(
+        help_text="Links to resources related to this resource.",
+        required=True,
+        allow_null=False)
diff --git a/lcm/lcm/nf_pm/serializers/threshold.py b/lcm/lcm/nf_pm/serializers/threshold.py
new file mode 100644 (file)
index 0000000..1fc87fb
--- /dev/null
@@ -0,0 +1,28 @@
+# Copyright (c) 2019, CMCC Technologies Co., Ltd.
+#
+# 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 lcm.nf_pm.serializers.Link import LinkSerializer
+from lcm.nf_pm.serializers.create_thresho_id_request import ThresholdCriteriaSerializer
+
+
+class ThresholdSerializer(serializers.Serializer):
+    id = serializers.CharField(help_text="Identifier of this threshold resource.",
+                               required=True, allow_null=False)
+    objectInstanceId = serializers.CharField(help_text="Identifier of the VNF instance associated with the"
+                                                       "threshold.", required=True, allow_null=False)
+    criteria = ThresholdCriteriaSerializer(help_text="Criteria that define this threshold.",
+                                           required=True, allow_null=False)
+    _links = LinkSerializer(help_text="Links for this resource.", required=True, allow_null=False)
diff --git a/lcm/lcm/nf_pm/serializers/threshold_crossed_notification.py b/lcm/lcm/nf_pm/serializers/threshold_crossed_notification.py
new file mode 100644 (file)
index 0000000..2eecc1f
--- /dev/null
@@ -0,0 +1,42 @@
+# Copyright (c) 2019, CMCC Technologies Co., Ltd.
+#
+# 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 lcm.nf_pm.counst import CrossingDirectionType
+from lcm.nf_pm.serializers.Link import LinkSerializer
+
+
+class ThresholdCrossedNotificationSerializer(serializers.Serializer):
+    id = serializers.CharField(help_text="Identifier of this notification.", required=True, allow_null=False)
+    notificationType = serializers.CharField(help_text="Discriminator for the different notification types.",
+                                             required=True, allow_null=False)
+    subscriptionId = serializers.CharField(help_text="Identifier of the subscription that this notification "
+                                                     "relates to", required=True, allow_null=False)
+    timeStamp = serializers.DateField(help_text="Date and time of the generation of the notification",
+                                      required=True, allow_null=False)
+    thresholdId = serializers.CharField(help_text="Identifier of the threshold which has been crossed.",
+                                        required=True, allow_null=False)
+    crossingDirection = serializers.ChoiceField(help_text="An indication of whether the threshold was "
+                                                          "crossed in upward or downward direction.",
+                                                required=True, allow_null=False,
+                                                choices=CrossingDirectionType)
+    objectInstanceId = serializers.CharField(help_text="Identifier that identifies a VNF instance.",
+                                             required=True, allow_null=False)
+    performanceMetric = serializers.CharField(help_text="Performance metric associated with the threshold.",
+                                              required=True, allow_null=False)
+    performanceValue = serializers.CharField(help_text="Value of the metric that resulted in threshold "
+                                                       "crossing.", required=True, allow_null=False)
+    _links = LinkSerializer(help_text="Links to resources related to this notification",
+                            required=True, allow_null=False)