def _build_parser():
    parser = OptionParser(usage="%prog create DIR [options]")

    parser.add_option("-f", "--force",            dest = Creation.FORCE, action="store_true", default=False,
                                                  help = "Overwrite the contents even if the directory already existed.")

    parser.add_option("-q", "--quiet",            dest = Creation.QUIET, action="store_true", default=False,
                                                  help = "Do not display any output.")

    parser.add_option("-v", "--verbose",          dest = Creation.VERBOSE, action="store_true", default=False,
                                                  help = "Show more information about the process.")

    parser.add_option("--not-interactive",        dest = Creation.NOT_INTERACTIVE, action="store_true", default=False,
                                                  help = "Run the script in not interactive mode. Recommended for scripts only.")

    parser.add_option("--socket-wait",            dest = Creation.SOCKET_WAIT, metavar="PORT", type="int", default=None,
                                                  help = "Wait for a socket connection rather than sigterm/input")

    parser.add_option("--add-test-data",          dest = Creation.ADD_TEST_DATA, action="store_true", default=False,
                                                  help = "Populate the database with sample data")

    parser.add_option("--cores",                  dest = Creation.CORES,           type="int",    default=1,
                                                  help = "Number of core servers.")

    parser.add_option("--start-port",             dest = Creation.START_PORTS,     type="int",    default=10000,
                                                  help = "From which port start counting.")

    parser.add_option("-i", "--system-identifier",dest = Creation.SYSTEM_IDENTIFIER, type="string", default="",
                                                  help = "A human readable identifier for this system.")

    parser.add_option("--enable-https",           dest = Creation.ENABLE_HTTPS,   action="store_true", default=False,
                                                  help = "Tell external federated servers that they must use https when connecting here")

    parser.add_option("--base-url",               dest = Creation.BASE_URL,       type="string",    default="",
                                                  help = "Base location, before /weblab/. Example: /deusto.")

    parser.add_option(CreationFlags.HTTP_SERVER_PORT,  dest = Creation.HTTP_SERVER_PORT,   type="int",    default=None,
                                                  help = "Enable the builtin HTTP server (so as to not require apache while testing) and listen in that port.")

    parser.add_option("--entity-link",            dest = Creation.ENTITY_LINK,       type="string",  default="http://www.yourentity.edu",
                                                  help = "Link of the host entity (e.g. http://www.deusto.es ).")

    parser.add_option("--logo-path",              dest = Creation.LOGO_PATH,       metavar="IMG_FILE_PATH", type="string",  default=None,
                                                  help = "Path of the entity logo.")

    parser.add_option("--server-host",            dest = Creation.SERVER_HOST,     type="string",    default="localhost",
                                                  help = "Host address of this machine. Example: weblab.domain.")

    parser.add_option("--poll-time",              dest = Creation.POLL_TIME,     type="int",    default=350,
                                                  help = "Time in seconds that will wait before expiring a user session.")

    parser.add_option("--no-lab",                 dest = Creation.NO_LAB, action="store_true", default=False,
                                                  help = "Do not create any laboratory server or experiment server.")

    parser.add_option("--inline-lab-server",      dest = Creation.INLINE_LAB_SERV, action="store_true", default=False,
                                                  help = "Laboratory server included in the same process as the core server. "
                                                         "Only available if a single core is used." )

    parser.add_option("--lab-copies",             dest = Creation.LAB_COPIES, type="int",   default=1,
                                                  help = "Each experiment can be managed by a single laboratory server. "
                                                         "However, if the number of experiments managed by a single laboratory server "
                                                         "is high, it can become a bottleneck. This bottleneck effect can be reduced by "
                                                         "balancing the amount of experiments among different copies of the laboratories. "
                                                         "By establishing a higher number of laboratories, the generated deployment will "
                                                         "have the experiments balanced among them.")
    parser.add_option("--ignore-locations",       dest = Creation.IGNORE_LOCATIONS, action="store_true", default=False,
                                                  help = "Ignore locations. Otherwise, it will tell you to download two files for GeoLocation"),

    admin_data = OptionGroup(parser, "Administrator data",
                                                "Administrator basic data: username, password, etc.")
    admin_data.add_option("--admin-user",             dest = Creation.ADMIN_USER,       type="string",    default="admin",
                                                  help = "Username for the WebLab-Deusto administrator")
    admin_data.add_option("--admin-name",             dest = Creation.ADMIN_NAME,       type="string",    default="Administrator",
                                                  help = "Full name of the administrator")
    admin_data.add_option("--admin-password",       dest = Creation.ADMIN_PASSWORD, type="string",    default="password",
                                                  help = "Administrator password ('password' is the default)")
    admin_data.add_option("--admin-mail",             dest = Creation.ADMIN_MAIL,       type="string",    default="",
                                                  help = "E-mail address of the system administrator.")

    parser.add_option_group(admin_data)

    # TODO
    experiments = OptionGroup(parser, "Experiments options",
                                "While most laboratories are specific to a particular equipment, "
                                "some of them are useful anywhere (such as the VM experiment, as long as "
                                "you have a VirtualBox virtual machine that you'd like to deploy, or the "
                                "logic game, which does not require any equipment). Other experiments, "
                                "such as VISIR, have been deployed in many universities. Finally, for "
                                "development purposes, the XML-RPC experiment is particularly useful.")

    experiments.add_option("--xmlrpc-experiment",      dest = Creation.XMLRPC_EXPERIMENT, action="store_true", default=False,
                                                       help = "By default, the Experiment Server is located in the same process as the  "
                                                              "Laboratory server. However, it is possible to force that the laboratory  "
                                                              "uses XML-RPC to contact the Experiment Server. If you want to test a "
                                                              "Java, C++, .NET, etc. Experiment Server, you can enable this option, "
                                                              "and the system will try to find the Experiment Server in other port ")

    experiments.add_option("--xmlrpc-experiment-port", dest = Creation.XMLRPC_EXPERIMENT_PORT, type="int",    default=None,
                                                       help = "What port should the Experiment Server use. Useful for development.")

    experiments.add_option("--dummy-experiment-name",  dest = Creation.DUMMY_NAME, type="string",    default="dummy",
                                                       help = "There is a testing experiment called 'dummy'. You may change this name "
                                                              "(e.g. to dummy1 or whatever) by changing this option." )

    experiments.add_option("--dummy-category-name",    dest = Creation.DUMMY_CATEGORY_NAME, type="string",    default="Dummy experiments",
                                                       help = "You can change the category name of the dummy experiments. (by default,"
                                                              " Dummy experiments).")

    experiments.add_option("--dummy-copies",           dest = Creation.DUMMY_COPIES, type="int",    default=1,
                                                       help = "You may want to test the load balance among different copies of dummy." )

    experiments.add_option("--dummy-silent",           dest = Creation.DUMMY_SILENT, action="store_true", default=False,
                                                       help = "Not show the commands sent to the dummy experiment." )

    experiments.add_option("--visir", "--visir-server", dest = Creation.VISIR_SERVER, action="store_true", default=False,
                                                       help = "Add a VISIR server to the deployed system. "  )

    experiments.add_option("--visir-slots",            dest = Creation.VISIR_SLOTS, default=60, type="int", metavar='SLOTS',
                                                       help = "Number of concurrent users of VISIR. "  )

    experiments.add_option("--visir-experiment-name",  dest = Creation.VISIR_EXPERIMENT_NAME, default='visir', type="string", metavar='EXPERIMENT_NAME',
                                                       help = "Name of the VISIR experiment. "  )

    experiments.add_option("--visir-base-url",         dest = Creation.VISIR_BASE_URL, default='', type="string", metavar='VISIR_BASE_URL',
                                                       help = "URL of the VISIR system (e.g. http://weblab-visir.deusto.es/electronics/ ). It should contain login.php, for instance. "  )

    experiments.add_option("--visir-measurement-server", dest = Creation.VISIR_MEASUREMENT_SERVER, default=None, type="string", metavar='MEASUREMENT_SERVER',
                                                       help = "Measurement server. E.g. weblab-visir.deusto.es:8080 "  )

    experiments.add_option("--visir-use-php",          dest = Creation.VISIR_USE_PHP, action="store_true", default=True,
                                                       help = "VISIR can manage the authentication through a PHP code. This option is slower, but required if that scheme is used."  )

    experiments.add_option("--visir-login",            dest = Creation.VISIR_LOGIN, default='guest', type="string", metavar='USERNAME',
                                                       help = "If the PHP version is used, define which username should be used. Default: guest."  )

    experiments.add_option("--visir-password",         dest = Creation.VISIR_PASSWORD, default='guest', type="string", metavar='PASSWORD',
                                                       help = "If the PHP version is used, define which password should be used. Default: guest."  )

    experiments.add_option("--logic", "--logic-server", dest = Creation.LOGIC_SERVER, action="store_true", default=False,
                                                       help = "Add a logic server to the deployed system. "  )

    # TODO
    experiments.add_option("--vm", "--virtual-machine", "--vm-server",  dest = Creation.VM_SERVER, action="store_true", default=False,
                                                       help = "Add a VM server to the deployed system. "  )

    experiments.add_option("--vm-experiment-name",  dest = Creation.VM_EXPERIMENT_NAME, default='vm', type="string", metavar='EXPERIMENT_NAME',
                                                       help = "Name of the VM experiment. "  )

    experiments.add_option("--vm-storage-dir",  dest = Creation.VM_STORAGE_DIR, default='C:\\Users\\lrg\\.VirtualBox\\Machines', type="string", metavar='STORAGE_DIR',
                                                   help = "Directory where the VirtualBox machines are located. For example: c:\\users\\lrg\\.VirtualBox\\Machines"  )

    experiments.add_option("--vbox-vm-name",  dest = Creation.VBOX_VM_NAME, default='UbuntuDefVM2', type="string", metavar='VBOX_VM_NAME',
                                                   help = "Name of the Virtual Box machine which this experiment uses. Is often different from the Hard Disk name."  )

    experiments.add_option("--vbox-base-snapshot",  dest = Creation.VBOX_BASE_SNAPSHOT, default='Ready', type="string", metavar='VBOX_BASE_SNAPSHOT',
                                                   help = "Name of the VirtualBox snapshot to which the system will be reset after every usage. It should be an snapshot of an started machine. Otherwise, it will take too long to start."  )

    experiments.add_option("--vm-url",  dest = Creation.VM_URL, default='vnc://192.168.51.82:5901', type="string", metavar='URL',
                                                   help = "URL which will be provided to users so that they can access the VM through VNC. For instance: vnc://192.168.51.82:5901"  )

    experiments.add_option("--http-query-user-manager-url",  dest = Creation.HTTP_QUERY_USER_MANAGER_URL, default='http://192.168.51.82:18080', type="string", metavar='URL',
                                                   help = "URL through which the user manager (which runs on the VM and resets it when needed) can be reached. For instance: http://192.168.51.82:18080"  )

    experiments.add_option("--vm-estimated-load-time",  dest = Creation.VM_ESTIMATED_LOAD_TIME, default='20', type="string", metavar='LOAD_TIME',
                                                   help = "Estimated time which is required for restarting the VM. Does not need to be accurate. It is displayed to the user and is essentially for cosmetic purposes. "  )



    parser.add_option_group(experiments)

    fed = OptionGroup(parser, "Federation options",
                                "WebLab-Deusto at the University of Deusto federates a set of laboratories. "
                                "You may put them by default in your WebLab-Deusto instance.")

    fed.add_option("--add-fed-submarine",       dest = Creation.ADD_FEDERATED_SUBMARINE, action="store_true", default=False,
                                                help = "Add the submarine laboratory.")

    fed.add_option("--add-fed-logic",           dest = Creation.ADD_FEDERATED_LOGIC, action="store_true", default=False,
                                                help = "Add the logic laboratory.")

    fed.add_option("--add-fed-visir",           dest = Creation.ADD_FEDERATED_VISIR, action="store_true", default=False,
                                                help = "Add the VISIR laboratory.")

    parser.add_option_group(fed)

    sess = OptionGroup(parser, "Session options",
                                "WebLab-Deusto may store sessions in a database, in memory or in redis."
                                "Choose one system and configure it." )

    sess.add_option("--session-storage",          dest = Creation.SESSION_STORAGE, choices = SESSION_ENGINES, default='memory',
                                                  help = "Session storage used. Values: %s." % (', '.join(SESSION_ENGINES)) )

    sess.add_option("--session-db-engine",        dest = Creation.SESSION_DB_ENGINE, type="string", default="sqlite",
                                                  help = "Select the engine of the sessions database.")

    sess.add_option("--session-db-host",          dest = Creation.SESSION_DB_HOST, type="string", default="localhost",
                                                  help = "Select the host of the session server, if any.")

    sess.add_option("--session-db-port",          dest = Creation.SESSION_DB_PORT, type="int", default=None,
                                                  help = "Select the port of the session server, if any.")

    sess.add_option("--session-db-name",          dest = Creation.SESSION_DB_NAME, type="string", default="WebLabSessions",
                                                  help = "Select the name of the sessions database.")

    sess.add_option("--session-db-user",          dest = Creation.SESSION_DB_USER, type="string", default="",
                                                  help = "Select the username to access the sessions database.")

    sess.add_option("--session-db-passwd",        dest = Creation.SESSION_DB_PASSWD, type="string", default="",
                                                  help = "Select the password to access the sessions database.")

    sess.add_option("--session-redis-db",         dest = Creation.SESSION_REDIS_DB, type="int", default=1,
                                                  help = "Select the redis db on which store the sessions.")

    sess.add_option("--session-redis-host",       dest = Creation.SESSION_REDIS_HOST, type="string", default="localhost",
                                                  help = "Select the redis server host on which store the sessions.")

    sess.add_option("--session-redis-port",       dest = Creation.SESSION_REDIS_PORT, type="int", default=6379,
                                                  help = "Select the redis server port on which store the sessions.")

    parser.add_option_group(sess)

    dbopt = OptionGroup(parser, "Database options",
                                "WebLab-Deusto uses a relational database for storing users, permissions, etc."
                                "The database must be configured: which engine, database name, user and password." )

    dbopt.add_option("--db-engine",               dest = Creation.DB_ENGINE,       choices = DATABASE_ENGINES, default = 'sqlite',
                                                  help = "Core database engine to use. Values: %s." % (', '.join(DATABASE_ENGINES)))

    dbopt.add_option("--db-name",                 dest = Creation.DB_NAME,         type="string", default="WebLab",
                                                  help = "Core database name.")

    dbopt.add_option("--db-host",                 dest = Creation.DB_HOST,         type="string", default="localhost",
                                                  help = "Core database host.")

    dbopt.add_option("--db-port",                 dest = Creation.DB_PORT,         type="int", default=None,
                                                  help = "Core database port.")

    dbopt.add_option("--db-user",                 dest = Creation.DB_USER,         type="string", default="weblab",
                                                  help = "Core database username.")

    dbopt.add_option("--db-passwd",               dest = Creation.DB_PASSWD,       type="string", default="weblab",
                                                  help = "Core database password.")


    parser.add_option_group(dbopt)

    coord = OptionGroup(parser, "Scheduling options",
                                "These options are related to the scheduling system.  "
                                "You must select if you want to use a database or redis, and configure it.")

    coord.add_option("--coordination-engine",    dest = Creation.COORD_ENGINE,    choices = COORDINATION_ENGINES, default = 'sql',
                                                  help = "Coordination engine used. Values: %s." % (', '.join(COORDINATION_ENGINES)))

    coord.add_option("--coordination-db-engine", dest = Creation.COORD_DB_ENGINE, choices = DATABASE_ENGINES, default = 'sqlite',
                                                  help = "Coordination database engine used, if the coordination is based on a database. Values: %s." % (', '.join(DATABASE_ENGINES)))

    coord.add_option("--coordination-db-name",   dest = Creation.COORD_DB_NAME,   type="string", default="WebLabCoordination",

                                                  help = "Coordination database name used, if the coordination is based on a database.")

    coord.add_option("--coordination-db-user",   dest = Creation.COORD_DB_USER,   type="string", default="weblab",
                                                  help = "Coordination database userused, if the coordination is based on a database.")

    coord.add_option("--coordination-db-passwd", dest = Creation.COORD_DB_PASSWD,  type="string", default="weblab",
                                                  help = "Coordination database password used, if the coordination is based on a database.")

    coord.add_option("--coordination-db-host",    dest = Creation.COORD_DB_HOST,    type="string", default="localhost",
                                                  help = "Coordination database host used, if the coordination is based on a database.")

    coord.add_option("--coordination-db-port",    dest = Creation.COORD_DB_PORT,    type="int", default=None,
                                                  help = "Coordination database port used, if the coordination is based on a database.")

    coord.add_option("--coordination-redis-db",  dest = Creation.COORD_REDIS_DB,   type="int", default=None,
                                                  help = "Coordination redis DB used, if the coordination is based on redis.")

    coord.add_option("--coordination-redis-passwd",  dest = Creation.COORD_REDIS_PASSWD,   type="string", default=None,
                                                  help = "Coordination redis password used, if the coordination is based on redis.")

    coord.add_option("--coordination-redis-host",  dest = Creation.COORD_REDIS_HOST,   type="string", default=None,
                                                  help = "Coordination redis host used, if the coordination is based on redis.")

    coord.add_option("--coordination-redis-port",  dest = Creation.COORD_REDIS_PORT,   type="int", default=None,
                                                  help = "Coordination redis port used, if the coordination is based on redis.")

    parser.add_option_group(coord)

    return parser
dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/weblab/admin/script/creation.py/_build_parser/original