'Check server status.
Accepts both server IDs and server objects.
Returns True if server is ACTIVE,
raises errors when server has an ERROR or unknown to Heat status,
returns False otherwise.
:param res_name: name of the resource to use in the exception message'

def _check_active(self, server, res_name='Server'):

    if isinstance(server, six.string_types):
        server = self.fetch_server(server)
        if (server is None):
            return False
        else:
            status = self.get_status(server)
    else:
        status = self.get_status(server)
        if (status != 'ACTIVE'):
            self.refresh_server(server)
            status = self.get_status(server)
    if (status in self.deferred_server_statuses):
        return False
    elif (status == 'ACTIVE'):
        return True
    elif (status == 'ERROR'):
        fault = getattr(server, 'fault', {})
        raise exception.ResourceInError(resource_status=status, status_reason=(_('Message:    %(message)s,    Code:    %(code)s') % {'message': fault.get('message', _('Unknown')), 'code': fault.get('code', _('Unknown'))}))
    else:
        raise exception.ResourceUnknownStatus(resource_status=server.status, result=(_('%s    is    not    active') % res_name))
