xentaur

diff xentaur.py @ 40:10444acb35f4

*** empty log message ***
author igor
date Fri Oct 12 17:31:34 2007 +0300 (2007-10-12)
parents 54b7c7ae50ec
children 8c00f233a1d4
line diff
     1.1 --- a/xentaur.py	Fri Sep 28 13:35:54 2007 +0300
     1.2 +++ b/xentaur.py	Fri Oct 12 17:31:34 2007 +0300
     1.3 @@ -8,8 +8,8 @@
     1.4  sys.path.append('/etc/xen')
     1.5  sys.path.append(xentaur_path)
     1.6  
     1.7 -network='netw'
     1.8 -domain='dyn3'
     1.9 +network='snrs_ipsec_preshared_1'
    1.10 +domain='qua1'
    1.11  from xendomain import *
    1.12  
    1.13  bridges_turned_down=[]
    1.14 @@ -38,7 +38,7 @@
    1.15  
    1.16  def create_bridges_script():
    1.17      unbound_bridges=set(bridges)-set(real_bridges)
    1.18 -    create_unbound_bridges="\n".join(map(lambda x: "sudo /usr/sbin/brctl show | awk '{print $1}' | grep -q "+x+" || sudo /usr/sbin/brctl addbr "+x, unbound_bridges))
    1.19 +    create_unbound_bridges="\n".join(map(lambda x: "sudo /usr/sbin/brctl show | awk '{print $1}' | grep -qx "+x+" || sudo /usr/sbin/brctl addbr "+x, unbound_bridges))
    1.20      create_unbound_bridges+="\n"+"\n".join(map(lambda x: "sudo /bin/ip link set "+x+" up", unbound_bridges))
    1.21  
    1.22      print """#!/bin/sh
    1.23 @@ -185,6 +185,7 @@
    1.24  """ % graph_dot)
    1.25      f.close()
    1.26      run_command("neato -Tpng -o xenomips.png xenomips.dot ")
    1.27 +    run_command("neato -Tsvg -o xenomips.svg xenomips.dot ")
    1.28  
    1.29  def autoredraw():
    1.30      graph()
    1.31 @@ -386,9 +387,85 @@
    1.32  
    1.33  
    1.34  def configure_ip_addresses(doms=domains):
    1.35 +
    1.36 +    cisco_set_ip_on_int="""
    1.37 +\n\n\n
    1.38 +int fa%s/0
    1.39 +no ip address
    1.40 +ip address %s 255.255.255.0
    1.41 +no shutdown
    1.42 +exit
    1.43 +"""
    1.44 +
    1.45 +    quagga_set_ip_on_int="""
    1.46 +int eth%s
    1.47 +no ip address
    1.48 +ip address %s/24
    1.49 +no shutdown
    1.50 +exit
    1.51 +"""
    1.52 +
    1.53 +    for dom in doms:
    1.54 +        i=domains.index(dom)+1
    1.55 +        if domain_types[domains.index(dom)] == 'quagga':
    1.56 +            command = quagga_set_ip_on_int
    1.57 +            write_to(i,"\nconf t\n")
    1.58 +            j=0
    1.59 +            for br in  vbridges_table[dom]:
    1.60 +                write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
    1.61 +                j+=1
    1.62 +            write_to(i,"\nend\n")
    1.63 +        else:
    1.64 +            command = cisco_set_ip_on_int
    1.65 +            write_to(i,"\nena\nconf t\n")
    1.66 +            j=0
    1.67 +            for br in  vbridges_table[dom]:
    1.68 +                write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
    1.69 +                j+=1
    1.70 +            write_to(i,"\nend\n")
    1.71 +    return 0
    1.72 +
    1.73 +def configure_no_ip_addresses(doms=domains):
    1.74 +
    1.75 +    cisco_set_ip_on_int="""
    1.76 +\n\n\n
    1.77 +int fa%s/0
    1.78 +no ip address %s 255.255.255.0
    1.79 +exit
    1.80 +"""
    1.81 +
    1.82 +    quagga_set_ip_on_int="""
    1.83 +int eth%s
    1.84 +no ip address %s/24
    1.85 +exit
    1.86 +"""
    1.87 +
    1.88 +    for dom in doms:
    1.89 +        i=domains.index(dom)+1
    1.90 +        if domain_types[domains.index(dom)] == 'quagga':
    1.91 +            command = quagga_set_ip_on_int
    1.92 +            write_to(i,"\nconf t\n")
    1.93 +            j=0
    1.94 +            for br in  vbridges_table[dom]:
    1.95 +                write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
    1.96 +                j+=1
    1.97 +            write_to(i,"\nend\n")
    1.98 +        else:
    1.99 +            command = cisco_set_ip_on_int
   1.100 +            write_to(i,"\nena\nconf t\n")
   1.101 +            j=0
   1.102 +            for br in  vbridges_table[dom]:
   1.103 +                write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
   1.104 +                j+=1
   1.105 +            write_to(i,"\nend\n")
   1.106      return 0
   1.107  
   1.108  def configure_ospf(doms=domains):
   1.109 +    for dom in doms:
   1.110 +        if domain_types[domains.index(dom)] == 'quagga':
   1.111 +            write_to(dom,"\n\nconf t\nrouter ospf\nnetwork 192.168.0.0/16 area 0\nend\n")
   1.112 +        else:
   1.113 +            write_to(dom,"\n\nena\nconf t\nrouter ospf 1\nnetwork 192.168.0.0 0.0.255.255 area 0\nend\n")
   1.114      return 0
   1.115  
   1.116  def configure_save(doms=domains):