Ignore:
Timestamp:
Oct 8, 2007, 3:37:59 AM (17 years ago)
Author:
ecprice
Message:

Help!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/templates/main.py

    r138 r139  
    2525    pass
    2626
     27def helppopup(subj):
     28    return '<span class="helplink"><a href="help?subject='+subj+'&amp;simple=true" target="_blank" onclick="return helppopup(\''+subj+'\')">(?)</a></span>'
     29
     30
     31global_dict = {}
     32global_dict['helppopup'] = helppopup
     33
     34
    2735# ... and stolen from xend/uuid.py
    2836def randomUUID():
     
    4856def error(op, user, fields, err):
    4957    d = dict(op=op, user=user, errorMessage=str(err))
    50     print Template(file='error.tmpl', searchList=d);
     58    print Template(file='error.tmpl', searchList=[d, global_dict]);
    5159
    5260def validMachineName(name):
     
    268276             machine=machine)
    269277    print Template(file='create.tmpl',
    270                    searchList=d);
     278                   searchList=[d, global_dict]);
    271279
    272280def listVms(user, fields):
     
    282290            has_vnc[m.name] = True
    283291        else:
    284             help_name = 'paravm_console'
    285             has_vnc[m.name] = 'ParaVM <span class="helplink"><a href="help?subject=%s&amp;simple=true" target="_blank" onclick="return helppopup(\'%s\')">(?)</a></span>' % (help_name, help_name)
     292            has_vnc[m.name] = "ParaVM"+helppopup("paravm_console")
    286293    #     for m in machines:
    287294    #         status = statusInfo(m)
     
    295302             uptimes=uptimes,
    296303             cdroms=CDROM.select())
    297     print Template(file='list.tmpl', searchList=d)
     304    print Template(file='list.tmpl', searchList=[d, global_dict])
    298305
    299306def testMachineId(user, machineId, exists=True):
     
    346353             authtoken=token)
    347354    print Template(file='vnc.tmpl',
    348                    searchList=d)
     355                   searchList=[d, global_dict])
    349356
    350357def getNicInfo(data_dict, machine):
     
    421428             command=action,
    422429             machine=machine)
    423     print Template(file="command.tmpl", searchList=d)
     430    print Template(file="command.tmpl", searchList=[d, global_dict])
    424431       
    425432def modify(user, fields):
    426433    machine = testMachineId(user, fields.getfirst('machine_id'))
     434   
     435def help(user, fields):
     436    simple = fields.getfirst('simple')
     437    subjects = fields.getlist('subject')
     438   
     439    mapping = dict(paravm_console="""
     440ParaVM machines do not support console access over VNC.  To access
     441these machines, you either need to boot with a liveCD and ssh in or
     442hope that the sipb-xen maintainers add support for serial consoles.""",
     443                   hvm_paravm="""
     444HVM machines use the virtualization features of the processor, while
     445ParaVM machines use Xen's emulation of virtualization features.  You
     446want an HVM virtualized machine.""",
     447                   cpu_weight="""Don't ask us!  We're as mystified as you are.""")
     448   
     449    d = dict(user=user,
     450             simple=simple,
     451             subjects=subjects,
     452             mapping=mapping)
     453   
     454    print Template(file="help.tmpl", searchList=[d, global_dict])
    427455   
    428456
     
    452480                      'DISK_INFO',
    453481                      ('state', 'state (xen format)'),
    454                       ('cpu_weight', 'CPU weight'),
     482                      ('cpu_weight', 'CPU weight'+helppopup('cpu_weight')),
    455483                      ('on_reboot', 'Action on VM reboot'),
    456484                      ('on_poweroff', 'Action on VM poweroff'),
     
    497525             fields = fields)
    498526    print Template(file='info.tmpl',
    499                    searchList=d)
     527                   searchList=[d, global_dict])
    500528
    501529mapping = dict(list=listVms,
     
    504532               modify=modify,
    505533               info=info,
    506                create=create)
     534               create=create,
     535               help=help)
    507536
    508537if __name__ == '__main__':
     
    513542        email = 'moo@cow.com'
    514543    u = User()
    515     connect('postgres://sipb-xen@sipb-xen-dev/sipb_xen')
    516544    operation = os.environ.get('PATH_INFO', '')
    517545    if not operation:
     
    528556                          error(operation, u, e,
    529557                                "Invalid operation '%s'" % operation))
     558    if fun not in (help, ):
     559        connect('postgres://sipb-xen@sipb-xen-dev/sipb_xen')
    530560    try:
    531561        fun(u, fields)
Note: See TracChangeset for help on using the changeset viewer.