You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/09/16 09:23:03 UTC

[1/2] git commit: updated refs/heads/4.5 to 52e2399

Repository: cloudstack
Updated Branches:
  refs/heads/4.5 17166eb63 -> 52e23996b


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.

(cherry picked from commit 4a6e2cdeeecae6953245ce3213513f4d5dd82e7f)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 5f95f1688ec78d122c5dc16e88b18f3fbbd39071
Parents: 17166eb
Author: Suresh Kumar Anaparti <su...@citrix.com>
Authored: Fri Sep 11 15:39:09 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Sep 16 12:52:18 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/5f95f168/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 f3f7e0c..f8bf5e5 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
@@ -147,13 +147,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;
     }
 
@@ -572,41 +585,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;
     }
 


[2/2] git commit: updated refs/heads/4.5 to 52e2399

Posted by bh...@apache.org.
CLOUDSTACK-8820: Updated the code for vCenter6 data center support.

(cherry picked from commit 1d73418c2c2b3881952f9dab0ed235ebfb096a50)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/4.5
Commit: 52e23996b8b09a2c73ca7afc8976f5a31684346a
Parents: 5f95f16
Author: Suresh Kumar Anaparti <su...@citrix.com>
Authored: Mon Sep 14 15:27:52 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Sep 16 12:52:46 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/hypervisor/vmware/util/VmwareClient.java    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/52e23996/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 f8bf5e5..b2b2919 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
@@ -151,6 +151,7 @@ public class VmwareClient {
         vimPort.login(serviceContent.getSessionManager(), userName, password, null);
 
         if (cookies == null) {
+            // Get the cookie from the response header. See vmware sample program com.vmware.httpfileaccess.GetVMFiles
             @SuppressWarnings("unchecked")
             Map<String, List<String>> responseHeaders = (Map<String, List<String>>)((BindingProvider)vimPort).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
             cookies = responseHeaders.get("Set-cookie");
@@ -622,9 +623,12 @@ public class VmwareClient {
                     }
                 }
             }
-        } catch (Exception e) {
-            s_logger.debug("Failed to get mor for name: " + name + " and type: " + type, e);
-            throw e;
+        } catch (InvalidPropertyFaultMsg invalidPropertyException) {
+            s_logger.debug("Failed to get Vmware ManagedObjectReference for name: " + name + " and type: " + type + " due to " + invalidPropertyException.getMessage());
+            throw invalidPropertyException;
+        } catch (RuntimeFaultFaultMsg runtimeFaultException) {
+            s_logger.debug("Failed to get Vmware ManagedObjectReference for name: " + name + " and type: " + type + " due to " + runtimeFaultException.getMessage());
+            throw runtimeFaultException;
         }
 
         return null;