source: trunk/packages/invirt-web/code/templates/list.tmpl @ 1665

Last change on this file since 1665 was 1661, checked in by price, 16 years ago

merge about.html's remaining caveats into unauth front page

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