mirror of https://github.com/apache/cloudstack.git
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.
This commit is contained in:
parent
295a87ea40
commit
d188534f3d
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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() {",
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue