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

45 statements  

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

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

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

3# a copy of the License at 

4# 

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

6# 

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

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

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

10# License for the specific language governing permissions and limitations 

11# under the License. 

12 

13from nova.notifications.objects import base 

14from nova.objects import base as nova_base 

15from nova.objects import fields 

16 

17 

18@nova_base.NovaObjectRegistry.register_notification 

19class AggregatePayload(base.NotificationPayloadBase): 

20 SCHEMA = { 

21 'id': ('aggregate', 'id'), 

22 'uuid': ('aggregate', 'uuid'), 

23 'name': ('aggregate', 'name'), 

24 'hosts': ('aggregate', 'hosts'), 

25 'metadata': ('aggregate', 'metadata'), 

26 } 

27 # Version 1.0: Initial version 

28 # 1.1: Making the id field nullable 

29 VERSION = '1.1' 

30 fields = { 

31 # NOTE(gibi): id is nullable as aggregate.create.start is sent before 

32 # the id is generated by the db 

33 'id': fields.IntegerField(nullable=True), 

34 'uuid': fields.UUIDField(nullable=False), 

35 'name': fields.StringField(), 

36 'hosts': fields.ListOfStringsField(nullable=True), 

37 'metadata': fields.DictOfStringsField(nullable=True), 

38 } 

39 

40 def __init__(self, aggregate): 

41 super(AggregatePayload, self).__init__() 

42 self.populate_schema(aggregate=aggregate) 

43 

44 

45@base.notification_sample('aggregate-create-start.json') 

46@base.notification_sample('aggregate-create-end.json') 

47@base.notification_sample('aggregate-delete-start.json') 

48@base.notification_sample('aggregate-delete-end.json') 

49@base.notification_sample('aggregate-add_host-start.json') 

50@base.notification_sample('aggregate-add_host-end.json') 

51@base.notification_sample('aggregate-remove_host-start.json') 

52@base.notification_sample('aggregate-remove_host-end.json') 

53@base.notification_sample('aggregate-update_metadata-start.json') 

54@base.notification_sample('aggregate-update_metadata-end.json') 

55@base.notification_sample('aggregate-update_prop-start.json') 

56@base.notification_sample('aggregate-update_prop-end.json') 

57@base.notification_sample('aggregate-cache_images-start.json') 

58@base.notification_sample('aggregate-cache_images-end.json') 

59@nova_base.NovaObjectRegistry.register_notification 

60class AggregateNotification(base.NotificationBase): 

61 # Version 1.0: Initial version 

62 VERSION = '1.0' 

63 

64 fields = { 

65 'payload': fields.ObjectField('AggregatePayload') 

66 } 

67 

68 

69@nova_base.NovaObjectRegistry.register_notification 

70class AggregateCachePayload(base.NotificationPayloadBase): 

71 SCHEMA = { 

72 'id': ('aggregate', 'id'), 

73 'uuid': ('aggregate', 'uuid'), 

74 'name': ('aggregate', 'name'), 

75 } 

76 

77 # Version 1.0: Initial version 

78 VERSION = '1.0' 

79 

80 fields = { 

81 'id': fields.IntegerField(), 

82 'uuid': fields.UUIDField(), 

83 'name': fields.StringField(), 

84 

85 # The host that we just worked 

86 'host': fields.StringField(), 

87 

88 # The images that were downloaded or are already there 

89 'images_cached': fields.ListOfStringsField(), 

90 

91 # The images that are unable to be cached for some reason 

92 'images_failed': fields.ListOfStringsField(), 

93 

94 # The N/M progress information for this operation 

95 'index': fields.IntegerField(), 

96 'total': fields.IntegerField(), 

97 } 

98 

99 def __init__(self, aggregate, host, index, total): 

100 super(AggregateCachePayload, self).__init__() 

101 self.populate_schema(aggregate=aggregate) 

102 self.host = host 

103 self.index = index 

104 self.total = total 

105 

106 

107@base.notification_sample('aggregate-cache_images-progress.json') 

108@nova_base.NovaObjectRegistry.register_notification 

109class AggregateCacheNotification(base.NotificationBase): 

110 # Version 1.0: Initial version 

111 VERSION = '1.0' 

112 

113 fields = { 

114 'payload': fields.ObjectField('AggregateCachePayload'), 

115 }