def buildUploadParser(parser): parser.usage = '''usage: %prog [options] <image-file>''' parser.add_option('-C', '--compress', dest='compressionFormat', help='Compression format. One of: %s, none' % ', '.join(Compressor.compressionFormats), default='gz', metavar='FORMAT') parser.add_option('--image-only', dest='imageOnly', help='Do not upload metadata file to Marketplace', action='store_true', default=False) MarketplaceUtil.addEndpointOption(parser) PDiskEndpoint.addOptions(parser) PDiskVolume.addOptions(parser)
def checkUploadOptions(options, parser): if options.marketplaceEndpoint: options.withMarketPlace = True if not options.imageOnly: MarketplaceUtil.checkEndpointOption(options) allowedFormats = list(Compressor.compressionFormats) allowedFormats.append('none') if options.compressionFormat not in allowedFormats: parser.error('Unknown compression format') # Do NOT check the validity of the pdisk options, so that the # values can be taken from non-pdisk options when necessary. # PDiskEndpoint.checkOptions(options) # This essentially just checks that the volume tag is acceptable. PDiskVolume.checkOptions(options)
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)