Ejemplo n.º 1
0
def get_fake_driver_deployable_objs():
    deployables_list = get_fake_driver_depolyables_as_dict()
    obj_deployables = []
    for deployable in deployables_list:
        obj_driver_deployable = driver_deployable.DriverDeployable()
        for field in deployable.keys():
            obj_driver_deployable[field] = deployable[field]
        obj_deployables.append(obj_driver_deployable)
    return obj_deployables
Ejemplo n.º 2
0
def _generate_dep_list(nic):
    dep_list = []
    # pf without sriov enabled.
    if "vfs" not in nic:
        driver_dep = driver_deployable.DriverDeployable()
        driver_dep.num_accelerators = 1
        driver_dep.attach_handle_list = [_generate_attach_handle(nic)]
        driver_dep.name = nic["name"]
        driver_dep.driver_name = DRIVER_NAME
        driver_dep.attribute_list = _generate_attribute_list(nic)
        dep_list = [driver_dep]
    # pf with sriov enabled, may have several vfs.
    else:
        for vf in nic["vfs"]:
            driver_dep = driver_deployable.DriverDeployable()
            driver_dep.num_accelerators = 1
            driver_dep.attach_handle_list = [_generate_attach_handle(vf)]
            driver_dep.name = vf["name"]
            driver_dep.driver_name = DRIVER_NAME
            driver_dep.attribute_list = _generate_attribute_list(vf)
            dep_list.append(driver_dep)
    return dep_list
Ejemplo n.º 3
0
def _generate_dep_list(fpga):
    dep_list = []
    driver_dep = driver_deployable.DriverDeployable()
    driver_dep.attribute_list = _generate_attribute_list(fpga)
    driver_dep.attach_handle_list = []
    # NOTE(wenping) Now simply named as <Compute_hostname>_<Device_address>
    # 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)]
    dep_list.append(driver_dep)
    return dep_list
Ejemplo n.º 4
0
def _generate_dep_list(gpu):
    dep_list = []
    driver_dep = driver_deployable.DriverDeployable()
    driver_dep.attach_handle_list = []
    # NOTE(wangzhh): The name of deployable should be unique, its format is
    # under disscussion, may looks like
    # <ComputeNodeName>_<NumaNodeName>_<CyborgName>_<NumInHost>, now simply
    # named <Device_name>_<Device_address>
    driver_dep.name = gpu.get('name', '') + '_' + gpu["devices"]
    driver_dep.num_accelerators = 1
    driver_dep.attach_handle_list = \
        [_generate_attach_handle(gpu)]
    dep_list.append(driver_dep)
    return dep_list
Ejemplo n.º 5
0
def _generate_dep_list(ssd):
    dep_list = []
    driver_dep = driver_deployable.DriverDeployable()
    driver_dep.attribute_list = _generate_attribute_list(ssd)
    driver_dep.attach_handle_list = []
    # NOTE(wenping) Now simply named as <Compute_hostname>_<Device_address>
    # once cyborg needs to support SSD devices discovered from a baremetal
    # node, we might need to support more formats.
    driver_dep.name = ssd.get('hostname', '') + '_' + ssd["devices"]
    driver_dep.driver_name = VENDOR_MAPS.get(ssd["vendor_id"]).upper()
    # driver_dep.num_accelerators for SSD is 1
    driver_dep.num_accelerators = 1
    driver_dep.attach_handle_list = [_generate_attach_handle(ssd)]
    dep_list.append(driver_dep)
    return dep_list
Ejemplo n.º 6
0
 def _generate_dep_list(self, pci):
     driver_dep = driver_deployable.DriverDeployable()
     driver_dep.attach_handle_list = self._generate_attach_handles(
         pci, self.NUM_ACCELERATORS)
     # NOTE(sean-k-mooney): we need to prepend the host name to the
     # device name as this is used to generate the RP name and uuid in
     # the cyborg conductor when updating placement. As such this needs
     # to be unique per host to allow multi node testing with the fake
     # driver.
     name = "%s_%s" % (CONF.host, pci.get('device'))
     # Replace any non alphanumeric, hyphen or underscore character with
     # underscore to comply with placement RP name requirements
     driver_dep.name = re.sub(r"(?![a-zA-Z0-9_\-]).", "_", name)
     driver_dep.driver_name = 'fake'
     driver_dep.num_accelerators = self.NUM_ACCELERATORS
     driver_dep.attribute_list = self._generate_attribute_list()
     return [driver_dep]
