Commit cb2b1b03 by Zuul Committed by Gerrit Code Review

Merge "Add New Driver OVO."

parents 21613278 620bf0ca
......@@ -16,6 +16,12 @@
CONDUCTOR_TOPIC = 'cyborg-conductor'
AGENT_TOPIC = 'cyborg-agent'
DEVICE_GPU = 'GPU'
DEVICE_FPGA = 'FPGA'
ARQ_STATES = (ARQINITIAL, ARQBOUND, ARQUNBOUND, ARQBINDFAILED) = \
('Initial', 'Bound', 'Unbound', 'BindFailed')
# Device type
DEVICE_TYPE = (DEVICE_GPU, DEVICE_FPGA)
......@@ -33,3 +33,4 @@ def register_all():
__import__('cyborg.objects.control_path')
__import__('cyborg.objects.device')
__import__('cyborg.objects.device_profile')
__import__('cyborg.objects.driver_objects')
......@@ -176,3 +176,16 @@ def obj_equal_prims(obj_1, obj_2, ignore=None):
prim_1 = _strip(obj_1.obj_to_primitive(), keys)
prim_2 = _strip(obj_2.obj_to_primitive(), keys)
return prim_1 == prim_2
class DriverObjectBase(CyborgObject):
@staticmethod
def _from_db_object(obj, db_obj):
fields = obj.fields
fields.pop("updated_at")
fields.pop("created_at")
for field in fields:
obj[field] = db_obj[field]
obj.obj_reset_changes()
return obj
__import__('cyborg.objects.driver_objects.driver_device')
__import__('cyborg.objects.driver_objects.driver_attribute')
__import__('cyborg.objects.driver_objects.driver_attach_handle')
__import__('cyborg.objects.driver_objects.driver_deployable')
__import__('cyborg.objects.driver_objects.driver_controlpath_id')
# Copyright 2018 Lenovo (Beijing) Co.,LTD.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as object_base
from cyborg.objects import fields as object_fields
from cyborg.objects import base
@base.CyborgObjectRegistry.register
class DriverAttachHandle(base.DriverObjectBase,
object_base.VersionedObjectDictCompat):
# Version 1.0: Initial version
VERSION = '1.0'
fields = {
'attach_type': object_fields.StringField(nullable=False),
# PCI BDF or mediated device ID...
'attach_info': object_fields.StringField(nullable=False),
}
# Copyright 2018 Lenovo (Beijing) Co.,LTD.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as object_base
from cyborg.objects import base
from cyborg.objects import fields as object_fields
@base.CyborgObjectRegistry.register
class DriverAttribute(base.DriverObjectBase,
object_base.VersionedObjectDictCompat):
# Version 1.0: Initial version
VERSION = '1.0'
fields = {
'key': object_fields.StringField(nullable=False),
'value': object_fields.StringField(nullable=False)
}
# Copyright 2018 Lenovo (Beijing) Co.,LTD.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as object_base
from cyborg.objects import fields as object_fields
from cyborg.objects import base
@base.CyborgObjectRegistry.register
class DriverControlPathID(base.DriverObjectBase,
object_base.VersionedObjectDictCompat):
# Version 1.0: Initial version
VERSION = '1.0'
fields = {
'cpid_type': object_fields.StringField(nullable=False),
# PCI BDF, PowerVM device, etc.
'cpid_info': object_fields.StringField(nullable=False),
}
# Copyright 2018 Lenovo (Beijing) Co.,LTD.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as object_base
from cyborg.objects import base
from cyborg.objects import fields as object_fields
from cyborg.objects.driver_objects.driver_attribute import DriverAttribute
from cyborg.objects.driver_objects.driver_attach_handle import \
DriverAttachHandle
@base.CyborgObjectRegistry.register
class DriverDeployable(base.DriverObjectBase,
object_base.VersionedObjectDictCompat):
# Version 1.0: Initial version
VERSION = '1.0'
fields = {
'num_accelerators': object_fields.IntegerField(nullable=False),
'attribute_list': object_fields.ListOfObjectsField(
'DriverAttribute', default=[], nullable=True),
# TODO: add field related to local_memory or just store in the
# attribute list?
'attach_handle_list': object_fields.ListOfObjectsField(
'DriverAttachHandle', default=[], nullable=True)
}
# Copyright 2018 Lenovo (Beijing) Co.,LTD.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_versionedobjects import base as object_base
from cyborg.objects import base
from cyborg.objects import fields as object_fields
from cyborg.objects.driver_objects.driver_deployable import DriverDeployable
from cyborg.objects.driver_objects.driver_controlpath_id import \
DriverControlPathID
@base.CyborgObjectRegistry.register
class DriverDevice(base.DriverObjectBase,
object_base.VersionedObjectDictCompat):
# Version 1.0: Initial version
VERSION = '1.0'
fields = {
# standard borad info: vendor_id, product_id, remotable?
'vendor': object_fields.StringField(nullable=False),
'model': object_fields.StringField(nullable=False),
'type': object_fields.DeviceTypeField(nullable=False),
'std_board_info': object_fields.StringField(nullable=True),
# vendor board info should be a dict: like acc_topology which is used
# for driver-specific resource provider.
'vendor_board_info': object_fields.StringField(nullable=True),
'hostname': object_fields.StringField(nullable=False),
# Each controlpath_id corresponds to a different PF. For now
# we are sticking with a single cpid.
'controlpath_id': object_fields.ObjectField('DriverControlPathID',
nullable=False),
'deployable_list': object_fields.ListOfObjectsField('DriverDeployable',
default=[],
nullable=False)
}
......@@ -42,3 +42,7 @@ class ARQState(object_fields.Enum):
class ARQStateField(object_fields.BaseEnumField):
AUTO_TYPE = ARQState()
class DeviceTypeField(object_fields.AutoTypedField):
AUTO_TYPE = object_fields.Enum(valid_values=constants.DEVICE_TYPE)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment