xentaur

diff xentaur.py @ 60:e7b9761c03e8

info() + logo()
author igor
date Sun Nov 11 20:57:50 2007 +0200 (2007-11-11)
parents 308b524d9a70
children 6471afbee150
line diff
     1.1 --- a/xentaur.py	Sat Nov 10 19:58:39 2007 +0200
     1.2 +++ b/xentaur.py	Sun Nov 11 20:57:50 2007 +0200
     1.3 @@ -1,5 +1,5 @@
     1.4  #!/usr/bin/python
     1.5 -
     1.6 +# vim: set fileencoding=utf-8 :
     1.7  
     1.8  import sys,os,time
     1.9  
    1.10 @@ -158,11 +158,11 @@
    1.11  ####################################################
    1.12  
    1.13  def screen():
    1.14 -    wait_seconds=5
    1.15 +    wait_seconds=1
    1.16      screens=[]
    1.17      for domain in domains:
    1.18          screens.append("screen -t %s %s sh -c 'while true; do %s ; echo Retrying in %s secods...; sleep %s ; clear; done'" %
    1.19 -                                 (domain,domains.index(domain),node_object[domain].console_string(),wait_seconds,wait_seconds))
    1.20 +                                 (domain,domains.index(domain)+1,node_object[domain].console_string(),wait_seconds,wait_seconds))
    1.21      screenlist="\n".join(screens)
    1.22  
    1.23      hardstatus='hardstatus string "%{rk}Xentaur%{bk}@%H %{gk}%c %{yk}%d.%m %{wk}%?%-Lw%?%{bw}%n*%f%t%?(%u)%?%{wk}%?%+Lw%?"'
    1.24 @@ -173,9 +173,10 @@
    1.25  hardstatus alwayslastline
    1.26  %s
    1.27  
    1.28 -screen -t console 0 bash
    1.29 +screen -t console 0 sh -c 'while true; do cd %s; ./xentaur.py shell ; echo Retrying in %s secods...; sleep %s ; clear; done'
    1.30 +#screen -t xentaur - sh -c 'while true; do bash ; echo Retrying in %s secods...; sleep %s ; clear; done'
    1.31  %s
    1.32 -""" % (hardstatus,screenlist))
    1.33 +""" % (hardstatus,xentaur_path,wait_seconds,wait_seconds,wait_seconds,wait_seconds,screenlist))
    1.34      f.close()
    1.35      print "# GNU Screen config file is written to: %s" % screenrc
    1.36  
    1.37 @@ -234,6 +235,38 @@
    1.38      ipshell = IPShellEmbed()
    1.39      ipshell()
    1.40  
    1.41 +def version():
    1.42 +    print "Xentaur 0.1-PRE"
    1.43 +    print "(Godzilla-mutant)  _"
    1.44 +    print "                 / * \\"
    1.45 +    print "                /   .-"
    1.46 +    print "               /   |"
    1.47 +    print "              | \\ \\\\ \\"
    1.48 +    print "     _ -------|  \\ \\\\ \\"
    1.49 +    print " / /              \\_\\ -"
    1.50 +    print "/ |\\           |   |"
    1.51 +    print "| |  \\ .-----. | \\ |"
    1.52 +    print "  |  /        \\ \\ \\ \\"
    1.53 +    print "  \\/|.\\        \\ \\ \\ \\"
    1.54 +    print "   \\| - .       \\_\\ \\_\\"
    1.55 +    print "-----------------------------------------------"
    1.56 +
    1.57 +
    1.58 +def info():
    1.59 +    version()
    1.60 +
    1.61 +    print "Network name: ", network
    1.62 +    print "-----------------------------------------------"
    1.63 +    print
    1.64 +    print "Nodes: ", len(domains)
    1.65 +    print "  * virtual nodes: ", len(domains)-len(real_nodes)
    1.66 +    print "  * real nodes:", len(real_nodes)
    1.67 +    print 
    1.68 +    print "Bridges:", len(bridges)
    1.69 +    print "  * virtual bridges:", len(bridges)-len(real_bridges)-len(cross_bridges)
    1.70 +    print "  * real switches:", len(real_bridges)
    1.71 +    print "  * direct links:", len(cross_bridges)
    1.72 +
    1.73  def show_usage():
    1.74      print """Usage:
    1.75      xentaur <command> [<argument>]
    1.76 @@ -703,6 +736,8 @@
    1.77          graph()
    1.78      elif sys.argv[1] == 'shell':
    1.79          shell()
    1.80 +    elif sys.argv[1] == 'info':
    1.81 +        info()
    1.82      else:
    1.83          show_usage()
    1.84          sys.exit(1)