Fix GPU's improper cpid_type allowed value and attach_handle_type value

``ControlPathID`` table tracks identifiers for a control path interface to devices.
When we were discussing the valid values of cpid_type at 2020-02-27 Cyborg
weekly meeting[0], an agreement was made that allowed cpid_type values are
"PCI". And for GPUs (either pGPU or vGPU), they all report
"PCI" as their cpid_type, while ``attach_handle_type`` of them are different.

This patch fixes the improper cpid_type allowed value and attach_handle_type
value. No unit test is affected.
vGPU report will be implemented in future release.

[0]http://eavesdrop.openstack.org/meetings/openstack_cyborg/2020/openstack_cyborg.2020-02-27-03.00.log.html

Closes task: 38954

Change-Id: Iafb23b47bf022f81776af77d205fc788d1b0d6b6
This commit is contained in:
Yumeng Bao 2020-02-24 01:22:09 -08:00 committed by YumengBao
parent 809fd6003b
commit 0303fde937
3 changed files with 14 additions and 5 deletions

View File

@ -119,6 +119,8 @@ def _generate_driver_device(gpu):
def _generate_controlpath_id(gpu):
driver_cpid = driver_controlpath_id.DriverControlPathID()
# NOTE: GPUs (either pGPU or vGPU), they all report "PCI" as
# their cpid_type, while attach_handle_type of them are different.
driver_cpid.cpid_type = "PCI"
driver_cpid.cpid_info = utils.pci_str_to_json(gpu["devices"])
return driver_cpid
@ -147,7 +149,10 @@ def _generate_dep_list(gpu):
def _generate_attach_handle(gpu):
driver_ah = driver_attach_handle.DriverAttachHandle()
driver_ah.attach_type = constants.AH_TYPE_PCI
if gpu["rc"] == "PGPU":
driver_ah.attach_type = constants.AH_TYPE_PCI
else:
driver_ah.attach_type = constants.AH_TYPE_MDEV
driver_ah.in_use = False
driver_ah.attach_info = utils.pci_str_to_json(gpu["devices"])
return driver_ah

View File

@ -66,6 +66,10 @@ ATTACH_HANDLE_TYPES = (AH_TYPE_PCI, AH_TYPE_MDEV, AH_TYPE_TEST_PCI) = (
"PCI", "MDEV", "TEST_PCI")
# Control Path ID type
CPID_TYPE = (CPID_TYPE_PCI) = ("PCI")
# Resource Class
RESOURCES = {
"FPGA": orc.FPGA,

View File

@ -17,14 +17,13 @@ from oslo_log import log as logging
from oslo_serialization import jsonutils
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__)
CPID_TYPE = ["PCI", "MDEV"]
@base.CyborgObjectRegistry.register
class ControlpathID(base.CyborgObject, object_base.VersionedObjectDictCompat):
@ -38,8 +37,9 @@ class ControlpathID(base.CyborgObject, object_base.VersionedObjectDictCompat):
'id': object_fields.IntegerField(nullable=False),
'uuid': object_fields.UUIDField(nullable=False),
'device_id': object_fields.IntegerField(nullable=False),
'cpid_type': object_fields.EnumField(valid_values=CPID_TYPE,
nullable=False),
'cpid_type': object_fields.EnumField(
valid_values=constants.CPID_TYPE,
nullable=False),
'cpid_info': object_fields.StringField(nullable=False)
}