Esempio n. 1
0
    def remove_unit(self, unit):
        """
        Removes the association between the given content unit and the repository
        being synchronized.

        This call will only remove the association owned by this importer
        between the repository and unit. If the unit was manually associated by
        a user, the repository will retain that instance of the association.

        This call does not delete Pulp's representation of the unit in its
        database. If this call removes the final association of the unit to a
        repository, the unit will become "orphaned" and will be deleted from
        Pulp outside of this plugin.

        Units passed to this call must have their id fields set by the Pulp server.

        This call is idempotent. If no association, owned by this importer, exists
        between the unit and repository, this call has no effect.

        @param unit: unit object (must have its id value set)
        @type  unit: L{Unit}
        """

        try:
            self._association_manager.unassociate_unit_by_id(
                self.repo_id, unit.type_id, unit.id)
            self._removed_count += 1
        except Exception, e:
            _logger.exception(_('Content unit unassociation failed'))
            raise ImporterConduitException(e), None, sys.exc_info()[2]
Esempio n. 2
0
    def associate_unit(self, unit):
        """
        Associates the given unit with the destination repository for the import.

        This call is idempotent. If the association already exists, this call
        will have no effect.

        :param unit: unit object returned from the init_unit call
        :type  unit: pulp.plugins.model.Unit

        :return: object reference to the provided unit
        :rtype:  pulp.plugins.model.Unit
        """

        try:
            self.__association_manager.associate_unit_by_id(
                self.dest_repo_id, unit.type_id, unit.id)
            return unit
        except Exception, e:
            _logger.exception(_('Content unit association failed [%s]' % str(unit)))
            raise ImporterConduitException(e), None, sys.exc_info()[2]