当前位置: 首页>>代码示例>>Python>>正文


Python Util.getHostnamePortFromUri方法代码示例

本文整理汇总了Python中stratuslab.Util.getHostnamePortFromUri方法的典型用法代码示例。如果您正苦于以下问题:Python Util.getHostnamePortFromUri方法的具体用法?Python Util.getHostnamePortFromUri怎么用?Python Util.getHostnamePortFromUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stratuslab.Util的用法示例。


在下文中一共展示了Util.getHostnamePortFromUri方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_updatePDiskSrcUrlFromPublicToLocalIp

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import getHostnamePortFromUri [as 别名]
    def test_updatePDiskSrcUrlFromPublicToLocalIp(self):
        tm = TMCloneCache({TMCloneCache._ARG_SRC_POS : 'foo:bar',
                           TMCloneCache._ARG_DST_POS : 'foo:bar',
                           'bar' : 'baz'},
                           conf_filename=self.conf_filename)
        assert 'https://example.com:8445' == tm.persistentDiskPublicBaseUrl
        tm.diskSrc = 'https://%s/uuid-123' % Util.getHostnamePortFromUri(
                                                tm.persistentDiskPublicBaseUrl)
        tm._updatePDiskSrcUrlFromPublicToLocalIp()
        assert 'https://127.0.0.1:8445/uuid-123' == tm.diskSrc

        # The URI shouldn't be updated when it points to an IP different to the public one.
        tm._updatePDiskSrcUrlFromPublicToLocalIp()
        assert 'https://127.0.0.1:8445/uuid-123' == tm.diskSrc
开发者ID:StratusLab,项目名称:client,代码行数:16,代码来源:TMCloneCacheTest.py

示例2: testGenerateManifest

# 需要导入模块: from stratuslab import Util [as 别名]
# 或者: from stratuslab.Util import getHostnamePortFromUri [as 别名]
    def testGenerateManifest(self):
        manifest_info = ManifestInfo()
        manifest_info.parseManifest(self.TEST_MANIFEST)
        ManifestDownloader.getManifestInfo = Mock(return_value=manifest_info)

        PDISK_ENDPOINT = 'pdisk:0.0.0.0:8445'

        TMSaveCache._getAttachedVolumeURIs = Mock(
            return_value=[PDISK_ENDPOINT + ':48ac4190-9a11-4a06-8bef-03fd97080eba'])

        tm = TMSaveCache({TMSaveCache._ARG_SRC_POS: 'foo:/bar/1'},
                         conf_filename=self.conf_filename)
        tm._parseArgs()
        tm._retrieveAttachedVolumeInfo()
        tm.createImageInfo = {VmManager.CREATE_IMAGE_KEY_CREATOR_EMAIL: '[email protected]',
                              VmManager.CREATE_IMAGE_KEY_CREATOR_NAME: 'Jay Random',
                              VmManager.CREATE_IMAGE_KEY_NEWIMAGE_COMMENT: 'test',
                              VmManager.CREATE_IMAGE_KEY_NEWIMAGE_VERSION: '0.0',
                              VmManager.CREATE_IMAGE_KEY_NEWIMAGE_MARKETPLACE: 'http://new.markeplace.org'}
        tm.imageSha1 = 'ea7d0ddf7af4e2ea431db89639feb7036fb23062'
        tm.createdPDiskId = 'foo-bar-baz'

        try:
            tm._generateP12Cert()
            self.failUnless(os.path.exists(tm.p12cert))

            tm._generateP12Cert()
            tm._retrieveManifestsPath()
            tm.pdiskPathNew = tm._buildPDiskPath(tm.createdPDiskId)
            tm._buildAndSaveManifest()
            self.failUnless(os.path.exists(tm.manifestNotSignedPath))

            minfo = ManifestInfo()
            minfo.parseManifestFromFile(tm.manifestNotSignedPath)
            assert minfo.comment == 'test'
            assert minfo.creator == 'Jay Random'
            assert minfo.version == '0.0'
            assert minfo.sha1 == tm.imageSha1
            assert minfo.locations == ['pdisk:' + Util.getHostnamePortFromUri(tm.persistentDiskPublicBaseUrl) + ':foo-bar-baz']

            self.failUnless('foo-bar-baz' in str(tm._emailText()))

            if not Signator.findJar():
                print "Skipping signature sub-test as Signator jar can not be found."
                return
            tm._signManifest()
            self.failUnless(os.path.exists(tm.manifestPath))
        finally:
            tm._cleanup()
开发者ID:StratusLab,项目名称:client,代码行数:51,代码来源:TMSaveCacheTest.py


注:本文中的stratuslab.Util.getHostnamePortFromUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。