Ejemplo n.º 7
0
def _generate_dep_list(gpu):
    dep_list = []
    driver_dep = driver_deployable.DriverDeployable()
    driver_dep.attribute_list = _generate_attribute_list(gpu)
    driver_dep.attach_handle_list = []
    # NOTE(wangzhh): The name of deployable should be unique, its format is
    # under disscussion, may looks like
    # <ComputeNodeName>_<NumaNodeName>_<CyborgName>_<NumInHost>, now simply
    # named <Device_name>_<Device_address>
    driver_dep.name = gpu.get('name', '') + '_' + gpu["devices"]
    driver_dep.driver_name = VENDOR_MAPS.get(gpu["vendor_id"]).upper()
    # driver_dep.num_accelerators for PGPU is 1, for VGPU should be the
    # sriov_numvfs of the vGPU device.
    # TODO(yumeng) support VGPU num report soon
    driver_dep.num_accelerators = 1
    driver_dep.attach_handle_list = \
        [_generate_attach_handle(gpu)]
    dep_list.append(driver_dep)
    return dep_list
Ejemplo n.º 8
0
def _generate_dep_list(fpga, pf_has_vf):
    dep_list = []
    driver_dep = driver_deployable.DriverDeployable()
    driver_dep.attach_handle_list = []
    # pf without sriov enabled.
    if not pf_has_vf:
        driver_dep.num_accelerators = 1
        driver_dep.attach_handle_list = \
            [_generate_attach_handle(fpga, pf_has_vf)]
        driver_dep.name = fpga["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:
        driver_dep.num_accelerators = len(fpga["regions"])
        for vf in fpga["regions"]:
            driver_dep.attach_handle_list.append(
                _generate_attach_handle(vf, False))
            driver_dep.name = vf["name"]
    dep_list.append(driver_dep)
    return dep_list
Ejemplo n.º 9
0
def _generate_dep_list(vmlu, pf_has_vf):
    driver_dep = driver_deployable.DriverDeployable()
    driver_dep.attribute_list = _generate_attribute_list(vmlu)
    driver_dep.attach_handle_list = []
    # pf without sriov enabled.
    if not pf_has_vf:
        driver_dep.num_accelerators = 1
        driver_dep.attach_handle_list = \
            [_generate_attach_handle(vmlu)]
        driver_dep.name = vmlu["name"]
        driver_dep.driver_name = DRIVER_NAME

    else:
        driver_dep.num_accelerators = len(vmlu["mlu"])
        for vf in vmlu["mlu"]:
            # Only vfs in mlu can be attach, no pf.
            driver_dep.attach_handle_list.append(_generate_attach_handle(vf))
            driver_dep.name = vf["name"]
            driver_dep.driver_name = DRIVER_NAME
    return [driver_dep]
Ejemplo n.º 10
0
def _generate_dep_list(fpga, pf_has_vf):
    driver_dep = driver_deployable.DriverDeployable()
    driver_dep.attribute_list = _generate_attribute_list(fpga)
    driver_dep.attach_handle_list = []
    # pf without sriov enabled.
    if not pf_has_vf:
        driver_dep.num_accelerators = 1
        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:
        driver_dep.num_accelerators = len(fpga["regions"])
        for vf in fpga["regions"]:
            # Only vfs in regions can be attach, no pf.
            driver_dep.attach_handle_list.append(_generate_attach_handle(vf))
            driver_dep.name = vf["name"]
            driver_dep.driver_name = DRIVER_NAME
    return [driver_dep]