def _updatePDiskSrcUrlFromPublicToLocalIp(self): """When PDisk is running behind a proxy, KVMs usually can't connect to it on the public IP. Instead substitute the public IP with the local one. Substitution is only made if the pdisk URL points to the public IP of the PDisk (i.e., the source disk is located on this site). persistent_disk_public_base_url should be set in the configuration.""" src_pdisk_hostname = Util.getHostnameFromUri(self.diskSrc) public_pdisk_hostname = Util.getHostnameFromUri(self.persistentDiskPublicBaseUrl) or self.persistentDiskIp if src_pdisk_hostname == public_pdisk_hostname: disk_src_parts = urlparse(self.diskSrc) (scheme, _, path, params, query, fragment) = disk_src_parts netloc = self.persistentDiskIp if disk_src_parts.port: netloc = netloc + ":" + str(disk_src_parts.port) self.diskSrc = urlunparse((scheme, netloc, path, params, query, fragment))