script_wrapper.py.in 92.7 KB
Newer Older
1 2
#! /usr/bin/env python
#
3
# Copyright (c) 2004-2015 University of Utah and the Flux Group.
4
# 
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
# 
24 25 26 27 28 29 30 31

#
# Wrapper to convert select commands into XMLRPC calls to boss. The point
# is to provide a script interface that is backwards compatable with the
# pre-rpc API, but not have to maintain that interface beyond this simple
# conversion.
#
import sys
32
import pwd
33 34 35
sys.path.append("@prefix@/lib")
import getopt
import os
36
import re
37

38
import xmlrpclib
39 40 41 42 43 44 45 46 47
from emulabclient import *

##
# The package version number
#
PACKAGE_VERSION = 0.1

# Default server
XMLRPC_SERVER   = "@BOSSNODE@"
48
XMLRPC_PORT   = 3069
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

# User supplied server name.
xmlrpc_server   = XMLRPC_SERVER

# User supplied login ID to use (overrides env variable USER if exists).
login_id        = os.environ["USER"]

# Debugging output.
debug           = 0
impotent        = 0

#
# For admin people, and for using their devel trees. These options are
# meaningless unless you are an Emulab developer; they will be rejected
# at the server most ungraciously.
#
SERVER_PATH     = "@prefix@"
SERVER_DIR      = "sbin"
DEVEL_DIR       = "devel"
develuser       = None
path            = None
admin           = 0
devel           = 0
needhelp        = 0

74 75 76 77 78 79 80 81 82 83 84 85
try:
    pw = pwd.getpwuid(os.getuid())
    pass
except KeyError:
    sys.stderr.write("error: unknown user id %d" % os.getuid())
    sys.exit(2)
    pass

USER = pw.pw_name
HOME = pw.pw_dir

CERTIFICATE = os.path.join(HOME, ".ssl", "emulab.pem")
86
certificate = CERTIFICATE
87

88 89 90 91 92 93 94 95 96 97 98 99 100 101
API = {
    "node_admin"        : { "func" : "adminmode",
                            "help" : "Boot selected nodes into FreeBSD MFS" },
    "node_reboot"       : { "func" : "reboot",
                            "help" : "Reboot selected nodes or all nodes in " +
                                     "an experiment" },
    "os_load"           : { "func" : "reload",
                            "help" : "Reload disks on selected nodes or all " +
                                     "nodes in an experiment" },
    "create_image"      : { "func" : "create_image",
                            "help" : "Create a disk image from a node" },
    "node_list"         : { "func" : "node_list",
                            "help" : "Print physical mapping of nodes " +
                                     "in an experiment" },
102 103
    "node_avail"        : { "func" : "node_avail",
                            "help" : "Print free node counts" },
104 105 106
    "node_avail_list"   : { "func" : "node_avail_list",
                            "help" : "Print physical node_ids for matching" +
                                     "free nodes" },
107 108 109
    "delay_config"      : { "func" : "delay_config",
                            "help" : "Change the link shaping characteristics " +
                                     "for a link or lan" },
110 111 112
    "wilink_config"     : { "func" : "wilink_config",
                            "help" : "Change INTERFACE parameters " +
                                     "for a WIRELESS link" },
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
    "savelogs"          : { "func" : "savelogs",
                            "help" : "Save console tip logs to experiment " +
                                     "directory" },
    "portstats"         : { "func" : "portstats",
                            "help" : "Get portstats from the switches" },
    "eventsys_control"  : { "func" : "eventsys_control",
                            "help" : "Start/Stop/Restart the event system" },
    "readycount"        : { "func" : "readycount",
                            "help" : "Get readycounts for nodes in experiment " +
                                     "(deprecated)" },
    "nscheck"           : { "func" : "nscheck",
                            "help" : "Check and NS file for parser errors" },
    "startexp"          : { "func" : "startexp",
                            "help" : "Start an Emulab experiment" },
    "batchexp"          : { "func" : "startexp",
                            "help" : "Synonym for startexp" },
    "swapexp"           : { "func" : "swapexp",
                            "help" : "Swap experiment in or out" },
    "modexp"            : { "func" : "modexp",
                            "help" : "Modify experiment" },
    "endexp"            : { "func" : "endexp",
                            "help" : "Terminate an experiment" },
    "expinfo"           : { "func" : "expinfo",
                            "help" : "Get information about an experiment" },
137 138
    "tbuisp"            : { "func" : "tbuisp",
                            "help" : "Upload code to a mote" },
139 140
    "expwait"           : { "func" : "expwait",
                            "help" : "Wait for experiment to reach a state" },
141 142
    "tipacl"            : { "func" : "tipacl",
                            "help" : "Get console acl" },
143 144 145 146
    "template_commit"   : { "func" : "template_commit",
                            "help" : "Commit changes to template (modify)" },
    "template_export"   : { "func" : "template_export",
                            "help" : "Export template record" },
147 148
    "template_checkout" : { "func" : "template_checkout",
                            "help" : "Checkout a template" },
149
    "template_instantiate": { "func" : "template_instantiate",
150
                            "help" : "Instantiate a template" },
151 152
    "template_swapin":    { "func" : "template_swapin",
                            "help" : "Swapin a preloaded template instance" },
153 154 155 156
    "template_swapout"  : { "func" : "template_swapout",
                            "help" : "Terminate template instance" },
    "template_startrun" : { "func" : "template_startrun",
                            "help" : "Start new experiment run" },
157 158
    "template_modrun"   : { "func" : "template_modrun",
                            "help" : "Modify resources for run" },
159 160
    "template_stoprun"  : { "func" : "template_stoprun",
                            "help" : "Stop current experiment run" },
161
    "mkblob"            : { "func" : "mkblob",
162 163
                            "help" : "Create a new blob in the blob store" },
    "rmblob"            : { "func" : "rmblob",
164 165 166 167 168
                            "help" : "Remove a blob from the blob store" },
    "createdataset"     : { "func" : "createdataset",
                            "help" : "Create a persistent dataset" },
    "deletedataset"     : { "func" : "deletedataset",
                            "help" : "Delete a persistent dataset" },
169 170
    "extenddataset"     : { "func" : "extenddataset",
                            "help" : "Extend the lease on a persistent dataset" },
171 172
    "showdataset"       : { "func" : "showdataset",
                            "help" : "Show persistent datasets" }
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
};

#
# Print the usage statement to stdout.
#
def usage():
    print ("Usage: wrapper [wrapper options] command [command args and opts]");
    print "";
    print "Commands:";
    for key, val in API.items():
	print ("    %-12s %s." % (key, val["help"]));
        pass
    print "(Specify the --help option to specific commands for more help)";
    wrapperoptions();
    print
    print "Example:"
    print ("  "
           + "wrapper"
           + " --server=boss.emulab.net node_admin -n testbed one-node")

