Add "interface_type" field in deployable DB

The added "interface_type" field represents deployables' interface
type when attaching to the hypervisor, e.g pci,mdev etc.
When "interface_type" equals "pci", the "address" field represents
the pci_address, and  when "interface_type" equals "mdev", the
"address" field represents mdev_path.

Change-Id: I9acbecab2aa8741e9aa7f19f7543a5c05defd90b
This commit is contained in:
Coco 2018-07-20 05:10:52 -04:00
parent 88b95ae654
commit 06970bcd0b
10 changed files with 38 additions and 25 deletions

View File

@ -36,7 +36,7 @@ DEPLOYABLE_VERSION = "1.0"
# need to change the driver field name
DEPLOYABLE_HOST_MAPS = {"assignable": "assignable",
"pcie_address": "devices",
"address": "devices",
"board": "product_id",
"type": "function",
"vendor": "vendor_id",
@ -98,8 +98,8 @@ class ResourceTracker(object):
deployables = self.conductor_api.deployable_get_by_host(
context, self.host)
# NOTE(Shaohe Feng) when no "pcie_address" in deployable?
accls = dict([(v["pcie_address"], v) for v in deployables])
# NOTE(Shaohe Feng) when no "address" in deployable?
accls = dict([(v["address"], v) for v in deployables])
accl_bdfs = set(accls.keys())
# Firstly update

View File

@ -49,8 +49,8 @@ class Deployable(base.APIBase):
root_uuid = types.uuid
"""The root UUID of the deployable"""
pcie_address = wtypes.text
"""The pcie address of the deployable"""
address = wtypes.text
"""The address(pci/mdev) of the deployable"""
host = wtypes.text
"""The host on which the deployable is located"""
@ -67,6 +67,9 @@ class Deployable(base.APIBase):
type = wtypes.text
"""The type of the deployable"""
interface_type = wtypes.text
"""The interface type of deployable"""
assignable = types.boolean
"""Whether the deployable is assignable"""
@ -119,7 +122,7 @@ class DeployablePatchType(types.JsonPatchType):
@staticmethod
def internal_attrs():
defaults = types.JsonPatchType.internal_attrs()
return defaults + ['/pcie_address', '/host', '/type']
return defaults + ['/address', '/host', '/type']
class DeployablesController(rest.RestController):

View File

@ -40,8 +40,8 @@ def upgrade():
sa.Column('project_id', sa.String(length=36), nullable=True),
sa.Column('user_id', sa.String(length=36), nullable=True),
sa.Column('device_type', sa.Text(), nullable=False),
sa.Column('acc_type', sa.Text(), nullable=False),
sa.Column('acc_capability', sa.Text(), nullable=False),
sa.Column('acc_type', sa.Text(), nullable=True),
sa.Column('acc_capability', sa.Text(), nullable=True),
sa.Column('vendor_id', sa.Text(), nullable=False),
sa.Column('product_id', sa.Text(), nullable=False),
sa.Column('remotable', sa.Integer(), nullable=False),
@ -62,12 +62,13 @@ def upgrade():
sa.ForeignKey('deployables.uuid'), nullable=True),
sa.Column('root_uuid', sa.String(length=36),
sa.ForeignKey('deployables.uuid'), nullable=True),
sa.Column('pcie_address', sa.Text(), nullable=False),
sa.Column('address', sa.Text(), nullable=False),
sa.Column('host', sa.Text(), nullable=False),
sa.Column('board', sa.Text(), nullable=False),
sa.Column('vendor', sa.Text(), nullable=False),
sa.Column('version', sa.Text(), nullable=False),
sa.Column('type', sa.Text(), nullable=False),
sa.Column('interface_type', sa.Text(), nullable=False),
sa.Column('assignable', sa.Boolean(), nullable=False),
sa.Column('instance_uuid', sa.String(length=36), nullable=True),
sa.Column('availability', sa.Text(), nullable=False),

View File

