xentaur

diff xentaur.py @ 5:83a41d802a52

function write_to has improved.

Several templates of cisco configuration secuences have added.
author igor
date Sun Jul 15 14:34:59 2007 +0300 (2007-07-15)
parents 98c2dffcf484
children e4d8da085a2e
line diff
     1.1 --- a/xentaur.py	Sun Jul 15 10:57:30 2007 +0300
     1.2 +++ b/xentaur.py	Sun Jul 15 14:34:59 2007 +0300
     1.3 @@ -5,7 +5,7 @@
     1.4  import xenomips_vars
     1.5  xenomips_vars.N='1'
     1.6  sys.path.append('/etc/xen')
     1.7 -from xenomipsN import vbridges_table, hidden_bridges, domains, broken_links, temporary_links, domain_types
     1.8 +from xenomipsN import bridges,vbridges_table, hidden_bridges, domains, broken_links, temporary_links, domain_types
     1.9  from IPython.Shell import IPShellEmbed
    1.10  
    1.11  
    1.12 @@ -70,7 +70,7 @@
    1.13      nodelist=";\n    ".join(map(graph_node,nodes))
    1.14      if nodelist: nodelist += ";"
    1.15  
    1.16 -    bridgelist=";\n    ".join(bridges-set(hidden_bridges))
    1.17 +    bridgelist=";\n    ".join(set(bridges)-set(hidden_bridges))
    1.18      if bridgelist: bridgelist += ";"
    1.19  
    1.20      links=[]
    1.21 @@ -184,27 +184,52 @@
    1.22          Type *string* to the screen with the number *screen*
    1.23  
    1.24      """
    1.25 -    screen_number=screen
    1.26 -    run_command("screen -X select "+str(screen_number))
    1.27 -    time.sleep(wt_timeout)
    1.28 -    for line in string.splitlines():
    1.29 -	    f=open('/tmp/xentaurbuf', 'w')
    1.30 -	    f.write(line+"\n")
    1.31 -	    f.close()
    1.32 -	    run_command("screen -X readreg p /tmp/xentaurbuf")
    1.33 -	    time.sleep(wt_timeout)
    1.34 -	    run_command("nohup screen -X paste p >& /dev/null")
    1.35 -	    time.sleep(wt_timeout)
    1.36 -
    1.37 -    run_command("screen -X select 0")
    1.38 -    #time.sleep(wt_timeout)
    1.39 +    screen_numbers=[]           # number of the screens to write to
    1.40 +    if type(screen) == list:
    1.41 +        screen_numbers=map(lambda x: domains.index(x)+1, screen)
    1.42 +    elif type(screen) == int:
    1.43 +        screen_numbers=[screen]
    1.44 +    else:
    1.45 +        screen_numbers=[domains.index(screen)+1]
    1.46 +    
    1.47 +    for screen_number in screen_numbers:
    1.48 +        run_command("screen -X select "+str(screen_number))
    1.49 +        time.sleep(wt_timeout)
    1.50 +        for line in string.splitlines():
    1.51 +            f=open('/tmp/xentaurbuf', 'w')
    1.52 +            f.write(line+"\n")
    1.53 +            f.close()
    1.54 +            run_command("screen -X readreg p /tmp/xentaurbuf")
    1.55 +            time.sleep(wt_timeout)
    1.56 +            run_command("nohup screen -X paste p >& /dev/null")
    1.57 +            time.sleep(wt_timeout)
    1.58 +    
    1.59 +        run_command("screen -X select 0")
    1.60 +        time.sleep(wt_timeout)
    1.61  
    1.62  #-----------------------------------------------------------------------
    1.63  
    1.64 -bridges=[]
    1.65 -for domain in vbridges_table.keys():
    1.66 -    bridges += set(vbridges_table[domain])
    1.67 -bridges=set(bridges)
    1.68 +cisco_fa01_up="""
    1.69 +ena
    1.70 +conf t
    1.71 +int fa0/0
    1.72 +no shutdown
    1.73 +exit
    1.74 +int fa1/0
    1.75 +no shutdown
    1.76 +exit
    1.77 +exit
    1.78 +exit
    1.79 +"""
    1.80 +
    1.81 +cisco_set_ip_on_int="""
    1.82 +interface fa%s/0
    1.83 +no ip address
    1.84 +ip address %s 255.255.255.0
    1.85 +exit
    1.86 +"""
    1.87 +
    1.88 +#-----------------------------------------------------------------------
    1.89  
    1.90  nodes=domains
    1.91