def checkOptions(self):
        if len(self.args) != 1:
            self.parser.error('Please specify an image as <filename>.img')
        self.image = self.args[0]

        Uploader.checkUploadOptions(self.options, self.parser)
        if not self.options.imageOnly:
            self.checkP12CertOptionsOnly()

        if not os.path.isfile(self.image):
            self.parser.error('Image file does not exist: ' + self.image)
    def doWork(self):
        configHolder = ConfigHolder(self.options.__dict__, self.config or {})
        configHolder.set('imageMetadata',
                         PDiskVolume.extractVolumeOptionsAsDict(self.options))

        uploader = Uploader(self.image, configHolder)

        try:
            uploader.start()
        except InputException, e:
            print e
            sys.exit(1)
    def parse(self):
        Uploader.buildUploadParser(self.parser)

        self.parser.usage = '''%prog [options] image-file'''

        self.parser.description = '''
Uploads the given machine or disk image file to the persistent
disk service.  The image-file argument is the file to upload.
'''

        self.addP12CertOptions(self.parser, AuthnCommand.defaultRunOptions())

        self.options, self.args = self.parser.parse_args()
Exemple #4
0
    def test_uploadImageNoVolumeUpdate(self):

        uploader = Uploader('image.img', self.ch)
        uploader.pdisk.uploadVolume = self._uploadVolume
        uploader.pdisk.updateVolumeAsUser = self._updateVolumeAsUser
        uploader._uploadImage()

        assert uploader.pdisk.uploadVolume.called == True
        assert uploader.pdisk.uploadVolume.call_count == 1
        assert uploader.pdisk.uploadVolume.call_args == (('image.img',), {})
        assert uploader.pdisk.uploadVolume._return_value == 'https://example.com/pdisk/uuid'

        assert uploader.pdisk.updateVolumeAsUser.called == False
Exemple #5
0
    def test_uploadImageVolumeUpdate(self):
        self.ch.set('imageMetadata', {'foo':'bar'})

        uploader = Uploader('image.img', self.ch)
        uploader.pdisk.uploadVolume = self._uploadVolume
        uploader.pdisk.updateVolumeAsUser = self._updateVolumeAsUser
        uploader._uploadImage()

        assert uploader.pdisk.uploadVolume.called == True
        assert uploader.pdisk.uploadVolume.call_count == 1
        assert uploader.pdisk.uploadVolume.call_args == (('image.img',), {})
        assert uploader.pdisk.uploadVolume._return_value == 'https://example.com/pdisk/uuid'

        assert uploader.pdisk.updateVolumeAsUser.called == True
        assert uploader.pdisk.updateVolumeAsUser.call_count == 1
        assert uploader.pdisk.updateVolumeAsUser.call_args == (({'foo':'bar'}, 'uuid'), {})