def wrapperoptions():
    print "";
    print "Wrapper Options:"
    print "    --help      Display this help message"
    print "    --server    Set the server hostname"
    print "    --login     Set the login id (defaults to $USER)"
199
    print "    --cert      Specify the path to your testbed SSL certificate"
200 201 202 203 204 205 206 207 208 209 210 211 212
    print "    --debug     Turn on semi-useful debugging"
    return

#
# Process a single command line
#
def do_method(module, method, params):
    if debug:
        print module + " " + method + " " + str(params);
        pass
    if impotent:
        return 0;

213 214 215
    if not os.path.exists(certificate):
        sys.stderr.write("error: certificate not found: %s\n" %
                         certificate)
216 217
        sys.exit(2)
        pass
218
    
219 220 221
    from M2Crypto.m2xmlrpclib import SSL_Transport
    from M2Crypto import SSL
    
222
    URI = "https://" + xmlrpc_server + ":" + str(XMLRPC_PORT) + SERVER_PATH
223 224
    
    ctx = SSL.Context("sslv23")
225
    ctx.load_cert(certificate, certificate)
226 227 228 229
    ctx.set_verify(SSL.verify_none, 16)
    ctx.set_allow_unknown_ca(0)
    
    # Get a handle on the server,
230
    server = xmlrpclib.ServerProxy(URI, SSL_Transport(ctx), verbose=debug)
231
        
232
    # Get a pointer to the function we want to invoke.
233
    meth      = getattr(server, module + "." + method)
234 235 236 237 238 239 240 241 242 243
    meth_args = [ PACKAGE_VERSION, params ]

    #
    # Make the call. 
    #
    try:
        response = apply(meth, meth_args)
        pass
    except xmlrpclib.Fault, e:
        print e.faultString
244
        return (-1, None)
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265

    #
    # Parse the Response, which is a Dictionary. See EmulabResponse in the
    # emulabclient.py module. The XML standard converts classes to a plain
    # Dictionary, hence the code below. 
    # 
    if len(response["output"]):
        print response["output"],
        pass

    rval = response["code"]

    #
    # If the code indicates failure, look for a "value". Use that as the
    # return value instead of the code. 
    # 
    if rval != RESPONSE_SUCCESS:
        if response["value"]:
            rval = response["value"]
            pass
        pass
266
    return (rval, response)
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331

#
# node_admin
#
class adminmode:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "nw", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;
        
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
                pass
            elif opt == "-n":
                params["reboot"] = "no";
                pass
            elif opt == "-w":
                params["wait"] = "yes";
                pass
            pass

        # Do this after so --help is seen.
        if len(req_args) != 2:
            self.usage();
            return -1;
        
        params["mode"]  = req_args[0];
        params["node"]  = req_args[1];

        rval,response = do_method("node", "adminmode", params);
        return rval;

    def usage(self):
	print "node_admin [options] on|off node";
	print "where:";
	print "    -n    - Do not reboot node; just change OSID";
	print "    -w    - If rebooting, wait for node to reboot";
        print "on|off    - Turn admin mode on or off";
	print "  node    - Node to change (pcXXX)";
        wrapperoptions();
        return
    pass


#
# node_reboot
#
class reboot:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
332
            opts, req_args = getopt.getopt(self.argv, "wcfse:", [ "help" ]);
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        module = "node";
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
                pass
            elif opt == "-c":
                params["reconfig"] = "yes";
                pass
            elif opt == "-f":
                params["power"] = "yes";
                pass
            elif opt == "-w":
                params["wait"] = "yes";
                pass
355 356 357
            elif opt == "-s":
                params["slow"] = "yes";
                pass
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                module = "experiment";
                pass
            pass

        if module == "node":
            # Do this after so --help is seen.
            if len(req_args) < 1:
                self.usage();
                return -1;

            params["nodes"]  = string.join(req_args, ",");
            pass
        else:
            if len(req_args):
                self.usage();
                return -1;
            pass
        
        rval,response = do_method(module, "reboot", params);
        return rval;

    def usage(self):
        print "node_reboot [options] node [node ...]";
        print "node_reboot [options] -e pid,eid"
	print "where:";
	print "    -w    - Wait for nodes is come back up";
	print "    -c    - Reconfigure nodes instead of rebooting";
389 390
	print "    -f    - Force power cycle of nodes (skip reboot!)";
	print "    -s    - Slow power cycle of nodes (power off; sleep 10; power on)";
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
 	print "    -e    - Reboot all nodes in an experiment";
	print "  node    - Node to reboot (pcXXX)";
        wrapperoptions();
        return
    pass

