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 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))
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))
def flow_deleter(): print 'Deleting 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 result = delete_flow(formated_flow) if result < 400: success_counter += 1 else: fail_counter += 1 print '==========================================' print 'Total number Deleted 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) + ' flows ' + 'deleted.'
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 ''
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
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
def flow_deleter(): print '**********************************************************' print '* *' print '* Delete ALL flowx(except D0~D6) *' 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 result=delete_flow(formated_flow) if result<400: success_counter+=1 else: fail_counter+=1 print '' print 'Summary' print '==========================================================' print 'Total number of deleted flows: '+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() print '----------------------------------------------------------' endtime=time() print 'Finished in '+'%.2f'%float(endtime-starttime)+'seconds' return str(success_counter)+' flows '+ 'deleted.'
def flow_deleter(): print '**********************************************************' print '* *' print '* Delete ALL flowx(except D0~D6) *' 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 result = delete_flow(formated_flow) if result < 400: success_counter += 1 else: fail_counter += 1 print '' print 'Summary' print '==========================================================' print 'Total number of deleted flows: ' + 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() print '----------------------------------------------------------' endtime = time() print 'Finished in ' + '%.2f' % float(endtime - starttime) + 'seconds' return str(success_counter) + ' flows ' + 'deleted.'
def flow_deleter(): print 'Deleting 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 result=delete_flow(formated_flow) if result<400: success_counter+=1 else: fail_counter+=1 print '==========================================' print 'Total number Deleted 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)+' flows '+ 'deleted.'