Changeset 2409 for package_branches


Ignore:
Timestamp:
Aug 9, 2009, 6:45:34 PM (15 years ago)
Author:
quentin
Message:

Implement help handler

Location:
package_branches/invirt-web/cherrypy/code
Files:
1 added
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • package_branches/invirt-web/cherrypy/code/main.py

    r2408 r2409  
    6666        return d
    6767    index=list
     68
     69    @cherrypy.expose
     70    @cherrypy.tools.mako(filename="/help.mako")
     71    def help(self, subject=None, simple=False):
     72        """Handler for help messages."""
     73
     74        help_mapping = {
     75            'Autoinstalls': """
     76The autoinstaller builds a minimal Debian or Ubuntu system to run as a
     77ParaVM.  You can access the resulting system by logging into the <a
     78href="help?simple=true&subject=ParaVM+Console">serial console server</a>
     79with your Kerberos tickets; there is no root password so sshd will
     80refuse login.</p>
     81
     82<p>Under the covers, the autoinstaller uses our own patched version of
     83xen-create-image, which is a tool based on debootstrap.  If you log
     84into the serial console while the install is running, you can watch
     85it.
     86""",
     87            'ParaVM Console': """
     88ParaVM machines do not support local console access over VNC.  To
     89access the serial console of these machines, you can SSH with Kerberos
     90to %s, using the name of the machine as your
     91username.""" % config.console.hostname,
     92            'HVM/ParaVM': """
     93HVM machines use the virtualization features of the processor, while
     94ParaVM machines rely on a modified kernel to communicate directly with
     95the hypervisor.  HVMs support boot CDs of any operating system, and
     96the VNC console applet.  The three-minute autoinstaller produces
     97ParaVMs.  ParaVMs typically are more efficient, and always support the
     98<a href="help?subject=ParaVM+Console">console server</a>.</p>
     99
     100<p>More details are <a
     101href="https://xvm.scripts.mit.edu/wiki/Paravirtualization">on the
     102wiki</a>, including steps to prepare an HVM guest to boot as a ParaVM
     103(which you can skip by using the autoinstaller to begin with.)</p>
     104
     105<p>We recommend using a ParaVM when possible and an HVM when necessary.
     106""",
     107            'CPU Weight': """
     108Don't ask us!  We're as mystified as you are.""",
     109            'Owner': """
     110The owner field is used to determine <a
     111href="help?subject=Quotas">quotas</a>.  It must be the name of a
     112locker that you are an AFS administrator of.  In particular, you or an
     113AFS group you are a member of must have AFS rlidwka bits on the
     114locker.  You can check who administers the LOCKER locker using the
     115commands 'attach LOCKER; fs la /mit/LOCKER' on Athena.)  See also <a
     116href="help?subject=Administrator">administrator</a>.""",
     117            'Administrator': """
     118The administrator field determines who can access the console and
     119power on and off the machine.  This can be either a user or a moira
     120group.""",
     121            'Quotas': """
     122Quotas are determined on a per-locker basis.  Each locker may have a
     123maximum of 512 mebibytes of active ram, 50 gibibytes of disk, and 4
     124active machines.""",
     125            'Console': """
     126<strong>Framebuffer:</strong> At a Linux boot prompt in your VM, try
     127setting <tt>fb=false</tt> to disable the framebuffer.  If you don't,
     128your machine will run just fine, but the applet's display of the
     129console will suffer artifacts.
     130""",
     131            'Windows': """
     132<strong>Windows Vista:</strong> The Vista image is licensed for all MIT students and will automatically activate off the network; see <a href="/static/msca-email.txt">the licensing confirmation e-mail</a> for details. The installer requires 512 MiB RAM and at least 7.5 GiB disk space (15 GiB or more recommended).<br>
     133<strong>Windows XP:</strong> This is the volume license CD image. You will need your own volume license key to complete the install. We do not have these available for the general MIT community; ask your department if they have one.
     134"""
     135            }
     136
     137        if not subject:
     138            subject = sorted(help_mapping.keys())
     139        if not isinstance(subject, list):
     140            subject = [subject]
     141
     142        return dict(user=cherrypy.request.login,
     143                    simple=simple,
     144                    subjects=subject,
     145                    mapping=help_mapping)
     146    help._cp_config['tools.require_login.on'] = False
    68147
    69148    @cherrypy.expose
     
    435514    return templates.info(searchList=[info_dict])
    436515
    437 
    438 def helpHandler(username, state, path, fields):
    439     """Handler for help messages."""
    440     simple = fields.getfirst('simple')
    441     subjects = fields.getlist('subject')
    442 
    443     help_mapping = {
    444                     'Autoinstalls': """
    445 The autoinstaller builds a minimal Debian or Ubuntu system to run as a
    446 ParaVM.  You can access the resulting system by logging into the <a
    447 href="help?simple=true&subject=ParaVM+Console">serial console server</a>
    448 with your Kerberos tickets; there is no root password so sshd will
    449 refuse login.</p>
    450 
    451 <p>Under the covers, the autoinstaller uses our own patched version of
    452 xen-create-image, which is a tool based on debootstrap.  If you log
    453 into the serial console while the install is running, you can watch
    454 it.
    455 """,
    456                     'ParaVM Console': """
    457 ParaVM machines do not support local console access over VNC.  To
    458 access the serial console of these machines, you can SSH with Kerberos
    459 to %s, using the name of the machine as your
    460 username.""" % config.console.hostname,
    461                     'HVM/ParaVM': """
    462 HVM machines use the virtualization features of the processor, while
    463 ParaVM machines rely on a modified kernel to communicate directly with
    464 the hypervisor.  HVMs support boot CDs of any operating system, and
    465 the VNC console applet.  The three-minute autoinstaller produces
    466 ParaVMs.  ParaVMs typically are more efficient, and always support the
    467 <a href="help?subject=ParaVM+Console">console server</a>.</p>
    468 
    469 <p>More details are <a
    470 href="https://xvm.scripts.mit.edu/wiki/Paravirtualization">on the
    471 wiki</a>, including steps to prepare an HVM guest to boot as a ParaVM
    472 (which you can skip by using the autoinstaller to begin with.)</p>
    473 
    474 <p>We recommend using a ParaVM when possible and an HVM when necessary.
    475 """,
    476                     'CPU Weight': """
    477 Don't ask us!  We're as mystified as you are.""",
    478                     'Owner': """
    479 The owner field is used to determine <a
    480 href="help?subject=Quotas">quotas</a>.  It must be the name of a
    481 locker that you are an AFS administrator of.  In particular, you or an
    482 AFS group you are a member of must have AFS rlidwka bits on the
    483 locker.  You can check who administers the LOCKER locker using the
    484 commands 'attach LOCKER; fs la /mit/LOCKER' on Athena.)  See also <a
    485 href="help?subject=Administrator">administrator</a>.""",
    486                     'Administrator': """
    487 The administrator field determines who can access the console and
    488 power on and off the machine.  This can be either a user or a moira
    489 group.""",
    490                     'Quotas': """
    491 Quotas are determined on a per-locker basis.  Each locker may have a
    492 maximum of 512 mebibytes of active ram, 50 gibibytes of disk, and 4
    493 active machines.""",
    494                     'Console': """
    495 <strong>Framebuffer:</strong> At a Linux boot prompt in your VM, try
    496 setting <tt>fb=false</tt> to disable the framebuffer.  If you don't,
    497 your machine will run just fine, but the applet's display of the
    498 console will suffer artifacts.
    499 """,
    500                     'Windows': """
    501 <strong>Windows Vista:</strong> The Vista image is licensed for all MIT students and will automatically activate off the network; see <a href="/static/msca-email.txt">the licensing confirmation e-mail</a> for details. The installer requires 512 MiB RAM and at least 7.5 GiB disk space (15 GiB or more recommended).<br>
    502 <strong>Windows XP:</strong> This is the volume license CD image. You will need your own volume license key to complete the install. We do not have these available for the general MIT community; ask your department if they have one.
    503 """
    504                     }
    505 
    506     if not subjects:
    507         subjects = sorted(help_mapping.keys())
    508 
    509     d = dict(user=username,
    510              simple=simple,
    511              subjects=subjects,
    512              mapping=help_mapping)
    513 
    514     return templates.help(searchList=[d])
    515 
    516 
    517516def badOperation(u, s, p, e):
    518517    """Function called when accessing an unknown URI."""
     
    636635    raise RuntimeError("test of the emergency broadcast system")
    637636
    638 mapping = dict(#list=listVms,
    639                vnc=vnc,
     637mapping = dict(vnc=vnc,
    640638               command=command,
    641639               modify=modify,
    642640               info=info,
    643641               create=create,
    644                help=helpHandler,
    645642               unauth=unauthFront,
    646643               admin=admin,
Note: See TracChangeset for help on using the changeset viewer.