def test_find_destination_when_runs_out_of_hosts(self):
    self.mox.StubOutWithMock(compute_utils, 'get_image_metadata')
    self.mox.StubOutWithMock(scheduler_utils, 'build_request_spec')
    self.mox.StubOutWithMock(scheduler_utils, 'setup_instance_group')
    self.mox.StubOutWithMock(self.task.scheduler_client, 'select_destinations')
    compute_utils.get_image_metadata(self.context, self.task.image_api, self.instance_image, self.instance).AndReturn('image')
    scheduler_utils.build_request_spec(self.context, mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({})
    scheduler_utils.setup_instance_group(self.context, {}, {'ignore_hosts': [self.instance_host]})
    self.task.scheduler_client.select_destinations(self.context, mox.IgnoreArg(), mox.IgnoreArg()).AndRaise(exception.NoValidHost(reason=''))
    self.mox.ReplayAll()
    self.assertRaises(exception.NoValidHost, self.task._find_destination)
def test_find_destination_when_runs_out_of_hosts(self):
    self.mox.StubOutWithMock(compute_utils, 'get_image_metadata')
    self.mox.StubOutWithMock(scheduler_utils, 'build_request_spec')
    self.mox.StubOutWithMock(scheduler_utils, 'setup_instance_group')
    self.mox.StubOutWithMock(self.task.scheduler_client, 'select_destinations')
    compute_utils.get_image_metadata(self.context, self.task.image_api, self.instance_image, self.instance).AndReturn('image')
    scheduler_utils.build_request_spec(self.context, mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({})
    scheduler_utils.setup_instance_group(self.context, {}, {'ignore_hosts': [self.instance_host]})
    self.task.scheduler_client.select_destinations(self.context, mox.IgnoreArg(), mox.IgnoreArg()).AndRaise(exception.NoValidHost(reason=))
    self.mox.ReplayAll()
    self.assertRaises(exception.NoValidHost, self.task._find_destination)