Add terminal page
authorQuentin Smith <quentin@mit.edu>
Tue, 11 Aug 2009 04:54:08 +0000 (00:54 -0400)
committerQuentin Smith <quentin@mit.edu>
Tue, 11 Aug 2009 04:54:08 +0000 (00:54 -0400)
svn path=/package_branches/invirt-web/ajaxterm-rebased/; revision=2751

code/main.py
code/static/ajaxterm/ajaxterm.css
code/templates/info.mako
code/templates/skeleton.mako
code/templates/terminal.mako [new file with mode: 0644]

index dd2b591..0f8ed77 100755 (executable)
@@ -37,6 +37,7 @@ from invirt.config import structs as config
 from invirt.common import InvalidInput, CodeError
 
 from view import View, revertStandardError
 from invirt.common import InvalidInput, CodeError
 
 from view import View, revertStandardError
+import ajaxterm
 
 
 static_dir = os.path.join(os.path.dirname(__file__), 'static')
 
 
 static_dir = os.path.join(os.path.dirname(__file__), 'static')
@@ -388,6 +389,23 @@ console will suffer artifacts.
             else:
                 raise InvalidInput('back', back, 'Not a known back page.')
 
             else:
                 raise InvalidInput('back', back, 'Not a known back page.')
 
+        atmulti = ajaxterm.Multiplex()
+        atsessions = {}
+
+        @cherrypy.expose
+        @cherrypy.tools.mako(filename="/terminal.mako")
+        def terminal(self, machine_id):
+            machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
+
+            status = controls.statusInfo(machine)
+            has_vnc = hasVnc(status)
+
+            d = dict(on=status,
+                     has_vnc=has_vnc,
+                     machine=machine,
+                     hostname=cherrypy.request.local.name)
+            return d
+
     machine = MachineView()
 
 
     machine = MachineView()
 
 
index b9a5f87..5dd6ca5 100644 (file)
@@ -58,7 +58,6 @@ pre.term span.b5  { background-color: #b0b; }
 pre.term span.b6  { background-color: #0bb; }
 pre.term span.b7  { background-color: #bbb; }
 
 pre.term span.b6  { background-color: #0bb; }
 pre.term span.b7  { background-color: #bbb; }
 
-body { background-color: #888; }
 #term {
        float: left;
 }
 #term {
        float: left;
 }
index 0d1b66b..cd74458 100644 (file)
@@ -17,11 +17,11 @@ Info on ${machine.name}
 <%def name="commands()">
 % if on:
  % if not machine.type.hvm:
 <%def name="commands()">
 % if on:
  % if not machine.type.hvm:
-  Console access: type
+  Console access: <a href="machine/${machine.machine_id}/terminal">Web Terminal</a> or type
   <tt>ssh ${machine.name}@${config.console.hostname}</tt>
   on Athena. <a href="https://xvm.scripts.mit.edu/wiki/SerialConsole">(more info)</a>
  % elif has_vnc:
   <tt>ssh ${machine.name}@${config.console.hostname}</tt>
   on Athena. <a href="https://xvm.scripts.mit.edu/wiki/SerialConsole">(more info)</a>
  % elif has_vnc:
-  <strong><a href="machine/${machine.machine_id}/vnc">Get Console</a></strong>
+  <strong><a href="machine/${machine.machine_id}/vnc">Get Console</a> or <a href="machine/${machine.machine_id}/terminal">Web Terminal</a></strong>
  % else:
   VNC console not enabled; still booting?
  % endif
  % else:
   VNC console not enabled; still booting?
  % endif
index 37a053d..9414cf2 100644 (file)
@@ -61,6 +61,7 @@ You are currently authenticated as an administrator.
 % if machine:
 <li><a href="machine/${machine.machine_id}">Info</a></li>
 <li><a href="machine/${machine.machine_id}/vnc">Console</a></li>
 % if machine:
 <li><a href="machine/${machine.machine_id}">Info</a></li>
 <li><a href="machine/${machine.machine_id}/vnc">Console</a></li>
+<li><a href="machine/${machine.machine_id}/terminal">Terminal</a></li>
 % endif
 <li><a href="help">Help</a></li>
 </ul>
 % endif
 <li><a href="help">Help</a></li>
 </ul>
diff --git a/code/templates/terminal.mako b/code/templates/terminal.mako
new file mode 100644 (file)
index 0000000..246c29d
--- /dev/null
@@ -0,0 +1,28 @@
+<%page expression_filter="h" />
+<%inherit file="skeleton.mako" />
+
+<%def name="title()">
+Terminal for ${machine.name}
+</%def>
+
+<style type='text/css'>body { max-width: none }</style>
+% if not on:
+<p> Your machine appears to be off.</p>
+% elif has_vnc:
+<p> Your machine appears to be an HVM; you will need to specially configure a serial console before you can use this terminal.</p>
+% endif
+
+<%def name="header_extra()">
+${parent.header_extra()}
+<link rel="stylesheet" type="text/css" href="static/ajaxterm/ajaxterm.css"/>
+<script type="text/javascript" src="static/ajaxterm/sarissa.js"></script>      
+<script type="text/javascript" src="static/ajaxterm/sarissa_dhtml.js"></script>        
+<script type="text/javascript" src="static/ajaxterm/ajaxterm.js"></script>
+<script type="text/javascript">
+window.onload=function() {
+       t=ajaxterm.Terminal("term", 80,25);
+}
+</script>
+</%def>
+
+<div id="term"></div>