How to use productmd - 10 common examples

To help you get started, we’ve selected a few productmd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github product-definition-center / product-definition-center / pdc / apps / release / lib.py View on Github external
short=release.short.lower(),
        version=release.version.split('.')[0]
    )
    try:
        integrated_release, _ = _logged_get_or_create(
            request, models.Release,
            name=release.name,
            short=release.short.lower(),
            release_type=orig_release.release_type,
            version=release.version,
            base_product=integrated_base_product,
            integrated_with=orig_release,
            product_version=integrated_product_version
        )
    except ValidationError:
        release_id = create_release_id(
            release.short.lower(),
            release.version,
            orig_release.release_type.short,
            integrated_base_product.short,
            integrated_base_product.version,
            integrated_base_product.release_type.short,
        )
        msg = ('Failed to create release {} for integrated layered product.' +
               ' A conflicting release already exists.' +
               ' There is likely a version mismatch between the imported' +
               ' release and its layered integrated product in the composeinfo.')
        raise ValidationError(msg.format(release_id))
    return integrated_release
github product-definition-center / product-definition-center / pdc / apps / release / lib.py View on Github external
def release__import_from_composeinfo(request, composeinfo_json):
    """
    Import release including variants and architectures from composeinfo json.
    """
    ci = productmd.composeinfo.ComposeInfo()
    common_hacks.deserialize_wrapper(ci.deserialize, composeinfo_json)

    if ci.release.is_layered:
        release_type_obj = models.ReleaseType.objects.get(short=getattr(ci.base_product, "type", "ga"))
        base_product_obj, _ = _logged_get_or_create(
            request, models.BaseProduct,
            name=ci.base_product.name,
            short=ci.base_product.short.lower(),
            version=ci.base_product.version,
            release_type=release_type_obj,
        )
    else:
        base_product_obj = None

    product_obj, _ = _logged_get_or_create(
        request, models.Product,
github product-definition-center / product-definition-center / pdc / apps / compose / lib.py View on Github external
def _set_compose_tree_location(request, compose_id, composeinfo, location, url, scheme):
    ci = productmd.composeinfo.ComposeInfo()
    common_hacks.deserialize_wrapper(ci.deserialize, composeinfo)
    num_set_locations = 0
    synced_content = [item.name for item in ContentCategory.objects.all()]

    for variant in ci.get_variants(recursive=True):
        variant_uid = variant.uid
        variant_obj = models.Variant.objects.get(compose__compose_id=compose_id, variant_uid=variant_uid)
        for arch_name in variant.arches:
            data = {'compose': compose_id,
                    'variant': variant_uid,
                    'arch': arch_name,
                    'location': location,
                    'url': url,
                    'scheme': scheme,
                    'synced_content': synced_content}
            request.data['compose'] = compose_id
github product-definition-center / product-definition-center / pdc / apps / compose / lib.py View on Github external
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,
github product-definition-center / product-definition-center / pdc / apps / compose / lib.py View on Github external
def compose__import_rpms(request, release_id, composeinfo, rpm_manifest):
    release_obj = release_models.Release.objects.get(release_id=release_id)

    ci = productmd.composeinfo.ComposeInfo()
    common_hacks.deserialize_wrapper(ci.deserialize, composeinfo)
    rm = Rpms()
    common_hacks.deserialize_wrapper(rm.deserialize, rpm_manifest)

    _maybe_raise_inconsistency_error(ci, rm, 'rpms')

    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)
    acceptance_status = models.ComposeAcceptanceTestingState.objects.get(name='untested')
    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,
github product-definition-center / product-definition-center / pdc / apps / compose / lib.py View on Github external
def _store_relative_path_for_compose(compose_obj, variants_info, variant, variant_obj, add_to_changelog):
    vp = productmd.composeinfo.VariantPaths(variant)
    common_hacks.deserialize_wrapper(vp.deserialize, variants_info.get(variant.name, {}).get('paths', {}))
    for path_type in vp._fields:
        path_type_obj, created = models.PathType.objects.get_or_create(name=path_type)
        if created:
            add_to_changelog.append(path_type_obj)
        for arch in variant.arches:
            field_value = getattr(vp, path_type)
            if field_value and field_value.get(arch, None):
                arch_obj = common_models.Arch.objects.get(name=arch)
                crp_obj, created = models.ComposeRelPath.objects.get_or_create(arch=arch_obj, variant=variant_obj,
                                                                               compose=compose_obj, type=path_type_obj,
                                                                               path=field_value[arch])
                if created:
                    add_to_changelog.append(crp_obj)
github product-definition-center / product-definition-center / pdc / apps / compose / models.py View on Github external
def _get_compose_info(self):
        if not hasattr(self, '_compose_info'):
            self._compose_info = composeinfo.Compose(None)
            self._compose_info.id = self.compose_id
            self._compose_info.date = self.compose_date
            self._compose_info.respin = self.compose_respin
            self._compose_info.type = self.compose_type.name
        return self._compose_info
github product-definition-center / product-definition-center / pdc / apps / compose / lib.py View on Github external
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'):
github product-definition-center / product-definition-center / pdc / apps / package / serializers.py View on Github external
from pdc.apps.common.fields import ChoiceSlugField
from pdc.apps.common.serializers import StrictSerializerMixin
from pdc.apps.repository.serializers import RepoField


class ImageFormatSerializer(serializers.SlugRelatedField):
    doc_format = " | ".join(images.SUPPORTED_IMAGE_FORMATS)

    def __init__(self):
        super(ImageFormatSerializer, self).__init__(
            slug_field='name',
            queryset=models.ImageFormat.objects.all())


class ImageTypeSerializer(serializers.SlugRelatedField):
    doc_format = " | ".join(images.SUPPORTED_IMAGE_TYPES)

    def __init__(self):
        super(ImageTypeSerializer, self).__init__(
            slug_field='name',
            queryset=models.ImageType.objects.all())


class DefaultFilenameGenerator(object):
    doc_format = '{name}-{version}-{release}.{arch}.rpm'

    def __call__(self):
        return models.RPM.default_filename(self.field.parent.initial_data)

    def set_context(self, field):
        self.field = field
github product-definition-center / product-definition-center / pdc / apps / package / models.py View on Github external
def sync_image_formats_and_types():
    logger = logging.getLogger(__name__)
    missing_image_formats = set(images.SUPPORTED_IMAGE_FORMATS) - set([obj.name for obj in ImageFormat.objects.all()])
    missing_image_types = set(images.SUPPORTED_IMAGE_TYPES) - set([obj.name for obj in ImageType.objects.all()])

    for image_format in missing_image_formats:
        ImageFormat.objects.create(name=image_format)
        logger.info("Created image format %s" % image_format)
    for image_type in missing_image_types:
        ImageType.objects.create(name=image_type)
        logger.info("Created image type %s" % image_type)