Make image_type and distro required arguments
Distro, in composer terms "distribution", and "image_type" are required for composer, so make that explicit everywhere in the code.
This commit is contained in:
parent
c735ebc6d0
commit
8fb1342631
3 changed files with 20 additions and 17 deletions
15
compose.py
15
compose.py
|
|
@ -29,6 +29,9 @@ def main():
|
|||
parser.add_argument("target", metavar="TARGET", help='The build target')
|
||||
parser.add_argument("arch", metavar="ARCHITECTURE", help='Request the architecture',
|
||||
type=str, nargs="+")
|
||||
parser.add_argument("--image-type", metavar="TYPE",
|
||||
help='Request an image-type [default: qcow2]',
|
||||
type=str, action="append", default=[])
|
||||
args = parser.parse_args()
|
||||
|
||||
opts = {"user": args.user, "password": args.password, "serverca": args.serverca}
|
||||
|
|
@ -39,10 +42,12 @@ def main():
|
|||
session.gssapi_login(principal=args.principal, keytab=args.keytab)
|
||||
|
||||
name, version, arch, target = args.name, args.version, args.arch, args.target
|
||||
distro, image_types = args.distro, args.image_type
|
||||
|
||||
opts = {
|
||||
"distro": args.distro,
|
||||
}
|
||||
if not image_types:
|
||||
image_types = ["qcow2"]
|
||||
|
||||
opts = {}
|
||||
|
||||
if args.release:
|
||||
opts["release"] = args.release
|
||||
|
|
@ -52,12 +57,14 @@ def main():
|
|||
|
||||
print("name:", name)
|
||||
print("version:", version)
|
||||
print("distro:", distro)
|
||||
print("arches:", ", ".join(arch))
|
||||
print("target:", target)
|
||||
print("image types ", str(image_types))
|
||||
if opts:
|
||||
pprint(opts)
|
||||
|
||||
session.osbuildImage(name, version, arch, target, opts=opts)
|
||||
session.osbuildImage(name, version, distro, image_types, target, arch, opts=opts)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -220,7 +220,8 @@ class OSBuildImage(BaseTaskHandler):
|
|||
self.logger.debug("user repo override: %s", urls)
|
||||
return [Repository(u.strip()) for u in urls]
|
||||
|
||||
def handler(self, name, version, arches, target, opts):
|
||||
def handler(self, name, version, distro, image_types, target, arches, opts):
|
||||
"""Main entry point for the task"""
|
||||
self.logger.debug("Building image via osbuild %s, %s, %s, %s",
|
||||
name, str(arches), str(target), str(opts))
|
||||
|
||||
|
|
@ -254,19 +255,14 @@ class OSBuildImage(BaseTaskHandler):
|
|||
if not nvr.release:
|
||||
nvr.release = self.session.getNextRelease(nvr.as_dict())
|
||||
|
||||
distro = opts.get("distro", f"{name}-{version}")
|
||||
formats = ["qcow2"]
|
||||
images = []
|
||||
for fmt in formats:
|
||||
for arch in arches:
|
||||
ireq = ImageRequest(arch, fmt, repos)
|
||||
images.append(ireq)
|
||||
|
||||
# Arches and image types
|
||||
ireqs = [ImageRequest(a, i, repos) for a in arches for i in image_types]
|
||||
self.logger.debug("Creating compose: %s (%s)\n koji: %s\n images: %s",
|
||||
nvr, distro, self.koji_url,
|
||||
str([i.as_dict() for i in images]))
|
||||
str([i.as_dict() for i in ireqs]))
|
||||
|
||||
cid, bid = client.compose_create(nvr, distro, images, self.koji_url)
|
||||
# Setup down, talk to composer to create the compose
|
||||
cid, bid = client.compose_create(nvr, distro, ireqs, self.koji_url)
|
||||
self.logger.info("Compose id: %s", cid)
|
||||
|
||||
self.logger.debug("Waiting for comose to finish")
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ import kojihub
|
|||
|
||||
|
||||
@koji.plugin.export
|
||||
def osbuildImage(name, version, arches, target, opts=None, priority=None):
|
||||
def osbuildImage(name, version, distro, image_types, target, arches, opts=None, priority=None):
|
||||
"""Create an image via osbuild"""
|
||||
context.session.assertPerm("image")
|
||||
args = [name, version, arches, target, opts]
|
||||
args = [name, version, distro, image_types, target, arches, opts]
|
||||
task = {"channel": "image"}
|
||||
|
||||
if priority and priority < 0 and not context.session.hasPerm('admin'):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue