Ejemplo n.º 1
0
def _create_missing_queues(session, queuelog_queues, confd_queues_by_name,
                           master_tenant):
    new_queue_names = set(confd_queues_by_name.keys())
    db_queue_query = session.query(StatQueue).filter(
        StatQueue.deleted.is_(False))
    old_queue_names = set(queue.name for queue in db_queue_query.all())
    missing_queues = list(new_queue_names - old_queue_names)
    for queue_name in missing_queues:
        queue = confd_queues_by_name[queue_name]
        new_queue = StatQueue()
        new_queue.name = queue_name
        new_queue.tenant_uuid = queue['tenant_uuid']
        new_queue.queue_id = queue['id']
        new_queue.deleted = False
        session.add(new_queue)
        session.flush()

    db_queue_query = session.query(StatQueue).filter(
        StatQueue.deleted.is_(True))
    old_queue_names = set(queue.name for queue in db_queue_query.all())
    missing_queues = list(
        set(queuelog_queues) - old_queue_names - new_queue_names)
    for queue_name in missing_queues:
        new_queue = StatQueue()
        new_queue.name = queue_name
        new_queue.tenant_uuid = master_tenant
        new_queue.deleted = True
        session.add(new_queue)
        session.flush()
    def _insert_queue_to_stat_queue(self):
        queue = StatQueue()
        queue.name = 'test_queue'

        self.add_me(queue)

        return queue.name, queue.id
Ejemplo n.º 3
0
    def _insert_queue(self, name):
        queue = StatQueue()
        queue.name = name

        self.add_me(queue)

        return queue
Ejemplo n.º 4
0
    def _insert_queue_to_stat_queue(self, queue_name=None):
        queue_name = queue_name if queue_name else 'test_queue'
        queue = StatQueue()
        queue.name = queue_name

        self.add_me(queue)

        return queue.name, queue.id
Ejemplo n.º 5
0
    def _insert_queue_to_stat_queue(self, tenant_uuid=None):
        queue = StatQueue()
        queue.name = 'test_queue'
        queue.tenant_uuid = tenant_uuid or self.default_tenant.uuid

        self.add_me(queue)

        return queue.name, queue.id
    def _insert_queue_to_stat_queue(self):
        queue = StatQueue()
        queue.name = 'test_queue'

        self.session.begin()
        self.session.add(queue)
        self.session.commit()

        return queue.name, queue.id
Ejemplo n.º 7
0
    def _insert_queue_to_stat_queue(self):
        queue = StatQueue()
        queue.name = 'test_queue'

        self.session.begin()
        self.session.add(queue)
        self.session.commit()

        return queue.name, queue.id
Ejemplo n.º 8
0
    def _insert_queue(self, name):
        queue = StatQueue()
        queue.name = name

        self.session.begin()
        self.session.add(queue)
        self.session.commit()

        return queue
Ejemplo n.º 9
0
def insert_if_missing(session, all_queues):
    all_queues = set(all_queues)
    old_queues = set(r[0] for r in session.query(distinct(StatQueue.name)))

    missing_queues = list(all_queues - old_queues)

    for queue_name in missing_queues:
        new_queue = StatQueue()
        new_queue.name = queue_name
        session.add(new_queue)
Ejemplo n.º 10
0
def insert_if_missing(session, all_queues):
    all_queues = set(all_queues)
    old_queues = set(r[0] for r in session.query(distinct(StatQueue.name)))

    missing_queues = list(all_queues - old_queues)

    for queue_name in missing_queues:
        new_queue = StatQueue()
        new_queue.name = queue_name
        session.add(new_queue)
Ejemplo n.º 11
0
    def _insert_queue(self,
                      name,
                      tenant_uuid=None,
                      queue_id=None,
                      deleted=False):
        queue = StatQueue()
        queue.name = name
        queue.tenant_uuid = tenant_uuid or self.default_tenant.uuid
        queue.queue_id = queue_id
        queue.deleted = deleted

        self.add_me(queue)

        return queue