本文整理汇总了Python中stratuslab.Util.getHostnameFromUri方法的典型用法代码示例。如果您正苦于以下问题:Python Util.getHostnameFromUri方法的具体用法?Python Util.getHostnameFromUri怎么用?Python Util.getHostnameFromUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stratuslab.Util
的用法示例。
在下文中一共展示了Util.getHostnameFromUri方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _updatePDiskSrcUrlFromPublicToLocalIp
# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import getHostnameFromUri [as 别名]
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))