def loadbalancer(datarate,Balancer,chain):
        if  Balancer['type']=='min':
                if datarate<float(Balancer['threshhold']):
                        for flow_delete in Balancer['Delete flows']:
                            delete_flow(flow_finder(flow_delete))
                        for flow_add in Balancer['Add flows']:
                            add_flow(flow_finder(flow_add))
                        return 'used'
                else:
                        return ''
        elif  Balancer['type']=='max':
                if datarate>float(Balancer['threshhold']):

                        print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
                        print '[LB Info]'+ctime()
                        print 'Load balancer triggered:'+' Chain- '+chain+' Rule- '+Balancer['balancerName']

                        for flow_delete in Balancer['Delete flows']:
                                delete_flow(flow_finder(flow_delete))

                        for flow_add in Balancer['Add flows']:
                                add_flow(flow_finder(flow_add))


                        return 'used'
                else:
                        return ''
Exemple #2
0
def loadbalancer(datarate, Balancer, chain):
    if Balancer['type'] == 'min':
        if datarate < float(Balancer['threshhold']):
            for flow_delete in Balancer['Delete flows']:
                delete_flow(flow_finder(flow_delete))
            for flow_add in Balancer['Add flows']:
                add_flow(flow_finder(flow_add))
            return 'used'
        else:
            return ''
    elif Balancer['type'] == 'max':
        if datarate > float(Balancer['threshhold']):

            print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
            print '[LB Info]' + ctime()
            print 'Load balancer triggered:' + ' Chain- ' + chain + ' Rule- ' + Balancer[
                'balancerName']

            for flow_delete in Balancer['Delete flows']:
                delete_flow(flow_finder(flow_delete))

            for flow_add in Balancer['Add flows']:
                add_flow(flow_finder(flow_add))

            return 'used'
        else:
            return ''
def recovery_manager(tailNodeConnector, headNodeConnector, reds):

    # search if any redundancy rules hit
    for red in reds:
        if tailNodeConnector == red["tailNodeConnector"]:
            if headNodeConnector == red["headNodeConnector"]:
                print "A previous failed link recovered:", red["redundancy name"]
                for flow_add in red["Add flows"]:
                    delete_flow(flow_finder(flow_add))
                for flow_delete in red["Delete flows"]:
                    add_flow(flow_finder(flow_delete))
Exemple #4
0
def recovery_manager(tailNodeConnector, headNodeConnector, reds):

    #search if any redundancy rules hit
    for red in reds:
        if tailNodeConnector == red['tailNodeConnector']:
            if headNodeConnector == red['headNodeConnector']:
                print 'A previous failed link recovered:', red[
                    'redundancy name']
                for flow_add in red['Add flows']:
                    delete_flow(flow_finder(flow_add))
                for flow_delete in red['Delete flows']:
                    add_flow(flow_finder(flow_delete))
def redundancy_manager(tailNodeConnector, headNodeConnector, reds):

    #search if any redundancy rules hit
    for red in reds:
        if tailNodeConnector == red['tailNodeConnector']:
            if headNodeConnector == red['headNodeConnector']:
                print 'redundancy activated:', red['redundancy name']
                for flow_delete in red['Delete flows']:
                    delete_flow(flow_finder(flow_delete))

                delete_flow(flow_finder(red['Add flows'][0]))

                for flow_add in red['Add flows']:
                    add_flow(flow_finder(flow_add))
def redundancy_manager(tailNodeConnector,headNodeConnector,reds):

    #search if any redundancy rules hit
    for red in reds:
        if tailNodeConnector==red['tailNodeConnector']:
            if headNodeConnector==red['headNodeConnector']:
                print 'redundancy activated:',red['redundancy name']
                for flow_delete in red['Delete flows']:
                    delete_flow(flow_finder(flow_delete))

                delete_flow(flow_finder(red['Add flows'][0]))

                for flow_add in red['Add flows']:
                    add_flow(flow_finder(flow_add))
Exemple #7
0
def loadbalancer(datarate,Balancer):
        if  Balancer['type']=='min':
                if datarate<float(Balancer['threshhold']):
                        for flow_delete in red['Delete flows']:
                            delete_flow(flow_finder(flow_delete))
                        for flow_add in red['Add flows']:
                            add_flow(flow_finder(flow_add))
                        return 'used'
                else:
                        return ''
        elif  Balancer['type']=='max':
                if datarate>float(Balancer['threshhold']):
                        print 'lb truggered'
                        for flow_add in red['Add flows']:
                                add_flow_tcp(flow_finder(flow_add))
                        return 'used'
                else:
                        return ''
Exemple #8
0
def flow_adder():
    print '**********************************************************'
    print '*                                                        *'
    print '*                  Add the default flows                 *'
    print '*                                                        *'
    print '**********************************************************'

    starttime = time()

    input = open('flowtable.txt', 'r')
    input.readline()
    success_counter = 0
    fail_counter = 0
    while 1:
        line = input.readline()
        if not line:
            break
        formated_flow = extract_flow(line)

        #if the flow is defaultly inactive, turn off the flow
        if formated_flow['Status'] == '1':
            result = add_flow(formated_flow)
            sleep(0.2)
            if result < 400:
                success_counter += 1
            else:
                fail_counter += 1

    print ''
    print 'Summary'
    print '=========================================================='
    print 'Total number of flow: ' + str(success_counter + fail_counter)
    print 'Succeed: ' + str(success_counter)
    print 'Failed: ' + str(fail_counter)
    print 'For more Info, please check the log.'
    print '----------------------------------------------------------'
    input.close()

    endtime = time()
    print 'Finished in ' + '%.2f' % float(endtime - starttime) + ' seconds'
    return str(success_counter) + ' Primary flow added ' + str(
        18 - success_counter) + ' failed'
    print '=========================================================='
def flow_adder():
    print 'Reading flow conf and assign flow...'
    print '=========================================='

    starttime=datetime.datetime.now()

    input = open('flowtable.txt', 'r')
    input.readline()
    success_counter=0
    fail_counter=0
    while 1:
        line=input.readline()
        if not line:
                break
        formated_flow=extract_flow(line)
        print formated_flow
        #if the flow is defaultly inactive, turn off the flow
        if formated_flow['Status']=='1':
            result=add_flow(formated_flow)
            if result<400:
                success_counter+=1                    
            else:
                fail_counter+=1

        

        
    print 'Flow assign done!'
    print '=========================================='
    print 'Total number of flow: '+str(success_counter+fail_counter)
    print 'Succeed: '+str(success_counter)
    print 'Failed: '+str(fail_counter)
    print 'For more Info, please check the log.'
    input.close()

    endtime=datetime.datetime.now()
    print 'Finished in '+str((endtime-starttime))+'seconds'
    return str(success_counter)+' Primary flow added '+str(18-success_counter)+' failed'
Exemple #10
0
def flow_adder():
    print 'Reading flow conf and assign flow...'
    print '=========================================='

    starttime = datetime.datetime.now()

    input = open('flowtable.txt', 'r')
    input.readline()
    success_counter = 0
    fail_counter = 0
    while 1:
        line = input.readline()
        if not line:
            break
        formated_flow = extract_flow(line)
        print formated_flow
        #if the flow is defaultly inactive, turn off the flow
        if formated_flow['Status'] == '1':
            result = add_flow(formated_flow)
            if result < 400:
                success_counter += 1
            else:
                fail_counter += 1

    print 'Flow assign done!'
    print '=========================================='
    print 'Total number of flow: ' + str(success_counter + fail_counter)
    print 'Succeed: ' + str(success_counter)
    print 'Failed: ' + str(fail_counter)
    print 'For more Info, please check the log.'
    input.close()

    endtime = datetime.datetime.now()
    print 'Finished in ' + str((endtime - starttime)) + 'seconds'
    return str(success_counter) + ' Primary flow added ' + str(
        18 - success_counter) + ' failed'
def redundancy_manager(tailNodeConnector,headNodeConnector,reds,red_status):

    #search if any redundancy rules hit
    for red in reds:
        if tailNodeConnector==red['tailNodeConnector']:
            if headNodeConnector==red['headNodeConnector']:
                if red['depend']!='self':
                    if red_status[red['depend']]=='active':
                        print '[Service Info]'+ctime()
                        print 'Redundancy triggered:',red['redundancy name']
                        
                        for red_d in reds:
                            if red_d['redundancy name']==red['depend']:
                                for flow_add in red['Add flows']:
                                    delete_flow(flow_finder(flow_add))
                                for flow_delete in red['Delete flows']:
                                    add_flow(flow_finder(flow_delete))

                                    
                        for flow_delete in red['Delete flows']:
                            delete_flow(flow_finder(flow_delete))
                        delete_flow(flow_finder(red['Add flows'][0]))
                        for flow_add in red['Add flows']:
                            add_flow(flow_finder(flow_add))
                        red_status[red['redundancy name']]='active'                              
                        break

                
                elif red['depend']=='self':
                    print '[Service Info]'+ctime()
                    print 'Redundancy triggered:',red['redundancy name']
                    for flow_delete in red['Delete flows']:
                        delete_flow(flow_finder(flow_delete))

                    delete_flow(flow_finder(red['Add flows'][0]))

                    for flow_add in red['Add flows']:
                        add_flow(flow_finder(flow_add))
                    red_status[red['redundancy name']]='active'
    return red_status
Exemple #12
0
def redundancy_manager(tailNodeConnector, headNodeConnector, reds, red_status):

    #search if any redundancy rules hit
    for red in reds:
        if tailNodeConnector == red['tailNodeConnector']:
            if headNodeConnector == red['headNodeConnector']:
                if red['depend'] != 'self':
                    if red_status[red['depend']] == 'active':
                        print '[Service Info]' + ctime()
                        print 'Redundancy triggered:', red['redundancy name']

                        for red_d in reds:
                            if red_d['redundancy name'] == red['depend']:
                                for flow_add in red['Add flows']:
                                    delete_flow(flow_finder(flow_add))
                                for flow_delete in red['Delete flows']:
                                    add_flow(flow_finder(flow_delete))

                        for flow_delete in red['Delete flows']:
                            delete_flow(flow_finder(flow_delete))
                        delete_flow(flow_finder(red['Add flows'][0]))
                        for flow_add in red['Add flows']:
                            add_flow(flow_finder(flow_add))
                        red_status[red['redundancy name']] = 'active'
                        break

                elif red['depend'] == 'self':
                    print '[Service Info]' + ctime()
                    print 'Redundancy triggered:', red['redundancy name']
                    for flow_delete in red['Delete flows']:
                        delete_flow(flow_finder(flow_delete))

                    delete_flow(flow_finder(red['Add flows'][0]))

                    for flow_add in red['Add flows']:
                        add_flow(flow_finder(flow_add))
                    red_status[red['redundancy name']] = 'active'
    return red_status