mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-7334. [VMware] AddHost command fails if there is a space in the VMware DC/Cluster name.
URL decode vCenter path during cluster discovery.
This commit is contained in:
parent
4c4d89f4d9
commit
6a4a11ed71
|
|
@ -68,6 +68,7 @@ import org.apache.log4j.Logger;
|
|||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -150,10 +151,14 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||
_clusterDetailsDao.persist(clusterId, clusterDetails);
|
||||
}
|
||||
String updatedInventoryPath = validateCluster(url, vmwareDc);
|
||||
if (!url.getPath().equals(updatedInventoryPath)) {
|
||||
// If url from API doesn't specify DC then update url in database with DC associated with this zone.
|
||||
clusterDetails.put("url", url.getScheme() + "://" + url.getHost() + updatedInventoryPath);
|
||||
_clusterDetailsDao.persist(clusterId, clusterDetails);
|
||||
try {
|
||||
if (!URLDecoder.decode(url.getPath(), "UTF-8").equals(updatedInventoryPath)) {
|
||||
// If url from API doesn't specify DC then update url in database with DC associated with this zone.
|
||||
clusterDetails.put("url", url.getScheme() + "://" + url.getHost() + updatedInventoryPath);
|
||||
_clusterDetailsDao.persist(clusterId, clusterDetails);
|
||||
}
|
||||
} catch(UnsupportedEncodingException e) {
|
||||
throw new DiscoveredWithErrorException("Unable to decode URL path, URL path : " + url.getPath(), e);
|
||||
}
|
||||
} else {
|
||||
// For legacy zones insist on the old model of asking for credentials for each cluster being added.
|
||||
|
|
@ -455,12 +460,17 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||
String vmwareDcNameFromDb;
|
||||
String vmwareDcNameFromApi;
|
||||
String vCenterHost;
|
||||
String updatedInventoryPath = url.getPath();
|
||||
String updatedInventoryPath;
|
||||
String clusterName = null;
|
||||
String inventoryPath;
|
||||
|
||||
vmwareDcNameFromApi = vmwareDcNameFromDb = vmwareDc.getVmwareDatacenterName();
|
||||
vCenterHost = vmwareDc.getVcenterHost();
|
||||
String inventoryPath = url.getPath();
|
||||
try {
|
||||
inventoryPath = updatedInventoryPath = URLDecoder.decode(url.getPath(), "UTF-8");
|
||||
} catch(UnsupportedEncodingException e) {
|
||||
throw new DiscoveredWithErrorException("Unable to decode URL path, URL path : " + url.getPath(), e);
|
||||
}
|
||||
|
||||
assert (inventoryPath != null);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue