Coverage for nova/notifications/objects/keypair.py: 100%
21 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-17 15:08 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-17 15:08 +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.
13from nova.notifications.objects import base
14from nova.objects import base as nova_base
15from nova.objects import fields
18@nova_base.NovaObjectRegistry.register_notification
19class KeypairPayload(base.NotificationPayloadBase):
20 SCHEMA = {
21 'user_id': ('keypair', 'user_id'),
22 'name': ('keypair', 'name'),
23 'public_key': ('keypair', 'public_key'),
24 'fingerprint': ('keypair', 'fingerprint'),
25 'type': ('keypair', 'type')
26 }
27 # Version 1.0: Initial version
28 VERSION = '1.0'
29 fields = {
30 'user_id': fields.StringField(nullable=True),
31 'name': fields.StringField(nullable=False),
32 'fingerprint': fields.StringField(nullable=True),
33 'public_key': fields.StringField(nullable=True),
34 'type': fields.StringField(nullable=False),
35 }
37 def __init__(self, keypair, **kwargs):
38 super(KeypairPayload, self).__init__(**kwargs)
39 self.populate_schema(keypair=keypair)
42@base.notification_sample('keypair-create-start.json')
43@base.notification_sample('keypair-create-end.json')
44@base.notification_sample('keypair-delete-start.json')
45@base.notification_sample('keypair-delete-end.json')
46@base.notification_sample('keypair-import-start.json')
47@base.notification_sample('keypair-import-end.json')
48@nova_base.NovaObjectRegistry.register_notification
49class KeypairNotification(base.NotificationBase):
50 # Version 1.0: Initial version
51 VERSION = '1.0'
53 fields = {
54 'payload': fields.ObjectField('KeypairPayload')
55 }