mirror of https://github.com/apache/cloudstack.git
Merge pull request #806 from sureshanaparti/CLOUDSTACK-8820
CLOUDSTACK-8820: Support for VMware vCenter 6 data centerCLOUDSTACK-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. * pr/806: CLOUDSTACK-8820: Updated the code for vCenter6 data center support. 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. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
commit
1ba362dc01
|
|
@ -152,13 +152,27 @@ 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) {
|
||||
// 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");
|
||||
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 +591,51 @@ public class VmwareClient {
|
|||
return null;
|
||||
}
|
||||
|
||||
// Create PropertySpecs
|
||||
PropertySpec pSpec = new PropertySpec();
|
||||
pSpec.setType(type);
|
||||
pSpec.setAll(false);
|
||||
pSpec.getPathSet().add("name");
|
||||
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());
|
||||
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);
|
||||
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);
|
||||
ManagedObjectReference propCollector = getPropCol();
|
||||
List<ObjectContent> ocary = vimPort.retrieveProperties(propCollector, specArr);
|
||||
|
||||
if (ocary == null || ocary.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
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 (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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue