'Ensure that instances are not stuck in build.'

@periodic_task.periodic_task
def _check_instance_build_time(self, context):

    timeout = CONF.instance_build_timeout
    if (timeout == 0):
        return
    filters = {'vm_state': vm_states.BUILDING, 'host': self.host}
    building_insts = objects.InstanceList.get_by_filters(context, filters, expected_attrs=[], use_slave=True)
    for instance in building_insts:
        if timeutils.is_older_than(instance.created_at, timeout):
            self._set_instance_obj_error_state(context, instance)
            LOG.warning('Instance    build    timed    out.    Set    to    error    state.', instance=instance)
