# HG changeset patch # User igor # Date 1184499299 -10800 # Node ID 83a41d802a522b017bf1c1de40fad18c5d0a573d # Parent 98c2dffcf484aa0cf25b1ba556b4ada5ee5c49b4 function write_to has improved. Several templates of cisco configuration secuences have added. diff -r 98c2dffcf484 -r 83a41d802a52 xentaur.py --- a/xentaur.py Sun Jul 15 10:57:30 2007 +0300 +++ b/xentaur.py Sun Jul 15 14:34:59 2007 +0300 @@ -5,7 +5,7 @@ import xenomips_vars xenomips_vars.N='1' sys.path.append('/etc/xen') -from xenomipsN import vbridges_table, hidden_bridges, domains, broken_links, temporary_links, domain_types +from xenomipsN import bridges,vbridges_table, hidden_bridges, domains, broken_links, temporary_links, domain_types from IPython.Shell import IPShellEmbed @@ -70,7 +70,7 @@ nodelist=";\n ".join(map(graph_node,nodes)) if nodelist: nodelist += ";" - bridgelist=";\n ".join(bridges-set(hidden_bridges)) + bridgelist=";\n ".join(set(bridges)-set(hidden_bridges)) if bridgelist: bridgelist += ";" links=[] @@ -184,27 +184,52 @@ Type *string* to the screen with the number *screen* """ - screen_number=screen - run_command("screen -X select "+str(screen_number)) - time.sleep(wt_timeout) - for line in string.splitlines(): - f=open('/tmp/xentaurbuf', 'w') - f.write(line+"\n") - f.close() - run_command("screen -X readreg p /tmp/xentaurbuf") - time.sleep(wt_timeout) - run_command("nohup screen -X paste p >& /dev/null") - time.sleep(wt_timeout) - - run_command("screen -X select 0") - #time.sleep(wt_timeout) + screen_numbers=[] # number of the screens to write to + if type(screen) == list: + screen_numbers=map(lambda x: domains.index(x)+1, screen) + elif type(screen) == int: + screen_numbers=[screen] + else: + screen_numbers=[domains.index(screen)+1] + + for screen_number in screen_numbers: + run_command("screen -X select "+str(screen_number)) + time.sleep(wt_timeout) + for line in string.splitlines(): + f=open('/tmp/xentaurbuf', 'w') + f.write(line+"\n") + f.close() + run_command("screen -X readreg p /tmp/xentaurbuf") + time.sleep(wt_timeout) + run_command("nohup screen -X paste p >& /dev/null") + time.sleep(wt_timeout) + + run_command("screen -X select 0") + time.sleep(wt_timeout) #----------------------------------------------------------------------- -bridges=[] -for domain in vbridges_table.keys(): - bridges += set(vbridges_table[domain]) -bridges=set(bridges) +cisco_fa01_up=""" +ena +conf t +int fa0/0 +no shutdown +exit +int fa1/0 +no shutdown +exit +exit +exit +""" + +cisco_set_ip_on_int=""" +interface fa%s/0 +no ip address +ip address %s 255.255.255.0 +exit +""" + +#----------------------------------------------------------------------- nodes=domains