@@ -181,10 +181,12 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
181181 return ;
182182 }
183183
184+ String websocketConsole = req .getParameter ("websocketconsole" );
185+
184186 if (cmd .equalsIgnoreCase ("thumbnail" )) {
185187 handleThumbnailRequest (req , resp , vmId );
186188 } else if (cmd .equalsIgnoreCase ("access" )) {
187- handleAccessRequest (req , resp , vmId );
189+ handleAccessRequest (req , resp , vmId , Boolean . valueOf ( websocketConsole ) );
188190 } else {
189191 handleAuthRequest (req , resp , vmId );
190192 }
@@ -245,7 +247,7 @@ private void handleThumbnailRequest(HttpServletRequest req, HttpServletResponse
245247 }
246248 }
247249
248- private void handleAccessRequest (HttpServletRequest req , HttpServletResponse resp , long vmId ) {
250+ private void handleAccessRequest (HttpServletRequest req , HttpServletResponse resp , long vmId , Boolean webSocketRequest ) {
249251 VirtualMachine vm = _vmMgr .findById (vmId );
250252 if (vm == null ) {
251253 s_logger .warn ("VM " + vmId + " does not exist, sending blank response for console access request" );
@@ -287,7 +289,7 @@ private void handleAccessRequest(HttpServletRequest req, HttpServletResponse res
287289 }
288290
289291 StringBuffer sb = new StringBuffer ();
290- sb .append ("<html><title>" ).append (escapeHTML (vmName )).append ("</title><frameset><frame src=\" " ).append (composeConsoleAccessUrl (rootUrl , vm , host ));
292+ sb .append ("<html><title>" ).append (escapeHTML (vmName )).append ("</title><frameset><frame src=\" " ).append (composeConsoleAccessUrl (rootUrl , vm , host , webSocketRequest ));
291293 sb .append ("\" ></frame></frameset></html>" );
292294 s_logger .debug ("the console url is :: " + sb .toString ());
293295 sendResponse (resp , sb .toString ());
@@ -405,7 +407,7 @@ private String composeThumbnailUrl(String rootUrl, VirtualMachine vm, HostVO hos
405407 param .setClientTunnelSession (parsedHostInfo .third ());
406408 }
407409
408- sb .append ("/ajaximg?token=" + encryptor .encryptObject (ConsoleProxyClientParam .class , param ));
410+ sb .append ("/ajaximg/ ?token=" + encryptor .encryptObject (ConsoleProxyClientParam .class , param ));
409411 sb .append ("&w=" ).append (w ).append ("&h=" ).append (h ).append ("&key=0" );
410412
411413 if (s_logger .isDebugEnabled ()) {
@@ -414,7 +416,7 @@ private String composeThumbnailUrl(String rootUrl, VirtualMachine vm, HostVO hos
414416 return sb .toString ();
415417 }
416418
417- private String composeConsoleAccessUrl (String rootUrl , VirtualMachine vm , HostVO hostVo ) {
419+ private String composeConsoleAccessUrl (String rootUrl , VirtualMachine vm , HostVO hostVo , Boolean webSocketRequest ) {
418420 StringBuffer sb = new StringBuffer (rootUrl );
419421 String host = hostVo .getPrivateIpAddress ();
420422
@@ -461,7 +463,12 @@ private String composeConsoleAccessUrl(String rootUrl, VirtualMachine vm, HostVO
461463 param .setClientTunnelSession (parsedHostInfo .third ());
462464 }
463465
464- sb .append ("/ajax?token=" + encryptor .encryptObject (ConsoleProxyClientParam .class , param ));
466+
467+ if (webSocketRequest ){
468+ sb .append ("/novnc/?token=" + encryptor .encryptObject (ConsoleProxyClientParam .class , param ));
469+ }else {
470+ sb .append ("/ajax/?token=" + encryptor .encryptObject (ConsoleProxyClientParam .class , param ));
471+ }
465472
466473 // for console access, we need guest OS type to help implement keyboard
467474 long guestOs = vm .getGuestOSId ();
0 commit comments