Beispiel #1
0
    def get_listener_status(self, listener_id):
        """Gets the status of a listener

        This method will consult the stats socket
        so calling this method will interfere with
        the health daemon with the risk of the amphora
        shut down

        Currently type==SSL is not detected
        :param listener_id: The id of the listener
        """
        self._check_listener_exists(listener_id)

        status = self._check_listener_status(listener_id)

        if status != consts.ACTIVE:
            stats = dict(status=status, uuid=listener_id, type='')
            return webob.Response(json=stats)

        cfg = self._parse_haproxy_file(listener_id)
        stats = dict(status=status, uuid=listener_id, type=cfg['mode'])

        # read stats socket
        q = query.HAProxyQuery(cfg['stats_socket'])
        servers = q.get_pool_status()
        stats['pools'] = list(servers.values())
        return webob.Response(json=stats)
Beispiel #2
0
def get_listener_status(listener_id):
    _check_listener_exists(listener_id)

    status = _check_listener_status(listener_id)

    if status != consts.ACTIVE:
        stats = dict(status=status, uuid=listener_id, type='')
        return flask.jsonify(stats)

    cfg = _parse_haproxy_file(listener_id)
    stats = dict(status=status, uuid=listener_id, type=cfg['mode'])

    # read stats socket
    q = query.HAProxyQuery(cfg['stats_socket'])
    servers = q.get_pool_status()
    stats['pools'] = list(servers.values())
    return flask.jsonify(stats)
Beispiel #3
0
def get_stats(stat_sock_file):
    stats_query = haproxy_query.HAProxyQuery(stat_sock_file)
    stats = stats_query.show_stat()
    pool_status = stats_query.get_pool_status()
    return stats, pool_status
Beispiel #4
0
 def setUp(self):
     self.q = query.HAProxyQuery('')
     super(QueryTestCase, self).setUp()
 def setUp(self):
     self.q = query.HAProxyQuery('')
     super().setUp()