You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2013/10/25 14:07:51 UTC

git commit: updated refs/heads/4.2 to d188534

Updated Branches:
  refs/heads/4.2 295a87ea4 -> d188534f3


CLOUDSTACK-4612: Specified locale keyboard language is not showing as default in consoleView passed during deployVM.

While deploying a VM, user passes the "keyboard" parameter to specify the
default language for that VM but in the consoleView, the default language
selected is en-us irrespective of the default language of the VM.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d188534f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d188534f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d188534f

Branch: refs/heads/4.2
Commit: d188534f3de95a174c0bb4bcf2073b5fe62870af
Parents: 295a87e
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Thu Sep 5 17:34:06 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Fri Oct 25 17:17:55 2013 +0530

----------------------------------------------------------------------
 .../cloud/servlet/ConsoleProxyClientParam.java  | 10 +++++++-
 .../com/cloud/servlet/ConsoleProxyServlet.java  |  7 +++++-
 services/console-proxy/server/js/ajaxviewer.js  |  9 +++++---
 .../consoleproxy/ConsoleProxyAjaxHandler.java   |  8 ++++---
 .../consoleproxy/ConsoleProxyClientBase.java    |  8 ++++---
 .../consoleproxy/ConsoleProxyClientParam.java   | 12 ++++++++--
 .../ConsoleProxyHttpHandlerHelper.java          | 24 +++++++++++---------
 7 files changed, 54 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d188534f/server/src/com/cloud/servlet/ConsoleProxyClientParam.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/servlet/ConsoleProxyClientParam.java b/server/src/com/cloud/servlet/ConsoleProxyClientParam.java
