aboutsummaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authoryangyan <yangyanyj@chinamobile.com>2019-10-12 09:39:25 +0800
committerYan Yang <yangyanyj@chinamobile.com>2019-10-12 07:55:09 +0000
commit67b4aa43395d5787f7bcb67dcc7f1b313b4f0793 (patch)
tree81672eaa9273f2b55d2725ad87d4d9ea85ca91b7 /lcm
parenta7bcbbec8a29579e776419e84021339c5a682ed4 (diff)
Update Rresource and notification data types serializer
Change-Id: I49adb673f5d96a47e016bc28354c46d21bc8749f Issue-ID: VFC-1547 Signed-off-by: yangyan <yangyanyj@chinamobile.com>
Diffstat (limited to 'lcm')
-rw-r--r--lcm/ns/enum.py7
-rw-r--r--lcm/ns/serializers/sol/ns_performance_anagement_interface.py212
2 files changed, 219 insertions, 0 deletions
diff --git a/lcm/ns/enum.py b/lcm/ns/enum.py
index e2755ec2..08ef1207 100644
--- a/lcm/ns/enum.py
+++ b/lcm/ns/enum.py
@@ -194,3 +194,10 @@ VNF_STATE = enum(
STARTED="STARTED",
STOPPED="STOPPED"
)
+CROSSINGDIRECTION_Type = enum(
+ UP="UP",
+ DOWN="DOWN"
+)
+threshold_Type = enum(
+ SIMPLE="Single-valued static threshold"
+)
diff --git a/lcm/ns/serializers/sol/ns_performance_anagement_interface.py b/lcm/ns/serializers/sol/ns_performance_anagement_interface.py
new file mode 100644
index 00000000..844b5db0
--- /dev/null
+++ b/lcm/ns/serializers/sol/ns_performance_anagement_interface.py
@@ -0,0 +1,212 @@
+# 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
+
+
+# PmSubscriptionRequest
+from lcm.ns.enum import CROSSINGDIRECTION_Type, threshold_Type
+from lcm.pub.utils.enumutil import enum_to_list
+
+
+class NsInstanceSubscriptionFilterSerializer(serializers.Serializer):
+ nsdIds = serializers.CharField(help_text="If present, match NS instances that were created based on a"
+ " NSD identified by one of the nsdId values listed in this"
+ " attribute.", required=False, allow_null=True, many=True)
+ vnfdIds = serializers.CharField(help_text="If present, match NS instances that contain VNF instances that"
+ " were created based on a VNFD identified by one of the vnfdId "
+ "values listed in this attribute.", required=False,
+ allow_null=True, many=True)
+ pnfdIds = serializers.CharField(help_text="If present, match NS instances that contain PNFs that are "
+ "represented by a PNFD identified by one of the pnfdId values "
+ "listed in this attribute", required=False,
+ allow_null=True, many=True)
+ nsInstanceIds = serializers.CharField(help_text="If present, match NS instances with an instance "
+ "identifier listed in this attribute.",
+ required=False, allow_null=True, many=True)
+ nsInstanceNames = serializers.CharField(help_text="If present, match NS instances with a NS Instance Name"
+ " listed in this attribute",
+ required=False, allow_null=True, many=True)
+
+
+class PmNotificationsFilterSerializer(serializers.Serializer):
+ nsInstanceSubscriptionFilter = NsInstanceSubscriptionFilterSerializer(help_text="Filter criteria to"
+ " select NS instances "
+ "about which to notify",
+ required=False, allow_null=True,
+ allow_blank=True)
+ notificationTypes = serializers.ChoiceField(help_text="Match particular notification types.",
+ choices=["ThresholdCrossedNotification",
+ "PerformanceInformationAvailableNotification"],
+ required=False, allow_null=True, many=True)
+
+
+class SubscriptionAuthenticationSerializer(serializers.Serializer):
+ authType = serializers.ChoiceField(help_text="Defines the types of Authentication Authorization the API"
+ " consumer is willing to accept when receiving a"
+ " notification.", choices=["BASIC",
+ "OAUTH2_CLIENT_CREDENTIALS",
+ "TLS_CERT"], required=True,
+ allow_null=False, many=True)
+ paramsBasic = serializers.CharField(help_text="Parameters for authentication authorization using BASIC",
+ required=False, allow_null=True, allow_blank=True)
+ paramsOauth2ClientCredentials = serializers.CharField(help_text="Parameters for authentication "
+ "authorization using OAUTH2"
+ "_CLIENT_CREDENTIALS.",
+ required=False, allow_null=True, allow_blank=True)
+
+
+class PmSubscriptionRequestSerializer(serializers.Serializer):
+ 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,
+ allow_blank=True)
+ callbackUri = serializers.CharField(help_text="The URI of the endpoint to send the notification to",
+ required=True, allow_null=False, allow_blank=False)
+ authentication = SubscriptionAuthenticationSerializer(help_text="Authentication parameters to conFigure"
+ " the use of Authorization when sending"
+ " notifications corresponding to "
+ "this subscription",
+ required=False, allow_null=True, allow_blank=True)
+
+
+# PmSubscription
+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 = serializers.CharField(help_text="Links to resources related to this resource.",
+ required=True, allow_null=False)
+
+
+# ThresholdCrossedNotification
+class ThresholdCrossedNotificationSerializer(serializers.Serializer):
+ id = serializers.CharField(help_text="Identifier of this notification. If a notification is sent multiple"
+ " times due to multiple subscriptions",
+ 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.CharField(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.ListField(help_text="An indication of whether the threshold was crossed "
+ "in upward or downward direction.",
+ child=serializers.ChoiceField(
+ required=True,
+ choices=enum_to_list(CROSSINGDIRECTION_Type)),
+ required=True, allow_null=False)
+ objectInstanceId = serializers.CharField(help_text="Identifier that identifies a NS 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 = serializers.CharField(help_text="Links to resources related to this notification",
+ required=True, allow_null=False)
+
+
+# PerformanceInformationAvailableNotification
+class PerformanceInformationAvailableNotification(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)
+ objectInstanceId = serializers.CharField(help_text="Identifier that identifies a NS instance.",
+ required=True, allow_null=False)
+ _links = serializers.CharField(help_text="Links to resources related to this notification",
+ required=True, allow_null=False)
+
+
+# CreatePmJobRequest
+class PmJobCriteriaSerializer(serializers.Serializer):
+ performanceMetric = serializers.CharField(help_text="This defines the types of performance metrics for"
+ " the specified object instances",
+ required=False, allow_null=True, many=True)
+ performanceMetricGroup = serializers.CharField(help_text="Group of performance metrics.",
+ required=False, allow_null=True, many=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="Identifies a time boundary after which the "
+ "reporting will stop",
+ required=False, allow_null=True)
+
+
+class CreatePmJobRequestSerializer(serializers.Serializer):
+ objectInstanceIds = serializers.CharField(help_text="Identifiers of the NS instances for which"
+ " performance information is requested to be"
+ " collected.",
+ required=True, allow_null=False, many=True)
+ criteria = PmJobCriteriaSerializer(help_text="Criteria of the collection of performance information.",
+ required=True, allow_null=False)
+
+
+# PmJob
+class PmJobSerializer(serializers.Serializer):
+ id = serializers.CharField(help_text="Identifier of this PM job.", required=True, allow_null=False)
+ objectInstanceIds = serializers.CharField(help_text="Identifiers of the NS instances for which "
+ "performance information is collected.",
+ required=True, allow_null=False, many=True)
+ criteria = PmJobCriteriaSerializer(help_text="Criteria of the collection of performance "
+ "information.", required=True)
+ reports = serializers.CharField(help_text="Information about available reports collected by this PM job",
+ required=False, allow_null=True, many=True)
+ _links = serializers.CharField(help_text="Links for this resource.", required=False, allow_null=True)
+
+
+# CreateThresholdRequest
+class ThresholdCriteriaSerializer(serializers.Serializer):
+ performanceMetric = serializers.CharField(help_text="Defines the performance metric associated with the "
+ "threshold", required=True, allow_null=False)
+ thresholdType = serializers.ListField(help_text="Type of threshold.",
+ child=serializers.ChoiceField(
+ required=True, choices=enum_to_list(threshold_Type)),
+ required=True, allow_null=False)
+
+
+class CreateThresholdRequestSerializer(serializers.Serializer):
+ objectInstanceId = serializers.CharField(help_text="Identifier of the NS instance associated with this "
+ "threshold", required=True, allow_null=False)
+ criteria = ThresholdCriteriaSerializer(help_text="Criteria that define this threshold.",
+ required=True, allow_null=False)
+
+
+# Threshold
+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 NS instance associated with the "
+ "threshold.", required=True, allow_null=False)
+ criteria = serializers.CharField(help_text="Criteria that define this threshold.",
+ required=True, allow_null=False)
+ _links = serializers.CharField(help_text="Links for this resource.", required=True, allow_null=False)
+
+
+# PerformanceReport
+class PerformanceReportSerializer(serializers.Serializer):
+ entries = serializers.CharField(help_text="List of performance information entries.",
+ required=True, allow_null=False, many=True)