xentaur

diff xentaur.py @ 33:c68d804c3017

* Trying to add classes (bridge class)
* Configuration templates
* Function save() --- dumps network topology
author igor
date Sat Sep 22 02:25:18 2007 +0300 (2007-09-22)
parents bf2d7c5bb340
children 244f1602496a
line diff
     1.1 --- a/xentaur.py	Sat Sep 22 01:35:51 2007 +0300
     1.2 +++ b/xentaur.py	Sat Sep 22 02:25:18 2007 +0300
     1.3 @@ -6,7 +6,7 @@
     1.4  xenomips_vars.N='1'
     1.5  sys.path.append('/etc/xen')
     1.6  
     1.7 -xen_config_name='fabergeN'
     1.8 +xen_config_name='four_quaggasN'
     1.9  try:
    1.10      exec 'from '+xen_config_name+' import bridges,vbridges_table, hidden_bridges, domains, broken_links, temporary_links, domain_types'
    1.11  except:
    1.12 @@ -57,7 +57,6 @@
    1.13          print "sudo /usr/sbin/xm shutdown "+domains[N]
    1.14  
    1.15  def create_screens_script():
    1.16 -
    1.17      N=1
    1.18      screens=[]
    1.19      for domain in domains:
    1.20 @@ -205,6 +204,33 @@
    1.21      xentaur {start|stop|start-bridges|start-domains|stop-domains|screen|graph}
    1.22  """
    1.23  
    1.24 +def save():
    1.25 +    print "network =",          xen_config_name
    1.26 +    print "domains =",          domains
    1.27 +    print "domain_types =",     domain_types
    1.28 +    print "bridges =",          bridges
    1.29 +    print "vbridges_table =",   vbridges_table
    1.30 +    print "hidden_bridges =",   hidden_bridges
    1.31 +    print "broken_links =",     broken_links
    1.32 +    print "temporary_links =",  temporary_links
    1.33 +    print "bridges_turned_down =", bridges_turned_down
    1.34 +
    1.35 +#-----------------------------------------------------------------------
    1.36 +# CLASSES
    1.37 +
    1.38 +class Bridge:
    1.39 +    def __init__ (self,name):
    1.40 +        self.name=name
    1.41 +    def up(self):
    1.42 +        bridge_up(self.name)
    1.43 +    def down(self):
    1.44 +        bridge_down(self.name)
    1.45 +    def show(self):
    1.46 +        show_bridge(self.name)
    1.47 +    def dump_start(self,filter=""):
    1.48 +        dump_start(self.name,filter)
    1.49 +
    1.50 +
    1.51  #-----------------------------------------------------------------------
    1.52  # DOMAINS
    1.53  
    1.54 @@ -308,7 +334,21 @@
    1.55  
    1.56  def dump_stop():
    1.57      return 0
    1.58 -     
    1.59 +
    1.60 +
    1.61 +#-----------------------------------------------------------------------
    1.62 +# CONFIGURATION TEMPLATES
    1.63 +
    1.64 +
    1.65 +def configure_ip_addresses(doms=domains):
    1.66 +    return 0
    1.67 +
    1.68 +def configure_ospf(doms=domains):
    1.69 +    return 0
    1.70 +
    1.71 +def configure_save(doms=domains):
    1.72 +    write_to(doms,"\nwr\n")
    1.73 +
    1.74  #-----------------------------------------------------------------------
    1.75  
    1.76  
    1.77 @@ -376,7 +416,7 @@
    1.78  exit
    1.79  """
    1.80  
    1.81 -#-----------------------------------------------------------------------
    1.82 +
    1.83  
    1.84  nodes=domains
    1.85