xentaur

annotate xentaur.py @ 45:9c7a4cfa9738

many platforms support
author igor
date Wed Oct 24 15:17:30 2007 +0300 (2007-10-24)
parents 10444acb35f4
children 85794a582ef5
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@10 158 f = open("xenomips.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@10 188 run_command("neato -Tpng -o xenomips.png xenomips.dot ")
igor@40 189 run_command("neato -Tsvg -o xenomips.svg xenomips.dot ")
igor@0 190
igor@27 191 def autoredraw():
igor@27 192 graph()
igor@27 193
igor@0 194 def start_all():
igor@0 195 create_bridges_script()
igor@0 196 create_screens_script()
igor@0 197 create_domains_script()
igor@0 198 graph()
igor@0 199 print """
igor@0 200 cat <<NOTE_FOR_USER
igor@0 201 # To view virtual network map, run:
igor@0 202 gqview xenomips.png
igor@0 203 # To attach to VM consoles, run:
igor@0 204 screen -c screenrc
igor@0 205 NOTE_FOR_USER
igor@0 206 """
igor@0 207
igor@0 208 def shell():
nata@31 209 autoredraw()
igor@0 210 ipshell = IPShellEmbed()
igor@0 211 ipshell()
igor@0 212
igor@0 213 def stop_all():
igor@4 214 destroy_domains_script()
igor@0 215
igor@0 216 def show_usage():
igor@0 217 print """Usage:
igor@0 218 xentaur {start|stop|start-bridges|start-domains|stop-domains|screen|graph}
igor@0 219 """
igor@0 220
igor@33 221 def save():
igor@33 222 print "network =", xen_config_name
igor@33 223 print "domains =", domains
igor@33 224 print "domain_types =", domain_types
igor@33 225 print "bridges =", bridges
igor@33 226 print "vbridges_table =", vbridges_table
igor@33 227 print "hidden_bridges =", hidden_bridges
igor@33 228 print "broken_links =", broken_links
igor@33 229 print "temporary_links =", temporary_links
igor@33 230 print "bridges_turned_down =", bridges_turned_down
igor@33 231
igor@33 232 #-----------------------------------------------------------------------
igor@33 233 # CLASSES
igor@33 234
igor@33 235 class Bridge:
igor@33 236 def __init__ (self,name):
igor@33 237 self.name=name
igor@33 238 def up(self):
igor@33 239 bridge_up(self.name)
igor@33 240 def down(self):
igor@33 241 bridge_down(self.name)
igor@33 242 def show(self):
igor@33 243 show_bridge(self.name)
igor@33 244 def dump_start(self,filter=""):
igor@33 245 dump_start(self.name,filter)
igor@33 246
igor@33 247
igor@38 248 class Domain:
igor@38 249 def __init__ (self,name):
igor@38 250 self.name=name
igor@38 251 def start(self):
igor@38 252 return ""
igor@38 253 def stop(self):
igor@38 254 return ""
igor@38 255 def start_commandline(self):
igor@38 256 return ""
igor@38 257 def graphviz(self):
igor@38 258 return ""
igor@38 259 def get_domain_id(self):
igor@38 260 return get_domain_id(self.name)
igor@38 261
igor@23 262 #-----------------------------------------------------------------------
igor@23 263 # DOMAINS
igor@23 264
igor@23 265 def get_domain_id(domain):
igor@23 266 return run_command_return_stdout("sudo xm list | awk '{if ($1 == \"'%s'\") print $2}'" % domain).rstrip("\n")
igor@23 267
igor@22 268
igor@22 269 #-----------------------------------------------------------------------
igor@22 270 # BRIDGES and IFACES
igor@22 271
igor@22 272 def bridge_down(bridge):
igor@22 273 """
igor@22 274 Turn the bridge <bridge> down
igor@22 275 """
igor@38 276 if bridge in real_bridges:
igor@38 277 print "Bridge %s is a real bridge" % (bridge)
igor@38 278 return -1
igor@29 279 if bridge in bridges_turned_down:
igor@29 280 print "Bridge %s is turned down already" % (bridge)
igor@29 281 else:
igor@29 282 bridges_turned_down.append(bridge)
igor@29 283 run_command("sudo ip link set %s down" % bridge)
igor@29 284 autoredraw()
igor@22 285
igor@22 286 def bridge_up(bridge):
igor@22 287 """
igor@22 288 Turn the bridge <bridge> up
igor@22 289 """
igor@38 290 if bridge in real_bridges:
igor@38 291 print "Bridge %s is a real bridge" % (bridge)
igor@38 292 return -1
igor@29 293 if not (bridge in bridges_turned_down):
igor@29 294 print "Bridge %s is turned up already" % (bridge)
igor@29 295 else:
igor@29 296 bridges_turned_down.remove(bridge)
igor@29 297 run_command("sudo ip link set %s up" % bridge)
igor@29 298 autoredraw()
igor@22 299
igor@22 300 def show_bridge(bridge):
igor@22 301 """
igor@22 302 Show the state of the bridge <bridge>
igor@22 303 """
igor@38 304 if bridge in real_bridges:
igor@38 305 print "Bridge %s is a real bridge" % (bridge)
igor@38 306 return -1
igor@22 307 run_command("sudo ip link show %s" % bridge)
igor@22 308
igor@23 309
igor@23 310 def int_disconnect(domain, int_number):
igor@23 311 """
igor@23 312 Disconnect the interface with the number <int_number>
igor@23 313 of the domain <domain> from the bridge to which
igor@23 314 it is connected
igor@23 315 """
igor@23 316 dom_id=get_domain_id(domain)
igor@23 317 bridge=vbridges_table[domain][int_number]
igor@23 318 if not bridge:
igor@23 319 print "Interface %s of the %s domain is not connected" % (int_number, domain)
igor@23 320 return 1
igor@23 321 run_command("sudo brctl delif %s vif%s.%s" % (bridge, dom_id, int_number))
igor@23 322 vbridges_table[domain][int_number]=''
igor@28 323 if [ domain, int_number, bridge ] in temporary_links:
igor@28 324 temporary_links.remove([ domain, int_number, bridge ])
igor@27 325 else:
igor@28 326 broken_links.append([ domain, int_number, bridge ])
igor@27 327 autoredraw()
igor@23 328
igor@23 329 def int_connect(domain, int_number, bridge):
igor@23 330 """
igor@23 331 Connect the interface with the number <int_number>
igor@24 332 of the domain <domain> to the bridge <bridge>
igor@23 333 """
igor@38 334 if bridge in real_bridges:
igor@38 335 print "Bridge %s is a real bridge" % (bridge)
igor@38 336 return -1
igor@38 337
igor@23 338 dom_id=get_domain_id(domain)
igor@23 339 if vbridges_table[domain][int_number]:
igor@23 340 print "Interface %s of the %s domain is connected already to the %s bridge" % (int_number, domain, vbridges_table[domain][int_number])
igor@23 341 return 1
igor@23 342 run_command("sudo brctl addif %s vif%s.%s" % (bridge, dom_id, int_number))
igor@23 343 vbridges_table[domain][int_number]=bridge
igor@28 344 if [ domain, int_number, bridge ] in broken_links:
igor@28 345 broken_links.remove([ domain, int_number, bridge ])
igor@27 346 else:
igor@28 347 temporary_links.append([ domain, int_number, bridge ])
igor@27 348 autoredraw()
igor@23 349
igor@24 350 def int_reconnect(domain, int_number, bridge):
igor@24 351 """
igor@24 352 Reconnect the interface with the number <int_number>
igor@24 353 of the domain <domain> from the bridge to which
igor@24 354 it is connected to the bridge <bridge>
igor@24 355 """
igor@38 356 if bridge in real_bridges:
igor@38 357 print "Bridge %s is a real bridge" % (bridge)
igor@38 358 return -1
igor@38 359
igor@24 360 int_disconnect(domain, int_number)
igor@24 361 int_connect(domain, int_number, bridge)
igor@24 362
igor@24 363 def show_int(domain, int_number):
igor@25 364 """
igor@25 365 Show information about the interface <int_nuber>
igor@25 366 of the domain <domain>
igor@25 367 """
igor@26 368 return vbridges_table[domain][int_number]
igor@24 369
igor@28 370
igor@28 371 def dump_start(bridge, filter=""):
igor@38 372 if bridge in real_bridges:
igor@38 373 print "Bridge %s is a real bridge" % (bridge)
igor@38 374 return -1
igor@32 375 try:
igor@32 376 print "Writing dump... (press Ctrl-C to stop)"
igor@32 377 run_command("sudo tcpdump -w xentaur.dump -i %s %s > /dev/null 2>&1 " % (bridge,filter))
igor@32 378 except:
igor@32 379 print "Done.\n Dump is written to xentaur.dump"
igor@28 380 return 0
igor@28 381
igor@28 382 def dump_stop():
igor@28 383 return 0
igor@33 384
igor@33 385
igor@33 386 #-----------------------------------------------------------------------
igor@33 387 # CONFIGURATION TEMPLATES
igor@33 388
igor@33 389
igor@33 390 def configure_ip_addresses(doms=domains):
igor@40 391
igor@40 392 cisco_set_ip_on_int="""
igor@40 393 \n\n\n
igor@40 394 int fa%s/0
igor@40 395 no ip address
igor@40 396 ip address %s 255.255.255.0
igor@40 397 no shutdown
igor@40 398 exit
igor@40 399 """
igor@40 400
igor@40 401 quagga_set_ip_on_int="""
igor@40 402 int eth%s
igor@40 403 no ip address
igor@40 404 ip address %s/24
igor@40 405 no shutdown
igor@40 406 exit
igor@40 407 """
igor@40 408
igor@40 409 for dom in doms:
igor@40 410 i=domains.index(dom)+1
igor@40 411 if domain_types[domains.index(dom)] == 'quagga':
igor@40 412 command = quagga_set_ip_on_int
igor@40 413 write_to(i,"\nconf t\n")
igor@40 414 j=0
igor@40 415 for br in vbridges_table[dom]:
igor@40 416 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
igor@40 417 j+=1
igor@40 418 write_to(i,"\nend\n")
igor@40 419 else:
igor@40 420 command = cisco_set_ip_on_int
igor@40 421 write_to(i,"\nena\nconf t\n")
igor@40 422 j=0
igor@40 423 for br in vbridges_table[dom]:
igor@40 424 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
igor@40 425 j+=1
igor@40 426 write_to(i,"\nend\n")
igor@40 427 return 0
igor@40 428
igor@40 429 def configure_no_ip_addresses(doms=domains):
igor@40 430
igor@40 431 cisco_set_ip_on_int="""
igor@40 432 \n\n\n
igor@40 433 int fa%s/0
igor@40 434 no ip address %s 255.255.255.0
igor@40 435 exit
igor@40 436 """
igor@40 437
igor@40 438 quagga_set_ip_on_int="""
igor@40 439 int eth%s
igor@40 440 no ip address %s/24
igor@40 441 exit
igor@40 442 """
igor@40 443
igor@40 444 for dom in doms:
igor@40 445 i=domains.index(dom)+1
igor@40 446 if domain_types[domains.index(dom)] == 'quagga':
igor@40 447 command = quagga_set_ip_on_int
igor@40 448 write_to(i,"\nconf t\n")
igor@40 449 j=0
igor@40 450 for br in vbridges_table[dom]:
igor@40 451 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
igor@40 452 j+=1
igor@40 453 write_to(i,"\nend\n")
igor@40 454 else:
igor@40 455 command = cisco_set_ip_on_int
igor@40 456 write_to(i,"\nena\nconf t\n")
igor@40 457 j=0
igor@40 458 for br in vbridges_table[dom]:
igor@40 459 write_to(i,command % (j, "192.168.%s.%s"%(bridges.index(br)+1,i)))
igor@40 460 j+=1
igor@40 461 write_to(i,"\nend\n")
igor@33 462 return 0
igor@33 463
igor@33 464 def configure_ospf(doms=domains):
igor@40 465 for dom in doms:
igor@40 466 if domain_types[domains.index(dom)] == 'quagga':
igor@40 467 write_to(dom,"\n\nconf t\nrouter ospf\nnetwork 192.168.0.0/16 area 0\nend\n")
igor@40 468 else:
igor@40 469 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 470 return 0
igor@33 471
igor@33 472 def configure_save(doms=domains):
igor@33 473 write_to(doms,"\nwr\n")
igor@33 474
igor@0 475 #-----------------------------------------------------------------------
igor@0 476
igor@0 477
igor@0 478 def add_domain(name,type):
igor@0 479 domains.append(name)
igor@0 480 domain_types.append(type)
igor@0 481
igor@0 482 def brake_link(domain,bridge):
igor@0 483 broken_links.append([domain,bridge])
igor@0 484
igor@4 485 wt_timeout=0.5
igor@8 486 def write_to(screen,string,return_to_screen=""):
igor@2 487 """
igor@2 488 write_to(screen,string):
igor@2 489
igor@8 490 Type *string* to the specified screen(s).
igor@8 491 Screen may be specified with the number *screen*,
igor@8 492 with array of numbers,
igor@8 493 with array of names.
igor@2 494
igor@2 495 """
igor@5 496 screen_numbers=[] # number of the screens to write to
igor@5 497 if type(screen) == list:
igor@5 498 screen_numbers=map(lambda x: domains.index(x)+1, screen)
igor@5 499 elif type(screen) == int:
igor@5 500 screen_numbers=[screen]
igor@5 501 else:
igor@5 502 screen_numbers=[domains.index(screen)+1]
igor@5 503
igor@5 504 for screen_number in screen_numbers:
igor@5 505 run_command("screen -X select "+str(screen_number))
igor@5 506 time.sleep(wt_timeout)
igor@5 507 for line in string.splitlines():
igor@5 508 f=open('/tmp/xentaurbuf', 'w')
igor@5 509 f.write(line+"\n")
igor@5 510 f.close()
igor@5 511 run_command("screen -X readreg p /tmp/xentaurbuf")
igor@5 512 time.sleep(wt_timeout)
igor@5 513 run_command("nohup screen -X paste p >& /dev/null")
igor@5 514 time.sleep(wt_timeout)
igor@5 515
igor@8 516 if return_to_screen != "":
igor@8 517 run_command("screen -X select %s" % (return_to_screen))
igor@8 518 time.sleep(wt_timeout)
igor@0 519
igor@0 520 #-----------------------------------------------------------------------
igor@0 521
igor@5 522 cisco_fa01_up="""
igor@5 523 ena
igor@5 524 conf t
igor@5 525 int fa0/0
igor@5 526 no shutdown
igor@5 527 exit
igor@5 528 int fa1/0
igor@5 529 no shutdown
igor@5 530 exit
igor@5 531 exit
igor@5 532 exit
igor@5 533 """
igor@5 534
igor@5 535 cisco_set_ip_on_int="""
igor@5 536 interface fa%s/0
igor@5 537 no ip address
igor@5 538 ip address %s 255.255.255.0
igor@5 539 exit
igor@5 540 """
igor@5 541
igor@33 542
igor@0 543
igor@0 544 nodes=domains
igor@0 545
igor@0 546 if len(sys.argv) > 1:
igor@0 547 if sys.argv[1] == 'start':
igor@0 548 start_all()
igor@0 549 if sys.argv[1] == 'stop':
igor@0 550 stop_all()
igor@0 551 if sys.argv[1] == 'start-bridges':
igor@3 552 create_bridges_script()
igor@0 553 if sys.argv[1] == 'start-domains':
igor@3 554 create_domains_script()
igor@0 555 if sys.argv[1] == 'stop-domains':
igor@3 556 destroy_domains_script()
igor@0 557 elif sys.argv[1] == 'screen':
igor@3 558 create_screens_script()
igor@0 559 elif sys.argv[1] == 'graph':
igor@0 560 graph()
igor@0 561 elif sys.argv[1] == 'shell':
igor@0 562 shell()
igor@0 563
igor@0 564 else:
igor@0 565 show_usage()
igor@0 566 sys.exit(1)
igor@0 567
igor@0 568 sys.exit(0)
igor@0 569
igor@0 570