diff --git a/cyborg/agent/resource_tracker.py b/cyborg/agent/resource_tracker.py index cb44051b..6cc420b2 100644 --- a/cyborg/agent/resource_tracker.py +++ b/cyborg/agent/resource_tracker.py @@ -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 diff --git a/cyborg/api/controllers/v1/deployables.py b/cyborg/api/controllers/v1/deployables.py index 7d8aa680..afb5e2cc 100644 --- a/cyborg/api/controllers/v1/deployables.py +++ b/cyborg/api/controllers/v1/deployables.py @@ -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): diff --git a/cyborg/db/sqlalchemy/alembic/versions/f50980397351_initial_migration.py b/cyborg/db/sqlalchemy/alembic/versions/f50980397351_initial_migration.py index 9d250df8..890c6bb5 100644 --- a/cyborg/db/sqlalchemy/alembic/versions/f50980397351_initial_migration.py +++ b/cyborg/db/sqlalchemy/alembic/versions/f50980397351_initial_migration.py @@ -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), diff --git a/cyborg/db/sqlalchemy/api.py b/cyborg/db/sqlalchemy/api.py index 89953b4d..48635944 100644 --- a/cyborg/db/sqlalchemy/api.py +++ b/cyborg/db/sqlalchemy/api.py @@ -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, diff --git a/cyborg/db/sqlalchemy/models.py b/cyborg/db/sqlalchemy/models.py index 4c9c0829..842bdeb9 100644 --- a/cyborg/db/sqlalchemy/models.py +++ b/cyborg/db/sqlalchemy/models.py @@ -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) diff --git a/cyborg/objects/accelerator.py b/cyborg/objects/accelerator.py index 6c6eb2e2..42ac7066 100644 --- a/cyborg/objects/accelerator.py +++ b/cyborg/objects/accelerator.py @@ -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,... diff --git a/cyborg/objects/deployable.py b/cyborg/objects/deployable.py index 645fc5df..bf7dbed6 100644 --- a/cyborg/objects/deployable.py +++ b/cyborg/objects/deployable.py @@ -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), diff --git a/cyborg/tests/unit/fake_deployable.py b/cyborg/tests/unit/fake_deployable.py index c86b5b39..1525bf4d 100644 --- a/cyborg/tests/unit/fake_deployable.py +++ b/cyborg/tests/unit/fake_deployable.py @@ -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', diff --git a/cyborg/tests/unit/fake_physical_function.py b/cyborg/tests/unit/fake_physical_function.py index b32145ef..52cb54ca 100644 --- a/cyborg/tests/unit/fake_physical_function.py +++ b/cyborg/tests/unit/fake_physical_function.py @@ -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', diff --git a/cyborg/tests/unit/fake_virtual_function.py b/cyborg/tests/unit/fake_virtual_function.py index e6f45df2..898c776f 100644 --- a/cyborg/tests/unit/fake_virtual_function.py +++ b/cyborg/tests/unit/fake_virtual_function.py @@ -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',