def relate_manifest(self, dc): """ Relate an ImageManifest to a Tag or ManifestList. Args: dc (pulpcore.plugin.stages.DeclarativeContent): dc for a ManifestList """ related_dc = dc.extra_data.get('relation') assert related_dc is not None if type(related_dc.content) is Tag: assert related_dc.content.manifest is None related_dc.content.manifest = dc.content try: related_dc.content.save() except IntegrityError: existing_tag = Tag.objects.get(name=related_dc.content.name, manifest=dc.content) related_dc.content = existing_tag elif type(related_dc.content) is ManifestList: thru = ManifestListManifest(manifest_list=related_dc.content, manifest=dc.content) try: thru.save() except IntegrityError: pass
def relate_manifest_to_list(self, dc): """ Relate an ImageManifest to a ManifestList. Args: dc (pulpcore.plugin.stages.DeclarativeContent): dc for a Manifest list """ related_dc_id_list = dc.extra_data.get('man_rel') # find manifests by id # We are relying on the order of the processed DC # Manifests should have passed through ContentSaver stage already man_list = Manifest.objects.filter(digest__in=related_dc_id_list) # read json file to revieve platfrom data with dc.content._artifacts.get().file.open() as content_file: raw = content_file.read() content_data = json.loads(raw) manifests_from_json = content_data['manifests'] for manifest in manifests_from_json: digest = manifest['digest'] for item in man_list: if item.digest == digest: break platform = manifest['platform'] thru = ManifestListManifest( manifest_list=item, image_manifest=dc.content, architecture=platform['architecture'], os=platform['os'], features=platform.get('features', ''), variant=platform.get('variant', ''), os_version=platform.get('os.version', ''), os_features=platform.get('os.features', '')) thru.save()
def relate_manifest_to_list(self, dc): """ Relate an ImageManifest to a ManifestList. Args: dc (pulpcore.plugin.stages.DeclarativeContent): dc for a ImageManifest """ related_dc = dc.extra_data.get('relation') thru = ManifestListManifest(manifest_list=related_dc.content, manifest=dc.content) try: thru.save() except IntegrityError: pass
def relate_manifest_to_list(self, dc): """ Relate an ImageManifest to a ManifestList. Args: dc (pulpcore.plugin.stages.DeclarativeContent): dc for a ImageManifest """ related_dc = dc.extra_data.get('relation') thru = ManifestListManifest(manifest_list=dc.content, image_manifest=related_dc.content) try: thru.save() except IntegrityError: pass
def relate_manifest_to_list(self, dc): """ Relate an ImageManifest to a ManifestList. Args: dc (pulpcore.plugin.stages.DeclarativeContent): dc for a ImageManifest """ related_dc = dc.extra_data.get('relation') platform = dc.extra_data.get('platform') thru = ManifestListManifest(manifest_list=dc.content, image_manifest=related_dc.content, architecture=platform['architecture'], os=platform['os'], features=platform.get('features'), variant=platform.get('variant'), os_version=platform.get('os.version'), os_features=platform.get('os.features')) try: thru.save() except IntegrityError: pass