Ejemplo n.º 1
0
    def add_catalog_entries(self, units):
        """
        Add entries to the deferred downloading (lazy) catalog.

        Skip entries which are not eligible for lazy catalog.
        (Don't have url attribute.)

        :param units: A list of: pulp_rpm.plugins.db.models.ISO.
        :type units: list
        """
        for unit in units:
            # Unit is from pulp manifest
            if not hasattr(unit, "url"):
                continue
            if not unit.storage_path:
                unit.set_storage_path(unit.name)
            entry = LazyCatalogEntry()
            entry.path = unit.storage_path
            entry.importer_id = str(self.sync_conduit.importer_object_id)
            entry.unit_id = unit.id
            entry.unit_type_id = unit.type_id
            entry.url = unit.url
            entry.checksum = unit.checksum
            # The current ISO model does not define a checksum type, but appears to use sha256.
            # Once the model includes the checksum type, this should use that field.
            entry.checksum_algorithm = 'sha256'
            entry.save_revision()
Ejemplo n.º 2
0
    def add(self, unit):
        """
        Add the specified content unit to the catalog.

        :param unit: A unit being added.
        :type unit: pulp_rpm.plugins.db.models.RpmBase
        """
        unit.set_storage_path(unit.filename)
        entry = LazyCatalogEntry()
        entry.path = unit.storage_path
        entry.importer_id = str(self.importer_id)
        entry.unit_id = unit.id
        entry.unit_type_id = unit.type_id
        entry.url = urljoin(self.base_url, unit.download_path)
        entry.checksum = unit.checksum
        entry.checksum_algorithm = unit.checksumtype
        entry.save_revision()
Ejemplo n.º 3
0
    def add_catalog_entries(self, units):
        """
        Add entries to the deferred downloading (lazy) catalog.

        :param units: A list of: pulp_rpm.plugins.db.models.ISO.
        :type units: list
        """
        for unit in units:
            unit.set_storage_path(unit.name)
            entry = LazyCatalogEntry()
            entry.path = unit.storage_path
            entry.importer_id = str(self.sync_conduit.importer_object_id)
            entry.unit_id = unit.id
            entry.unit_type_id = unit.type_id
            entry.url = unit.url
            entry.save_revision()
Ejemplo n.º 4
0
    def update_catalog_entries(self, unit, files):
        """
        Update entries to the deferred downloading (lazy) catalog.

        :param unit: A distribution model object.
        :type unit: pulp_rpm.plugins.db.models.Distribution
        :param files: List of distribution files.
        :type files: list
        """
        for _file in files:
            root = unit.storage_path
            entry = LazyCatalogEntry()
            entry.path = os.path.join(root, _file[RELATIVE_PATH])
            entry.url = urljoin(self.feed, _file[RELATIVE_PATH])
            entry.unit_id = unit.id
            entry.unit_type_id = unit.type_id
            entry.importer_id = str(self.parent.conduit.importer_object_id)
            entry.checksum = _file[CHECKSUM]
            entry.checksum_algorithm = _file[CHECKSUM_TYPE]
            entry.save_revision()
Ejemplo n.º 5
0
    def add(self, unit, path):
        """
        Add the specified content unit to the catalog.

        :param unit: A unit being added.
        :type unit: pulp_rpm.plugins.db.models.RpmBase
        :param path: The relative path within the upstream YUM repository
#           used to construct the download URL.
        :type path: str
        """
        unit.set_storage_path(unit.filename)
        entry = LazyCatalogEntry()
        entry.path = unit.storage_path
        entry.importer_id = str(self.importer_id)
        entry.unit_id = unit.id
        entry.unit_type_id = unit.type_id
        entry.url = urljoin(self.base_url, path)
        entry.checksum = unit.checksum
        entry.checksum_algorithm = unit.checksumtype
        entry.save_revision()
Ejemplo n.º 6
0
    def update_catalog_entries(self, unit, files):
        """
        Update entries to the deferred downloading (lazy) catalog.

        :param unit: A distribution model object.
        :type unit: pulp_rpm.plugins.db.models.Distribution
        :param files: List of distribution files.
        :type files: list
        """
        for _file in files:
            root = unit.storage_path
            entry = LazyCatalogEntry()
            entry.path = os.path.join(root, _file[RELATIVE_PATH])
            entry.url = urljoin(self.feed, _file[RELATIVE_PATH])
            entry.unit_id = unit.id
            entry.unit_type_id = unit.type_id
            entry.importer_id = str(self.parent.conduit.importer_object_id)
            entry.save_revision()
