From 9bfb7ff4fdcf608ced5b25ad50e20a0ddbcbe012 Mon Sep 17 00:00:00 2001 From: yangyan Date: Mon, 14 Oct 2019 16:37:40 +0800 Subject: [PATCH] Update ns fault management interface serializer Change-Id: Ic6fff9ed5245a94c0be7046c94ad8abea9963f24 Issue-ID: VFC-1551 Signed-off-by: yangyan --- lcm/ns/enum.py | 33 +++- .../sol/ns_fault_management_interface.py | 198 +++++++++++++++++++++ .../sol/ns_performance_anagement_interface.py | 6 +- 3 files changed, 232 insertions(+), 5 deletions(-) create mode 100644 lcm/ns/serializers/sol/ns_fault_management_interface.py diff --git a/lcm/ns/enum.py b/lcm/ns/enum.py index 08ef1207..0763ee6a 100644 --- a/lcm/ns/enum.py +++ b/lcm/ns/enum.py @@ -194,10 +194,39 @@ VNF_STATE = enum( STARTED="STARTED", STOPPED="STOPPED" ) -CROSSINGDIRECTION_Type = enum( +CROSSINGDIRECTION_TYPE = enum( UP="UP", DOWN="DOWN" ) -threshold_Type = enum( +THRESHOLD_TYPE = enum( SIMPLE="Single-valued static threshold" ) +NOTIFICATION_TYPES = enum( + AlarmNotification="AlarmNotification", + AlarmClearedNotification="AlarmClearedNotification", + AlarmListRebuiltNotification="AlarmListRebuiltNotification" +) +EVENT_TYPE = enum( + COMMUNICATIONS_ALARM="COMMUNICATIONS_ALARM", + PROCESSING_ERROR_ALARM="PROCESSING_ERROR_ALARM", + ENVIRONMENTAL_ALARM="ENVIRONMENTAL_ALARM", + QOS_ALARM="QOS_ALARM", + EQUIPMENT_ALARM="EQUIPMENT_ALARM" +) +PERCEIVED_SEVERITY_TYPE = enum( + CRITICAL="CRITICAL", + MAJOR="MAJOR", + MINOR="MINOR", + WARNING="WARNING", + INDETERMINATE="INDETERMINATE", + CLEARED="CLEARED" +) +FAULTY_RESOURCE_TYPE = enum( + COMPUTE="COMPUTE", + STORAGE="STORAGE", + NETWORK="NETWORK" +) +ACK_STATE = enum( + UNACKNOWLEDGED="UNACKNOWLEDGED", + ACKNOWLEDGED="ACKNOWLEDGED" +) diff --git a/lcm/ns/serializers/sol/ns_fault_management_interface.py b/lcm/ns/serializers/sol/ns_fault_management_interface.py new file mode 100644 index 00000000..31c248af --- /dev/null +++ b/lcm/ns/serializers/sol/ns_fault_management_interface.py @@ -0,0 +1,198 @@ +# 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.ns.enum import NOTIFICATION_TYPES, EVENT_TYPE, PERCEIVED_SEVERITY_TYPE, FAULTY_RESOURCE_TYPE, \ + ACK_STATE +from lcm.ns.serializers.sol.ns_performance_anagement_interface import NsInstanceSubscriptionFilterSerializer, \ + SubscriptionAuthenticationSerializer +from lcm.pub.utils.enumutil import enum_to_list + + +# FmSubscriptionRequest +class FmNotificationsFilterSerializer(serializers.Serializer): + nsInstanceSubscriptionFilter = NsInstanceSubscriptionFilterSerializer( + help_text="Filter criteria to select NS instances about which to notify.", + required=False, allow_null=True) + notificationTypes = serializers.ListField(help_text="Match particular notification types", + child=serializers.ChoiceField( + required=False, + choices=enum_to_list(NOTIFICATION_TYPES)), + required=False, allow_null=True, many=True) + faultyResourceTypes = serializers.ListField(help_text="Match alarms related to NSs with a faulty " + "resource type listed in this attribute", + child=serializers.ChoiceField( + choices=enum_to_list(FAULTY_RESOURCE_TYPE)), + required=False, allow_null=True, many=True,) + perceivedSeverities = serializers.ListField(help_text="Match alarms related to NSs with a perceived " + "severity listed in this attribute.", + child=serializers.ChoiceField( + choices=enum_to_list(PERCEIVED_SEVERITY_TYPE)), + required=False, allow_null=True, many=True,) + eventTypes = serializers.ListField(help_text="Match alarms releted to NSs with an event type listed in" + "this attribute.", + child=serializers.ChoiceField(choices=enum_to_list(EVENT_TYPE)), + required=False, allow_null=True, many=True,) + probableCauses = serializers.CharField(help_text="Match alarms related to NSs with a probable cause " + "listed in this attribute", + required=False, allow_null=True, many=True) + + +class FmSubscriptionRequestSerializer(serializers.Serializer): + filter = FmNotificationsFilterSerializer(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) + authentication = SubscriptionAuthenticationSerializer( + help_text="Authentication parameters to conFigure the use of Authorization when sendingnotifications" + " corresponding to this subscription", required=False, allow_null=True) + + +# FmSubscription +class FmSubscriptionSerializer(serializers.Serializer): + id = serializers.CharField(help_text="Identifier of this subscription resource", + required=True, allow_null=False) + filter = FmNotificationsFilterSerializer(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=False, allow_null=True) + _links = serializers.CharField(help_text="Links for this resource.", required=True, allow_null=False) + + +# Alarm +class FaultyComponentInfoSerializer(serializers.Serializer): + faultyNestedNsInstanceId = serializers.CharField(help_text="Identifier of the faulty nested NS instance", + required=False, allow_null=True) + faultyNsVirtualLinkInstanceId = serializers.CharField(help_text="Identifier of the faulty NS " + "virtual link instance.", + required=True, allow_null=False) + faultyVnfInstanceId = serializers.CharField(help_text="Identifier of the faulty VNF instance", + required=True, allow_null=False) + + +class ResourceHandleSerualizer(serializers.Serializer): + vimId = serializers.CharField(help_text="Identifier of the VIM under whose control this resource is " + "placed.", required=False, allow_null=True) + resourceProviderId = serializers.CharField(help_text="Identifier of the entity responsible for the " + "management of the resource.", + required=False, allow_null=True) + resourceId = serializers.CharField(help_text="Identifier of the resource in the scope of the VIM or the " + "resource provider", required=True, allow_null=False) + vimLevelResourceType = serializers.CharField(help_text="Type of the resource in the scope of the VIM or" + " the resource provider.", + required=False, allow_null=True) + + +class FaultyResourceInfoSerialzier(serializers.Serializer): + faultyResource = ResourceHandleSerualizer(help_text="Information that identifies the faulty resource " + "instance and its managing entity", + required=True, allow_null=False) + faultyResourceType = serializers.ListField(help_text="Type of the faulty resource.", + child=serializers.ChoiceField( + choices=enum_to_list(FAULTY_RESOURCE_TYPE)), + required=True, allow_null=False,) + + +class AlarmSerializer(serializers.Serializer): + id = serializers.CharField(help_text="Identifier of this Alarm information element.", + required=True, allow_null=False) + managedObjectId = serializers.CharField(help_text="Identifier of the affected NS instance.", + required=True, allow_null=False) + rootCauseFaultyComponent = FaultyComponentInfoSerializer( + help_text="The NS components that are causing the NS fault.", required=False, allow_null=True) + rootCauseFaultyResource = FaultyResourceInfoSerialzier(help_text="The virtualised resources that are" + " causing the NS fault.", + required=False, allow_null=True) + alarmRaisedTime = serializers.DateField(help_text="Time stamp indicating when the alarm is raised by " + "the managed object", required=True, allow_null=False) + alarmChangedTime = serializers.DateField(help_text="Time stamp indicating when the alarm was last" + " changed.", required=False, allow_null=True) + alarmClearedTime = serializers.DateField(help_text="Time stamp indicating when the alarm was cleared.", + required=False, allow_null=True) + ackState = serializers.ListField(help_text="Acknowledgement state of the alarm.", + child=serializers.ChoiceField(choices=enum_to_list(ACK_STATE)), + required=True, allow_null=False) + perceivedSeverity = serializers.ListField(help_text="Perceived severity of the managed object failure.", + child=serializers.ChoiceField( + choices=enum_to_list(PERCEIVED_SEVERITY_TYPE)), + required=True, allow_null=False) + eventTime = serializers.DateField(help_text="Time stamp indicating when the fault was observed.", + required=True, allow_null=False) + eventType = serializers.ListField(help_text="Type of event", + child=serializers.ChoiceField( + choices=enum_to_list(EVENT_TYPE)), + required=True, allow_null=False) + faultType = serializers.CharField(help_text="Additional information to clarify the type of the fault.", + required=False, allow_null=True) + probableCause = serializers.CharField(help_text="Information about the probable cause of the fault.", + required=True, allow_null=False) + + +# AlarmNotification +class AlarmNotificationSerializer(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-time of the generation of the notification.", + required=True, allow_null=False) + alarm = AlarmSerializer(help_text="Information about an alarm including AlarmId, affected NS identifier," + " and FaultDetails.", required=True, allow_null=False) + _links = serializers.CharField(help_text="Links to resources related to this notification.", + required=True, allow_null=False) + + +# AlarmClearedNotification +class AlarmClearedNotificationSerializer(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-time of the generation of the notification.", + required=True, allow_null=False) + alarmId = serializers.CharField(help_text="Alarm identifier.", required=True, allow_null=False) + alarmClearedTime = serializers.DateField(help_text="The time stamp indicating when the alarm was" + " cleared.", required=True, allow_null=False) + _links = serializers.CharField(help_text="Links to resources related to this notification.", + required=True, allow_null=False) + + +# AlarmListRebuiltNotification +class AlarmListRebuiltNotificationSerializer(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-time of the generation of the notification.", + required=True, allow_null=False) + _links = serializers.CharField(help_text="Links to resources related to this notification.", + required=True, allow_null=False) + + +# AlarmModifications +class AlarmModificationsSerializer(serializers.Serializer): + ackState = serializers.ListField(help_text="New value of the ackState attribute in Alarm", + child=serializers.ChoiceField(choices=enum_to_list(ACK_STATE)), + required=True, allow_null=False) diff --git a/lcm/ns/serializers/sol/ns_performance_anagement_interface.py b/lcm/ns/serializers/sol/ns_performance_anagement_interface.py index 844b5db0..c3ea9f56 100644 --- a/lcm/ns/serializers/sol/ns_performance_anagement_interface.py +++ b/lcm/ns/serializers/sol/ns_performance_anagement_interface.py @@ -16,7 +16,7 @@ from rest_framework import serializers # PmSubscriptionRequest -from lcm.ns.enum import CROSSINGDIRECTION_Type, threshold_Type +from lcm.ns.enum import CROSSINGDIRECTION_TYPE, THRESHOLD_TYPE from lcm.pub.utils.enumutil import enum_to_list @@ -111,7 +111,7 @@ class ThresholdCrossedNotificationSerializer(serializers.Serializer): "in upward or downward direction.", child=serializers.ChoiceField( required=True, - choices=enum_to_list(CROSSINGDIRECTION_Type)), + 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) @@ -184,7 +184,7 @@ class ThresholdCriteriaSerializer(serializers.Serializer): "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, choices=enum_to_list(THRESHOLD_TYPE)), required=True, allow_null=False) -- 2.16.6