예제 #1
0
파일: Testor.py 프로젝트: StratusLab/client
    def _registerInvalidImageInMarketplace(self):
        manifest_file = Util.get_resources_file(["manifest-invalid-sha1.xml"])

        manifestInfo = ManifestInfo()
        manifestInfo.parseManifestFromFile(manifest_file)

        image_id = manifestInfo.identifier

        configHolder = ConfigHolder()
        configHolder.set("marketplaceEndpoint", self.marketplaceEndpoint)
        uploader = marketplaceUploader(configHolder)
        uploader.upload(manifest_file)

        return image_id
예제 #2
0
    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: '*****@*****.**',
                              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()
예제 #3
0
    def download(self, uri):
        """uri is the full resource uri uniquely identifying a single manifest entry"""
        tempMetadataFilename = tempfile.mktemp()
        ManifestDownloader(self.configHolder).getManifestAsFile(uri, tempMetadataFilename)
        manifestInfo = ManifestInfo(self.configHolder)

        manifestInfo.parseManifestFromFile(tempMetadataFilename)

        tempImageFilename = self._downloadFromLocations(manifestInfo)
        self._verifySignature(tempImageFilename, tempMetadataFilename)

        tempImageFilename = self._inflateImage(tempImageFilename)
        if not os.path.exists(tempImageFilename):
            raise InputException('Failed to find image matching image resource uri: %s' % uri)

        self._verifyHash(tempImageFilename, manifestInfo.sha1)

        shutil.copy2(tempImageFilename, self.localImageFilename)

        os.remove(tempImageFilename)
        os.remove(tempMetadataFilename)

        return self.localImageFilename
예제 #4
0
 def _parseManifest(self):
     manifestInfo = ManifestInfo()
     manifestInfo.parseManifestFromFile(self.manifestFile)