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

Last change on this file since 2583 was 2238, checked in by broder, 16 years ago

Power off VMs after a Javascript popup.

File size: 5.1 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
[1705]76$helppopup('Autoinstalls')#slurp
[447]77#end filter
78</td>
[1738]79          <td><input type="radio" name="cd_or_auto" id="cd_or_auto_auto"
80                 onchange="\$('cdromlist').value = ''; \$('vmtype-linux').checked = true">
[447]81#filter None
[1693]82$autoList($defaults.cdrom, "$('cd_or_auto_auto').checked = true;$('cdromlist').value = '';$('vmtype-linux').checked = true")
83              (experimental; 2-3 minutes, and you have a machine with empty root password.)
[447]84#end filter
[443]85          </input>
[629]86        </tr>
[228]87        <tr>
[443]88          <td>Boot CD</td>
[2190]89          <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked="checked"
[1738]90                onchange="\$('autoinstalllist').value = ''; \$('vmtype-linux-hvm').checked = true">
[447]91#filter None
[1693]92$cdromList($defaults.cdrom, "$('cd_or_auto_cd').checked = true;$('autoinstalllist').value = '';$('vmtype-linux-hvm').checked = true")
[447]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>
[912]107      <input type="submit" class="button" value="Create it!"/><br />
108      Windows notes: #slurp
109#filter None
110$helppopup('Windows')#slurp
111#end filter
[205]112    </form>
113#end if
114#end def
115
116#def machineRow($machine)
[113]117      <tr>
[618]118        <td rowspan="2">
119          <form action="command" method="post">
120            <input type="hidden" name="back" value="list"/>
121            <input type="hidden" name="machine_id"
122                   value="$machine.machine_id"/>
[644]123<input type="submit" class="power #slurp
[639]124#if $machine.uptime then 'on' else 'off'
125" name="action" value="#slurp
[618]126#if $machine.uptime then 'Power off' else 'Power on'
[2238]127"#slurp
128#if $machine.uptime
129 onclick="return confirm('Are you sure you want to power off this VM?');"
130#end if
131/>
[618]132          </form>
133        </td>
[113]134        <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td>
135        <td>${machine.memory}M</td>
136        <td>$machine.owner</td>
[234]137        <td>$machine.administrator</td>
[113]138#if $machine.nics
139#set $nic = $machine.nics[0]
140        <td>$nic.ip</td>
141#else
142        <td></td>
143#end if
[133]144<td>#slurp
[205]145#if $machine.uptime
[535]146${datetime.timedelta(seconds=int(machine.uptime))}#slurp
[133]147#end if
148</td>
149        <td>#slurp
[144]150#if $has_vnc[$machine] == True
[133]151<a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp
[424]152#else if $has_vnc[$machine] != 'Off'
[447]153#filter None
[144]154$has_vnc[$machine]
[447]155#end filter
[133]156#end if
157</td>
[113]158      </tr>
[609]159      <tr>
160        <td colspan="7" style="padding-left: 1em; color: #666">$machine.description</td>
161      </tr>
[205]162#end def
163
164#def machineList($machines)
[618]165    <table cellspacing="0" cellpadding="2">
[205]166      <tr>
[618]167        <th></th>
[424]168        <th>Name</th>
169        <th>Memory</th>
[447]170        <th>Owner#slurp
171#filter None
[536]172$helppopup('Owner')#slurp
[447]173#end filter
174</th>
175        <th>Administrator#slurp
176#filter None
[536]177$helppopup('Administrator')#slurp
[447]178#end filter
179</th>
[424]180        <th>IP</th>
181        <th>Uptime</th>
182        <th>VNC</th>
183      </tr>
[205]184      #for $machine in $machines:
[447]185    #filter None
[205]186        $machineRow($machine)
[447]187    #end filter
[113]188      #end for
189    </table>
[618]190    <script type="text/javascript" src="/static/stripe.js"></script>
191    <script type="text/javascript">
192        document.observe("dom:loaded", function() {
193            stripe(\$('machinelist').getElementsByTagName('table')[0],
194                   'stripedrow');
195        });
196    </script>
[205]197#end def
198
199
200#def body
[1661]201<p style="font-size: 125%;"><a href="http://${config.web.hostname}">What is XVM?</a></p>
[205]202#if not $machines
203<p>You don't currently control any VMs.</p>  
[144]204#end if
[207]205    <p><a href="list">refresh</a></p>
[205]206    <div id="machinelist">
[447]207    #filter None
[205]208    $machineList($machines)
[447]209    #end filter
[205]210    </div>
[447]211#filter None
[425]212$createForm()
[447]213#end filter
[113]214#end def
Note: See TracBrowser for help on using the repository browser.