diff --git a/cyborg/accelerator/drivers/fpga/inspur/sysinfo.py b/cyborg/accelerator/drivers/fpga/inspur/sysinfo.py index 3949e36f..dd7e0625 100644 --- a/cyborg/accelerator/drivers/fpga/inspur/sysinfo.py +++ b/cyborg/accelerator/drivers/fpga/inspur/sysinfo.py @@ -24,6 +24,7 @@ from oslo_serialization import jsonutils from cyborg.accelerator.common import utils from cyborg.common import constants +from cyborg.conf import CONF from cyborg.objects.driver_objects import driver_attach_handle from cyborg.objects.driver_objects import driver_attribute from cyborg.objects.driver_objects import driver_controlpath_id @@ -122,7 +123,10 @@ def _generate_dep_list(fpga): driver_dep = driver_deployable.DriverDeployable() driver_dep.attribute_list = _generate_attribute_list(fpga) driver_dep.attach_handle_list = [] - driver_dep.name = fpga.get('name', '') + '_' + fpga["devices"] + # NOTE(wenping) Now simply named as _ + # once cyborg needs to support Inspur FPGA devices discovered from a + # baremetal node, we might need to support more formats. + driver_dep.name = CONF.host + '_' + fpga["devices"] driver_dep.driver_name = VENDOR_MAPS.get(fpga["vendor_id"]).upper() driver_dep.num_accelerators = 1 driver_dep.attach_handle_list = [_generate_attach_handle(fpga)] diff --git a/cyborg/tests/unit/accelerator/drivers/fpga/inspur/test_driver.py b/cyborg/tests/unit/accelerator/drivers/fpga/inspur/test_driver.py index e11fbf89..e9a0d574 100644 --- a/cyborg/tests/unit/accelerator/drivers/fpga/inspur/test_driver.py +++ b/cyborg/tests/unit/accelerator/drivers/fpga/inspur/test_driver.py @@ -46,6 +46,7 @@ class TestInspurFPGADriver(base.TestCase): 'inspur.sysinfo.lspci_privileged') def test_discover(self, mock_devices_for_vendor): mock_devices_for_vendor.return_value = self.p.stdout.readlines() + self.set_defaults(host='host-192-168-32-195', debug=True) fpga_list = InspurFPGADriver().discover() self.assertEqual(1, len(fpga_list)) attach_handle_list = [ @@ -72,9 +73,7 @@ class TestInspurFPGADriver(base.TestCase): { 'num_accelerators': 1, 'driver_name': 'INSPUR', - 'name': - 'Inspur Electronic Information Industry Co., Ltd.' - ' Device_0000:86:00.0', + 'name': 'host-192-168-32-195_0000:86:00.0', 'attach_handle_list': attach_handle_list, 'attribute_list': attribute_list },