示例#1
0
    def test_scatter_gather_single_cell(self, mock_scatter):
        ctxt = context.get_context()
        mapping0 = objects.CellMapping(database_connection='fake://db0',
                                       transport_url='none:///',
                                       uuid=objects.CellMapping.CELL0_UUID)

        filters = {'deleted': False}
        context.scatter_gather_single_cell(ctxt, mapping0,
            objects.InstanceList.get_by_filters, filters, sort_dir='foo')

        mock_scatter.assert_called_once_with(
            ctxt, [mapping0], context.CELL_TIMEOUT,
            objects.InstanceList.get_by_filters, filters,
            sort_dir='foo')
    def test_scatter_gather_single_cell(self, mock_scatter):
        ctxt = context.get_context()
        mapping0 = objects.CellMapping(database_connection='fake://db0',
                                       transport_url='none:///',
                                       uuid=objects.CellMapping.CELL0_UUID)

        filters = {'deleted': False}
        context.scatter_gather_single_cell(ctxt, mapping0,
            objects.InstanceList.get_by_filters, filters, sort_dir='foo')

        mock_scatter.assert_called_once_with(
            ctxt, [mapping0], context.CELL_TIMEOUT,
            objects.InstanceList.get_by_filters, filters,
            sort_dir='foo')
示例#3
0
def get_instances_without_type(
    context: 'nova_context.RequestContext',
    cell_uuid: ty.Optional[str] = None,
) -> ty.List[objects.instance.Instance]:
    """Find instances without hw_machine_type set, optionally within a cell.

    :param context: Request context
    :param cell_uuid: Optional cell UUID to look within
    :returns: A list of Instance objects or an empty list
    """
    if cell_uuid:
        cell_mapping = objects.CellMapping.get_by_uuid(context, cell_uuid)
        results = nova_context.scatter_gather_single_cell(
            context,
            cell_mapping,
            _get_instances_without_mtype
        )

    results = nova_context.scatter_gather_skip_cell0(
        context,
        _get_instances_without_mtype
    )

    # Flatten the returned list of results into a single list of instances
    return list(itertools.chain(*[r for c, r in results.items()]))