diff --git a/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java b/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java index 0320982a58e..060bf7a5cdd 100644 --- a/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java +++ b/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyPasswordBasedEncryptor.java @@ -14,7 +14,6 @@ package com.cloud.consoleproxy; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -import java.util.UUID; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; diff --git a/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java b/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java index 11fd8f55e95..09895f0831e 100644 --- a/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java +++ b/console-proxy/src/com/cloud/consoleproxy/ConsoleProxyVncClient.java @@ -83,9 +83,12 @@ public class ConsoleProxyVncClient extends ConsoleProxyClientBase { client.connectTo(getClientHostAddress(), getClientHostPort(), getClientHostPassword()); } } catch (UnknownHostException e) { - s_logger.error("Unexpected exception: ", e); + s_logger.error("Unexpected exception", e); + break; } catch (IOException e) { - s_logger.error("Unexpected exception: ", e); + s_logger.error("Unexpected exception (will retry until timeout) ", e); + } catch (Throwable e) { + s_logger.error("Unexpected exception (will retry until timeout) ", e); } try { diff --git a/console-proxy/src/com/cloud/consoleproxy/vnc/VncClient.java b/console-proxy/src/com/cloud/consoleproxy/vnc/VncClient.java index b7ed80c008c..954480648e8 100644 --- a/console-proxy/src/com/cloud/consoleproxy/vnc/VncClient.java +++ b/console-proxy/src/com/cloud/consoleproxy/vnc/VncClient.java @@ -154,6 +154,8 @@ public class VncClient { handshake(); authenticate(password); initialize(); + + s_logger.info("Connecting to VNC server succeeded, start session"); // Run client-to-server packet sender sender = new VncClientPacketSender(os, screen, this); @@ -219,8 +221,10 @@ public class VncClient { String rfbProtocol = new String(buf); // Server should use RFB protocol 3.x - if (!rfbProtocol.contains(RfbConstants.RFB_PROTOCOL_VERSION_MAJOR)) + if (!rfbProtocol.contains(RfbConstants.RFB_PROTOCOL_VERSION_MAJOR)) { + s_logger.error("Cannot handshake with VNC server. Unsupported protocol version: \"" + rfbProtocol + "\"."); throw new RuntimeException("Cannot handshake with VNC server. Unsupported protocol version: \"" + rfbProtocol + "\"."); + } // Send response: we support RFB 3.3 only String ourProtocolString = RfbConstants.RFB_PROTOCOL_VERSION + "\n"; @@ -243,7 +247,8 @@ public class VncClient { byte[] buf = new byte[length]; is.readFully(buf); String reason = new String(buf, RfbConstants.CHARSET); - + + s_logger.error("Authentication to VNC server is failed. Reason: " + reason); throw new RuntimeException("Authentication to VNC server is failed. Reason: " + reason); } @@ -253,11 +258,13 @@ public class VncClient { } case RfbConstants.VNC_AUTH: { + s_logger.info("VNC server requires password authentication"); doVncAuth(password); break; } default: + s_logger.error("Unsupported VNC protocol authorization scheme, scheme code: " + authType + "."); throw new RuntimeException("Unsupported VNC protocol authorization scheme, scheme code: " + authType + "."); } } @@ -276,6 +283,7 @@ public class VncClient { try { response = encodePassword(challenge, password); } catch (Exception e) { + s_logger.error("Cannot encrypt client password to send to server: " + e.getMessage()); throw new RuntimeException("Cannot encrypt client password to send to server: " + e.getMessage()); } @@ -293,12 +301,15 @@ public class VncClient { } case RfbConstants.VNC_AUTH_TOO_MANY: + s_logger.error("Connection to VNC server failed: too many wrong attempts."); throw new RuntimeException("Connection to VNC server failed: too many wrong attempts."); case RfbConstants.VNC_AUTH_FAILED: + s_logger.error("Connection to VNC server failed: wrong password."); throw new RuntimeException("Connection to VNC server failed: wrong password."); default: + s_logger.error("Connection to VNC server failed, reason code: " + authResult); throw new RuntimeException("Connection to VNC server failed, reason code: " + authResult); } } diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 4201e275828..602bf0dcf17 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -219,6 +219,7 @@ import com.xensource.xenapi.Session; import com.xensource.xenapi.Task; import com.xensource.xenapi.Types; import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.ConsoleProtocol; import com.xensource.xenapi.Types.IpConfigurationMode; import com.xensource.xenapi.Types.VmPowerState; import com.xensource.xenapi.Types.XenAPIException; @@ -2733,17 +2734,20 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe protected String getVncUrl(Connection conn, VM vm) { VM.Record record; Console c; - String consoleurl; try { record = vm.getRecord(conn); Set consoles = record.consoles; + if (consoles.isEmpty()) { s_logger.warn("There are no Consoles available to the vm : " + record.nameDescription); return null; } Iterator i = consoles.iterator(); - c = i.next(); - consoleurl = c.getLocation(conn); + while(i.hasNext()) { + c = i.next(); + if(c.getProtocol(conn) == ConsoleProtocol.RFB) + return c.getLocation(conn); + } } catch (XenAPIException e) { String msg = "Unable to get console url due to " + e.toString(); s_logger.warn(msg, e); @@ -2753,18 +2757,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe s_logger.warn(msg, e); return null; } - - if (consoleurl.isEmpty()) - return null; - else - return consoleurl; - - - + return null; } - - - @Override public RebootAnswer execute(RebootCommand cmd) {