Merge "fake driver bug fix"
This commit is contained in:
commit
fcdb495619
@ -25,7 +25,7 @@ class FakeDriver(GenericDriver):
|
||||
def _generate_attach_handle(self, pci):
|
||||
driver_ah = driver_attach_handle.DriverAttachHandle()
|
||||
# The virt driver will ignore this type when attaching
|
||||
driver_ah.attach_type = "fake"
|
||||
driver_ah.attach_type = constants.AH_TYPE_TEST_PCI
|
||||
driver_ah.in_use = False
|
||||
driver_ah.attach_info = pci["slot"]
|
||||
return driver_ah
|
||||
@ -36,8 +36,7 @@ class FakeDriver(GenericDriver):
|
||||
attr_traits.value = "CUSTOM_FAKE_DEVICE"
|
||||
attr_rc = driver_attribute.DriverAttribute()
|
||||
attr_rc.key = "rc"
|
||||
attr_rc.value = rc_fields.ResourceClass.normalize_name(
|
||||
rc_fields.ResourceClass.FPGA)
|
||||
attr_rc.value = orc.FPGA
|
||||
return [attr_traits, attr_rc]
|
||||
|
||||
def _generate_dep_list(self, pci):
|
||||
@ -49,15 +48,14 @@ class FakeDriver(GenericDriver):
|
||||
return [driver_dep]
|
||||
|
||||
def discover(self):
|
||||
npu_list = []
|
||||
fpga_list = []
|
||||
pci_addr = '{"domain":"0000","bus":"0c","device":"00","function":"0"}'
|
||||
pci_dict = {
|
||||
'slot': pci_addr, # PCI slot address
|
||||
'device': 'FakeDevice', # Name of the device
|
||||
'vendor_id': 'fake', # ID of the vendor
|
||||
'vendor_id': '0xABCD', # ID of the vendor
|
||||
'class': 'Fake class', # Name of the class
|
||||
'device_id': 'fake', # ID of the device
|
||||
'revision': '20' # Revision number
|
||||
'device_id': '0xabcd' # ID of the device
|
||||
}
|
||||
device = driver_device.DriverDevice()
|
||||
device.vendor = pci_dict["vendor_id"]
|
||||
@ -66,11 +64,12 @@ class FakeDriver(GenericDriver):
|
||||
'class': pci_dict.get('class', None)}
|
||||
device.std_board_info = jsonutils.dumps(std_board_info)
|
||||
device.vendor_board_info = 'fake_vendor_info'
|
||||
device.type = orc.PGPU
|
||||
device.type = constants.DEVICE_FPGA
|
||||
device.stub = False
|
||||
device.controlpath_id = self._generate_controlpath_id(pci_dict)
|
||||
device.deployable_list = self._generate_dep_list(pci_dict)
|
||||
npu_list.append(device)
|
||||
return npu_list
|
||||
fpga_list.append(device)
|
||||
return fpga_list
|
||||
|
||||
def update(self, control_path, image_path):
|
||||
return True
|
||||
|
@ -282,7 +282,7 @@ def _generate_dep_list(fpga, pf_has_vf):
|
||||
|
||||
def _generate_attach_handle(fpga):
|
||||
driver_ah = driver_attach_handle.DriverAttachHandle()
|
||||
driver_ah.attach_type = "PCI"
|
||||
driver_ah.attach_type = constants.AH_TYPE_PCI
|
||||
driver_ah.attach_info = utils.pci_str_to_json(fpga["devices"])
|
||||
driver_ah.in_use = False
|
||||
return driver_ah
|
||||
|
@ -114,7 +114,7 @@ def _generate_dep_list(gpu):
|
||||
|
||||
def _generate_attach_handle(gpu):
|
||||
driver_ah = driver_attach_handle.DriverAttachHandle()
|
||||
driver_ah.attach_type = "PCI"
|
||||
driver_ah.attach_type = constants.AH_TYPE_PCI
|
||||
driver_ah.in_use = False
|
||||
driver_ah.attach_info = utils.pci_str_to_json(gpu["devices"])
|
||||
return driver_ah
|
||||
|
@ -26,3 +26,8 @@ ARQ_STATES = (ARQ_INITIAL, ARQ_BOUND, ARQ_UNBOUND, ARQ_BIND_FAILED) = \
|
||||
|
||||
# Device type
|
||||
DEVICE_TYPE = (DEVICE_GPU, DEVICE_FPGA, DEVICE_AICHIP)
|
||||
|
||||
# Attach handle type
|
||||
# 'TEST_PCI': used by fake driver, ignored by Nova virt driver.
|
||||
ATTACH_HANDLE_TYPES = (AH_TYPE_PCI, AH_TYPE_MDEV, AH_TYPE_TEST_PCI) = (
|
||||
"PCI", "MDEV", "TEST_PCI")
|
||||
|
@ -65,3 +65,12 @@ def upgrade():
|
||||
op.alter_column(
|
||||
'extended_accelerator_requests', 'state',
|
||||
existing_type=ns, nullable=False, default=constants.ARQ_INITIAL)
|
||||
|
||||
# update attach type fields
|
||||
new_attach_type = sa.Enum(constants.AH_TYPE_PCI,
|
||||
constants.AH_TYPE_MDEV,
|
||||
constants.AH_TYPE_TEST_PCI,
|
||||
name='attach_type')
|
||||
op.alter_column('attach_handles', 'attach_type',
|
||||
existing_type=new_attach_type,
|
||||
nullable=False)
|
||||
|
@ -164,7 +164,10 @@ class AttachHandle(Base):
|
||||
ForeignKey('controlpath_ids.id', ondelete="RESTRICT"),
|
||||
nullable=False)
|
||||
in_use = Column(Boolean, default=False)
|
||||
attach_type = Column(Enum('PCI', 'MDEV', name='attach_type'),
|
||||
attach_type = Column(Enum(constants.AH_TYPE_PCI,
|
||||
constants.AH_TYPE_MDEV,
|
||||
constants.AH_TYPE_TEST_PCI,
|
||||
name='attach_type'),
|
||||
nullable=False)
|
||||
attach_info = Column(String(255), nullable=False)
|
||||
|
||||
|
@ -16,14 +16,13 @@
|
||||
from oslo_log import log as logging
|
||||
from oslo_versionedobjects import base as object_base
|
||||
|
||||
from cyborg.common import constants
|
||||
from cyborg.db import api as dbapi
|
||||
from cyborg.objects import base
|
||||
from cyborg.objects import fields as object_fields
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
ATTACH_TYPE = ["PCI", "MDEV"]
|
||||
|
||||
|
||||
@base.CyborgObjectRegistry.register
|
||||
class AttachHandle(base.CyborgObject, object_base.VersionedObjectDictCompat):
|
||||
@ -37,8 +36,9 @@ class AttachHandle(base.CyborgObject, object_base.VersionedObjectDictCompat):
|
||||
'uuid': object_fields.UUIDField(nullable=False),
|
||||
'deployable_id': object_fields.IntegerField(nullable=False),
|
||||
'cpid_id': object_fields.IntegerField(nullable=False),
|
||||
'attach_type': object_fields.EnumField(valid_values=ATTACH_TYPE,
|
||||
nullable=False),
|
||||
'attach_type': object_fields.EnumField(
|
||||
valid_values=constants.ATTACH_HANDLE_TYPES,
|
||||
nullable=False),
|
||||
# attach_info should be JSON here.
|
||||
'attach_info': object_fields.StringField(nullable=False),
|
||||
'in_use': object_fields.BooleanField(nullable=False, default=False)
|
||||
|
Loading…
Reference in New Issue
Block a user