Merge "Fill "driver_name" field in Deployable object"

This commit is contained in:
Zuul 2019-08-29 14:36:32 +00:00 committed by Gerrit Code Review
commit a80d07d850
4 changed files with 13 additions and 4 deletions

View File

@ -55,6 +55,8 @@ RESOURCES = {
"fpga": RC_FPGA
}
DRIVER_NAME = "intel"
def read_line(filename):
with open(filename) as f:
@ -268,6 +270,7 @@ def _generate_dep_list(fpga, pf_has_vf):
driver_dep.attach_handle_list = \
[_generate_attach_handle(fpga)]
driver_dep.name = fpga["name"]
driver_dep.driver_name = DRIVER_NAME
# pf with sriov enabled, may have several regions and several vfs.
# For now, there is only region, this maybe improve in next release.
else:
@ -277,6 +280,7 @@ def _generate_dep_list(fpga, pf_has_vf):
driver_dep.attach_handle_list.append(
_generate_attach_handle(vf))
driver_dep.name = vf["name"]
driver_dep.driver_name = DRIVER_NAME
return [driver_dep]

View File

@ -44,8 +44,10 @@ class Deployable(base.CyborgObject, object_base.VersionedObjectDictCompat):
# name of the deployable
'num_accelerators': object_fields.IntegerField(nullable=False),
# number of accelerators spawned by this deployable
'device_id': object_fields.IntegerField(nullable=False)
'device_id': object_fields.IntegerField(nullable=False),
# Foreign key constrain to reference device table
'driver_name': object_fields.StringField(nullable=True)
# Will change it to non-nullable after other driver report it.
}
def _get_parent_root_id(self, context):

View File

@ -37,7 +37,8 @@ class DriverDeployable(base.DriverObjectBase,
# TODO: add field related to local_memory or just store in the
# attribute list?
'attach_handle_list': object_fields.ListOfObjectsField(
'DriverAttachHandle', default=[], nullable=True)
'DriverAttachHandle', default=[], nullable=True),
'driver_name': object_fields.StringField(nullable=True)
}
def create(self, context, device_id, cpid_id):
@ -49,7 +50,8 @@ class DriverDeployable(base.DriverObjectBase,
deployable_obj = Deployable(context=context,
name=self.name,
num_accelerators=self.num_accelerators,
device_id=device_id
device_id=device_id,
driver_name=self.driver_name
)
deployable_obj.create(context)
# create attribute_list for this deployable

View File

@ -30,7 +30,8 @@ def fake_db_deployable(**updates):
'parent_id': None,
'root_id': 1,
'num_accelerators': 4,
'device_id': 0
'device_id': 0,
'driver_name': "fake-driver-name"
}
for name, field in objects.Deployable.fields.items():