added a few appliance-build options to pass to appliance-creator minor usage text alterations
This commit is contained in:
parent
6d4f601f79
commit
82b6a11d48
3 changed files with 74 additions and 50 deletions
|
|
@ -2333,6 +2333,11 @@ class ApplianceTask(ImageTask):
|
|||
|
||||
def handler(self, arch, target, ksfile, opts=None):
|
||||
|
||||
img_type = {'raw': 'Raw Appliance',
|
||||
'qcow': 'QCOW Image',
|
||||
'qcow2': 'QCOW2 Image',
|
||||
'vmx': 'VMWare Image'}
|
||||
|
||||
target_info = session.getBuildTarget(target, strict=True)
|
||||
build_tag = target_info['build_tag']
|
||||
repo_info = session.getRepo(build_tag)
|
||||
|
|
@ -2351,73 +2356,82 @@ class ApplianceTask(ImageTask):
|
|||
kskoji = self.prepareKickstart(repo_info, target_info, arch, broot,
|
||||
kspath)
|
||||
|
||||
# Run appliance-creator
|
||||
# TODO: handle --app-options
|
||||
odir = 'output'
|
||||
# Figure out appliance-creator arguments, we let it fail if something
|
||||
# is wrong.
|
||||
odir = 'app-output'
|
||||
opath = os.path.join(broot.rootdir(), 'tmp', odir)
|
||||
cachedir = '/tmp/koji-appliance' # arbitrary paths in chroot
|
||||
app_log = '/tmp/appliance.log'
|
||||
os.mkdir(opath)
|
||||
|
||||
cmd = ['/usr/bin/appliance-creator', '-c', kskoji, '-d', '-v',
|
||||
'--logfile', app_log, '--cache', cachedir, '-o', odir]
|
||||
for arg_name in ('version', 'name', 'release', 'vmem', 'vcpu', 'format'):
|
||||
arg = self.opts.get(arg_name)
|
||||
if arg != None:
|
||||
cmd.extend(['--%s' % arg_name, arg])
|
||||
|
||||
# Run appliance-creator
|
||||
rv = broot.mock(['--cwd', '/tmp', '--chroot', '--'] + cmd)
|
||||
self.uploadFile(os.path.join(broot.rootdir(), app_log[1:]))
|
||||
if rv:
|
||||
raise koji.ApplianceError, \
|
||||
"Could not create appliance: %s" % _parseStatus(rv, 'appliance-creator') + "; see root.log or appliance.log for more information"
|
||||
|
||||
# Find the resultant raw disk image and accompanying xml file
|
||||
rawpath, xmlpath = None, None
|
||||
for rdir, subdirs, files in os.walk(broot.rootdir(), 'tmp', odir):
|
||||
# Find the results
|
||||
results = []
|
||||
for directory, subdirs, files in os.walk(opath):
|
||||
for f in files:
|
||||
if f.endswith('.raw'):
|
||||
rawpath = os.path.join(broot.rootdir(), 'tmp', rdir, f)
|
||||
if f.endswith('.xml'):
|
||||
if f == 'repomd.xml': continue
|
||||
xmlpath = os.path.join(broot.rootdir(), 'tmp', rdir, f)
|
||||
results.append(os.path.join(broot.rootdir(), 'tmp',
|
||||
directory, f))
|
||||
self.logger.debug('output: %s' % results)
|
||||
if len(results) > 2:
|
||||
raise koji.ApplianceError, \
|
||||
"Unexpected output found! Full list is: %s" % results
|
||||
|
||||
self.logger.debug('raw: %s xml: %s' % (rawpath, xmlpath))
|
||||
if rawpath == None or xmlpath == None:
|
||||
raise koji.ApplianceError, 'missing appliance-creator output'
|
||||
app_path = None
|
||||
for ofile in results:
|
||||
if ofile.endswith('.xml'):
|
||||
self.uploadFile(ofile)
|
||||
else:
|
||||
app_path = ofile
|
||||
if app_path == None:
|
||||
raise kojiApplianceError, "Could not find appliance image!"
|
||||
app_file = os.path.basename(app_path)
|
||||
|
||||
try:
|
||||
filesize = os.path.getsize(rawpath)
|
||||
filesize = os.path.getsize(app_path)
|
||||
except OSError:
|
||||
raise koji.LiveCDError, 'Could not get appliance file size'
|
||||
|
||||
# if filesize is greater than a 32-bit signed integer's range, the
|
||||
# python XMLRPC module will break.
|
||||
# if filesize is greater than a 32-bit signed integer's range,
|
||||
# the python XMLRPC module will break.
|
||||
filesize = str(filesize)
|
||||
|
||||
# copy the output out of the chroot. If we were given a name, this is
|
||||
# where the renaming happens.
|
||||
self.logger.debug('uploading appliance output: %s' % rawpath)
|
||||
self.uploadFile(xmlpath)
|
||||
self.uploadFile(rawpath)
|
||||
|
||||
# TODO: get file manifest from the appliance
|
||||
|
||||
# Import info about the image into the database, unless
|
||||
# this is a scratch image.
|
||||
if not self.opts.get('scratch'):
|
||||
hdrlist = self.getImagePackages(os.path.join(broot.rootdir(),
|
||||
cachedir[1:]))
|
||||
hash = self.getImageHash(rawpath)
|
||||
|
||||
# Import info about the image into the database, unless this is a
|
||||
# scratch image.
|
||||
hdrlist = self.getImagePackages(
|
||||
os.path.join(broot.rootdir(), cachedir[1:]))
|
||||
hash = self.getImageHash(app_path)
|
||||
broot.markExternalRPMs(hdrlist)
|
||||
rawfile = os.path.basename(rawpath)
|
||||
image_id = session.host.importImage(self.id, rawfile, filesize,
|
||||
arch, 'Raw Appliance', hash,
|
||||
hdrlist)
|
||||
itype = img_type[self.opts.get('format')]
|
||||
image_id = session.host.importImage(self.id, app_file, filesize,
|
||||
arch, itype, hash, hdrlist)
|
||||
self.uploadFile(app_path)
|
||||
|
||||
broot.expire()
|
||||
if opts.get('scratch'):
|
||||
return 'Scratch appliance image created: %s' % \
|
||||
os.path.join(koji.pathinfo.work(),
|
||||
koji.pathinfo.taskrelpath(self.id), rawfile)
|
||||
koji.pathinfo.taskrelpath(self.id), app_file)
|
||||
else:
|
||||
return 'Created appliance image: %s' % \
|
||||
os.path.join(koji.pathinfo.imageFinalPath(),
|
||||
koji.pathinfo.applianceRelPath(image_id),
|
||||
rawfile)
|
||||
app_file)
|
||||
|
||||
# LiveCDTask begins with a mock chroot, and then installs livecd-tools into it
|
||||
# via the livecd-build group. livecd-creator is then executed in the chroot
|
||||
|
|
|
|||
31
cli/koji
31
cli/koji
|
|
@ -3959,24 +3959,36 @@ def handle_appliance_build(options, session, args):
|
|||
"help options)")
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.add_option("--nowait", action="store_true",
|
||||
help=_("Don't wait on appliance creation"))
|
||||
help=_("Do not wait on appliance creation."))
|
||||
parser.add_option("--noprogress", action="store_true",
|
||||
help=_("Do not display progress of the upload"))
|
||||
help=_("Do not display progress of the upload."))
|
||||
parser.add_option("--background", action="store_true",
|
||||
help=_("Run the appliance creation task at a lower priority"))
|
||||
help=_("Run the appliance creation task at a lower priority."))
|
||||
parser.add_option("--ksurl", metavar="SCMURL",
|
||||
help=_("The URL to the SCM containing the kickstart file"))
|
||||
help=_("The URL to the SCM containing the kickstart file."))
|
||||
parser.add_option("--ksversion", metavar="VERSION",
|
||||
help=_("The syntax version used in the kickstart file"))
|
||||
help=_("The syntax version used in the kickstart file."))
|
||||
parser.add_option("--scratch", action="store_true",
|
||||
help=_("Create a scratch appliance."))
|
||||
help=_("Create a scratch appliance"))
|
||||
parser.add_option("--repo",
|
||||
help=_("Specify a comma-separated list of repos that will override\n" +
|
||||
"the repo used to install RPMs in the appliance. The \n" +
|
||||
"build tag repo associated with the target is the default."))
|
||||
parser.add_option("--app-options", metavar="OPTIONS",
|
||||
help=_("Specify a comma-separated list of options that will be\n" +
|
||||
"passed down to appliance-creator in the chroot."))
|
||||
parser.add_option("--version", metavar="VERSION", default=None,
|
||||
help=_("Set an appliance version; used in .xml metadata."))
|
||||
parser.add_option("--name", metavar="NAME", default=None,
|
||||
help=_("Specify the appliance file name."))
|
||||
parser.add_option("--release", metavar="RELEASE", default=None,
|
||||
help=_("Set an appliance release number; used in .xml metadata."))
|
||||
parser.add_option("--vmem", metavar="VMEM", default=None,
|
||||
help=_("Set the amount of virtual memory in the appliance in MB,\n" +
|
||||
"default is 512."))
|
||||
parser.add_option("--vcpu", metavar="VCPU", default=None,
|
||||
help=_("Set the number of virtual cpus in the appliance,\n" +
|
||||
"default is 1."))
|
||||
parser.add_option("--format", metavar="DISK_FORMAT", default='raw',
|
||||
help=_("Disk format, default is raw. Other options are qcow,\n" +
|
||||
"qcow2, and vmx."))
|
||||
|
||||
(task_options, args) = parser.parse_args(args)
|
||||
|
||||
|
|
@ -3988,7 +4000,6 @@ def handle_appliance_build(options, session, args):
|
|||
assert False
|
||||
_build_image(options, task_options, session, args, 'appliance')
|
||||
|
||||
|
||||
def _build_image(options, task_opts, session, args, img_type):
|
||||
"""
|
||||
A private helper function that houses common CLI code for building
|
||||
|
|
|
|||
|
|
@ -5023,13 +5023,12 @@ def moveImageResults(task_id, image_id, arch, mediatype):
|
|||
"""
|
||||
source_path = os.path.join(koji.pathinfo.work(),
|
||||
koji.pathinfo.taskrelpath(task_id))
|
||||
# TODO: enum this
|
||||
if mediatype == 'Raw Appliance':
|
||||
final_path = os.path.join(koji.pathinfo.imageFinalPath(),
|
||||
koji.pathinfo.applianceRelPath(image_id))
|
||||
elif mediatype == 'LiveCD ISO':
|
||||
if mediatype == 'LiveCD ISO':
|
||||
final_path = os.path.join(koji.pathinfo.imageFinalPath(),
|
||||
koji.pathinfo.livecdRelPath(image_id))
|
||||
else:
|
||||
final_path = os.path.join(koji.pathinfo.imageFinalPath(),
|
||||
koji.pathinfo.applianceRelPath(image_id))
|
||||
log_path = os.path.join(final_path, 'data', 'logs', arch)
|
||||
if os.path.exists(final_path) or os.path.exists(log_path):
|
||||
raise koji.GenericError, "Error moving image: the final " + \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue