cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [1/3] git commit: updated refs/heads/master to 1ba362d
Date Wed, 16 Sep 2015 07:21:40 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 8f11b459f -> 1ba362dc0


CLOUDSTACK-8820: Showing error when try to add advance zone using VMWare ESXi 6.0 host
Summary: In vCenter 6.0, response headers need to be fetched after service login for server
cookie unlike previous versions of vCenter.


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

Branch: refs/heads/master
Commit: 4a6e2cdeeecae6953245ce3213513f4d5dd82e7f
Parents: 2d90f18
Author: Suresh Kumar Anaparti <sureshkumar.anaparti@citrix.com>
Authored: Fri Sep 11 15:39:09 2015 +0530
Committer: Suresh Kumar Anaparti <sureshkumar.anaparti@citrix.com>
Committed: Fri Sep 11 15:39:09 2015 +0530

----------------------------------------------------------------------
 .../hypervisor/vmware/util/VmwareClient.java    | 84 ++++++++++++--------
 1 file changed, 52 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a6e2cde/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
index 27d088a..b2de216 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
@@ -152,13 +152,26 @@ public class VmwareClient {
         @SuppressWarnings("unchecked")
         Map<String, List<String>> headers = (Map<String, List<String>>)((BindingProvider)vimPort).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
         List<String> cookies = headers.get("Set-cookie");
+
+        vimPort.login(serviceContent.getSessionManager(), userName, password, null);
+
+        if (cookies == null) {
+            @SuppressWarnings("unchecked")
+            Map<String, List<String>> responseHeaders = (Map<String, List<String>>)((BindingProvider)vimPort).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
+            cookies = responseHeaders.get("Set-cookie");
+            if (cookies == null) {
+                String msg = "Login successful, but failed to get server cookies from url
:[" + url + "]";
+                s_logger.error(msg);
+                throw new Exception(msg);
+            }
+        }
+
         String cookieValue = cookies.get(0);
         StringTokenizer tokenizer = new StringTokenizer(cookieValue, ";");
         cookieValue = tokenizer.nextToken();
         String pathData = "$" + tokenizer.nextToken();
         serviceCookie = "$Version=\"1\"; " + cookieValue + "; " + pathData;
 
-        vimPort.login(serviceContent.getSessionManager(), userName, password, null);
         isConnected = true;
     }
 
@@ -577,41 +590,48 @@ public class VmwareClient {
             return null;
         }
 
-        // Create PropertySpecs
-        PropertySpec pSpec = new PropertySpec();
-        pSpec.setType(type);
-        pSpec.setAll(false);
-        pSpec.getPathSet().add("name");
-
-        ObjectSpec oSpec = new ObjectSpec();
-        oSpec.setObj(root);
-        oSpec.setSkip(false);
-        oSpec.getSelectSet().addAll(constructCompleteTraversalSpec());
-
-        PropertyFilterSpec spec = new PropertyFilterSpec();
-        spec.getPropSet().add(pSpec);
-        spec.getObjectSet().add(oSpec);
-        List<PropertyFilterSpec> specArr = new ArrayList<PropertyFilterSpec>();
-        specArr.add(spec);
-
-        List<ObjectContent> ocary = vimPort.retrieveProperties(getPropCol(), specArr);
-
-        if (ocary == null || ocary.size() == 0) {
-            return null;
-        }
+        try {
+            // Create PropertySpecs
+            PropertySpec pSpec = new PropertySpec();
+            pSpec.setType(type);
+            pSpec.setAll(false);
+            pSpec.getPathSet().add("name");
+
+            ObjectSpec oSpec = new ObjectSpec();
+            oSpec.setObj(root);
+            oSpec.setSkip(false);
+            oSpec.getSelectSet().addAll(constructCompleteTraversalSpec());
+
+            PropertyFilterSpec spec = new PropertyFilterSpec();
+            spec.getPropSet().add(pSpec);
+            spec.getObjectSet().add(oSpec);
+            List<PropertyFilterSpec> specArr = new ArrayList<PropertyFilterSpec>();
+            specArr.add(spec);
+
+            ManagedObjectReference propCollector = getPropCol();
+            List<ObjectContent> ocary = vimPort.retrieveProperties(propCollector, specArr);
+
+            if (ocary == null || ocary.size() == 0) {
+                return null;
+            }
 
-        // filter through retrieved objects to get the first match.
-        for (ObjectContent oc : ocary) {
-            ManagedObjectReference mor = oc.getObj();
-            List<DynamicProperty> propary = oc.getPropSet();
-            if (type == null || type.equals(mor.getType())) {
-                if (propary.size() > 0) {
-                    String propval = (String)propary.get(0).getVal();
-                    if (propval != null && name.equalsIgnoreCase(propval))
-                        return mor;
+            // filter through retrieved objects to get the first match.
+            for (ObjectContent oc : ocary) {
+                ManagedObjectReference mor = oc.getObj();
+                List<DynamicProperty> propary = oc.getPropSet();
+                if (type == null || type.equals(mor.getType())) {
+                    if (propary.size() > 0) {
+                        String propval = (String)propary.get(0).getVal();
+                        if (propval != null && name.equalsIgnoreCase(propval))
+                            return mor;
+                    }
                 }
             }
+        } catch (Exception e) {
+            s_logger.debug("Failed to get mor for name: " + name + " and type: " + type,
e);
+            throw e;
         }
+
         return null;
     }
 


Mime
View raw message