xentaur

annotate xentaur.py @ 46:85794a582ef5

naming pics as configs
author igor
date Wed Oct 24 15:30:43 2007 +0300 (2007-10-24)
parents 8c00f233a1d4
children 65e80fabc89c
rev   line source
igor@0 1 #!/usr/bin/python
igor@0 2
igor@0 3
igor@2 4 import sys,os,time
igor@35 5
igor@35 6 xentaur_path=os.environ['HOME']+"/xentaur"
igor@35 7
igor@0 8 sys.path.append('/etc/xen')
igor@35 9 sys.path.append(xentaur_path)
igor@11 10
igor@41 11 network='snrs_ipsec_rsa_1'
igor@40 12 domain='qua1'
igor@35 13 from xendomain import *
igor@35 14
igor@29 15 bridges_turned_down=[]
igor@29 16
igor@0 17 from IPython.Shell import IPShellEmbed
igor@0 18
igor@2 19
igor@2 20 screenrc=os.environ['HOME']+"/.screenrc_xentaur"
igor@2 21
igor@10 22 def run(program, *args):
igor@10 23 pid = os.fork()
igor@10 24 if not pid:
igor@10 25 os.execvp(program, (program,) + args)
igor@10 26 return os.wait()[0]
igor@10 27
igor@10 28 def run_command(line):
igor@10 29 #cmds=line.split()
igor@10 30 #run(cmds[0],*cmds[1:])
igor@10 31 run("/bin/sh", "-c", line)
igor@10 32
igor@23 33 def run_command_return_stdout(line):
igor@23 34 p = os.popen(line)
igor@23 35 output = p.read()
igor@23 36 p.close()
igor@23 37 return output
igor@23 38
igor@0 39 def create_bridges_script():
igor@38 40 unbound_bridges=set(bridges)-set(real_bridges)
igor@41 41 create_unbound_bridges="\n".join(map(lambda x: "sudo brctl show | awk '{print $1}' | grep -qx "+x+" || sudo brctl addbr "+x, unbound_bridges))
igor@41 42 create_unbound_bridges+="\n"+"\n".join(map(lambda x: "sudo brctl stp "+x+" off", unbound_bridges))
igor@41 43 create_unbound_bridges+="\n"+"\n".join(map(lambda x: "sudo ip link set "+x+" up", unbound_bridges))
igor@0 44
igor@0 45 print """#!/bin/sh
igor@0 46 # create unbound bridges
igor@0 47 %(create_unbound_bridges)s
igor@0 48 """ % {'create_unbound_bridges' : create_unbound_bridges}
igor@0 49
igor@0 50
igor@0 51 def create_domains_script():
igor@35 52 for domain in domains:
igor@38 53 if not domain in real_nodes:
igor@41 54 print "sudo xm create "+xentaur_path+"/xendomain.py "+" domain="+domain+" network="+network+" && sleep 1 && sudo xm sched-credit -d $(sudo xm list | grep "+domain+" | awk '{print $2}') -c 10 && sleep 1"
igor@0 55
igor@0 56 def destroy_domains_script():
igor@35 57 for domain in domains:
igor@38 58 if not domain in real_nodes:
igor@41 59 print "sudo xm shutdown "+domain
igor@0 60
igor@0 61 def create_screens_script():
igor@7 62 N=1
igor@0 63 screens=[]
igor@0 64 for domain in domains:
igor@11 65 screens.append("screen -t "+domain+" "+str(N)+" sh -c 'while true; do sudo xm console "+domain+" ; echo Retrying in 5 seconds...; sleep 5; done'")
igor@0 66 N+=1
igor@0 67 screenlist="\n".join(screens)
igor@0 68
igor@11 69 #
igor@11 70 # Previous terminal acccess commands:
igor@11 71 # ip="192.168.80."+str(200+N)
igor@11 72 # screens.append("screen -t "+domain+" "+str(N)+" sh -c 'while true; do ssh root@"+ip+" ; done'")
igor@11 73 #
igor@11 74
igor@4 75 #hardstatus string "\%{gk}\%c \%{yk}\%M\%d \%{wk}\%?\%-Lw\%?\%{bw}\%n*\%f\%t\%?(\%u)\%?\%{wk}\%?\%+Lw\%?"
igor@10 76
igor@11 77 f=open(screenrc, "w");
igor@10 78 f.write("""
igor@2 79 hardstatus on
igor@2 80 hardstatus alwayslastline
igor@2 81
igor@0 82 screen -t console 0 bash
igor@10 83 %s
igor@10 84 """ % (screenlist))
igor@10 85 f.close()
igor@0 86
igor@0 87 def graph_node(node):
igor@0 88 i=0
igor@0 89 domain_type={}
igor@0 90 for domain in domains:
igor@0 91 domain_type[domain]=domain_types[i]
igor@0 92 i+=1
nata@31 93 return node+" [label=\" "+node+"\",shapefile=\"shapes/all/"+domain_type[node]+".png\",fontcolor=black,fontsize=16]"
igor@0 94
igor@29 95 def graph_bridge(bridge):
igor@29 96 if bridge in hidden_bridges:
igor@29 97 return ""
igor@38 98 if bridge in real_bridges:
igor@38 99 return "%s [shape=none,shapefile=\"shapes/all/real_switch.png\"]" % (bridge)
igor@38 100 elif bridge in bridges_turned_down:
igor@29 101 return "%s [shape=none,shapefile=\"shapes/all/switch_turned_down.png\"]" % (bridge)
igor@29 102 else:
igor@29 103 return "%s [shape=none,shapefile=\"shapes/all/switch.png\"]" % (bridge)
igor@29 104
igor@29 105
igor@0 106 def graph():
igor@0 107 nodelist=""
igor@0 108 bridgelist=""
igor@0 109 linklist=""
igor@0 110 physicallist=""
igor@0 111 networklist=""
igor@0 112
igor@0 113 nodelist=";\n ".join(map(graph_node,nodes))
igor@0 114 if nodelist: nodelist += ";"
igor@0 115
igor@29 116 bridgelist=";\n ".join(map(graph_bridge,bridges))
igor@0 117 if bridgelist: bridgelist += ";"
igor@0 118
igor@0 119 links=[]
igor@0 120 for host, bridges_raw in vbridges_table.iteritems():
igor@0 121 i=0
igor@0 122 for this_bridge in bridges_raw:
igor@27 123 if this_bridge in hidden_bridges or not this_bridge:
igor@0 124 continue
igor@28 125 if not [ host, bridges_raw.index(this_bridge), this_bridge ] in temporary_links:
igor@28 126 links.append(host+" -- "+this_bridge+" [taillabel=\"fa"+str(bridges_raw.index(this_bridge))+"/0\"]")
igor@27 127 i+=1
igor@0 128
igor@0 129 for link in temporary_links:
igor@28 130 links.append(link[0]+" -- "+link[2]+" [taillabel=\"fa"+str(link[1])+"/0\",color=blue,len=10,w=5,weight=5]")
igor@0 131
igor@27 132 for link in broken_links:
igor@28 133 links.append(link[0]+" -- "+link[2]+" [taillabel=\"fa"+str(link[1])+"/0\",style=dashed]")
igor@27 134
igor@39 135
igor@39 136 # bridge-bridge links
igor@39 137 for host, bridges_raw in bridge_bridge_table.iteritems():
igor@39 138 i=0
igor@39 139 for this_bridge in bridges_raw:
igor@39 140 if this_bridge in hidden_bridges or not this_bridge:
igor@39 141 continue
igor@39 142 if not [ host, bridges_raw.index(this_bridge), this_bridge ] in temporary_links:
igor@39 143 links.append(host+" -- "+this_bridge)
igor@39 144 i+=1
igor@39 145
igor@39 146
igor@39 147
igor@0 148 linklist=";\n ".join(links)
igor@0 149
igor@0 150 graph_dot = {
igor@0 151 'nodelist' : nodelist,
igor@0 152 'bridgelist' : bridgelist,
igor@0 153 'linklist' : linklist,
igor@0 154 'physicallist' : physicallist,
igor@0 155 'networklist' : networklist,
igor@0 156 }
igor@0 157
igor@46 158 f = open(network+".dot", "w");
igor@10 159 f.write ("""
igor@0 160 graph G {
igor@0 161 edge [len=1.25];
igor@0 162 splines=true;
igor@0 163 // nodes
igor@0 164
igor@0 165 node [shape=plaintext,color=white,shapefile="shapes/cisco.bmp/router.png"];
igor@0 166 %(nodelist)s
igor@0 167
igor@0 168 // bridges
igor@0 169
igor@6 170 node [shape=none,shapefile="shapes/all/switch.png"];
igor@0 171 %(bridgelist)s
igor@0 172
igor@0 173 // physical
igor@0 174
igor@0 175 node [shape=rectangle,color=blue];
igor@0 176 %(physicallist)s
igor@0 177
igor@0 178 // networks (not bridges, not physical)
igor@0 179 node [shape=rectangle,color=green];
igor@0 180 %(networklist)s
igor@0 181
igor@0 182 // links (between nodes and bridges)
igor@0 183 %(linklist)s
igor@0 184
igor@0 185 };
igor@10 186 """ % graph_dot)
igor@10 187 f.close()
igor@46 188 run_command("neato -Tpng -o %s.png %s.dot "%(network,network))
igor@46 189 run_command("neato -Tjpg -o %s.jpg %s.dot "%(network,network))
igor@46 190 run_command("neato -Tsvg -o %s.svg %s.dot "%(network,network))
igor@0 191
igor@27 192 def autoredraw():
igor@27 193 graph()
igor@27 194
igor@0 195 def start_all():
igor@0 196 create_bridges_script()
igor@0 197 create_screens_script()
igor@0 198 create_domains_script()
igor@0 199 graph()
igor@0 200 print """
igor@0 201 cat <<NOTE_FOR_USER
igor@0 202 # To view virtual network map, run:
igor@0 203 gqview xenomips.png
igor@0 204 # To attach to VM consoles, run:
igor@0 205 screen -c screenrc
igor@0 206 NOTE_FOR_USER
igor@0 207 """
igor@0 208
igor@0 209 def shell():
nata@31 210 autoredraw()
igor@0 211 ipshell = IPShellEmbed()
igor@0 212 ipshell()
igor@0 213
igor@0 214 def stop_all():
igor@4 215 destroy_domains_script()
igor@0 216
igor@0 217 def show_usage():
igor@0 218 print """Usage:
igor@0 219 xentaur {start|stop|start-bridges|start-domains|stop-domains|screen|graph}
igor@0 220 """
igor@0 221
igor@33 222 def save():
igor@33 223 print "network =", xen_config_name
igor@33 224 print "domains =", domains
igor@33 225 print "domain_types =", domain_types
igor@33 226 print "bridges =", bridges
igor@33 227 print "vbridges_table =", vbridges_table
igor@33 228 print "hidden_bridges =", hidden_bridges
igor@33 229 print "broken_links =", broken_links
igor@33 230 print "temporary_links =", temporary_links
igor@33 231 print "bridges_turned_down =", bridges_turned_down
igor@33 232
igor@33 233 #-----------------------------------------------------------------------
igor@33 234 # CLASSES
igor@33 235
igor@33 236 class Bridge:
igor@33 237 def __init__ (self,name):
igor@33 238 self.name=name
igor@33 239 def up(self):
igor@33 240 bridge_up(self.name)
igor@33 241 def down(self):
igor@33 242 bridge_down(self.name)
igor@33 243 def show(self):
igor@33 244 show_bridge(self.name)
igor@33 245 def dump_start(self,filter=""):
igor@33 246 dump_start(self.name,filter)
igor@33 247
igor@33 248
igor@38 249 class Domain:
igor@38 250 def __init__ (self,name):
igor@38 251 self.name=name
igor@38 252 def start(self):
igor@38 253 return ""
igor@38 254 def stop(self):
igor@38 255 return ""
igor@38 256 def start_commandline(self):
igor@38 257 return ""
igor@38 258 def graphviz(self):
igor@38 259 return ""
igor@38 260 def get_domain_id(self):
igor@38 261 return get_domain_id(self.name)
igor@38 262
igor@23 263 #-----------------------------------------------------------------------
igor@23 264 # DOMAINS
igor@23 265
igor@23 266 def get_domain_id(domain):
igor@23 267 return run_command_return_stdout("sudo xm list | awk '{if ($1 == \"'%s'\") print $2}'" % domain).rstrip("\n")
igor@23 268
igor@22 269
igor@22 270 #-----------------------------------------------------------------------
igor@22 271 # BRIDGES and IFACES
igor@22 272
igor@22 273 def bridge_down(bridge):
igor@22 274 """
igor@22 275 Turn the bridge <bridge> down
igor@22 276 """
igor@38 277 if bridge in real_bridges:
igor@38 278 print "Bridge %s is a real bridge" % (bridge)
igor@38 279 return -1
igor@29 280 if bridge in bridges_turned_down:
igor@29 281 print "Bridge %s is turned down already" % (bridge)
igor@29 282 else:
igor@29 283 bridges_turned_down.append(bridge)
igor@29 284 run_command("sudo ip link set %s down" % bridge)
igor@29 285 autoredraw()
igor@22 286
igor@22 287 def bridge_up(bridge):
igor@22 288 """
igor@22 289 Turn the bridge <bridge> up
igor@22 290 """
igor@38 291 if bridge in real_bridges:
igor@38 292 print "Bridge %s is a real bridge" % (bridge)
igor@38 293 return -1
igor@29 294 if not (bridge in bridges_turned_down):
igor@29 295 print "Bridge %s is turned up already" % (bridge)
igor@29 296 else:
igor@29 297 bridges_turned_down.remove(bridge)
igor@29 298 run_command("sudo ip link set %s up" % bridge)
igor@29 299 autoredraw()
igor@22 300
igor@22 301 def show_bridge(bridge):
igor@22 302 """
igor@22 303 Show the state of the bridge <bridge>
igor@22 304 """
igor@38 305 if bridge in real_bridges:
igor@38 306 print "Bridge %s is a real bridge" % (bridge)
igor@38 307 return -1
igor@22 308 run_command("sudo ip link show %s" % bridge)
igor@22 309
igor@23 310
igor@23 311 def int_disconnect(domain, int_number):
igor@23 312 """
igor@23 313 Disconnect the interface with the number <int_number>
igor@23 314 of the domain <domain> from the bridge to which
igor@23 315 it is connected
igor@23 316 """
igor@23 317 dom_id=get_domain_id(domain)
igor@23 318 bridge=vbridges_table[domain][int_number]
igor@23 319 if not bridge:
igor@23 320 print "Interface %s of the %s domain is not connected" % (int_number, domain)
igor@23 321 return 1
igor@23 322 run_command("sudo brctl delif %s vif%s.%s" % (bridge, dom_id, int_number))
igor@23 323 vbridges_table[domain][int_number]=''
igor@28 324 if [ domain, int_number, bridge ] in temporary_links:
igor@28 325 temporary_links.remove([ domain, int_number, bridge ])
igor@27 326 else:
igor@28 327 broken_links.append([ domain, int_number, bridge ])
igor@27 328 autoredraw()
igor@23 329
igor@23 330 def int_connect(domain, int_number, bridge):
igor@23 331 """
igor@23 332 Connect the interface with the number <int_number>
igor@24 333 of the domain <domain> to the bridge <bridge>
igor@23 334 """
igor@38 335 if bridge in real_bridges:
igor@38 336 print "Bridge %s is a real bridge" % (bridge)
igor@38 337 return -1
igor@38 338
igor@23 339 dom_id=get_domain_id(domain)
igor@23 340 if vbridges_table[domain][int_number]:
igor@23 341 print "Interface %s of the %s domain is connected already to the %s bridge" % (int_number, domain, vbridges_table[domain][int_number])
igor@23 342 return 1
igor@23 343 run_command("sudo brctl addif %s vif%s.%s" % (bridge, dom_id, int_number))
igor@23 344 vbridges_table[domain][int_number]=bridge
igor@28 345 if [ domain, int_number, bridge ] in broken_links:
igor@28 346 broken_links.remove([ domain, int_number, bridge ])
igor@27 347 else:
igor@28 348 temporary_links.append([ domain, int_number, bridge ])
igor@27 349 autoredraw()
igor@23 350
igor@24 351 def int_reconnect(domain, int_number, bridge):
igor@24 352 """
igor@24 353 Reconnect the interface with the number <int_number>
igor@24 354 of the domain <domain> from the bridge to which
igor@24 355 it is connected to the bridge <bridge>
igor@24 356 """
igor@38 357 if bridge in real_bridges:
igor@38 358 print "Bridge %s is a real bridge" % (bridge)
igor@38 359 return -1
igor@38 360
igor@24 361 int_disconnect(domain, int_number)
igor@24 362 int_connect(domain, int_number, bridge)
igor@24 363
igor@24 364 def show_int(domain, int_number):
igor@25 365 """
igor@25 366 Show information about the interface <int_nuber>
igor@25 367 of the domain <domain>
igor@25 368 """
igor@26 369 return vbridges_table[domain][int_number]
igor@24 370
igor@28 371
igor@28 372 def dump_start(bridge, filter=""):
igor@38 373 if bridge in real_bridges:
igor@38 374 print "Bridge %s is a real bridge" % (bridge)
igor@38 375 return -1
igor@32 376 try:
igor@32 377 print "Writing dump... (press Ctrl-C to stop)"
igor@32 378 run_command("sudo tcpdump -w xentaur.dump -i %s %s > /dev/null 2>&1 " % (bridge,filter))
igor@32 379 except:
igor@32 380 print "Done.\n Dump is written to xentaur.dump"
igor@28 381 return 0
igor@28 382
igor@28 383 def dump_stop():
igor@28 384 return 0
igor@33 385
igor@33 386
igor@33 387 #-----------------------------------------------------------------------
igor@33 388 # CONFIGURATION TEMPLATES
igor@33 389
igor@33 390
igor@33 391 def configure_ip_addresses(doms=domains):
igor@40 392
igor@40 393 cisco_set_ip_on_int="""
igor@40 394 \n\n\n
igor@40 395 int fa%s/0
igor@40 396 no ip address
igor@40 397 ip address %s 255.255.255.0
igor@40 398 no shutdown
igor@40 399 exit
igor@40 400 """
igor@40 401
igor@40 402 quagga_set_ip_on_int="""
igor@40 403 int eth%s
igor@40 404 no ip address
igor@40 405 ip address %s/24
igor@40 406 no shutdown
igor@40 407 exit
igor@40 408 """
igor@40 409
igor@40 410 for dom in doms:
igor@40 411 i=domains.index(dom)+1
igor@40 412 if domain_types[domains.index(dom)] == 'quagga':
igor@40 413 command = quagga_set_ip_on_int
igor@40 414 write_to(i,"\nconf t\n")
igor@40 415 j=0
igor@40 416 for br in vbridges_table[dom]:
igor@40 417 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
igor@40 418 j+=1
igor@40 419 write_to(i,"\nend\n")
igor@40 420 else:
igor@40 421 command = cisco_set_ip_on_int
igor@40 422 write_to(i,"\nena\nconf t\n")
igor@40 423 j=0
igor@40 424 for br in vbridges_table[dom]:
igor@40 425 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
igor@40 426 j+=1
igor@40 427 write_to(i,"\nend\n")
igor@40 428 return 0
igor@40 429
igor@40 430 def configure_no_ip_addresses(doms=domains):
igor@40 431
igor@40 432 cisco_set_ip_on_int="""
igor@40 433 \n\n\n
igor@40 434 int fa%s/0
igor@40 435 no ip address %s 255.255.255.0
igor@40 436 exit
igor@40 437 """
igor@40 438
igor@40 439 quagga_set_ip_on_int="""
igor@40 440 int eth%s
igor@40 441 no ip address %s/24
igor@40 442 exit
igor@40 443 """
igor@40 444
igor@40 445 for dom in doms:
igor@40 446 i=domains.index(dom)+1
igor@40 447 if domain_types[domains.index(dom)] == 'quagga':
igor@40 448 command = quagga_set_ip_on_int
igor@40 449 write_to(i,"\nconf t\n")
igor@40 450 j=0
igor@40 451 for br in vbridges_table[dom]:
igor@40 452 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
igor@40 453 j+=1
igor@40 454 write_to(i,"\nend\n")
igor@40 455 else:
igor@40 456 command = cisco_set_ip_on_int
igor@40 457 write_to(i,"\nena\nconf t\n")
igor@40 458 j=0
igor@40 459 for br in vbridges_table[dom]:
igor@40 460 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
igor@40 461 j+=1
igor@40 462 write_to(i,"\nend\n")
igor@33 463 return 0
igor@33 464
igor@33 465 def configure_ospf(doms=domains):
igor@40 466 for dom in doms:
igor@40 467 if domain_types[domains.index(dom)] == 'quagga':
igor@40 468 write_to(dom,"\n\nconf t\nrouter ospf\nnetwork 192.168.0.0/16 area 0\nend\n")
igor@40 469 else:
igor@40 470 write_to(dom,"\n\nena\nconf t\nrouter ospf 1\nnetwork 192.168.0.0 0.0.255.255 area 0\nend\n")
igor@33 471 return 0
igor@33 472
igor@33 473 def configure_save(doms=domains):
igor@33 474 write_to(doms,"\nwr\n")
igor@33 475
igor@0 476 #-----------------------------------------------------------------------
igor@0 477
igor@0 478
igor@0 479 def add_domain(name,type):
igor@0 480 domains.append(name)
igor@0 481 domain_types.append(type)
igor@0 482
igor@0 483 def brake_link(domain,bridge):
igor@0 484 broken_links.append([domain,bridge])
igor@0 485
igor@4 486 wt_timeout=0.5
igor@8 487 def write_to(screen,string,return_to_screen=""):
igor@2 488 """
igor@2 489 write_to(screen,string):
igor@2 490
igor@8 491 Type *string* to the specified screen(s).
igor@8 492 Screen may be specified with the number *screen*,
igor@8 493 with array of numbers,
igor@8 494 with array of names.
igor@2 495
igor@2 496 """
igor@5 497 screen_numbers=[] # number of the screens to write to
igor@5 498 if type(screen) == list:
igor@5 499 screen_numbers=map(lambda x: domains.index(x)+1, screen)
igor@5 500 elif type(screen) == int:
igor@5 501 screen_numbers=[screen]
igor@5 502 else:
igor@5 503 screen_numbers=[domains.index(screen)+1]
igor@5 504
igor@5 505 for screen_number in screen_numbers:
igor@5 506 run_command("screen -X select "+str(screen_number))
igor@5 507 time.sleep(wt_timeout)
igor@5 508 for line in string.splitlines():
igor@5 509 f=open('/tmp/xentaurbuf', 'w')
igor@5 510 f.write(line+"\n")
igor@5 511 f.close()
igor@5 512 run_command("screen -X readreg p /tmp/xentaurbuf")
igor@5 513 time.sleep(wt_timeout)
igor@5 514 run_command("nohup screen -X paste p >& /dev/null")
igor@5 515 time.sleep(wt_timeout)
igor@5 516
igor@8 517 if return_to_screen != "":
igor@8 518 run_command("screen -X select %s" % (return_to_screen))
igor@8 519 time.sleep(wt_timeout)
igor@0 520
igor@0 521 #-----------------------------------------------------------------------
igor@0 522
igor@5 523 cisco_fa01_up="""
igor@5 524 ena
igor@5 525 conf t
igor@5 526 int fa0/0
igor@5 527 no shutdown
igor@5 528 exit
igor@5 529 int fa1/0
igor@5 530 no shutdown
igor@5 531 exit
igor@5 532 exit
igor@5 533 exit
igor@5 534 """
igor@5 535
igor@5 536 cisco_set_ip_on_int="""
igor@5 537 interface fa%s/0
igor@5 538 no ip address
igor@5 539 ip address %s 255.255.255.0
igor@5 540 exit
igor@5 541 """
igor@5 542
igor@33 543
igor@0 544
igor@0 545 nodes=domains
igor@0 546
igor@0 547 if len(sys.argv) > 1:
igor@0 548 if sys.argv[1] == 'start':
igor@0 549 start_all()
igor@0 550 if sys.argv[1] == 'stop':
igor@0 551 stop_all()
igor@0 552 if sys.argv[1] == 'start-bridges':
igor@3 553 create_bridges_script()
igor@0 554 if sys.argv[1] == 'start-domains':
igor@3 555 create_domains_script()
igor@0 556 if sys.argv[1] == 'stop-domains':
igor@3 557 destroy_domains_script()
igor@0 558 elif sys.argv[1] == 'screen':
igor@3 559 create_screens_script()
igor@0 560 elif sys.argv[1] == 'graph':
igor@0 561 graph()
igor@0 562 elif sys.argv[1] == 'shell':
igor@0 563 shell()
igor@0 564
igor@0 565 else:
igor@0 566 show_usage()
igor@0 567 sys.exit(1)
igor@0 568
igor@0 569 sys.exit(0)
igor@0 570
igor@0 571