@ -254,10 +254,11 @@ class Connection(api.Connection):
exact_match_filter_names = ['uuid', 'name',
'parent_uuid', 'root_uuid',
'pcie_address', 'host',
'address', 'host',
'board', 'vendor', 'version',
'type', 'assignable', 'instance_uuid',
'availability', 'accelerator_id']
'type', 'interface_type', 'assignable',
'instance_uuid', 'availability',
'accelerator_id']
attribute_filters = {}
filters_copy = copy.deepcopy(filters)
for key, value in filters_copy.iteritems():
@ -399,10 +400,11 @@ class Connection(api.Connection):
exact_match_filter_names = ['uuid', 'name',
'parent_uuid', 'root_uuid',
'pcie_address', 'host',
'address', 'host',
'board', 'vendor', 'version',
'type', 'assignable', 'instance_uuid',
'availability', 'accelerator_id']
'type', 'interface_type', 'assignable',
'instance_uuid', 'availability',
'accelerator_id']
# Filter the query
query_prefix = self._exact_deployable_filter(query_prefix,

View File

@ -68,8 +68,8 @@ class Accelerator(Base):
project_id = Column(String(36), nullable=True)
user_id = Column(String(36), nullable=True)
device_type = Column(String(255), nullable=False)
acc_type = Column(String(255), nullable=False)
acc_capability = Column(String(255), nullable=False)
acc_type = Column(String(255), nullable=True)
acc_capability = Column(String(255), nullable=True)
vendor_id = Column(String(255), nullable=False)
product_id = Column(String(255), nullable=False)
remotable = Column(Integer, nullable=False)
@ -94,12 +94,13 @@ class Deployable(Base):
ForeignKey('deployables.uuid'), nullable=True)
root_uuid = Column(String(36),
ForeignKey('deployables.uuid'), nullable=True)
pcie_address = Column(String(255), nullable=False)
address = Column(String(255), nullable=False)
host = Column(String(255), nullable=False)
board = Column(String(255), nullable=False)
vendor = Column(String(255), nullable=False)
version = Column(String(255), nullable=False)
type = Column(String(255), nullable=False)
interface_type = Column(String(255), nullable=False)
assignable = Column(Boolean, nullable=False)
instance_uuid = Column(String(36), nullable=True)
availability = Column(String(255), nullable=False)

View File

@ -40,9 +40,9 @@ class Accelerator(base.CyborgObject, object_base.VersionedObjectDictCompat):
'user_id': object_fields.UUIDField(nullable=True),
'device_type': object_fields.StringField(nullable=False),
# The type of the accelerator device, e.g GPU, FPGA, ...
'acc_type': object_fields.StringField(nullable=False),
'acc_type': object_fields.StringField(nullable=True),
# acc_type defines the usage of the accelerator, e.g Crypto
'acc_capability': object_fields.StringField(nullable=False),
'acc_capability': object_fields.StringField(nullable=True),
# acc_capability defines the specific capability, e.g AES
'vendor_id': object_fields.StringField(nullable=False),
# vendor_id refers to ids like NVIDIA, XILINX, INTEL,...

View File

@ -42,14 +42,17 @@ class Deployable(base.CyborgObject, object_base.VersionedObjectDictCompat):
# parent_uuid refers to the id of the VF's parent node
'root_uuid': object_fields.UUIDField(nullable=True),
# root_uuid refers to the id of the VF's root which has to be a PF
'pcie_address': object_fields.StringField(nullable=False),
'address': object_fields.StringField(nullable=False),
# if interface_type is pci(/mdev), address is the pci_address(/path)
'host': object_fields.StringField(nullable=False),
'board': object_fields.StringField(nullable=False),
# board refers to a specific acc board type, e.g P100 GPU card
'vendor': object_fields.StringField(nullable=False),
'version': object_fields.StringField(nullable=False),
'type': object_fields.StringField(nullable=False),
# similar to the acc_type in accelerator.py
# type of deployable, e.g, pf/vf/*f
'interface_type': object_fields.StringField(nullable=False),
# interface to hypervisor(libvirt), e.g, pci/mdev...
'assignable': object_fields.BooleanField(nullable=False),
# identify if an accelerator is in use
'instance_uuid': object_fields.UUIDField(nullable=True),

View File

@ -30,12 +30,13 @@ def fake_db_deployable(**updates):
'name': 'dp_name',
'parent_uuid': None,
'root_uuid': root_uuid,
'pcie_address': '00:7f:0b.2',
'address': '00:7f:0b.2',
'host': 'host_name',
'board': 'KU115',
'vendor': 'Xilinx',
'version': '1.0',
'type': 'pf',
'interface_type': 'pci',
'assignable': True,
'instance_uuid': None,
'availability': 'Available',

View File

@ -31,12 +31,13 @@ def fake_db_physical_function(**updates):
'name': 'dp_name',
'parent_uuid': None,
'root_uuid': root_uuid,
'pcie_address': '00:7f:0b.2',
'address': '00:7f:0b.2',
'host': 'host_name',
'board': 'KU115',
'vendor': 'Xilinx',
'version': '1.0',
'type': 'pf',
'interface_type': 'pci',
'assignable': True,
'instance_uuid': None,
'availability': 'Available',

View File

@ -31,12 +31,13 @@ def fake_db_virtual_function(**updates):
'name': 'dp_name',
'parent_uuid': None,
'root_uuid': root_uuid,
'pcie_address': '00:7f:bb.2',
'address': '00:7f:bb.2',
'host': 'host_name',
'board': 'KU115',
'vendor': 'Xilinx',
'version': '1.0',
'type': 'vf',
'interface_type': 'pci',
'assignable': True,
'instance_uuid': None,
'availability': 'Available',