Ejemplo n.º 7
0
    def add_catalog_entries(self, units):
        """
        Add entries to the deferred downloading (lazy) catalog.

        :param units: A list of: pulp_rpm.plugins.db.models.ISO.
        :type units: list
        """
        for unit in units:
            unit.set_storage_path(unit.name)
            entry = LazyCatalogEntry()
            entry.path = unit.storage_path
            entry.importer_id = str(self.sync_conduit.importer_object_id)
            entry.unit_id = unit.id
            entry.unit_type_id = unit.type_id
            entry.url = unit.url
            entry.save_revision()
Ejemplo n.º 8
0
    def catalog_generator(self, base_url, units):
        """
        Provides a wrapper around the *units* generator.
        As the generator is iterated, the deferred downloading (lazy) catalog entry is added.

        :param base_url: The base download URL.
        :type base_url: str
        :param units: A generator of (rpm|drpm) units.
        :return: A generator of units.
        :rtype: generator
        """
        for unit in units:
            unit.set_storage_path(unit.filename)
            entry = LazyCatalogEntry()
            entry.path = unit.storage_path
            entry.importer_id = str(self.conduit.importer_object_id)
            entry.unit_id = unit.id
            entry.unit_type_id = unit.type_id
            entry.url = urljoin(base_url, unit.download_path)
            entry.checksum = unit.checksum
            entry.checksum_algorithm = unit.checksumtype
            entry.save_revision()
            yield unit
Ejemplo n.º 9
0
    def catalog_generator(self, base_url, units):
        """
        Provides a wrapper around the *units* generator.
        As the generator is iterated, the deferred downloading (lazy) catalog entry is added.

        :param base_url: The base download URL.
        :type base_url: str
        :param units: A generator of (rpm|drpm) units.
        :return: A generator of units.
        :rtype: generator
        """
        for unit in units:
            unit.set_storage_path(unit.filename)
            entry = LazyCatalogEntry()
            entry.path = unit.storage_path
            entry.importer_id = str(self.conduit.importer_object_id)
            entry.unit_id = unit.id
            entry.unit_type_id = unit.type_id
            entry.url = urljoin(base_url, unit.relativepath)
            entry.save_revision()
            yield unit
Ejemplo n.º 10
0
    def add_catalog_entries(self, units):
        """
        Add entries to the deferred downloading (lazy) catalog.

        Skip entries which are not eligible for lazy catalog.
        (Don't have url attribute.)

        :param units: A list of: pulp_rpm.plugins.db.models.ISO.
        :type units: list
        """
        for unit in units:
            # Unit is from pulp manifest
            if not hasattr(unit, "url"):
                continue
            if not unit.storage_path:
                unit.set_storage_path(unit.name)
            entry = LazyCatalogEntry()
            entry.path = unit.storage_path
            entry.importer_id = str(self.sync_conduit.importer_object_id)
            entry.unit_id = unit.id
            entry.unit_type_id = unit.type_id
            entry.url = unit.url
            entry.checksum = unit.checksum
            # The current ISO model does not define a checksum type, but appears to use sha256.
            # Once the model includes the checksum type, this should use that field.
            entry.checksum_algorithm = 'sha256'
            entry.save_revision()
Ejemplo n.º 11
0
    def add(self, unit):
        """
        Add the specified content unit to the catalog.

        :param unit: A unit being added.
        :type unit: pulp_rpm.plugins.db.models.RpmBase
        """
        unit.set_storage_path(unit.filename)
        entry = LazyCatalogEntry()
        entry.path = unit.storage_path
        entry.importer_id = str(self.importer_id)
        entry.unit_id = unit.id
        entry.unit_type_id = unit.type_id
        entry.url = urljoin(self.base_url, unit.download_path)
        entry.checksum = unit.checksum
        entry.checksum_algorithm = unit.checksumtype
        entry.save_revision()