#
# os_load
#
class reload:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
407
            opts, req_args = getopt.getopt(self.argv, "i:p:m:sre:cF",
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
                                           [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        module = "node";
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
                pass
            elif opt == "-i":
                params["imagename"] = val;
                pass
            elif opt == "-p":
                params["imageproj"] = val;
                pass
            elif opt == "-m":
                params["imageid"] = val;
                pass
            elif opt == "-s":
                params["wait"] = "no";
                pass
            elif opt == "-r":
                params["reboot"] = "no";
                pass
437 438 439
            elif opt == "-c":
                params["usecurrent"] = "yes";
                pass
440 441 442
            elif opt == "-F":
                params["force"] = "yes";
                pass
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                module = "experiment";
                pass
            pass

        if module == "node":
            # Do this after so --help is seen.
            if len(req_args) < 1:
                self.usage();
                return -1;

            params["nodes"]  = string.join(req_args, ",");
            pass
        else:
            if len(req_args):
                self.usage();
                return -1;
            pass
        
        rval,response = do_method(module, "reload", params);
        return rval;

    def usage(self):
        print "os_load [options] node [node ...]";
        print "os_load [options] -e pid,eid"
	print "where:";
	print "    -i    - Specify image name; otherwise load default image";
	print "    -p    - Specify project for finding image name (-i)";
	print "    -s    - Do *not* wait for nodes to finish reloading";
	print "    -m    - Specify internal image id (instead of -i and -p)";
	print "    -r    - Do *not* reboot nodes; do that yourself";
477
        print "    -c    - Reload nodes with the image currently on them";
478
        print "    -F    - Force; clobber any existing MBR/partition table";
479 480
 	print "    -e    - Reload all nodes in the given experiment";
	print "  node    - Node to reload (pcXXX)";
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
        wrapperoptions();
        return
    pass

#
# create_image
#
class create_image:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "p:w", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;
        
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
                pass
            elif opt == "-p":
                params["imageproj"] = val;
                pass
            elif opt == "-w":
                params["wait"] = "yes";
                pass
            pass

        # Do this after so --help is seen.
        if len(req_args) != 2:
            self.usage();
            return -1;
        
        params["imagename"]  = req_args[0];
        params["node"]      = req_args[1];

        rval,response = do_method("node", "create_image", params);
        return rval;

    def usage(self):
	print "create_image [options] imageid node";
	print "where:";
	print "     -w   - Wait for image to be created";
	print "     -p   - Project ID of imageid";
        print "imageid   - Name of the image";
	print "   node   - Node to create image from (pcXXX)";
        wrapperoptions();
        return
    pass


#
# node_list
#
class node_list:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
549
            opts, req_args = getopt.getopt(self.argv, "pPvhHme:", [ "help" ]);
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        which  = "phys";
        params = {};
        params["aspect"] = "mapping";

        for opt, val in opts:
            if opt == "--help":
                self.usage()
                return 0
                pass
            elif opt == "-p":
                which = "phys";
                pass
568 569 570
            elif opt == "-P":
                which = "phystype";
                pass
571 572 573 574 575 576
            elif opt == "-v":
                which = "virt";
                pass
            elif opt == "-h":
                which = "pphys";
                pass
577 578 579
            elif opt == "-H":
                which = "pphysauxtype";
                pass
580 581 582
            elif opt == "-m":
                which = "mapping";
                pass
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                pass
            pass

        # Do this after so --help is seen.
        if len(req_args) or not params.has_key("proj"):
            self.usage();
            return -1;

        rval,response = do_method("experiment", "info", params);
        if rval:
            return rval;

        for node in response["value"]:
            val = response["value"][node];

            if which == "virt":
                print node, " ",
                pass
            elif which == "phys":
                print val["node"], " ",
                pass
608 609 610
            elif which == "phystype":
                print ("%s=%s") % (val["node"],val["type"]), " ",
                pass
611 612 613
            elif which == "pphys":
                print val["pnode"], " ",
                pass
614 615 616
            elif which == "pphysauxtype":
                print "%s=%s"  % (val["pnode"],val["auxtype"]), " ",
                pass
617 618 619
            elif which == "mapping":
                print "%s=%s" % (node, val["pnode"]),
                pass
620 621 622 623 624 625 626 627 628
            pass
        print "";
        
        return rval;

    def usage(self):
	print "node_list [options] -e pid,eid";
	print "where:";
	print "     -p   - Print physical (Emulab database) names (default)";
629
	print "     -P   - Like -p, but include node type";
630 631
	print "     -v   - Print virtual (experiment assigned) names";
	print "     -h   - Print physical name of host for virtual nodes";
632
	print "     -H   - Like -h, but include node auxtypes";
633 634 635 636 637 638
 	print "     -e   - Project and Experiment ID to list";
        wrapperoptions();
        return
    pass


639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
#
# node_avail
#
class node_avail:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        params = {}
        
        try:
            opts, req_args = getopt.getopt(self.argv, "hp:t:c:", [
                "help", "project=", "node-type=", "node-class=" ])

            for opt, val in opts:
                if opt in ("-h", "--help"):
                    self.usage();
                    return 0
                elif opt in ("-p", "--project"):
                    params["proj"] = val
                    pass
                elif opt in ("-c", "--node-class"):
                    params["class"] = val
                    pass
                elif opt in ("-t", "--node-type"):
                    params["type"] = val
                    pass
                pass
            pass
        except  getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        rval,response = do_method("node", "available", params)
        return rval

    def usage(self):
        print "node_avail [-p project] [-c class] [-t type]"
        print "Print the number of available nodes."
        print "where:"
        print "     -p project  - Specify project credentials for node types"
        print "                   that are restricted"
        print "     -c class    - The node class (Default: pc)"
        print "     -t type     - The node type"
        print
        print "example:"
        print "  $ node_avail -t pc850"
        wrapperoptions()
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747
        return

    pass


#
# node_avail_list
#
class node_avail_list:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        params = {}
        
        try:
            opts, req_args = getopt.getopt(self.argv, "hp:t:c:n:", [
                "help", "project=", "node-type=", "node-class=", "nodes=" ])

            for opt, val in opts:
                if opt in ("-h", "--help"):
                    self.usage();
                    return 0
                elif opt in ("-p", "--project"):
                    params["proj"] = val
                    pass
                elif opt in ("-c", "--node-class"):
                    params["class"] = val
                    pass
                elif opt in ("-t", "--node-type"):
                    params["type"] = val
                    pass
                elif opt in ("-n", "--nodes"):
                    params["nodes"] = val
                    pass
                pass
            pass
        except  getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        rval,response = do_method("node", "getlist", params)
        return rval

    def usage(self):
        print "node_avail_list [-p project] [-c class] [-t type] [-n nodes]"
        print "Print physical node_ids of available nodes."
        print "where:"
        print "     -p project         - Specify project credentials for node"
        print "                          types that are restricted"
        print "     -c class           - The node class (Default: pc)"
        print "     -t type            - The node type"
        print "     -n pcX,pcY,...,pcZ - A list of physical node_ids"
        print
        print "example:"
        print "  $ node_avail_list -t pc850"
        wrapperoptions()
748 749 750 751 752
        return

    pass


753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778
#
# delay_config
#
class delay_config:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "s:me:", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        params = {};
        for opt, val in opts:
            if opt == "--help":
                self.usage()
                return 0
                pass
            elif opt == "-m":
                params["persist"] = "yes";
                pass
779 780 781
            elif opt == "-b":
                params["bridge"] = "yes";
                pass
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818
            elif opt == "-s":
                params["src"] = val;
                pass
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                pass
            pass

        #
        # The point is to allow backwards compatable pid eid arguments, but
        # move to the better -e pid,eid format eventually. 
        #
        if not params.has_key("proj"):
            if len(req_args) < 2:
                self.usage();
                return -1;
            
            params["proj"]  = req_args[0];
            params["exp"]   = req_args[1];
            req_args        = req_args[2:];
            pass

        # Do this after so --help is seen.
        if len(req_args) < 2:
            self.usage();
            return -1;

        # Next should be the link we want to control
        params["link"]  = req_args[0];

        # Now we turn the rest of the arguments into a dictionary
        linkparams = {}
        for linkparam in req_args[1:]:
            plist = string.split(linkparam, "=", 1)
            if len(plist) != 2:
Timothy Stack's avatar
Timothy Stack committed
819
                print ("Parameter, '" + linkparam
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835
                       + "', is not of the form: param=value!")
                self.usage();
                return -1
            
            linkparams[plist[0]] = plist[1];
            pass
        params["params"] = linkparams;

        rval,response = do_method("experiment", "delay_config", params);
        return rval;

    def usage(self):
	print "delay_config [options] -e pid,eid link PARAM=value ...";
	print "delay_config [options] pid eid link PARAM=value ...";
	print "where:";
	print "     -m   - Modify virtual experiment as well as current state";
836
        print "     -b   - bridge mode; operating on a bridge node instead of link";
837 838 839
	print "     -s   - Select the source of the link to change";
 	print "     -e   - Project and Experiment ID to operate on";
        print "   link   - Name of link from your NS file (ie: 'link1')";
840
        print "            Or the bridge name, if explicitly using a bridge node";
841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856
        print "";
        print "PARAMS";
        print " BANDWIDTH=NNN   - N=bandwidth (10-100000 Kbits per second)";
        print " PLR=NNN         - N=lossrate (0 <= plr < 1)";
        print " DELAY=NNN       - N=delay (one-way delay in milliseconds > 0)";
        print " LIMIT=NNN       - The queue size in bytes or packets";
        print " QUEUE-IN-BYTES=N- 0 means in packets, 1 means in bytes";
        print "RED/GRED Options: (only if link was specified as RED/GRED)";
        print " MAXTHRESH=NNN   - Maximum threshold for the average Q size";
        print " THRESH=NNN      - Minimum threshold for the average Q size";
        print " LINTERM=NNN     - Packet dropping probability";
        print " Q_WEIGHT=NNN    - For calculating the average queue size\n";
        wrapperoptions();
        return

#
857
# wilink_config
858
#
859
class wilink_config:
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "s:me:", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        params = {};
        for opt, val in opts:
            if opt == "--help":
                self.usage()
                return 0
                pass
            elif opt == "-m":
                params["persist"] = "yes";
                pass
            elif opt == "-s":
                params["src"] = val;
                pass
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                pass
            pass

        #
        # The point is to allow backwards compatable pid eid arguments, but
        # move to the better -e pid,eid format eventually. 
        #
        if not params.has_key("proj"):
            if len(req_args) < 2:
                self.usage();
                return -1;
            
            params["proj"]  = req_args[0];
            params["exp"]   = req_args[1];
            req_args        = req_args[2:];
            pass

        # Do this after so --help is seen.
        if len(req_args) < 2:
            self.usage();
            return -1;

        # Next should be the link we want to control
        params["link"]  = req_args[0];

        # Now we turn the rest of the arguments into a dictionary
        linkparams = {}
        for linkparam in req_args[1:]:
            plist = string.split(linkparam, "=", 1)
            if len(plist) != 2:
                print ("Parameter, '" + param
                       + "', is not of the form: param=value!")
                self.usage();
                return -1
            
            linkparams[plist[0]] = plist[1];
            pass
        params["params"] = linkparams;

        rval,response = do_method("experiment", "link_config", params);
        return rval;

    def usage(self):
932 933
	print "wilink_config [options] -e pid,eid link PARAM=value ...";
	print "wilink_config [options] pid eid link PARAM=value ...";
934 935 936 937 938 939 940 941
	print "where:";
	print "     -m   - Modify virtual experiment as well as current state";
	print "     -s   - Select the source of the link to change";
 	print "     -e   - Project and Experiment ID to operate on";
        print "   link   - Name of link from your NS file (ie: 'link1')";
        print "";
        print "Special Param";
        print " ENABLE=yes/no   - Bring the link up or down (or ENABLE=up/down)";
942 943 944 945 946 947
        print ""
        print "*********************** WARNING *******************************"
        print "   wilink_config is used to configure WIRELESS INTERFACES!"
        print "   Use delay_config to change the traffic shaping parameters"
        print "   on normal links and lans."
        print "***************************************************************"
948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308
        wrapperoptions();
        return

#
# savelogs
#
class savelogs:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "e:", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        params = {};
        for opt, val in opts:
            if opt == "--help":
                self.usage()
                return 0
                pass
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                pass
            pass

        # Do this after so --help is seen.
        #
        # The point is to allow backwards compatable pid eid arguments, but
        # move to the better -e pid,eid format eventually. 
        #
        if not params.has_key("proj"):
            if len(req_args) < 2:
                self.usage();
                return -1;
            
            params["proj"]  = req_args[0];
            params["exp"]   = req_args[1];
            pass

        rval,response = do_method("experiment", "savelogs", params);
        return rval;

    def usage(self):
	print "savelogs -e pid,eid";
	print "savelogs pid eid";
	print "where:";
 	print "     -e   - Project and Experiment ID";
        wrapperoptions();
        return
    pass

#
# portstats
#
class portstats:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "azqcpe", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        params = {};
        for opt, val in opts:
            if opt == "--help":
                self.usage()
                return 0
                pass
            elif opt == "-e":
                params["errors-only"] = "yes";
                pass
            elif opt == "-a":
                params["all"] = "yes";
                pass
            elif opt == "-z":
                params["clear"] = "yes";
                pass
            elif opt == "-q":
                params["quiet"] = "yes";
                pass
            elif opt == "-c":
                params["absolute"] = "yes";
                pass
            elif opt == "-p":
                params["physnames"] = "yes";
                pass
            pass

        # Do this after so --help is seen.
        if not params.has_key("physnames"):
            if len(req_args) < 2:
                self.usage();
                return -1;
            
            params["proj"]  = req_args[0];
            params["exp"]   = req_args[1];
            req_args        = req_args[2:];
            pass
        elif len(req_args) < 1:
            self.usage();
            return -1;
        
        # Send the rest of the args along as a list.
        params["nodeports"] = req_args;

        rval,response = do_method("experiment", "portstats", params);
        return rval;

    def usage(self):
 	print "portstats <-p | pid eid> [vname ...] [vname:port ...]";
	print "where:";
        print "    -e    - Show only error counters";
        print "    -a    - Show all stats";
        print "    -z    - Zero out counts for selected counters after printing";
        print "    -q    - Quiet: don't actually print counts - useful with -z";
        print "    -c    - Print absolute, rather than relative, counts";
        print "    -p    - The machines given are physical, not virtual, node";
        print "            IDs. No pid and eid should be given with this option";
        print "";
        print "If only pid and eid are given, prints out information about all";
        print "ports in the experiment. Otherwise, output is limited to the";
        print "nodes and/or ports given.";
        print "";
        print "NOTE: Statistics are reported from the switch's perspective.";
        print "      This means that 'In' packets are those sent FROM the node,";
        print "      and 'Out' packets are those sent TO the node.";
        print "";
        print "In the output, packets described as 'NUnicast' or 'NUcast' are ";
        print "non-unicast (broadcast or multicast) packets.";
        wrapperoptions();
        return
    pass


#
# readycount. This is totally deprecated, but we leave it around. Users
# should be using the sync daemon.
#
class readycount:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "scple:", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        params = {};
        for opt, val in opts:
            if opt == "--help":
                self.usage()
                return 0
                pass
            elif opt == "-s":
                params["set"] = "yes";
                pass
            elif opt == "-c":
                params["clear"] = "yes";
                pass
            elif opt == "-l":
                params["list"] = "yes";
                pass
            elif opt == "-p":
                params["physnames"] = "yes";
                pass
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                pass
            pass

        #
        # The point is to allow backwards compatable pid eid arguments, but
        # move to the better -e pid,eid format eventually. 
        #
        if params.has_key("physnames") and params.has_key("proj"):
            self.usage();
            return -1;
        
        if not params.has_key("physnames") and not params.has_key("proj"):
            if len(req_args) < 2:
                self.usage();
                return -1;
            
            params["proj"]  = req_args[0];
            params["exp"]   = req_args[1];
            req_args        = req_args[2:];
            pass
        elif params.has_key("physnames") and len(req_args) < 1:
            self.usage();
            return -1;
        
        # Send the rest of the args along as a list.
        params["nodes"] = req_args;

        rval,response = do_method("experiment", "readycount", params);
        return rval;

    def usage(self):
	print "readycount [-c | -s] [-l] -e pid,eid [node ...]";
	print "readycount [-c | -s] [-l] pid eid [node ...]";
	print "where:";
 	print "     -e   - Project and Experiment ID";
        print "     -s   - Set ready bits";
        print "     -c   - Clear ready bits";
        print "     -p   - Use physical node IDs instead of virtual (-c or -s).";
        print "            No pid and eid should be given with this option";
        print "     -l   - List ready status for each node in the experiment";
        print "";
        print "If no nodes are given, gives a summary of the nodes that have";
        print "reported ready. If nodes are given, reports just status for the";
        print "listed nodes. If -s or -c is given, sets or clears ready bits";
        print "for the listed nodes, or all them as being ready (or clears ";
        print "their ready bits if -c is given).";
        wrapperoptions();
        return
    pass

#
# eventsys_control
#
class eventsys_control:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "e:", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        params = {};
        for opt, val in opts:
            if opt == "--help":
                self.usage()
                return 0
                pass
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                pass
            pass

        #
        # The point is to allow backwards compatable pid eid arguments, but
        # move to the better -e pid,eid format eventually. 
        #
        if not params.has_key("proj"):
            if len(req_args) < 2:
                self.usage();
                return -1;
            
            params["proj"]   = req_args[0];
            params["exp"]    = req_args[1];
            params["action"] = req_args[2];
            pass
        elif len(req_args) != 1:
            self.usage();
            return -1;
        else:
            params["action"] = req_args[0];            

        rval,response = do_method("experiment", "eventsys_control", params);
        return rval;

    def usage(self):
	print "eventsys_control -e pid,eid start|stop|replay";
	print "eventsys_control pid eid start|stop|replay";
	print "where:";
 	print "     -e   - Project and Experiment ID";
        print "   stop   - Stop the event scheduler";
        print "  start   - Start the event stream from time index 0";
        print " replay   - Replay the event stream from time index 0";
        wrapperoptions();
        return
    pass

#
# nscheck
#
class nscheck:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;
        
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            pass

        # Do this after so --help is seen.
        if len(req_args) != 1:
            self.usage();
            return -1;

        try:
            nsfilestr = open(req_args[0]).read();
            pass
        except:
            print "Could not open file: " + req_args[0];
            return -1;

        params["nsfilestr"] = nsfilestr;
        rval,response = do_method("experiment", "nscheck", params);
        return rval;

    def usage(self):
	print "nscheck nsfile";
	print "where:";
	print " nsfile    - Path to NS file you to wish check for parse errors";
        wrapperoptions();
        return
    pass

#
# startexp
#
class startexp:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv,
1309
                                           "iwfqS:L:a:l:E:g:p:e:N",
1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356
                                           [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;
        
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-i":
                params["batch"] = "no";
                pass
            elif opt == "-E":
                params["description"] = val;
                pass
            elif opt == "-g":
                params["group"] = val;
                pass
            elif opt == "-e":
                params["exp"] = val;
                pass
            elif opt == "-p":
                params["proj"] = val;
                pass
            elif opt == "-S":
                params["swappable"]     = "no";
                params["noswap_reason"] = val;
                pass
            elif opt == "-L":
                params["idleswap"]          = 0;
                params["noidleswap_reason"] = val;
                pass
            elif opt == "-l":
                params["idleswap"] = val;
                pass
            elif opt == "-a":
                params["max_duration"] = val;
                pass
            elif opt == "-f":
                params["noswapin"] = "yes"
                pass
            elif opt == "-w":
                params["wait"] = "yes"
                pass
1357 1358 1359
            elif opt == "-N":
                params["noemail"] = "yes"
                pass
1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378
            pass

        # Do this after so --help is seen.
        if len(req_args) != 1:
            self.usage();
            return -1;

        try:
            nsfilestr = open(req_args[0]).read();
            pass
        except:
            print "Could not open file: " + req_args[0];
            return -1;

        params["nsfilestr"] = nsfilestr;
        rval,response = do_method("experiment", "startexp", params);
        return rval;

    def usage(self):
1379
        print "startexp [-q] [-i [-w]] [-f] [-N] [-E description] [-g gid]";
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394
        print "         [-S reason] [-L reason] [-a <time>] [-l <time>]";
        print "         -p <pid> -e <eid> <nsfile>";
	print "where:";
        print "   -i   - swapin immediately; by default experiment is batched";
        print "   -w   - wait for non-batchmode experiment to preload or swapin";
        print "   -f   - preload experiment (do not swapin or queue yet)";
        print "   -q   - be less chatty";
        print "   -S   - Experiment cannot be swapped; must provide reason";
        print "   -L   - Experiment cannot be IDLE swapped; must provide reason";
        print "   -a   - Auto swapout NN minutes after experiment is swapped in";
        print "   -l   - Auto swapout NN minutes after experiment goes idle";
        print "   -E   - A pithy sentence describing your experiment";
        print "   -g   - The subgroup in which to create the experiment";
        print "   -p   - The project in which to create the experiment";
        print "   -e   - The experiment name (unique, alphanumeric, no blanks)";
1395
	print "   -N   - Suppress most email to the user and testbed-ops";
1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410
        print "nsfile  - NS file to parse for experiment";
        wrapperoptions();
        return
    pass

#
# swapexp
#
class swapexp:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
1411
            opts, req_args = getopt.getopt(self.argv, "wNe:s:", [ "help" ]);
1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;
        
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-w":
                params["wait"] = "yes"
                pass
1426 1427 1428
            elif opt == "-N":
                params["noemail"] = "yes"
                pass
1429 1430 1431
            elif opt == "-s":
                params["direction"] = val
                pass
1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                pass
            pass

        #
        # The point is to allow backwards compatable pid eid arguments, but
        # move to the better -e pid,eid format eventually. 
        #
        if not params.has_key("proj"):
            if len(req_args) < 2:
                self.usage();
                return -1;
            
1448 1449 1450
            params["proj"] = req_args[0];
            params["exp"]  = req_args[1];
            req_args       = req_args[2:];
1451
            pass
1452

Leigh Stoller's avatar
Leigh Stoller committed
1453
        if not params.has_key("direction") and len(req_args) != 1:
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468
            self.usage();
            return -1;
        else:
            params["direction"] = req_args[0];
            pass

        rval,response = do_method("experiment", "swapexp", params);
        return rval;

    def usage(self):
	print "swapexp -e pid,eid in|out";
	print "swapexp pid eid in|out";
	print "where:";
	print "     -w   - Wait for experiment to finish swapping";
 	print "     -e   - Project and Experiment ID";
1469
	print "     -N   - Suppress most email to the user and testbed-ops";
1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489
        print "     in   - Swap experiment in  (must currently be swapped out)";
        print "    out   - Swap experiment out (must currently be swapped in)";
        print ""
        print "By default, swapexp runs in the background, sending you email ";
        print "when the transition has completed. Use the -w option to wait";
        print "in the foreground, returning exit status. Email is still sent.";
        wrapperoptions();
        return
    pass

#
# modexp
#
class modexp:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
1490
            opts, req_args = getopt.getopt(self.argv, "rswNe:", [ "help" ]);
1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;
        
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-w":
                params["wait"] = "yes"
                pass
            elif opt == "-r":
                params["reboot"] = "yes"
                pass
            elif opt == "-s":
                params["restart_eventsys"] = "yes"
                pass
1511 1512 1513
            elif opt == "-N":
                params["noemail"] = "yes"
                pass
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                pass
            pass

        #
        # The point is to allow backwards compatable pid eid arguments, but
        # move to the better -e pid,eid format eventually. 
        #
        if not params.has_key("proj"):
            if len(req_args) != 3:
                self.usage();
                return -1;
            
            params["proj"] = req_args[0];
            params["exp"]  = req_args[1];
            req_args       = req_args[2:];
            pass
        elif len(req_args) != 1:
            self.usage();
            return -1;

        #
        # Read in the NS file to pass along.
        # 
        try:
            nsfilestr = open(req_args[0]).read();
            pass
        except:
            print "Could not open file: " + req_args[0];
            return -1;

        params["nsfilestr"] = nsfilestr;
        rval,response = do_method("experiment", "modify", params);
        return rval;

    def usage(self):
1553 1554
	print "modexp [-r] [-s] [-w] [-N] -e pid,eid nsfile";
	print "modexp [-r] [-s] [-w] [-N] pid eid nsfile";
1555 1556 1557 1558 1559
	print "where:";
	print "     -w   - Wait for experiment to finish swapping";
 	print "     -e   - Project and Experiment ID";
        print "     -r   - Reboot nodes (when experiment is active)";
        print "     -s   - Restart event scheduler (when experiment is active)";
1560
	print "     -N   - Suppress most email to the user and testbed-ops";
1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584
        print ""
        print "By default, modexp runs in the background, sending you email ";
        print "when the transition has completed. Use the -w option to wait";
        print "in the foreground, returning exit status. Email is still sent.";
        print ""
        print "The experiment can be either swapped in *or* swapped out.";
        print "If the experiment is swapped out, the new NS file replaces the ";
        print "existing NS file (the virtual topology is updated). If the";
        print "experiment is swapped in (active), the physical topology is";
        print "also updated, subject to the -r and -s options above";
        wrapperoptions();
        return
    pass

#
# endexp
#
class endexp:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
1585
            opts, req_args = getopt.getopt(self.argv, "wNe:", [ "help" ]);
1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;
        
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-w":
                params["wait"] = "yes"
                pass
1600 1601 1602
            elif opt == "-N":
                params["noemail"] = "yes"
                pass
1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                pass
            pass

        #
        # The point is to allow backwards compatable pid eid arguments, but
        # move to the better -e pid,eid format eventually. 
        #
        if not params.has_key("proj"):
            if len(req_args) != 2:
                self.usage();
                return -1;
            
            params["proj"] = req_args[0];
            params["exp"]  = req_args[1];
            pass
        elif len(req_args) != 0:
            self.usage();
            return -1;

        rval,response = do_method("experiment", "endexp", params);
        return rval;

    def usage(self):
1630 1631
	print "endexp [-w] [-N] -e pid,eid";
	print "endexp [-w] [-N] pid eid";
1632 1633 1634
	print "where:";
	print "     -w   - Wait for experiment to finish terminating";
 	print "     -e   - Project and Experiment ID";
1635
	print "     -N   - Suppress most email to the user and testbed-ops";
1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724
        print ""
        print "By default, endexp runs in the background, sending you email ";
        print "when the transition has completed. Use the -w option to wait";
        print "in the foreground, returning exit status. Email is still sent.";
        print ""
        print "The experiment can be terminated when it is currently swapped";
        print "in *or* swapped out.";
        wrapperoptions();
        return
    pass

#
# expinfo
#
class expinfo:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "nmldae:", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        show   = [];
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-n":
                show.append("nodeinfo");
                pass
            elif opt == "-m":
                show.append("mapping");
                pass
            elif opt == "-l":
                show.append("linkinfo");
                pass
            elif opt == "-d":
                show.append("shaping");
                pass
            elif opt == "-a":
                show = ["nodeinfo", "mapping", "linkinfo", "shaping"];
                pass
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                pass
            pass

        #
        # The point is to allow backwards compatable pid eid arguments, but
        # move to the better -e pid,eid format eventually. 
        #
        if not params.has_key("proj"):
            if len(req_args) != 2:
                self.usage();
                return -1;
            
            params["proj"] = req_args[0];
            params["exp"]  = req_args[1];
            pass
        elif len(req_args) or len(show) == 0:
            self.usage();
            return -1;

        params["show"] = string.join(show, ",");
        rval,response = do_method("experiment", "expinfo", params);
        return rval;

    def usage(self):
	print "expinfo [-n] [-m] [-l] [-d] [-a] -e pid,eid";
	print "expinfo [-n] [-m] [-l] [-d] [-a] pid eid";
	print "where:";
 	print "     -e   - Project and Experiment ID";
        print "     -n   - Show node info";
        print "     -m   - Show node mapping";
        print "     -l   - Show link info";
        print "     -a   - Show all of the above";
        wrapperoptions();
        return
    pass

1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790
class tbuisp:
    def __init__(self, argv=None):
        self.argv = argv
        return

    def apply(self):
        params = {}
  
        try:
            opts, req_args = getopt.getopt(self.argv, "h", [
                "help", ])

            for opt, val in opts:
                if opt in ("-h", "--help"):
                    self.usage();
                    return 0
                pass

            if len(req_args) < 3:
                raise getopt.error(
                    "error: a file and one or more nodes must be specified")
            pass
        except  getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

	params["op"] = req_args[0]
        file = req_args[1]
        params["nodes"] = req_args[2:]
  
        try:
            filestr = open(file).read()
            pass
        except:
            print "Could not open file: " + file
            return -1

        # I don't know what is in the file, so we'll base64 encode before
        # sending it over XML-RPC.  On the receiving side you'll get a Binary
        # object with the bits stored in the data field.  In code:
        #
        #   filestr = params["filestr"].data
        #
        # I think...
        params["filestr"] = xmlrpclib.Binary(filestr)

        rval,response = do_method("node", "tbuisp", params)
                
        return rval
                    
    def usage(self):
        print "tbuisp <operation> <file> <node1> [<node2> ...]"
        print "where:"
	print "     operation - Operation to perform. Currently, only 'upload'"
	print "                 is supported"
        print "     file      - Name of the to upload to the mote"
        print "     nodeN     - The physical node name ..."
        print
        print "example:"   
        print "  $ tbuisp upload foo.srec mote1"
        wrapperoptions()
        return
        
    pass

1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856
#
# expwait
#
class expwait:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "ht:e:", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        show   = [];
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-t":
                params["timeout"] = val;
                pass
            elif opt == "-e":
                pid,eid = string.split(val, ",")
                params["proj"] = pid;
                params["exp"]  = eid;
                pass
            pass

        #
        # The point is to allow backwards compatable pid eid arguments, but
        # move to the better -e pid,eid format eventually. 
        #
        if not params.has_key("proj"):
            if len(req_args) != 3:
                self.usage();
                return -1;
            
            params["proj"]  = req_args[0];
            params["exp"]   = req_args[1];
            params["state"] = req_args[2];
            pass
        elif len(req_args) != 1:
            self.usage();
            return -1;
        else:
            params["state"] = req_args[0];
            pass

        rval,response = do_method("experiment", "statewait", params);
        return rval;

    def usage(self):
	print "expwait [-t timeout] -e pid,eid state";
	print "expwait [-t timeout] pid eid state";
	print "where:";
 	print "     -e   - Project and Experiment ID";
        print "     -t   - Maximum time to wait (in seconds).";
        wrapperoptions();
        return
    pass

1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907
#
# tipacl (get console acl goo)
#
class tipacl:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;
        
        params = {};
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
                pass
            pass

        # Do this after so --help is seen.
        if len(req_args) != 1:
            self.usage();
            return -1;
        
        params["node"]  = req_args[0];

        rval,response = do_method("node", "console", params);

        if rval == 0:
            for key in response["value"]:
                val = response["value"][key];
                print "%s: %s" % (key, val)
                pass
            pass
        
        return rval;

    def usage(self):
	print "tipacl node";
	print "where:";
	print "  node    - Node to get tipacl data for (pcXXX)";
        wrapperoptions();
        return
    pass

1908 1909 1910 1911 1912 1913 1914 1915 1916 1917
#
# template_commit
#
class template_commit:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
1918 1919
            opts, req_args = getopt.getopt(self.argv,
                                           "we:p:E:t:r:", [ "help" ]);
1920 1921 1922 1923 1924 1925 1926 1927
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        guid   = None
        params = {}
1928 1929
        eid    = None
        pid    = None
1930 1931 1932 1933 1934 1935 1936 1937 1938 1939
        
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-w":
                params["wait"] = "yes"
                pass
            elif opt == "-e":
                params["exp"] = val
1940 1941 1942 1943 1944
                eid = val
                pass
            elif opt == "-p":
                params["proj"] = val
                pid = val;
1945
                pass
1946 1947 1948 1949 1950 1951 1952 1953 1954
            elif opt == "-E":
                params["description"] = val;
                pass
            elif opt == "-t":
                params["tid"] = val;
                pass
            elif opt == "-r":
                params["tag"] = val;
                pass
1955 1956 1957
            pass
        
        # Try to infer the template guid/vers from the current path.
1958 1959
        if len(req_args) == 1:
            params["guid"] = req_args[0]
1960
            pass
1961 1962 1963 1964
        elif pid == None and eid == None:
            (guid, subdir) = infer_template()
            if subdir:
                params["path"] = os.getcwd()
1965
                pass
1966 1967 1968
            else:
                self.usage();
                return -1
1969
            pass
1970 1971 1972 1973
        else:
            self.usage();
            return -1
        
1974
        print "Committing template; please be (very) patient!"
1975 1976 1977 1978 1979
        
        rval,response = do_method("template", "template_commit", params);
        return rval;
    
    def usage(self):
1980
	print "template_commit [-w]"
1981
	print "template_commit [-w] [-e eid | -r tag] <guid/vers>"
1982
        print "template_commit [-w] -p pid -e eid"
1983
	print "where:";
1984
	print "     -w     - Wait for template to finish commit";
1985
        print "     -e     - Commit from specific template instance (eid)"
1986 1987
        print "     -E     - A pithy sentence describing your experiment"
        print "     -t     - The template name (alphanumeric, no blanks)"
1988 1989
        print "     -p     - Project for -e option (pid)"
        print "    guid    - Template GUID"
1990 1991 1992 1993 1994 1995
        print ""
        print "By default, commit runs in the background, sending you email ";
        print "when the operation has completed. Use the -w option to wait";
        print "in the foreground, returning exit status. Email is still sent.";
        print ""
        print "Environment:"
1996
        print "  cwd   The template will be inferred from the current"
1997
        print "        working directory if it is inside a template checkout."
1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008
        wrapperoptions();
        return
    pass

class template_export:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
2009
            opts, req_args = getopt.getopt(self.argv, "i:r:", [ "help" ]);
2010 2011 2012 2013 2014 2015
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

2016 2017
        instance = None
        params   = {}
2018 2019 2020 2021 2022 2023 2024
        
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-i":
                params["instance"] = val
2025 2026 2027 2028
                instance = val
                pass
            elif opt == "-r":
                params["run"] = val
2029 2030 2031 2032
                pass
            pass
        
        # Try to infer the template guid/vers from the current path.
2033
        if instance == None:
2034 2035
            self.usage();
            return -1
2036
        
2037 2038 2039 2040
        rval,response = do_method("template", "export", params);
        return rval;
    
    def usage(self):
2041
	print "template_export [-r runidx] -i instance_id";
2042
	print "where:";
2043
        print "     -i   - Export specific template instance (idx)";
2044
        print "     -r   - Optional run index to export";
2045 2046 2047 2048 2049 2050 2051 2052
        print ""
        print "Environment:"
        print "  cwd   The template GUID will be inferred from the current"
        print "        working directory, if it is inside the templates's"
        print "        directory (e.g. /proj/foo/templates/10005/18)."
        wrapperoptions();
        return
    pass
2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086

class template_checkout:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "d", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        if (len(req_args) == 0):
            self.usage()
            return -1

        params         = {}
        params["guid"] = req_args[0]
        params["path"] = os.getcwd()
        
        rval,response = do_method("template", "checkout", params);
        return rval;
    
    def usage(self):
	print "template_checkout guid/vers";
        print ""
        print "Environment:"
        print "  cwd   The template checkout is placed in the current dir"
        wrapperoptions();
        return
    pass
2087 2088

#
2089
# template_instantiate
2090
#
2091
class template_instantiate:
2092 2093 2094 2095 2096 2097 2098
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv,
2099
                                           "bwqS:L:a:l:E:e:x:",
2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123
                                           [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;
        
        guid        = None
        xmlfilename = None
        params      = {}
        
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-b":
                params["batch"] = "yes";
                pass
            elif opt == "-E":
                params["description"] = val;
                pass
            elif opt == "-e":
                params["exp"] = val;
                pass
2124
            elif opt == "-x":
2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146
                xmlfilename = val;
                pass
            elif opt == "-S":
                params["swappable"]     = "no";
                params["noswap_reason"] = val;
                pass
            elif opt == "-L":
                params["idleswap"]          = 0;
                params["noidleswap_reason"] = val;
                pass
            elif opt == "-l":
                params["idleswap"] = val;
                pass
            elif opt == "-a":
                params["max_duration"] = val;
                pass
            elif opt == "-f":
                params["noswapin"] = "yes"
                pass
            elif opt == "-w":
                params["wait"] = "yes"
                pass
2147 2148 2149
            elif opt == "-p":
                params["preload"] = "yes"
                pass
2150 2151 2152 2153 2154 2155
            pass

        # Try to infer the template guid/vers from the current path.
        if len(req_args) == 0:
            guid = infer_guid(os.getcwd())
            if guid == None:
2156 2157 2158 2159 2160
                (guid, subdir) = infer_template()
                if guid == None:
                    self.usage()
                    return -1
                pass
2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179
            pass
        elif len(req_args) == 1:
            guid = req_args[0]
            pass
        else:
            self.usage();
            return -1
        
        params["guid"] = guid

        if xmlfilename:
            try:
                params["xmlfilestr"] = open(xmlfilename).read();
                pass
            except:
                print "Could not open file: " + req_args[0];
                return -1;
            pass
        
2180
        rval,response = do_method("template", "instantiate", params);
2181 2182 2183
        return rval;

    def usage(self):
2184 2185 2186
        print "template_instantiate [-q] [-E description] [-p xmlfilename] ";
        print "     [-b] [-p] [-S reason] [-L reason] [-a <time>] [-l <time>]";
        print "     -e <eid> <guid>";
2187 2188
	print "where:";
        print "   -b   - queue for the batch system";
2189
        print "   -p   - preload only; do not swapin";
2190 2191 2192 2193 2194 2195 2196
        print "   -w   - wait for non-batchmode experiment to instantiate";
        print "   -q   - be less chatty";
        print "   -S   - Instance cannot be swapped; must provide reason";
        print "   -L   - Instance cannot be IDLE swapped; must provide reason";
        print "   -a   - Auto swapout NN minutes after instance is swapped in";
        print "   -l   - Auto swapout NN minutes after instance goes idle";
        print "   -E   - A pithy sentence describing your experiment";
2197
        print "   -x   - XML file of parameter bindings";
2198 2199 2200 2201 2202
        print "   -e   - The instance name (unique, alphanumeric, no blanks)";
        print "   guid - Template GUID";
        print ""
        print "Environment:"
        print "  cwd   The template GUID will be inferred from the current"
2203
        print "        working directory if it is inside a template checkout."
2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270
        wrapperoptions();
        return
    pass

#
# template_swapin
#
class template_swapin:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "wqe:", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;
        
        guid   = None
        params = {}
        
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-w":
                params["wait"] = "yes"
                pass
            elif opt == "-q":
                params["quiet"] = "yes"
                pass
            elif opt == "-e":
                params["exp"]  = val;
                pass
            pass

        # Try to infer the template guid/vers from the current path.
        if len(req_args) == 0:
            guid = infer_guid(os.getcwd())
            if guid == None:
                self.usage();
                return -1
            pass
        elif len(req_args) == 1:
            guid = req_args[0]
        else:
            self.usage();
            return -1
            
        params["guid"] = guid

        rval,response = do_method("template", "swapin", params);
        return rval;

    def usage(self):
	print "template_swapin -e id [<guid/vers>]";
	print "where:";
        print "     -e   - Instance ID (aka eid)";
        print "     -q   - be less chatty";
	print "     -w   - Wait for instance to finish swapping in";
        print "    guid  - Template GUID";
        print ""
        print "Environment:"
        print "  cwd   The template GUID will be inferred from the current"
2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342
        print "        working directory, if it is inside the templates's"
        print "        directory (e.g. /proj/foo/templates/10005/18)."
        wrapperoptions();
        return
    pass

#
# template_swapout
#
class template_swapout:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
            opts, req_args = getopt.getopt(self.argv, "we:", [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

        guid   = None
        params = {}
        
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-w":
                params["wait"] = "yes"
                pass
            elif opt == "-e":
                params["exp"]  = val;
                pass
            pass

        # Try to infer the template guid/vers from the current path.
        if len(req_args) == 0:
            guid = infer_guid(os.getcwd())
            if guid == None:
                self.usage();
                return -1
            pass
        elif len(req_args) == 1:
            guid = req_args[0]
        else:
            self.usage();
            return -1
            
        params["guid"] = guid

        rval,response = do_method("template", "swapout", params);
        return rval;

    def usage(self):
	print "template_swapout -e id [<guid/vers>]";
	print "where:";
        print "     -e   - Instance ID (aka eid)";
	print "     -w   - Wait for instance to finish terminating";
        print "    guid  - Template GUID";
        print ""
        print "Environment:"
        print "  cwd   The template GUID will be inferred from the current"
        print "        working directory, if it is inside the templates's"
        print "        directory (e.g. /proj/foo/templates/10005/18)."
        wrapperoptions();
        return
    pass

#
2343
# template_startrun and template_modrun
2344 2345 2346 2347 2348 2349 2350 2351
#
class template_startrun:
    def __init__(self, argv=None):
        self.argv = argv;
        return

    def apply(self):
        try:
2352
            opts, req_args = getopt.getopt(self.argv, "we:E:r:p:cx:my:",
2353 2354 2355 2356 2357 2358 2359
                                           [ "help" ]);
            pass
        except getopt.error, e:
            print e.args[0]
            self.usage();
            return -1;

2360
        pid         = None
2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374
        guid        = None
        xmlfilename = None
        params      = {}
        
        for opt, val in opts:
            if opt in ("-h", "--help"):
                self.usage()
                return 0
            elif opt == "-E":
                params["description"] = val;
                pass
            elif opt == "-w":
                params["wait"] = "yes"
                pass
2375 2376 2377
            elif opt == "-m":
                params["modify"] = "yes"
                pass
2378 2379 2380 2381 2382