Exemple #1
0
def deploy_pool_member_config(id_ip, id_pool, port_ip, spm, user):
    transaction.commit()
    # def prepare_and_save(self, server_pool, ip, ip_type, priority, weight, port_real, user, commit=False):
    # spm.prepare_and_save(sp, ip_object, IP_VERSION.IPv4[1], dic['priority'], dic['weight'], dic['port_real'], user, True)
    command = settings.POOL_REAL_CREATE % (id_pool, id_ip, port_ip)
    code, _, _ = exec_script(command)
    if code != 0:
        spm.delete()
        transaction.commit()
        raise exceptions.ScriptCreatePoolException()
Exemple #2
0
def update_load_balancing_method(balancing, old_lb_method, sp, user):
    sp.lb_method = balancing
    sp.save()
    if (old_lb_method != sp.lb_method and sp.pool_created):
        transaction.commit()
        command = settings.POOL_MANAGEMENT_LB_METHOD % (sp.id)
        code, _, _ = exec_script(command)
        if code != 0:
            sp.lb_method = old_lb_method
            sp.save()
            transaction.commit()
            raise exceptions.ScriptCreatePoolException()
Exemple #3
0
def apply_health_check(hc, old_healthcheck, sp, user):
    # Applies new healthcheck in pool
    sp.healthcheck = hc
    sp.save()
    if (old_healthcheck.id != hc.id and sp.pool_created):
        transaction.commit()
        command = settings.POOL_HEALTHCHECK % (sp.id)
        code, _, _ = exec_script(command)
        if code != 0:
            sp.healthcheck = old_healthcheck
            sp.save()
            transaction.commit()
            raise exceptions.ScriptCreatePoolException()
Exemple #4
0
def remove_pool_members(id_pool_member_noempty, sp, user):
    # exclue server pool member
    del_smp = sp.serverpoolmember_set.exclude(id__in=id_pool_member_noempty)
    if del_smp:
        for obj in del_smp:

            obj.delete()

            # execute script remove real if pool already created
            # commit transaction after each successful script call
            if sp.pool_created:
                command = settings.POOL_REAL_REMOVE % (
                    obj.server_pool_id, obj.ip_id if obj.ip else obj.ipv6_id,
                    obj.port_real)
                code, _, _ = exec_script(command)
                if code != 0:
                    raise exceptions.ScriptCreatePoolException()
                transaction.commit()