Exemple #1
0
 def _check_lb_exists(self, lb_id):
     # check if we know about that lb
     if lb_id not in util.get_loadbalancers():
         raise exceptions.HTTPException(response=webob.Response(json=dict(
             message='Loadbalancer Not Found',
             details="No loadbalancer with UUID: {0}".format(lb_id)),
                                                                status=404))
Exemple #2
0
def list_sock_stat_files(hadir=None):
    stat_sock_files = {}
    if hadir is None:
        hadir = CONF.haproxy_amphora.base_path
    lb_ids = util.get_loadbalancers()
    for lb_id in lb_ids:
        sock_file = lb_id + ".sock"
        stat_sock_files[lb_id] = os.path.join(hadir, sock_file)
    return stat_sock_files
Exemple #3
0
    def vrrp_check_script_update(self, lb_id, action):
        lb_ids = util.get_loadbalancers()
        if action == consts.AMP_ACTION_STOP:
            lb_ids.remove(lb_id)
        args = []
        for lbid in lb_ids:
            args.append(util.haproxy_sock_path(lbid))

        if not os.path.exists(util.keepalived_dir()):
            os.makedirs(util.keepalived_dir())
            os.makedirs(util.keepalived_check_scripts_dir())

        cmd = 'haproxy-vrrp-check {args}; exit $?'.format(args=' '.join(args))
        with open(util.haproxy_check_script_path(), 'w') as text_file:
            text_file.write(cmd)
Exemple #4
0
    def get_all_listeners_status(self, other_listeners=None):
        """Gets the status of all listeners

        This method will not consult the stats socket
        so a listener might show as ACTIVE but still be
        in ERROR

        Currently type==SSL is also not detected
        """
        listeners = list()

        for lb in util.get_loadbalancers():
            stats_socket, listeners_on_lb = util.parse_haproxy_file(lb)

            for listener_id, listener in listeners_on_lb.items():
                listeners.append({
                    'status': consts.ACTIVE,
                    'uuid': listener_id,
                    'type': listener['mode'],
                })

        if other_listeners:
            listeners = listeners + other_listeners
        return webob.Response(json=listeners, content_type='application/json')