index e420110..88da836 100644
--- a/server/src/com/cloud/servlet/ConsoleProxyClientParam.java
+++ b/server/src/com/cloud/servlet/ConsoleProxyClientParam.java
@@ -26,7 +26,7 @@ public class ConsoleProxyClientParam {
 	
 	private String clientTunnelUrl;
 	private String clientTunnelSession;
-	
+	private String locale;
 	private String ajaxSessionId;
 	
 	public ConsoleProxyClientParam() {
@@ -97,6 +97,14 @@ public class ConsoleProxyClientParam {
 		this.ajaxSessionId = ajaxSessionId;
 	}
 
+	public String getLocale() {
+		return this.locale;
+	}
+
+	public void setLocale(String locale) {
+		this.locale = locale;
+	}
+
 	public String getClientMapKey() {
 		if(clientTag != null && !clientTag.isEmpty())
 			return clientTag;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d188534f/server/src/com/cloud/servlet/ConsoleProxyServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/servlet/ConsoleProxyServlet.java b/server/src/com/cloud/servlet/ConsoleProxyServlet.java
index f6559a5..35f8b43 100644
--- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java
+++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java
@@ -55,6 +55,7 @@ import com.cloud.utils.db.Transaction;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineManager;
+import com.cloud.vm.dao.UserVmDetailsDaoImpl;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
@@ -74,7 +75,7 @@ public class ConsoleProxyServlet extends HttpServlet {
     @Inject VirtualMachineManager _vmMgr;
     @Inject ManagementServer _ms;
     @Inject IdentityService _identityService;
-
+    @Inject UserVmDetailsDaoImpl _userVmDetailsDaoImpl;
     static ManagementServer s_ms;
 
     private Gson _gson = new GsonBuilder().create();
@@ -384,6 +385,7 @@ public class ConsoleProxyServlet extends HttpServlet {
 
         Ternary<String, String, String> parsedHostInfo = parseHostInfo(portInfo.first());
 
+        Map<String, String> details = _userVmDetailsDaoImpl.findDetails(vm.getId());
         String sid = vm.getVncPassword();
         String tag = vm.getUuid();
         String ticket = genAccessTicket(host, String.valueOf(portInfo.second()), sid, tag);
@@ -394,6 +396,9 @@ public class ConsoleProxyServlet extends HttpServlet {
         param.setClientHostPassword(sid);
         param.setClientTag(tag);
         param.setTicket(ticket);
+        if (details != null && details.containsKey("keyboard")) {
+            param.setLocale(details.get("keyboard"));
+        }
         if(parsedHostInfo.second() != null  && parsedHostInfo.third() != null) {
             param.setClientTunnelUrl(parsedHostInfo.second());
             param.setClientTunnelSession(parsedHostInfo.third());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d188534f/services/console-proxy/server/js/ajaxviewer.js
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/js/ajaxviewer.js b/services/console-proxy/server/js/ajaxviewer.js
index 9643204..e5657e1 100644
--- a/services/console-proxy/server/js/ajaxviewer.js
+++ b/services/console-proxy/server/js/ajaxviewer.js
@@ -332,7 +332,7 @@ KeyboardMapper.prototype = {
 /////////////////////////////////////////////////////////////////////////////
 // class AjaxViewer
 //
-function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWidth, tileHeight) {
+function AjaxViewer(panelId, imageUrl, updateUrl, locale, tileMap, width, height, tileWidth, tileHeight) {
 	// logging is disabled by default so that it won't have negative impact on performance
 	// however, a back door key-sequence can trigger to open the logger window, it is designed to help
 	// trouble-shooting
@@ -358,8 +358,11 @@ function AjaxViewer(panelId, imageUrl, updateUrl, tileMap, width, height, tileWi
 	this.tileWidth = tileWidth;
 	this.tileHeight = tileHeight;
 	this.maxTileZIndex = 1;
-	
-	this.currentKeyboard = AjaxViewer.KEYBOARD_TYPE_ENGLISH;
+
+	if (locale == AjaxViewer.KEYBOARD_TYPE_UK_ENGLISH || locale == AjaxViewer.KEYBOARD_TYPE_JAPANESE)
+		this.currentKeyboard = locale;
+	else
+		this.currentKeyboard = AjaxViewer.KEYBOARD_TYPE_ENGLISH;
 	this.keyboardMappers = [];
 	
 	this.timer = 0;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d188534f/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java
index 6cadeca..04254a8 100644
--- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyAjaxHandler.java
@@ -77,7 +77,8 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
         String eventStr = queryMap.get("event");
         String console_url = queryMap.get("consoleurl");
         String console_host_session = queryMap.get("sessionref");
-        
+        String vm_locale = queryMap.get("locale");
+
         if(tag == null)
             tag = "";
         
@@ -124,7 +125,8 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
             param.setTicket(ticket);
             param.setClientTunnelUrl(console_url);
             param.setClientTunnelSession(console_host_session);
-            
+            param.setLocale(vm_locale);
+
             viewer = ConsoleProxy.getAjaxVncViewer(param, ajaxSessionIdStr);
         } catch(Exception e) {
 
@@ -181,7 +183,7 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
             }
         }
     }
-    
+
     private static String convertStreamToString(InputStream is, boolean closeStreamAfterRead) { 
         BufferedReader reader = new BufferedReader(new InputStreamReader(is)); 
         StringBuilder sb = new StringBuilder(); 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d188534f/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java
index 07a1b6f..b3cda0b 100644
--- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientBase.java
@@ -20,6 +20,8 @@ import java.awt.Image;
 import java.awt.Rectangle;
 import java.util.List;
 
+import javassist.tools.web.Viewer;
+
 import org.apache.log4j.Logger;
 
 import com.cloud.consoleproxy.util.TileInfo;
@@ -283,11 +285,11 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons
         return getAjaxViewerPageContent(sbTileSequence.toString(), imgUrl, 
             updateUrl, width, height, tileWidth, tileHeight, title, 
             ConsoleProxy.keyboardType == ConsoleProxy.KEYBOARD_RAW, 
-            languages, guest);
+            languages, guest, this.clientParam.getLocale());
     }
     
     private String getAjaxViewerPageContent(String tileSequence, String imgUrl, String updateUrl, int width,
-        int height, int tileWidth, int tileHeight, String title, boolean rawKeyboard, List<String> languages, String guest) {
+        int height, int tileWidth, int tileHeight, String title, boolean rawKeyboard, List<String> languages, String guest, String locale) {
 
         StringBuffer sbLanguages = new StringBuffer("");
         if(languages != null) {
@@ -342,7 +344,7 @@ public abstract class ConsoleProxyClientBase implements ConsoleProxyClient, Cons
             "<script language=\"javascript\">",
             "var acceptLanguages = '" + sbLanguages.toString() + "';",
             "var tileMap = [ " + tileSequence + " ];",
-            "var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + "', '" + updateUrl + "', tileMap, ", 
+            "var ajaxViewer = new AjaxViewer('main_panel', '" + imgUrl + "', '" + updateUrl + "', '" + locale + "', tileMap, ",
                 String.valueOf(width) + ", " + String.valueOf(height) + ", " + String.valueOf(tileWidth) + ", " + String.valueOf(tileHeight) + ");",
 
             "$(function() {",

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d188534f/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientParam.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientParam.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientParam.java
index 8de4955..ad29e67 100644
--- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientParam.java
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyClientParam.java
@@ -30,7 +30,7 @@ public class ConsoleProxyClientParam {
     
     private String clientTunnelUrl;
     private String clientTunnelSession;
-    
+    private String locale;
     private String ajaxSessionId;
     
     public ConsoleProxyClientParam() {
@@ -92,7 +92,7 @@ public class ConsoleProxyClientParam {
     public void setClientTunnelSession(String clientTunnelSession) {
         this.clientTunnelSession = clientTunnelSession;
     }
-    
+
     public String getAjaxSessionId() {
         return this.ajaxSessionId;
     }
@@ -101,6 +101,14 @@ public class ConsoleProxyClientParam {
         this.ajaxSessionId = ajaxSessionId;
     }
 
+    public String getLocale() {
+        return this.locale;
+    }
+
+    public void setLocale(String locale) {
+        this.locale = locale;
+    }
+
     public String getClientMapKey() {
         if(clientTag != null && !clientTag.isEmpty())
             return clientTag;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d188534f/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java
index 297e711..76fad30 100644
--- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyHttpHandlerHelper.java
@@ -69,22 +69,24 @@ public class ConsoleProxyHttpHandlerHelper {
                     map.put("sessionref", param.getClientTunnelSession());
                 if(param.getTicket() != null)
                     map.put("ticket", param.getTicket());
+                if(param.getLocale() != null)
+                    map.put("locale", param.getLocale());
             }
         } else {
-        	// we no longer accept information from parameter other than token 
-        	guardUserInput(map);
+            // we no longer accept information from parameter other than token
+            guardUserInput(map);
         }
-        
         return map;
     }
-    
+
     private static void guardUserInput(Map<String, String> map) {
-    	map.remove("host");
-    	map.remove("port");
-    	map.remove("tag");
-    	map.remove("sid");
-    	map.remove("consoleurl");
-    	map.remove("sessionref");
-       	map.remove("ticket");
+        map.remove("host");
+        map.remove("port");
+        map.remove("tag");
+        map.remove("sid");
+        map.remove("consoleurl");
+        map.remove("sessionref");
+        map.remove("ticket");
+        map.remove("locale");
     }
 }