Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def compose__import_images(request, release_id, composeinfo, image_manifest):
release_obj = release_models.Release.objects.get(release_id=release_id)
ci = productmd.composeinfo.ComposeInfo()
common_hacks.deserialize_wrapper(ci.deserialize, composeinfo)
im = productmd.images.Images()
common_hacks.deserialize_wrapper(im.deserialize, image_manifest)
_maybe_raise_inconsistency_error(ci, im, 'images')
compose_date = "%s-%s-%s" % (ci.compose.date[:4], ci.compose.date[4:6], ci.compose.date[6:])
compose_type = models.ComposeType.objects.get(name=ci.compose.type)
compose_obj, created = lib._logged_get_or_create(
request, models.Compose,
release=release_obj,
compose_id=ci.compose.id,
compose_date=compose_date,
compose_type=compose_type,
compose_respin=ci.compose.respin,
compose_label=ci.compose.label or None,
)
if created and hasattr(request._request, '_messagings'):
def retrieve(self, request, **kwargs):
"""
__Method__: `GET`
__URL__: $LINK:composeimage-detail:compose_id$
This API end-point allows retrieving RPM manifest for a given compose.
It will return the exact same data as was imported.
"""
compose = get_object_or_404(Compose, compose_id=kwargs['compose_id'])
cimages = ComposeImage.objects.filter(variant_arch__variant__compose=compose)
manifest = Images()
manifest.compose.date = compose.compose_date.strftime('%Y%m%d')
manifest.compose.id = compose.compose_id
manifest.compose.respin = compose.compose_respin
manifest.compose.type = compose.compose_type.name
for cimage in cimages:
im = Image(None)
im.path = os.path.join(cimage.path.path, cimage.image.file_name)
im.arch = cimage.image.arch
im.bootable = cimage.image.bootable
im.mtime = cimage.image.mtime
im.size = cimage.image.size
im.volume_id = cimage.image.volume_id
im.type = cimage.image.image_type.name
im.format = cimage.image.image_format.name
im.arch = cimage.image.arch