Esempio 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))
Esempio n. 2
0
 def test_nums(self):
     print len(get_vms_by_service("logstash"))
Esempio n. 3
0
 def test_get_vms_by_service(self):
     print(get_vms_by_service("logstash"))
Esempio n. 4
0
 def current_nodes(self):
     logging.debug("[ServiceInfrastructure.current_nodes] entering ...")
     from monscale.mappings.cloudforms import get_vms_by_service
     return len(get_vms_by_service(self.name))