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

Last change on this file since 2005 was 1738, checked in by price, 16 years ago

select para/hvm when radio buttons for autoinstall/boot cd are chosen, not just specific choices

File size: 5.0 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>
[1738]89          <td><input type="radio" name="cd_or_auto" id="cd_or_auto_cd" checked
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'
127"/>
128          </form>
129        </td>
[113]130        <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td>
131        <td>${machine.memory}M</td>
132        <td>$machine.owner</td>
[234]133        <td>$machine.administrator</td>
[113]134#if $machine.nics
135#set $nic = $machine.nics[0]
136        <td>$nic.ip</td>
137#else
138        <td></td>
139#end if
[133]140<td>#slurp
[205]141#if $machine.uptime
[535]142${datetime.timedelta(seconds=int(machine.uptime))}#slurp
[133]143#end if
144</td>
145        <td>#slurp
[144]146#if $has_vnc[$machine] == True
[133]147<a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp
[424]148#else if $has_vnc[$machine] != 'Off'
[447]149#filter None
[144]150$has_vnc[$machine]
[447]151#end filter
[133]152#end if
153</td>
[113]154      </tr>
[609]155      <tr>
156        <td colspan="7" style="padding-left: 1em; color: #666">$machine.description</td>
157      </tr>
[205]158#end def
159
160#def machineList($machines)
[618]161    <table cellspacing="0" cellpadding="2">
[205]162      <tr>
[618]163        <th></th>
[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      </tr>
[205]180      #for $machine in $machines:
[447]181    #filter None
[205]182        $machineRow($machine)
[447]183    #end filter
[113]184      #end for
185    </table>
[618]186    <script type="text/javascript" src="/static/stripe.js"></script>
187    <script type="text/javascript">
188        document.observe("dom:loaded", function() {
189            stripe(\$('machinelist').getElementsByTagName('table')[0],
190                   'stripedrow');
191        });
192    </script>
[205]193#end def
194
195
196#def body
[1661]197<p style="font-size: 125%;"><a href="http://${config.web.hostname}">What is XVM?</a></p>
[205]198#if not $machines
199<p>You don't currently control any VMs.</p>  
[144]200#end if
[207]201    <p><a href="list">refresh</a></p>
[205]202    <div id="machinelist">
[447]203    #filter None
[205]204    $machineList($machines)
[447]205    #end filter
[205]206    </div>
[447]207#filter None
[425]208$createForm()
[447]209#end filter
[113]210#end def
Note: See TracBrowser for help on using the repository browser.