Index: package_branches/invirt-web/cherrypy/code/main.py
===================================================================
--- package_branches/invirt-web/cherrypy/code/main.py (revision 2432)
+++ package_branches/invirt-web/cherrypy/code/main.py (revision 2433)
@@ -296,4 +296,25 @@
hostname=cherrypy.request.local.name)
return d
+
+ @cherrypy.expose
+ def at(self, machine_id, k=None, c=0):
+ machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
+ if machine_id in self.atsessions:
+ term = self.atsessions[machine_id]
+ else:
+ print >>sys.stderr, "spawning new session for terminal to ",machine_id
+ term = self.atsessions[machine_id] = self.atmulti.create(
+ ["ssh", "-e","none", "-l", machine.name, config.console.hostname]
+ )
+ if k:
+ self.atmulti.proc_write(term,k)
+ time.sleep(0.002)
+ dump=self.atmulti.dump(term,c)
+ cherrypy.response.headers['Content-Type']='text/xml'
+ if isinstance(dump,str):
+ return dump
+ else:
+ del self.atmulti[machine_id]
+ return ''
machine = MachineView()
Index: package_branches/invirt-web/cherrypy/code/static/ajaxterm/ajaxterm.js
===================================================================
--- package_branches/invirt-web/cherrypy/code/static/ajaxterm/ajaxterm.js (revision 2432)
+++ package_branches/invirt-web/cherrypy/code/static/ajaxterm/ajaxterm.js (revision 2433)
@@ -1,9 +1,9 @@
ajaxterm={};
-ajaxterm.Terminal_ctor=function(id,width,height) {
+ajaxterm.Terminal_ctor=function(id,machine_id) {
var ie=0;
if(window.ActiveXObject)
ie=1;
- var sid=""+Math.round(Math.random()*1000000000);
- var query0="s="+sid+"&w="+width+"&h="+height;
+ var base_path="machine/"+machine_id+"/at";
+ var query0="";
var query1=query0+"&c=1&k=";
var buf="";
@@ -104,10 +104,10 @@
var query=query1+send;
if(opt_get.className=='on') {
- r.open("GET","u?"+query,true);
+ r.open("GET",base_path+"?"+query,true);
if(ie) {
r.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
}
} else {
- r.open("POST","u",true);
+ r.open("POST",base_path,true);
}
r.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
@@ -274,6 +274,6 @@
init();
}
-ajaxterm.Terminal=function(id,width,height) {
- return new this.Terminal_ctor(id,width,height);
+ajaxterm.Terminal=function(id,machine_id) {
+ return new this.Terminal_ctor(id,machine_id);
}
Index: package_branches/invirt-web/cherrypy/code/templates/terminal.mako
===================================================================
--- package_branches/invirt-web/cherrypy/code/templates/terminal.mako (revision 2432)
+++ package_branches/invirt-web/cherrypy/code/templates/terminal.mako (revision 2433)
@@ -21,5 +21,5 @@
@@ -27,2 +27,3 @@
+