Files
deb-nova/nova/objects/virt_device_metadata.py
Artom Lifshitz 0c8f01d238 Add metadata objects for device tagging
This patch series adds the ability for a user to specify a tag to be
applied to a network interface or a disk when booting an instance.
This tag is then exposed through the metadata API. For example, a user
boots a VM with two network interfaces. One is connected to a private
network, the other to the public Internet. There is currently no
direct way to tell which interface is which. Specifying tags allows
the user to distinguish between the two interfaces.

This patch introduces the new metadata objects.

Implements: blueprint virt-device-role-tagging
Co-authored-by: Vladik Romanovsky <vromanso@redhat.com>
Change-Id: I8e7100f83ef8504f19b156283e0ade0fcb37dc56
2016-04-04 09:46:39 +00:00

97 lines
2.2 KiB
Python

# Copyright (C) 2016, Red Hat, Inc.
#
# 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 nova.objects import base
from nova.objects import fields
@base.NovaObjectRegistry.register_if(False)
class DeviceBus(base.NovaObject):
VERSION = '1.0'
@base.NovaObjectRegistry.register
class PCIDeviceBus(DeviceBus):
VERSION = '1.0'
fields = {
'address': fields.PCIAddressField(),
}
@base.NovaObjectRegistry.register
class USBDeviceBus(DeviceBus):
VERSION = '1.0'
fields = {
'address': fields.USBAddressField(),
}
@base.NovaObjectRegistry.register
class SCSIDeviceBus(DeviceBus):
VERSION = '1.0'
fields = {
'address': fields.SCSIAddressField(),
}
@base.NovaObjectRegistry.register
class IDEDeviceBus(DeviceBus):
VERSION = '1.0'
fields = {
'address': fields.IDEAddressField(),
}
@base.NovaObjectRegistry.register
class DeviceMetadata(base.NovaObject):
VERSION = '1.0'
fields = {
'bus': fields.ObjectField("DeviceBus", subclasses=True),
'tags': fields.ListOfStringsField(),
}
@base.NovaObjectRegistry.register
class NetworkInterfaceMetadata(DeviceMetadata):
VERSION = '1.0'
fields = {
'mac': fields.MACAddressField(),
}
@base.NovaObjectRegistry.register
class DiskMetadata(DeviceMetadata):
VERSION = '1.0'
fields = {
'serial': fields.StringField(nullable=True),
'path': fields.StringField(nullable=True),
}
@base.NovaObjectRegistry.register
class DeviceMetadataList(base.ObjectListBase, base.NovaObject):
VERSION = '1.0'
fields = {
'objects': fields.ListOfObjectsField('DeviceMetadata',
subclasses=True),
}