You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by an...@apache.org on 2014/03/25 19:25:29 UTC
git commit: updated refs/heads/master to a596edb
Repository: cloudstack
Updated Branches:
refs/heads/master 88c1da679 -> a596edbdf
make sure XS host is enabled when creating XAPI connection
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a596edbd
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a596edbd
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a596edbd
Branch: refs/heads/master
Commit: a596edbdf6a783cf79b411d3c33565ec21846017
Parents: 88c1da6
Author: Anthony Xu <an...@citrix.com>
Authored: Tue Mar 25 11:20:16 2014 -0700
Committer: Anthony Xu <an...@citrix.com>
Committed: Tue Mar 25 11:20:16 2014 -0700
----------------------------------------------------------------------
.../xen/resource/XenServer56FP1Resource.java | 7 +-
.../xen/resource/XenServer56Resource.java | 7 +-
.../xen/resource/XenServerConnectionPool.java | 144 +++++++++----------
3 files changed, 81 insertions(+), 77 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a596edbd/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
index ee9b05d..3dc527e 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
@@ -73,7 +73,12 @@ public class XenServer56FP1Resource extends XenServer56Resource {
protected FenceAnswer execute(FenceCommand cmd) {
Connection conn = getConnection();
try {
- if (check_heartbeat(cmd.getHostGuid())) {
+ Boolean alive = check_heartbeat(cmd.getHostGuid());
+ if ( alive == null ) {
+ s_logger.debug("Failed to check heartbeat, so unable to fence");
+ return new FenceAnswer(cmd, false, "Failed to check heartbeat, so unable to fence");
+ }
+ if ( alive ) {
s_logger.debug("Heart beat is still going so unable to fence");
return new FenceAnswer(cmd, false, "Heartbeat is still going on unable to fence");
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a596edbd/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java
index 9952ded..a78ed81 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java
@@ -236,7 +236,12 @@ public class XenServer56Resource extends CitrixResourceBase {
protected FenceAnswer execute(FenceCommand cmd) {
Connection conn = getConnection();
try {
- if (check_heartbeat(cmd.getHostGuid())) {
+ Boolean alive = check_heartbeat(cmd.getHostGuid());
+ if ( alive == null ) {
+ s_logger.debug("Failed to check heartbeat, so unable to fence");
+ return new FenceAnswer(cmd, false, "Failed to check heartbeat, so unable to fence");
+ }
+ if ( alive ) {
s_logger.debug("Heart beat is still going so unable to fence");
return new FenceAnswer(cmd, false, "Heartbeat is still going on unable to fence");
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a596edbd/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
index b779085..646d595 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java
@@ -20,7 +20,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.net.SocketException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@@ -95,7 +94,7 @@ public class XenServerConnectionPool {
}
protected XenServerConnectionPool() {
- _retries = 3;
+ _retries = 1;
_interval = 3;
}
@@ -242,19 +241,32 @@ public class XenServerConnectionPool {
}
}
- public Connection connect(String hostUuid, String poolUuid, String ipAddress, String username, Queue<String> password, int wait) {
+ public Connection connect(String hostUuid, String poolUuid, String ipAddress,
+ String username, Queue<String> password, int wait) {
XenServerConnection mConn = null;
if (hostUuid == null || poolUuid == null || ipAddress == null || username == null || password == null) {
- String msg = "Connect some parameter are null hostUuid:" + hostUuid + " ,poolUuid:" + poolUuid + " ,ipAddress:" + ipAddress;
+ String msg = "Connect some parameter are null hostUuid:" + hostUuid + " ,poolUuid:" + poolUuid
+ + " ,ipAddress:" + ipAddress;
s_logger.debug(msg);
throw new CloudRuntimeException(msg);
}
synchronized (poolUuid.intern()) {
- // Let's see if it is an existing connection.
mConn = getConnect(poolUuid);
if (mConn != null){
try{
- Host.getByUuid(mConn, hostUuid);
+ Host host = Host.getByUuid(mConn, hostUuid);
+ if (!host.getEnabled(mConn)) {
+ String msg = "Cannot connect this host " + ipAddress + " due to the host is not enabled";
+ s_logger.debug(msg);
+ if (mConn.getIp().equalsIgnoreCase(ipAddress)) {
+ removeConnect(poolUuid);
+ mConn = null;
+ }
+ throw new CloudRuntimeException(msg);
+ }
+ return mConn;
+ } catch (CloudRuntimeException e) {
+ throw e;
} catch (Exception e) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("connect through IP(" + mConn.getIp() + " for pool(" + poolUuid + ") is broken due to " + e.toString());
@@ -265,20 +277,44 @@ public class XenServerConnectionPool {
}
if ( mConn == null ) {
- mConn = new XenServerConnection(getURL(ipAddress), ipAddress, username, password, _retries, _interval, wait);
try {
+ Connection conn = new Connection(getURL(ipAddress), 5);
+ Session sess = loginWithPassword(conn, username, password, APIVersion.latest().toString());
+ Host host = sess.getThisHost(conn);
+ Boolean hostenabled = host.getEnabled(conn);
+ if( sess != null ){
+ try{
+ Session.logout(conn);
+ } catch (Exception e) {
+ }
+ conn.dispose();
+ }
+ if (!hostenabled) {
+ String msg = "Unable to create master connection, due to master Host " + ipAddress + " is not enabled";
+ s_logger.debug(msg);
+ throw new CloudRuntimeException(msg);
+ }
+ mConn = new XenServerConnection(getURL(ipAddress), ipAddress, username, password, _retries, _interval, wait);
loginWithPassword(mConn, username, password, APIVersion.latest().toString());
} catch (Types.HostIsSlave e) {
String maddress = e.masterIPAddress;
mConn = new XenServerConnection(getURL(maddress), maddress, username, password, _retries, _interval, wait);
try {
- loginWithPassword(mConn, username, password, APIVersion.latest().toString());
+ Session session = loginWithPassword(mConn, username, password, APIVersion.latest().toString());
+ Host host = session.getThisHost(mConn);
+ if (!host.getEnabled(mConn)) {
+ String msg = "Unable to create master connection, due to master Host " + maddress + " is not enabled";
+ s_logger.debug(msg);
+ throw new CloudRuntimeException(msg);
+ }
} catch (Exception e1) {
String msg = "Unable to create master connection to host(" + maddress +") , due to " + e1.toString();
s_logger.debug(msg);
throw new CloudRuntimeException(msg, e1);
}
+ } catch (CloudRuntimeException e) {
+ throw e;
} catch (Exception e) {
String msg = "Unable to create master connection to host(" + ipAddress +") , due to " + e.toString();
s_logger.debug(msg);
@@ -287,10 +323,11 @@ public class XenServerConnectionPool {
addConnect(poolUuid, mConn);
}
}
-
return mConn;
}
+
+
protected Session slaveLocalLoginWithPassword(Connection conn, String username, Queue<String> password) throws BadServerResponse, XenAPIException, XmlRpcException {
Session s = null;
boolean logged_in = false;
@@ -466,77 +503,34 @@ public class XenServerConnectionPool {
}
@Override
- protected Map dispatch(String methodCall, Object[] methodParams) throws XmlRpcException, XenAPIException {
- if (methodCall.equals("session.local_logout") || methodCall.equals("session.slave_local_login_with_password") || methodCall.equals("session.logout")) {
- return super.dispatch(methodCall, methodParams);
+ protected Map dispatch(String methodcall, Object[] methodparams) throws XmlRpcException, XenAPIException {
+ if (methodcall.equals("session.local_logout")
+ || methodcall.equals("session.slave_local_login_with_password")
+ || methodcall.equals("session.logout")
+ || methodcall.equals("session.login_with_password")) {
+ return super.dispatch(methodcall, methodparams);
}
- if (methodCall.equals("session.login_with_password")) {
- int retries = 0;
- while (retries++ < _retries) {
- try {
- return super.dispatch(methodCall, methodParams);
- } catch (XmlRpcException e) {
- Throwable cause = e.getCause();
- if (cause == null || !(cause instanceof SocketException)) {
- throw e;
- }
- if (retries >= _retries) {
- throw e;
- }
- s_logger.debug("Unable to login...retrying " + retries);
- }
- try {
- Thread.sleep(_interval);
- } catch (InterruptedException e) {
- s_logger.debug("Man....I was just getting comfortable there....who woke me up?");
- }
- }
- } else {
- int retries = 0;
- while (retries++ < _retries) {
- try {
- return super.dispatch(methodCall, methodParams);
- } catch (Types.SessionInvalid e) {
- s_logger.debug("Session is invalid for method: " + methodCall + " due to " + e.getMessage() + ". Reconnecting...retry=" + retries);
- if (retries >= _retries) {
- removeConnect(_poolUuid);
- throw e;
- }
- loginWithPassword(this, _username, _password, APIVersion.latest().toString());
- methodParams[0] = getSessionReference();
- } catch (XmlRpcClientException e) {
- s_logger.debug("XmlRpcClientException for method: " + methodCall + " due to " + e.getMessage());
- removeConnect(_poolUuid);
- throw e;
- } catch (XmlRpcException e) {
- s_logger.debug("XmlRpcException for method: " + methodCall + " due to " + e.getMessage() + ". Reconnecting...retry=" + retries);
- if (retries >= _retries) {
- removeConnect(_poolUuid);
- throw e;
- }
- Throwable cause = e.getCause();
- if (cause == null || !(cause instanceof SocketException)) {
- removeConnect(_poolUuid);
- throw e;
- }
- } catch (Types.HostIsSlave e) {
- s_logger.debug("HostIsSlave Exception for method: " + methodCall + " due to " + e.getMessage() + ". Reconnecting...retry=" + retries);
- removeConnect(_poolUuid);
- throw e;
- }
- try {
- Thread.sleep(_interval);
- } catch (InterruptedException e) {
- s_logger.info("Who woke me from my slumber?");
- }
- }
- assert false : "We should never get here";
+ try {
+ return super.dispatch(methodcall, methodparams);
+ } catch (Types.SessionInvalid e) {
+ s_logger.debug("Session is invalid for method: " + methodcall + " due to " + e.toString());
removeConnect(_poolUuid);
+ throw e;
+ } catch (XmlRpcClientException e) {
+ s_logger.debug("XmlRpcClientException for method: " + methodcall + " due to " + e.toString());
+ removeConnect(_poolUuid);
+ throw e;
+ } catch (XmlRpcException e) {
+ s_logger.debug("XmlRpcException for method: " + methodcall + " due to " + e.toString());
+ removeConnect(_poolUuid);
+ throw e;
+ } catch (Types.HostIsSlave e) {
+ s_logger.debug("HostIsSlave Exception for method: " + methodcall + " due to " + e.toString());
+ removeConnect(_poolUuid);
+ throw e;
}
- throw new CloudRuntimeException("After " + _retries + " retries, we cannot contact the host ");
}
-
}
public static class TrustAllManager implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {