# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
-import gevent.monkey # Monkey-patch everything for gevent early on
-gevent.monkey.patch_all()
-
from image_creator import __version__ as version
from image_creator import util
from image_creator.disk import Disk
help="overwrite output files if they exist")
parser.add_option("-s", "--silent", dest="silent", default=False,
- help="silent mode, only output errors",
+ help="output only errors",
action="store_true")
parser.add_option("-u", "--upload", dest="upload", type="string",
metavar="IMAGENAME")
parser.add_option("-a", "--account", dest="account", type="string",
- default=account, help="Use this ACCOUNT when "
+ default=account, help="use this ACCOUNT when "
"uploading/registering images [Default: %s]" % account)
parser.add_option("-m", "--metadata", dest="metadata", default=[],
- help="Add custom KEY=VALUE metadata to the image",
+ help="add custom KEY=VALUE metadata to the image",
action="append", metavar="KEY=VALUE")
parser.add_option("-t", "--token", dest="token", type="string",
- default=token, help="Use this token when "
+ default=token, help="use this token when "
"uploading/registering images [Default: %s]" % token)
parser.add_option("--print-sysprep", dest="print_sysprep", default=False,
metavar="SYSPREP")
parser.add_option("--no-sysprep", dest="sysprep", default=True,
- help="don't perform system preparation",
+ help="don't perform any system preparation operation",
action="store_false")
parser.add_option("--no-shrink", dest="shrink", default=True,
help="don't shrink any partition", action="store_false")
+ parser.add_option("--tmpdir", dest="tmp", type="string", default=None,
+ help="create large temporary image files under DIR",
+ metavar="DIR")
+
options, args = parser.parse_args(input_args)
if len(args) != 1:
raise FatalError("Image uploading cannot be performed. No ~okeanos "
"token is specified. User -t to set a token.")
+ if options.tmp is not None and not os.path.isdir(options.tmp):
+ raise FatalError("The directory `%s' specified with --tmpdir is not "
+ "valid." % options.tmp)
+
meta = {}
for m in options.metadata:
try:
raise FatalError("Output file %s exists "
"(use --force to overwrite it)." % filename)
- disk = Disk(options.source, out)
+ disk = Disk(options.source, out, options.tmp)
def signal_handler(signum, frame):
disk.cleanup()
if options.outfile is not None:
dev.dump(options.outfile)
- out.output('Dumping metadata file...', False)
+ out.output('Dumping metadata file ...', False)
with open('%s.%s' % (options.outfile, 'meta'), 'w') as f:
f.write(metastring)
out.success('done')
- out.output('Dumping md5sum file...', False)
+ out.output('Dumping md5sum file ...', False)
with open('%s.%s' % (options.outfile, 'md5sum'), 'w') as f:
f.write('%s %s\n' % (checksum,
os.path.basename(options.outfile)))
size=len(metastring),
remote_path="%s.%s" % (options.upload, 'meta'))
out.success('done')
- out.output("(4/4) Uploading md5sum file...", False)
+ out.output("(4/4) Uploading md5sum file ...", False)
md5sumstr = '%s %s\n' % (checksum,
os.path.basename(options.upload))
kamaki.upload(StringIO.StringIO(md5sumstr),
out.output()
if options.register:
- out.output('Registering image with ~okeanos...', False)
+ out.output('Registering image with ~okeanos ...', False)
kamaki.register(options.register, uploaded_obj, metadata)
out.success('done')
out.output()