You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by li...@apache.org on 2014/01/13 17:35:28 UTC
git commit: updated refs/heads/4.3 to 6bb15a0
Updated Branches:
refs/heads/4.3 f18c7ba74 -> 6bb15a000
CLOUDSTACK-5707. Hitting multiple 'User unauthenticated' exceptions when vCenter is upgraded to 5.5 from 5.1.
We hit these excptions whenever a management server held session that was with the old 5.1 vCenter server
is used to make resource calls to the new 5.5 vCenter.
Validate a vCenter session context before it is being used to make a resource call.
And if the context is invalid then discard the context and retrieve a new one.
During the invalidation of an old context handle the context disconnect better
by catching the appropriate exception and returning a newly created context.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6bb15a00
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6bb15a00
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6bb15a00
Branch: refs/heads/4.3
Commit: 6bb15a00050c87204960e90b58d9e0bf1dd7720c
Parents: f18c7ba
Author: Likitha Shetty <li...@citrix.com>
Authored: Mon Jan 13 10:14:54 2014 +0530
Committer: Likitha Shetty <li...@citrix.com>
Committed: Mon Jan 13 21:57:39 2014 +0530
----------------------------------------------------------------------
.../vmware/resource/VmwareContextFactory.java | 2 +-
.../vmware/resource/VmwareResource.java | 14 ++++++++++----
.../VmwareSecondaryStorageResourceHandler.java | 19 ++++++++++++-------
.../hypervisor/vmware/util/VmwareContext.java | 19 +++++++++++--------
4 files changed, 34 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bb15a00/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
index 6d959a3..d52cbd4 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
@@ -86,7 +86,7 @@ public class VmwareContextFactory {
} else {
// Validate current context and verify if vCenter session timeout value of the context matches the timeout value set by Admin
if(!context.validate() || (context.getVimClient().getVcenterSessionTimeout() != s_vmwareMgr.getVcenterSessionTimeout())) {
- s_logger.info("Validation of the context faild. dispose and create a new one");
+ s_logger.info("Validation of the context failed. dispose and create a new one");
context.close();
context = create(vCenterAddress, vCenterUserName, vCenterPassword);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bb15a00/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index f254c5c..161ef1e 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -6906,10 +6906,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
@Override
public VmwareContext getServiceContext(Command cmd) {
- if(s_serviceContext.get() != null)
- return s_serviceContext.get();
-
- VmwareContext context = null;
+ VmwareContext context = null;
+ if(s_serviceContext.get() != null) {
+ context = s_serviceContext.get();
+ if (context.validate()) {
+ return context;
+ } else {
+ s_logger.info("Validation of the context failed, dispose and use a new one");
+ invalidateServiceContext(context);
+ }
+ }
try {
context = VmwareContextFactory.getContext(_vCenterAddress, _username, _password);
s_serviceContext.set(context);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bb15a00/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
index 2e6c280..89c122e 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
@@ -211,20 +211,25 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
try {
_resource.ensureOutgoingRuleForAddress(vCenterAddress);
-
+
VmwareContext context = currentContext.get();
- if(context == null) {
+ if (context != null) {
+ if(!context.validate()) {
+ invalidateServiceContext(context);
+ context = null;
+ } else {
+ context.registerStockObject("serviceconsole", cmd.getContextParam("serviceconsole"));
+ context.registerStockObject("manageportgroup", cmd.getContextParam("manageportgroup"));
+ context.registerStockObject("noderuninfo", cmd.getContextParam("noderuninfo"));
+ }
+ }
+ if(context == null) {
s_logger.info("Open new VmwareContext. vCenter: " + vCenterAddress + ", user: " + username
+ ", password: " + StringUtils.getMaskedPasswordForDisplay(password));
VmwareSecondaryStorageContextFactory.setVcenterSessionTimeout(vCenterSessionTimeout);
context = VmwareSecondaryStorageContextFactory.getContext(vCenterAddress, username, password);
}
- if (context != null) {
- context.registerStockObject("serviceconsole", cmd.getContextParam("serviceconsole"));
- context.registerStockObject("manageportgroup", cmd.getContextParam("manageportgroup"));
- context.registerStockObject("noderuninfo", cmd.getContextParam("noderuninfo"));
- }
currentContext.set(context);
return context;
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bb15a00/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
index c499576..eefb7cb 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
@@ -37,6 +37,7 @@ import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
+import javax.xml.ws.soap.SOAPFaultException;
import org.apache.log4j.Logger;
@@ -624,16 +625,18 @@ public class VmwareContext {
public void close() {
clearStockObjects();
try {
+ s_logger.info("Disconnecting VMware session");
_vimClient.disconnect();
- } catch(Exception e) {
+ } catch(SOAPFaultException sfe) {
+ s_logger.debug("Tried to disconnect a session that is no longer valid");
+ } catch(Exception e) {
s_logger.warn("Unexpected exception: ", e);
- }
-
- if(_pool != null) {
- _pool.unregisterOutstandingContext(this);
- }
-
- unregisterOutstandingContext();
+ } finally {
+ if(_pool != null) {
+ _pool.unregisterOutstandingContext(this);
+ }
+ unregisterOutstandingContext();
+ }
}
public static class TrustAllManager implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {