return d
index = info
+ @cherrypy.expose
+ @cherrypy.tools.mako(filename="/vnc.mako")
+ def vnc(self, machine_id):
+ """VNC applet page.
+
+ Note that due to same-domain restrictions, the applet connects to
+ the webserver, which needs to forward those requests to the xen
+ server. The Xen server runs another proxy that (1) authenticates
+ and (2) finds the correct port for the VM.
+
+ You might want iptables like:
+
+ -t nat -A PREROUTING -s ! 18.181.0.60 -i eth1 -p tcp -m tcp \
+ --dport 10003 -j DNAT --to-destination 18.181.0.60:10003
+ -t nat -A POSTROUTING -d 18.181.0.60 -o eth1 -p tcp -m tcp \
+ --dport 10003 -j SNAT --to-source 18.187.7.142
+ -A FORWARD -d 18.181.0.60 -i eth1 -o eth1 -p tcp -m tcp \
+ --dport 10003 -j ACCEPT
+
+ Remember to enable iptables!
+ echo 1 > /proc/sys/net/ipv4/ip_forward
+ """
+ machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
+
+ token = controls.vnctoken(machine)
+ host = controls.listHost(machine)
+ if host:
+ port = 10003 + [h.hostname for h in config.hosts].index(host)
+ else:
+ port = 5900 # dummy
+
+ status = controls.statusInfo(machine)
+ has_vnc = hasVnc(status)
+
+ d = dict(on=status,
+ has_vnc=has_vnc,
+ machine=machine,
+ hostname=cherrypy.request.local.name,
+ port=port,
+ authtoken=token)
+ return d
+
machine = MachineView()
def pathSplit(path):
can_clone=can_clone)
return d
-def vnc(username, state, path, fields):
- """VNC applet page.
-
- Note that due to same-domain restrictions, the applet connects to
- the webserver, which needs to forward those requests to the xen
- server. The Xen server runs another proxy that (1) authenticates
- and (2) finds the correct port for the VM.
-
- You might want iptables like:
-
- -t nat -A PREROUTING -s ! 18.181.0.60 -i eth1 -p tcp -m tcp \
- --dport 10003 -j DNAT --to-destination 18.181.0.60:10003
- -t nat -A POSTROUTING -d 18.181.0.60 -o eth1 -p tcp -m tcp \
- --dport 10003 -j SNAT --to-source 18.187.7.142
- -A FORWARD -d 18.181.0.60 -i eth1 -o eth1 -p tcp -m tcp \
- --dport 10003 -j ACCEPT
-
- Remember to enable iptables!
- echo 1 > /proc/sys/net/ipv4/ip_forward
- """
- machine = validation.Validate(username, state, machine_id=fields.getfirst('machine_id')).machine
-
- token = controls.vnctoken(machine)
- host = controls.listHost(machine)
- if host:
- port = 10003 + [h.hostname for h in config.hosts].index(host)
- else:
- port = 5900 # dummy
-
- status = controls.statusInfo(machine)
- has_vnc = hasVnc(status)
-
- d = dict(user=username,
- on=status,
- has_vnc=has_vnc,
- machine=machine,
- hostname=state.environ.get('SERVER_NAME', 'localhost'),
- port=port,
- authtoken=token)
- return templates.vnc(searchList=[d])
-
def getHostname(nic):
"""Find the hostname associated with a NIC.
"""Throw an error, to test the error-tracing mechanisms."""
raise RuntimeError("test of the emergency broadcast system")
-mapping = dict(vnc=vnc,
+mapping = dict(
command=command,
modify=modify,
create=create,
--- /dev/null
+<%page expression_filter="h" />
+<%inherit file="skeleton.mako" />
+
+<%def name="title()">
+Console to ${machine.name}
+</%def>
+
+<style type='text/css'>body { max-width: none }</style>
+% if not on:
+<p> Your machine appears to be off.</p>
+% elif not has_vnc:
+<p> Your machine appears to not be accepting VNC connections. Perhaps you have a ParaVM machine?</p>
+% endif
+
+<p>See <a href="help?subject=Console" target="_blank">tips</a> about framebuffer and other issues.</p>
+<applet code="VncViewer.class" archive="https://${hostname}:446/static/VncViewer.jar"
+ width="100%" height="1000">
+<param name="PASSWORD" value="moocow">
+<param name="PORT" value="${port}">
+<param name="HOST" value="${hostname}">
+<param name="VMNAME" value="${machine.name}">
+<param name="AUTHTOKEN" value="${authtoken}">
+<param name="SocketFactory" value="VNCProxyConnectSocketFactory">
+</applet>
+++ /dev/null
-#from skeleton import skeleton
-#extends skeleton
-
-#def title
-Console to $machine.name
-#end def
-
-#def body
-<style type='text/css'>body { max-width: none }</style>
-#if not $on
-<p> Your machine appears to be off.</p>
-#else if not $has_vnc
-<p> Your machine appears to not be accepting VNC connections. Perhaps you have a ParaVM machine?</p>
-#end if
-<p>See <a href="help?subject=Console" target="_blank">tips</a> about framebuffer and other issues.</p>
-<APPLET CODE="VncViewer.class" ARCHIVE="https://$hostname:446/static/VncViewer.jar"
- WIDTH="100%" HEIGHT="1000">
-<PARAM NAME="PASSWORD" VALUE="moocow">
-<PARAM NAME="PORT" VALUE="$port">
-<PARAM NAME="HOST" VALUE="$hostname">
-<PARAM NAME="VMNAME" VALUE="$machine.name">
-<PARAM NAME="AUTHTOKEN" VALUE="$authtoken">
-<PARAM NAME="SocketFactory" VALUE="VNCProxyConnectSocketFactory">
-</APPLET>
-#end def