diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java index e0c19319a2a..0916813bb8c 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java @@ -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);