Пример #1
0
	def repp(graph):
		""" repp() method takes networkx object as input and enables and configures rep on all ports for all nodes in networkx object. """
		
		Userlogger.info("enabling rep in network")
		Userlogger.info("\nEnabling rep on Selected logical topology")
		graph_nodes_list=graph.nodes()
		node_num=1
		i=0
		while i< len(graph_nodes_list):
			try:					
				node_data=graph_nodes_list[i].split('\n')		
				if node_num==1:
					Userlogger.info('Enabling rep on '+str(node_data[0])+ ' edge')
					run.Switch_commands.commandExecute(node_data[1],node_data[2],'config','rep segment 1','enable',graph.node[graph_nodes_list[i]]['node_port'],'edge')
				else:
					Userlogger.info('Enabling rep on '+str(node_data[0]))
					run.Switch_commands.commandExecute(node_data[1],node_data[2],'config','rep segment 1','enable',graph.node[graph_nodes_list[i]]['node_port'],' ')
						
				node_num+=1
				i = i+1	
				#bar update
				bar.update(.4*barlen+( (.6*barlen*i)/len(graph_nodes_list) ))	
				
			except:
				pass			
		#end the bar
		bar.finish()	
def rror(topology, opt_rings):
	rep.Rep_configuration.disable_switch(topology)
	#for ring in opt_rings:
	rep.Rep_configuration.repp(opt_rings[0])
	print "wait for 10 seconds for rep to configure"
	bar.start()
	for i in range(0,10):
		bar.update((i+1)*10)
		time.sleep(1)
	bar.finish()	
Пример #3
0
	def restore(graph):
		""" restore() method takes networkx object as input and enables all ports and disables rep on all ports for all nodes in networkx object. """
		bar.start()
		Userlogger.info("restoring the previous network topology")
		Userlogger.info('\nRestoring prevoius Physical topology and diabling rep')	
		graph_nodes_list=graph.nodes()	
		i=0
		while i< len(graph_nodes_list):
			try:
				node_data=graph_nodes_list[i].split('\n')
				run.Switch_commands.commandExecute(node_data[1],node_data[2],'config','no rep segment 1','restore',graph.node[graph_nodes_list[i]]['node_port'])
				i+=1
				#bar update
				bar.update( (barlen*i)/len(graph_nodes_list) )
			except:
				pass	
		#end the bar		
		bar.finish()	
	"show_rings_manually" : show_rings,
	"srm" : show_rings, 
	"show_optimal_ring" : show_optimal_ring,
	"sor" : show_optimal_ring,
	"run_rep_on_optimal_ring" : rror,
	"rror" : rror,
	"restore_topology" : restore_topology,
	"rt" : restore_topology,
	"quit" : quit,
	"q" : quit,
	"showrep" :showrep_topology,
	"srt":showrep_topology 
}

#end the bar
bar.finish()

opt_rings = None

while True:
	print 'What would like to run?'
	inputs = raw_input("Command : ")
	inputs = inputs.lower()


	if inputs == "show_Topology" or inputs == "st":
		Topo_Flag = True
		Take_Action.get(inputs,errhandler)()
		
	elif inputs == "show_rings_automated" or inputs == "sra":
		if Topo_Flag: