Exemplo n.º 1
0
def synclb():
    """
    Retrieves the machines by monitoredservice tag from CloudForms and ensures that they
    exists as load balancer pool nodes
    """

    for infrastructure in ServiceInfrastructure.objects.filter(loadbalanced=True):
        good_nodes = ["%s:%s" % (socket.gethostbyname(x.name), infrastructure.loadbalancer_node_port) for x in get_vms_by_service(infrastructure.name)]
        lb_nodes = get_pool_members(
            infrastructure.loadbalancer_host,
            infrastructure.loadbalancer_username,
            infrastructure.loadbalancer_password,
            infrastructure.fqdn)

        struc = {
            "f5_host": infrastructure.loadbalancer_host,
            "f5_username": infrastructure.loadbalancer_username,
            "f5_password": infrastructure.loadbalancer_password,
            "pool_name": infrastructure.fqdn,
            "member_list": good_nodes
        }

        add_f5_pool_members(simplejson.dumps(struc))
        bad_nodes = [item for item in lb_nodes if item not in good_nodes]

        logger.debug("[synclb] loadbalancer nodes: %s" % lb_nodes)
        logger.debug("[synclb] nodes in cloudforms: %s" % good_nodes)
        logger.debug("[synclb] node to drop from lb pool: %s" % bad_nodes)

        if not len(bad_nodes):
            return
        struc["member_list"] = bad_nodes
        del_f5_pool_members(simplejson.dumps(struc))
Exemplo n.º 2
0
 def test_add_member(self):
     from monscale.mappings.actions import add_f5_pool_members
     
     add_f5_pool_members('{"f5_host": "172.21.200.49","f5_username": "******", "f5_password": "******", "pool_name": "pepito","member_list": ["172.21.200.184:80"]}')