source: trunk/web/templates/list.tmpl @ 234

Last change on this file since 234 was 234, checked in by ecprice, 17 years ago

Now ignore negative rights, rather than treat them as positive.

Also, rearrange and clean up code.

File size: 2.9 KB
RevLine 
[113]1#from skeleton import skeleton
2#extends skeleton
3
[205]4
[113]5#def title
6List of your VMs
7#end def
8
[205]9#def createTable()
10#if $cant_add_vm
11<p>$cant_add_vm</p>
[113]12#else
[205]13<p>Create a new VM:</p>
14#if $err
15<p class="error">We had a problem with your request:</p>
16#else if $varExists('new_machine')
17<p>Congratulations! You successfully created a new VM called $new_machine.</p>
18#end if
[207]19    <form action="create" method="POST">
20    <input type="hidden" name="back" value="list"/>
[205]21      <table>
22      $errorRow('create', $err)
23        <tr>
24          <td>Name</td>
25          <td><input type="text" name="name" value="$defaults.name"/></td>
26        </tr>
27$errorRow('name', $err)
28        <tr>
29          <td>Memory</td>
[229]30          <td><input type="text" name="memory" value="$defaults.memory" size=3/> MiB ($max_memory max)</td>
[205]31        </tr>
32$errorRow('memory', $err)
33        <tr>
34          <td>Disk</td>
[229]35          <td><input type="text" name="disk" value="$defaults.disk" size=3/> GiB (${"%0.1f" % ($max_disk-0.05)} max)</td>
[205]36        </tr>
37$errorRow('disk', $err)
38        <tr>
39          <td>HVM/ParaVM$helppopup('hvm_paravm')</td>
40          <td>
41#for $value, $name in (('hvm', 'HVM'), ('paravm', 'ParaVM'))
42   <input #slurp
43#if $defaults.vmtype == $value then 'checked' else ''
44 type="radio" name="vmtype" value="$value">$name</input>
45#end for
46          </td>
47        </tr>
48$errorRow('vmtype', $err)
49        <tr>
50          <td>Boot CD</td>
51          <td>$cdromList($cdroms, $defaults.cdrom)</td>
52        </tr>
53$errorRow('cdrom', $err)
[228]54        <tr>
55          <td>Owner</td>
56          <td><input type="text" name="owner" value="$defaults.owner"/></td>
57        </tr>
58        $errorRow('owner', $err)
[205]59      </table>
60      <input type="submit" class="button" value="Create it!"/>
61    </form>
62#end if
63#end def
64
65#def machineRow($machine)
[113]66      <tr>
67        <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td>
68        <td>${machine.memory}M</td>
69        <td>$machine.owner</td>
[234]70        <td>$machine.administrator</td>
[113]71#if $machine.nics
72#set $nic = $machine.nics[0]
73        <td>$nic.ip</td>
74#else
75        <td></td>
76#end if
[133]77<td>#slurp
[205]78#if $machine.uptime
79$machine.uptime#slurp
[133]80#else
81Off#slurp
82#end if
83</td>
84        <td>#slurp
[144]85#if $has_vnc[$machine] == True
[133]86<a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp
87#else
[144]88$has_vnc[$machine]
[133]89#end if
90</td>
[113]91        <td>
[207]92          <form action="command" method="post">
93            <input type="hidden" name="back" value="list"/>
[113]94            <input type="hidden" name="machine_id"
95                   value="$machine.machine_id"/>
[205]96<input type="submit" class="button" name="action" value="#slurp
[228]97#if $machine.uptime then 'Power off' else 'Power on'
[205]98"/>
[113]99          </form>
100        </td>
101      </tr>
[205]102#end def
103
104#def machineList($machines)
105    <table>
106      <tr>
107        <td>Name</td>
108        <td>Memory</td>
[228]109        <td>Owner</td>
[234]110        <td>Administrator</td>
[205]111        <td>IP</td>
112        <td>Uptime</td>
113        <td>VNC</td>
114        <td></td>
115      #for $machine in $machines:
116        $machineRow($machine)
[113]117      #end for
118    </table>
[205]119#end def
120
121
122#def body
123#if not $machines
124<p>You don't currently control any VMs.</p>  
[144]125#else
[205]126    <p>You have the following VMs:</p>
[144]127#end if
[207]128    <p><a href="list">refresh</a></p>
[205]129    <div id="machinelist">
130    $machineList($machines)
131    </div>
132<div id="createtable">
133$createTable()
134</div>
[113]135#end def
Note: See TracBrowser for help on using the repository browser.