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

Last change on this file since 581 was 572, checked in by ecprice, 16 years ago

Put validation behind more abstraction.

File size: 4.7 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>
34          <td>Memory</td>
[229]35          <td><input type="text" name="memory" value="$defaults.memory" size=3/> MiB ($max_memory max)</td>
[205]36        </tr>
[447]37#filter None
[205]38$errorRow('memory', $err)
[447]39#end filter
[205]40        <tr>
41          <td>Disk</td>
[572]42          <td><input type="text" name="disksize" value="$defaults.disk" size=3/> GiB (${"%0.1f" % ($max_disk-0.05)} max)</td>
[205]43        </tr>
[447]44#filter None
[205]45$errorRow('disk', $err)
[447]46#end filter
[440]47        <tr>
[447]48          <td>HVM/ParaVM#slurp
49#filter None
[536]50$helppopup('HVM/ParaVM')#slurp
[447]51#end filter
52</td>
53          <td>
54#filter None
55$vmTypeList($defaults.type)
56#end filter
57</td>
[440]58        </tr>
[447]59#filter None
[205]60$errorRow('vmtype', $err)
[447]61#end filter
[448]62        <tr>
63          <td>Clone image?</td>
[540]64#if $can_clone
[448]65          <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" onchange="onclone(event)"/>
66              (experimental; 1-2 minutes, and you have an etch machine; root pw is 'password'.)
67              <script type='text/javascript'>function onclone(e){ document.getElementById('cdromlist').value = ''; }</script></td>
[540]68#else
[559]69          <td><input type="checkbox" name="clone_from" id="clone_from" value="ice3" disabled="disabled"/> Image cloning is currently disabled for maintenance</td>
[540]70#end if
[448]71        </tr>
72#filter None
73$errorRow('autoinstall', $err)
74#end filter
75        <!--<tr>
[447]76          <td>Autoinstall#slurp
77#filter None
[536]78$helppopup('Autoinstall')#slurp
[447]79#end filter
80</td>
81          <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto">
82#filter None
83$autoList($defaults.cdrom, "document.getElementById('cd_or_auto_auto').checked = true;document.getElementById('cdromlist').value = ''")
[443]84              (experimental; 1-2 minutes, and you have a machine; root pw is 'password'.)
[447]85#end filter
[443]86          </input>
[448]87        </tr>-->
[228]88        <tr>
[443]89          <td>Boot CD</td>
[447]90          <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked>
91#filter None
92$cdromList($defaults.cdrom, "document.getElementById('cd_or_auto_cd').checked = true;document.getElementById('autoinstalllist').value = ''")
93#end filter
94</td>
[443]95          </input>
[340]96        </tr>
97$errorRow('cdrom', $err)
[443]98$errorRow('cdrom', $err)
[340]99        <tr>
[228]100          <td>Owner</td>
101          <td><input type="text" name="owner" value="$defaults.owner"/></td>
102        </tr>
[447]103#filter None
[228]104        $errorRow('owner', $err)
[447]105#end filter
[205]106      </table>
107      <input type="submit" class="button" value="Create it!"/>
108    </form>
109#end if
110#end def
111
112#def machineRow($machine)
[113]113      <tr>
114        <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td>
115        <td>${machine.memory}M</td>
116        <td>$machine.owner</td>
[234]117        <td>$machine.administrator</td>
[113]118#if $machine.nics
119#set $nic = $machine.nics[0]
120        <td>$nic.ip</td>
121#else
122        <td></td>
123#end if
[133]124<td>#slurp
[205]125#if $machine.uptime
[535]126${datetime.timedelta(seconds=int(machine.uptime))}#slurp
[133]127#end if
128</td>
129        <td>#slurp
[144]130#if $has_vnc[$machine] == True
[133]131<a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp
[424]132#else if $has_vnc[$machine] != 'Off'
[447]133#filter None
[144]134$has_vnc[$machine]
[447]135#end filter
[133]136#end if
137</td>
[113]138        <td>
[207]139          <form action="command" method="post">
140            <input type="hidden" name="back" value="list"/>
[113]141            <input type="hidden" name="machine_id"
142                   value="$machine.machine_id"/>
[205]143<input type="submit" class="button" name="action" value="#slurp
[228]144#if $machine.uptime then 'Power off' else 'Power on'
[205]145"/>
[113]146          </form>
147        </td>
148      </tr>
[205]149#end def
150
151#def machineList($machines)
152    <table>
153      <tr>
[424]154        <th>Name</th>
155        <th>Memory</th>
[447]156        <th>Owner#slurp
157#filter None
[536]158$helppopup('Owner')#slurp
[447]159#end filter
160</th>
161        <th>Administrator#slurp
162#filter None
[536]163$helppopup('Administrator')#slurp
[447]164#end filter
165</th>
[424]166        <th>IP</th>
167        <th>Uptime</th>
168        <th>VNC</th>
169        <th></th>
170      </tr>
[205]171      #for $machine in $machines:
[447]172    #filter None
[205]173        $machineRow($machine)
[447]174    #end filter
[113]175      #end for
176    </table>
[205]177#end def
178
179
180#def body
[423]181<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]182#if not $machines
183<p>You don't currently control any VMs.</p>  
[144]184#end if
[207]185    <p><a href="list">refresh</a></p>
[205]186    <div id="machinelist">
[447]187    #filter None
[205]188    $machineList($machines)
[447]189    #end filter
[205]190    </div>
[447]191#filter None
[425]192$createForm()
[447]193#end filter
[113]194#end def
Note: See TracBrowser for help on using the repository browser.