From 263010ff23d21486b8f5029cfd8c9bee9a04f3f8 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Sun, 9 Aug 2009 18:45:25 -0400 Subject: [PATCH] Port list to Mako svn path=/package_branches/invirt-web/cherrypy-rebased/; revision=2668 --- code/main.py | 2 +- code/templates/list.mako | 159 ++++++++++++++++++++++++++++++++++ code/templates/list.tmpl | 214 ---------------------------------------------- 3 files changed, 160 insertions(+), 215 deletions(-) create mode 100644 code/templates/list.mako delete mode 100644 code/templates/list.tmpl diff --git a/code/main.py b/code/main.py index 0a9342a..c3db122 100755 --- a/code/main.py +++ b/code/main.py @@ -60,7 +60,7 @@ class InvirtWeb(View): checkpoint.checkpoint('Getting list dict') d = getListDict(username, state) checkpoint.checkpoint('Got list dict') - return templates.list(searchList=[d]) + return d index=list @cherrypy.expose diff --git a/code/templates/list.mako b/code/templates/list.mako new file mode 100644 index 0000000..71a8943 --- /dev/null +++ b/code/templates/list.mako @@ -0,0 +1,159 @@ +<%page expression_filter="h"/> +<%inherit file="skeleton.mako" /> +<%! + from invirt.config import structs as config + import datetime +%> + + +<%def name="title()"> +VM List + + +<%def name="createForm()"> +% if cant_add_vm: +

${cant_add_vm}

+% else: +

Create a new VM

+% if err: +

We had a problem with your request:

+% elif new_machine: +

Congratulations! You successfully created a new VM called ${new_machine}.

+% endif +
+ + + ${self.fn.errorRow('create', err)} + + + + + ${self.fn.errorRow('name', err)} + + + + + ${self.fn.errorRow('description', err)} + + + + + ${self.fn.errorRow('memory', err)} + + + + + ${self.fn.errorRow('disk', err)} + + + + + ${self.fn.errorRow('vmtype', err)} + ${self.fn.errorRow('autoinstall', err)} + + + + + + + + + ${self.fn.errorRow('cdrom', err)} + ${self.fn.errorRow('cdrom', err)} + + + + + ${self.fn.errorRow('owner', err)} +
Name.${config.dns.domains[0]}
Description
Memory MiB (${max_memory} max)
Disk GiB (${"%0.1f" % (max_disk-0.05)} max)
HVM/ParaVM${self.fn.helppopup('HVM/ParaVM')} + ${self.fn.vmTypeList(defaults.type)} +
Autoinstall${self.fn.helppopup('Autoinstalls')} +${self.fn.autoList(defaults.cdrom, "$('cd_or_auto_auto').checked = true;$('cdromlist').value = '';$('vmtype-linux').checked = true")} + (experimental; 2-3 minutes, and you have a machine with empty root password.) + +
Boot CD +${self.fn.cdromList(defaults.cdrom, "$('cd_or_auto_cd').checked = true;$('autoinstalllist').value = '';$('vmtype-linux-hvm').checked = true")} +
Owner
+
+ Windows notes: ${self.fn.helppopup('Windows')} +
+% endif + + +<%def name="machineRow(machine)"> + + +
+ + + +
+ + ${machine.name} + ${machine.memory}M + ${machine.owner} + ${machine.administrator} +% if machine.nics: + ${', '.join(map(lambda x: x.ip, machine.nics))} +% else: + +% endif +\ +% if machine.uptime: +${datetime.timedelta(seconds=int(machine.uptime))}\ +% endif + + \ +% if has_vnc[machine] == True: +Console\ +% elif has_vnc[machine] != 'Off': +${has_vnc[machine]} +% endif + + + + ${machine.description} + + + +<%def name="machineList(machines)"> + + + + + + + + + + + +% for machine in machines: + ${machineRow(machine)} +% endfor +
NameMemoryOwner${self.fn.helppopup('Owner')}Administrator${self.fn.helppopup('Administrator')}IPUptimeVNC
+ + + + +

What is XVM?

+% if not machines: +

You don't currently control any VMs.

+% endif +

refresh

+
+ ${machineList(machines)} +
+${createForm()} diff --git a/code/templates/list.tmpl b/code/templates/list.tmpl deleted file mode 100644 index 8a0231e..0000000 --- a/code/templates/list.tmpl +++ /dev/null @@ -1,214 +0,0 @@ -#from skeleton import skeleton -#from invirt.config import structs as config -#extends skeleton -#import datetime - - -#def title -VM List -#end def - -#def createForm() -#if $cant_add_vm -

$cant_add_vm

-#else -

Create a new VM

-#if $err -

We had a problem with your request:

-#else if $varExists('new_machine') -

Congratulations! You successfully created a new VM called $new_machine.

-#end if -
- - -#filter None - $errorRow('create', $err) -#end filter - - - - -#filter None -$errorRow('name', $err) -#end filter - - - - -#filter None -$errorRow('description', $err) -#end filter - - - - -#filter None -$errorRow('memory', $err) -#end filter - - - - -#filter None -$errorRow('disk', $err) -#end filter - - - - -#filter None -$errorRow('vmtype', $err) -#end filter -#filter None -$errorRow('autoinstall', $err) -#end filter - - - - - - - - -$errorRow('cdrom', $err) -$errorRow('cdrom', $err) - - - - -#filter None - $errorRow('owner', $err) -#end filter -
Name.${config.dns.domains[0]}
Description
Memory MiB ($max_memory max)
Disk GiB (${"%0.1f" % ($max_disk-0.05)} max)
HVM/ParaVM#slurp -#filter None -$helppopup('HVM/ParaVM')#slurp -#end filter - -#filter None -$vmTypeList($defaults.type) -#end filter -
Autoinstall#slurp -#filter None -$helppopup('Autoinstalls')#slurp -#end filter - -#filter None -$autoList($defaults.cdrom, "$('cd_or_auto_auto').checked = true;$('cdromlist').value = '';$('vmtype-linux').checked = true") - (experimental; 2-3 minutes, and you have a machine with empty root password.) -#end filter - -
Boot CD -#filter None -$cdromList($defaults.cdrom, "$('cd_or_auto_cd').checked = true;$('autoinstalllist').value = '';$('vmtype-linux-hvm').checked = true") -#end filter -
Owner
-
- Windows notes: #slurp -#filter None -$helppopup('Windows')#slurp -#end filter -
-#end if -#end def - -#def machineRow($machine) - - -
- - - -
- - $machine.name - ${machine.memory}M - $machine.owner - $machine.administrator -#if $machine.nics -#set $nic = $machine.nics[0] - $nic.ip -#else - -#end if -#slurp -#if $machine.uptime -${datetime.timedelta(seconds=int(machine.uptime))}#slurp -#end if - - #slurp -#if $has_vnc[$machine] == True -Console#slurp -#else if $has_vnc[$machine] != 'Off' -#filter None -$has_vnc[$machine] -#end filter -#end if - - - - $machine.description - -#end def - -#def machineList($machines) - - - - - - - - - - - - #for $machine in $machines: - #filter None - $machineRow($machine) - #end filter - #end for -
NameMemoryOwner#slurp -#filter None -$helppopup('Owner')#slurp -#end filter -Administrator#slurp -#filter None -$helppopup('Administrator')#slurp -#end filter -IPUptimeVNC
- - -#end def - - -#def body -

What is XVM?

-#if not $machines -

You don't currently control any VMs.

-#end if -

refresh

-
- #filter None - $machineList($machines) - #end filter -
-#filter None -$createForm() -#end filter -#end def -- 1.7.9.5