source: trunk/packages/sipb-xen-www/code/templates/list.tmpl @ 610

Last change on this file since 610 was 609, checked in by andersk, 16 years ago

Add a description field.

File size: 5.0 KB
RevLine 
[113]1#from skeleton import skeleton
2#extends skeleton
[535]3#import datetime
[113]4
[205]5
[113]6#def title
[422]7VM List
[113]8#end def
9
[425]10#def createForm()
[205]11#if $cant_add_vm
12<p>$cant_add_vm</p>
[113]13#else
[425]14<h2>Create a new VM</h2>
[205]15#if $err
16<p class="error">We had a problem with your request:</p>
17#else if $varExists('new_machine')
18<p>Congratulations! You successfully created a new VM called $new_machine.</p>
19#end if
[207]20    <form action="create" method="POST">
21    <input type="hidden" name="back" value="list"/>
[205]22      <table>
[447]23#filter None
[205]24      $errorRow('create', $err)
[447]25#end filter
[205]26        <tr>
27          <td>Name</td>
28          <td><input type="text" name="name" value="$defaults.name"/></td>
29        </tr>
[447]30#filter None
[205]31$errorRow('name', $err)
[447]32#end filter
[205]33        <tr>
[609]34          <td>Description</td>
35          <td><textarea name="description" rows="4" cols="60">$defaults.description</textarea></td>
36        </tr>
37#filter None
38$errorRow('description', $err)
39#end filter
40        <tr>
[205]41          <td>Memory</td>
[229]42          <td><input type="text" name="memory" value="$defaults.memory" size=3/> MiB ($max_memory max)</td>
[205]43        </tr>
[447]44#filter None
[205]45$errorRow('memory', $err)
[447]46#end filter
[205]47        <tr>
48          <td>Disk</td>
[572]49          <td><input type="text" name="disksize" value="$defaults.disk" size=3/> GiB (${"%0.1f" % ($max_disk-0.05)} max)</td>
[205]50        </tr>
[447]51#filter None
[205]52$errorRow('disk', $err)
[447]53#end filter
[440]54        <tr>
[447]55          <td>HVM/ParaVM#slurp
56#filter None
[536]57$helppopup('HVM/ParaVM')#slurp
[447]58#end filter
59</td>
60          <td>
61#filter None
62$vmTypeList($defaults.type)
63#end filter
64</td>
[440]65        </tr>
[447]66#filter None
[205]67$errorRow('vmtype', $err)
[447]68#end filter
[448]69        <tr>
70          <td>Clone image?</td>
[540]71#if $can_clone
[448]72          <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" onchange="onclone(event)"/>
73              (experimental; 1-2 minutes, and you have an etch machine; root pw is 'password'.)
74              <script type='text/javascript'>function onclone(e){ document.getElementById('cdromlist').value = ''; }</script></td>
[540]75#else
[559]76          <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" disabled="disabled"/> Image cloning is currently disabled for maintenance</td>
[540]77#end if
[448]78        </tr>
79#filter None
80$errorRow('autoinstall', $err)
81#end filter
82        <!--<tr>
[447]83          <td>Autoinstall#slurp
84#filter None
[536]85$helppopup('Autoinstall')#slurp
[447]86#end filter
87</td>
88          <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto">
89#filter None
90$autoList($defaults.cdrom, "document.getElementById('cd_or_auto_auto').checked = true;document.getElementById('cdromlist').value = ''")
[443]91              (experimental; 1-2 minutes, and you have a machine; root pw is 'password'.)
[447]92#end filter
[443]93          </input>
[448]94        </tr>-->
[228]95        <tr>
[443]96          <td>Boot CD</td>
[447]97          <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked>
98#filter None
99$cdromList($defaults.cdrom, "document.getElementById('cd_or_auto_cd').checked = true;document.getElementById('autoinstalllist').value = ''")
100#end filter
101</td>
[443]102          </input>
[340]103        </tr>
104$errorRow('cdrom', $err)
[443]105$errorRow('cdrom', $err)
[340]106        <tr>
[228]107          <td>Owner</td>
108          <td><input type="text" name="owner" value="$defaults.owner"/></td>
109        </tr>
[447]110#filter None
[228]111        $errorRow('owner', $err)
[447]112#end filter
[205]113      </table>
114      <input type="submit" class="button" value="Create it!"/>
115    </form>
116#end if
117#end def
118
119#def machineRow($machine)
[113]120      <tr>
121        <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td>
122        <td>${machine.memory}M</td>
123        <td>$machine.owner</td>
[234]124        <td>$machine.administrator</td>
[113]125#if $machine.nics
126#set $nic = $machine.nics[0]
127        <td>$nic.ip</td>
128#else
129        <td></td>
130#end if
[133]131<td>#slurp
[205]132#if $machine.uptime
[535]133${datetime.timedelta(seconds=int(machine.uptime))}#slurp
[133]134#end if
135</td>
136        <td>#slurp
[144]137#if $has_vnc[$machine] == True
[133]138<a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp
[424]139#else if $has_vnc[$machine] != 'Off'
[447]140#filter None
[144]141$has_vnc[$machine]
[447]142#end filter
[133]143#end if
144</td>
[609]145        <td rowspan="2">
[207]146          <form action="command" method="post">
147            <input type="hidden" name="back" value="list"/>
[113]148            <input type="hidden" name="machine_id"
149                   value="$machine.machine_id"/>
[205]150<input type="submit" class="button" name="action" value="#slurp
[228]151#if $machine.uptime then 'Power off' else 'Power on'
[205]152"/>
[113]153          </form>
154        </td>
155      </tr>
[609]156      <tr>
157        <td colspan="7" style="padding-left: 1em; color: #666">$machine.description</td>
158      </tr>
[205]159#end def
160
161#def machineList($machines)
162    <table>
163      <tr>
[424]164        <th>Name</th>
165        <th>Memory</th>
[447]166        <th>Owner#slurp
167#filter None
[536]168$helppopup('Owner')#slurp
[447]169#end filter
170</th>
171        <th>Administrator#slurp
172#filter None
[536]173$helppopup('Administrator')#slurp
[447]174#end filter
175</th>
[424]176        <th>IP</th>
177        <th>Uptime</th>
178        <th>VNC</th>
179        <th></th>
180      </tr>
[205]181      #for $machine in $machines:
[447]182    #filter None
[205]183        $machineRow($machine)
[447]184    #end filter
[113]185      #end for
186    </table>
[205]187#end def
188
189
190#def body
[423]191<p style="font-size: 125%;">SIPB Virtual Servers is an <strong>alpha service</strong>.  <a href="/static/about.html">What does this mean?</a></p>
[205]192#if not $machines
193<p>You don't currently control any VMs.</p>  
[144]194#end if
[207]195    <p><a href="list">refresh</a></p>
[205]196    <div id="machinelist">
[447]197    #filter None
[205]198    $machineList($machines)
[447]199    #end filter
[205]200    </div>
[447]201#filter None
[425]202$createForm()
[447]203#end filter
[113]204#end def
Note: See TracBrowser for help on using the repository browser.