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()	
Пример #2
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()	
Пример #3
0
	def disable_switch(graph):
		""" disable_switch() method takes networkx object as input and disables all ports for all nodes in networkx object. """
		#start the progressbar	
		bar.start()
		
		Userlogger.info("disable all the ports in network")
		Userlogger.info('\nDisabling all ports of Physical topology')	 		
		graph_nodes_list=graph.nodes()
		i=0
		while i< len(graph_nodes_list):
			try:
				node_data=graph_nodes_list[i].split('\n')
				Userlogger.info('\nDisabling all ports of '+str(node_data[0]))	
				run.Switch_commands.commandExecute(node_data[1],node_data[2],'config','shutdown','disable',graph.node[graph_nodes_list[i]]['node_port'])
				i=i+1
				#bar update
				bar.update((.4*barlen*i)/len(graph_nodes_list))	
			except:
				pass		

#Entry point of the program

try:
	opts, args = getopt.getopt(sys.argv[1:],"hel")
except getopt.GetoptError:
	print 'To Take the help, Run command : \"python Self_Forming_Rings.py\" -h'
	sys.exit(2)

if len(opts) > 0:
	get_args(opts)
	sys.exit(1)
	
#start the progressbar	
bar.start()
Userlogger.info('\n\n\t'+'  ' + str(datetime.datetime.now()) )
# get topology
fout=open('4.txt','r')
lines=fout.readlines()

i=0
while i<len(lines):
	try:
		line=lines[i]
		Switch = mt.Network_topology(line.split()[0],line.split()[1])
		Switch.cdpread()		
		i+=1
		#bar update
		bar.update((.4*barlen)*(i)/len(lines))
	except: