Exemple #1
0
def fetch_update_hints(settings, lock):
    hints = {}
    logging.info("Getting and processing hints...")
    try:
        messages = _fetch_all_messages(settings)
    except Exception, error:
        raise JensMessagingError("Could not retrieve messages (%s)" % error)
Exemple #2
0
def purge_queue():
    settings = Settings()
    try:
        queue = Queue(settings.MESSAGING_QUEUEDIR, schema=MSG_SCHEMA)
        return queue.purge()
    except OSError, error:
        raise JensMessagingError("Failed to purge Queue object (%s)" % error)
Exemple #3
0
def count_pending_hints():
    settings = Settings()
    try:
        queue = Queue(settings.MESSAGING_QUEUEDIR, schema=MSG_SCHEMA)
        return queue.count()
    except OSError, error:
        raise JensMessagingError("Failed to create Queue object (%s)" % error)
Exemple #4
0
def enqueue_hint(settings, partition, name):
    if partition not in ("modules", "hostgroups", "common"):
        raise JensMessagingError("Unknown partition '%s'" % partition)
    hint = {
        'time' : datetime.now().isoformat(),
        'data' : pickle.dumps({partition : [name]})
    }
    _queue_item(settings, hint)
    logging.info("Hint '%s/%s' added to the queue" % (partition, name))
Exemple #5
0
def _fetch_all_messages(settings):
    try:
        queue = Queue(settings.MESSAGING_QUEUEDIR, schema=MSG_SCHEMA)
    except OSError, error:
        raise JensMessagingError("Failed to create Queue object (%s)" % error)
Exemple #6
0
        'time' : datetime.now().isoformat(),
        'data' : pickle.dumps({partition : [name]})
    }
    _queue_item(settings, hint)
    logging.info("Hint '%s/%s' added to the queue" % (partition, name))

def _queue_item(settings, item):
    try:
        queue = Queue(settings.MESSAGING_QUEUEDIR, schema=MSG_SCHEMA)
    except OSError, error:
        raise JensMessagingError("Failed to create Queue object (%s)" % error)

    try:
        queue.add(item)
    except QueueError, error:
        raise JensMessagingError("Failed to element (%s)" % error)

def count_pending_hints(settings):
    try:
        queue = Queue(settings.MESSAGING_QUEUEDIR, schema=MSG_SCHEMA)
        return queue.count()
    except OSError, error:
        raise JensMessagingError("Failed to create Queue object (%s)" % error)

def _fetch_all_messages(settings):
    try:
        queue = Queue(settings.MESSAGING_QUEUEDIR, schema=MSG_SCHEMA)
    except OSError, error:
        raise JensMessagingError("Failed to create Queue object (%s)" % error)
    msgs = []
    for i, name in enumerate(queue):
Exemple #7
0
def _queue_item(item):
    settings = Settings()
    try:
        queue = Queue(settings.MESSAGING_QUEUEDIR, schema=MSG_SCHEMA)
    except OSError, error:
        raise JensMessagingError("Failed to create Queue object (%s)" % error)