xentaur

diff xentaur.py @ 63:07c6777758dc

* path to shapes
* dynamips icon
author igor
date Fri Feb 29 07:22:46 2008 +0200 (2008-02-29)
parents e838c1223b89
children cf823d27b029
line diff
     1.1 --- a/xentaur.py	Thu Feb 21 21:41:20 2008 +0200
     1.2 +++ b/xentaur.py	Fri Feb 29 07:22:46 2008 +0200
     1.3 @@ -7,14 +7,15 @@
     1.4  
     1.5  sys.path.append('/etc/xen')
     1.6  sys.path.append(xentaur_path)
     1.7 +sys.path.append('.')
     1.8  
     1.9  #network='snrs_ipsec_rsa_1'
    1.10  node_object={}
    1.11  link_object={}
    1.12  bridge_object={}
    1.13  
    1.14 -network='ids2007dec'
    1.15 -domain='fbsd1'
    1.16 +network='openvpnbridge'
    1.17 +domain='debian1'
    1.18  
    1.19  #network='snrs'
    1.20  #domain='dyn1'
    1.21 @@ -26,6 +27,7 @@
    1.22  
    1.23  
    1.24  screenrc=os.environ['HOME']+"/.screenrc_xentaur"
    1.25 +path_shapes='/xen/xentaur/shapes'
    1.26  
    1.27  def run(program, *args):
    1.28      pid = os.fork()
    1.29 @@ -140,7 +142,7 @@
    1.30              int_label=""
    1.31              if this_bridge.find(':') != -1:
    1.32                  res = this_bridge.split(':')
    1.33 -                this_bridge= res[0]
    1.34 +                this_bridge= res[2]
    1.35                  bridges_raw[j] = this_bridge
    1.36                  int_label  = res[1]
    1.37              if not [ node, bridges_raw.index(this_bridge), this_bridge ] in temporary_links:
    1.38 @@ -203,11 +205,9 @@
    1.39      edge [len=1.25];
    1.40      splines=true;
    1.41  // nodes
    1.42 -//    node [shape=plaintext,color=white,shapefile="shapes/cisco.bmp/router.png"];
    1.43      %s
    1.44  
    1.45  // bridges
    1.46 -//    node [shape=none,shapefile="shapes/all/switch.png"];
    1.47      %s
    1.48  
    1.49  // physical
    1.50 @@ -339,15 +339,15 @@
    1.51  
    1.52      def graphviz_string(self):
    1.53          if self.is_hidden():
    1.54 -            return ""
    1.55 +            return "//"
    1.56          elif self.is_cross():
    1.57              return "%s [shape=circle,height=0.03,color=black,fillcolor=black,style=filled,label=\"\"]" % (self.name)
    1.58          elif self.is_real():
    1.59 -            return "%s [color=white,shape=none,shapefile=\"shapes/all/real_switch.png\"]" % (self.name)
    1.60 +            return "%s [color=white,shape=none,shapefile=\"%s/all/real_switch.png\"]" % (self.name, path_shapes)
    1.61          elif self.is_turned_down():
    1.62 -            return "%s [color=white,shape=none,shapefile=\"shapes/all/switch_turned_down.png\"]" % (self.name)
    1.63 +            return "%s [color=white,shape=none,shapefile=\"%s/all/switch_turned_down.png\"]" % (self.name, path_shapes)
    1.64          else:
    1.65 -            return "%s [color=white,shape=none,shapefile=\"shapes/all/switch.png\"]" % (self.name)
    1.66 +            return "%s [color=white,shape=none,shapefile=\"%s/all/switch.png\"]" % (self.name, path_shapes)
    1.67  
    1.68  
    1.69  class Node:
    1.70 @@ -363,7 +363,7 @@
    1.71      def get_domain_id(self):
    1.72          return get_domain_id(self.name)
    1.73      def graphviz_string(self):
    1.74 -        return self.name+" [color=white,shape=plaintext,label=\"  "+self.name+"\",shapefile=\"shapes/all/"+\
    1.75 +        return self.name+" [color=white,shape=plaintext,label=\"  "+self.name+"\",shapefile=\""+path_shapes+"/all/"+\
    1.76          domain_types[domains.index(self.name)]+".png\",fontcolor=black,fontsize=16,target=\"http://google.com\"]"
    1.77      def console_string(self):
    1.78          if self.type in [ 'quagga', 'xenomips', 'freebsd', 'linux' ]:
    1.79 @@ -386,7 +386,12 @@
    1.80      def is_broken(self):
    1.81          return ([self.node,self.interface,self.bridge] in broken_links)
    1.82  
    1.83 +    def is_hidden(self):
    1.84 +        return self.bridge in hidden_bridges
    1.85 +
    1.86      def graphviz_string(self):
    1.87 +        if self.is_hidden():
    1.88 +            return "//"
    1.89          if self.is_temporary():
    1.90              return self.node+" -- "+self.bridge+" [taillabel=\"fa"+str(self.interface)+"/0\",color=blue,len=10,w=5,weight=5]"
    1.91          if self.is_broken():
    1.92 @@ -549,6 +554,10 @@
    1.93  exit
    1.94  """
    1.95  
    1.96 +    linux_set_ip_on_int="""
    1.97 +ifconfig eth%s %s netmask 255.255.255.0
    1.98 +"""
    1.99 +
   1.100      for dom in doms:
   1.101          i=domains.index(dom)+1
   1.102          if domain_types[domains.index(dom)] == 'quagga':
   1.103 @@ -559,6 +568,13 @@
   1.104                  write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
   1.105                  j+=1
   1.106              write_to(i,"\nend\n")
   1.107 +        elif domain_types[domains.index(dom)] == 'linux':
   1.108 +            command = linux_set_ip_on_int
   1.109 +            j=0
   1.110 +            for br in  vbridges_table[dom]:
   1.111 +                #write_to(i, command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)) )
   1.112 +                print i, command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)) 
   1.113 +                j+=1
   1.114          else:
   1.115              command = cisco_set_ip_on_int
   1.116              write_to(i,"\nena\nconf t\n")