Coverage for nova/notifications/objects/service.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-04-24 11:16 +0000

1# Copyright (c) 2016 OpenStack Foundation 

2# All Rights Reserved. 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); you may 

5# not use this file except in compliance with the License. You may obtain 

6# a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

13# License for the specific language governing permissions and limitations 

14# under the License. 

15 

16from nova.notifications.objects import base 

17from nova.objects import base as nova_base 

18from nova.objects import fields 

19 

20 

21@base.notification_sample('service-create.json') 

22@base.notification_sample('service-update.json') 

23@base.notification_sample('service-delete.json') 

24@nova_base.NovaObjectRegistry.register_notification 

25class ServiceStatusNotification(base.NotificationBase): 

26 # Version 1.0: Initial version 

27 VERSION = '1.0' 

28 

29 fields = { 

30 'payload': fields.ObjectField('ServiceStatusPayload') 

31 } 

32 

33 

34@nova_base.NovaObjectRegistry.register_notification 

35class ServiceStatusPayload(base.NotificationPayloadBase): 

36 SCHEMA = { 

37 'host': ('service', 'host'), 

38 'binary': ('service', 'binary'), 

39 'topic': ('service', 'topic'), 

40 'report_count': ('service', 'report_count'), 

41 'disabled': ('service', 'disabled'), 

42 'disabled_reason': ('service', 'disabled_reason'), 

43 'availability_zone': ('service', 'availability_zone'), 

44 'last_seen_up': ('service', 'last_seen_up'), 

45 'forced_down': ('service', 'forced_down'), 

46 'version': ('service', 'version'), 

47 'uuid': ('service', 'uuid') 

48 } 

49 # Version 1.0: Initial version 

50 # Version 1.1: Added uuid field. 

51 VERSION = '1.1' 

52 fields = { 

53 'host': fields.StringField(nullable=True), 

54 'binary': fields.StringField(nullable=True), 

55 'topic': fields.StringField(nullable=True), 

56 'report_count': fields.IntegerField(), 

57 'disabled': fields.BooleanField(), 

58 'disabled_reason': fields.StringField(nullable=True), 

59 'availability_zone': fields.StringField(nullable=True), 

60 'last_seen_up': fields.DateTimeField(nullable=True), 

61 'forced_down': fields.BooleanField(), 

62 'version': fields.IntegerField(), 

63 'uuid': fields.UUIDField() 

64 } 

65 

66 def __init__(self, service): 

67 super(ServiceStatusPayload, self).__init__() 

68 self.populate_schema(service=service)