Пример #1
0
    def distributor_removed(self, repo, config):
        """
        Called when a distributor of this type is removed from a repository.
        This hook allows the distributor to clean up any files that may have
        been created during the actual publishing.

        The distributor may use the contents of the working directory in cleanup.
        It is not required that the contents of this directory be deleted by
        the distributor; Pulp will ensure it is wiped following this call.

        If this call raises an exception, the distributor will still be removed
        from the repository and the working directory contents will still be
        wiped by Pulp.

        :param repo: metadata describing the repository
        :type  repo: pulp.plugins.model.Repository

        :param config: plugin configuration
        :type  config: pulp.plugins.config.PluginCallConfiguration
        """
        # remove the directories that might have been created for this repo/distributor
        dir_list = [
            repo.working_dir,
            configuration.get_master_publish_dir(repo.repo_obj, config),
            configuration.get_web_publish_dir(repo.repo_obj, config)
        ]

        for repo_dir in dir_list:
            # in case repo_dir is None
            # ignore_errors set to True does not cover this.
            if repo_dir:
                shutil.rmtree(repo_dir, ignore_errors=True)
Пример #2
0
    def __init__(self, repo, conduit, config):
        """
        :param repo: Pulp managed Yum repository
        :type  repo: pulp.plugins.model.Repository
        :param conduit: Conduit providing access to relative Pulp functionality
        :type  conduit: pulp.plugins.conduits.repo_publish.RepoPublishConduit
        :param config: Pulp configuration for the distributor
        :type  config: pulp.plugins.config.PluginCallConfiguration
        """
        super(WebPublisher, self).__init__(
            constants.PUBLISH_STEP_WEB_PUBLISHER,
            repo,
            conduit,
            config)

        publish_dir = configuration.get_web_publish_dir(repo, config)
        self.web_working_dir = os.path.join(self.get_working_dir(), repo.id)
        master_publish_dir = configuration.get_master_publish_dir(repo, config)
        atomic_publish = AtomicDirectoryPublishStep(
            self.get_working_dir(),
            [(repo.id, publish_dir)],
            master_publish_dir,
            step_type=constants.PUBLISH_STEP_OVER_HTTP)

        atomic_publish.description = _('Making files available via web.')

        main = MainStep()
        self.add_child(main)
        self.add_child(atomic_publish)
        mkdir(self.web_working_dir)
Пример #3
0
    def distributor_removed(self, repo, config):
        """
        Called when a distributor of this type is removed from a repository.
        This hook allows the distributor to clean up any files that may have
        been created during the actual publishing.

        The distributor may use the contents of the working directory in cleanup.
        It is not required that the contents of this directory be deleted by
        the distributor; Pulp will ensure it is wiped following this call.

        If this call raises an exception, the distributor will still be removed
        from the repository and the working directory contents will still be
        wiped by Pulp.

        :param repo: metadata describing the repository
        :type  repo: pulp.plugins.model.Repository

        :param config: plugin configuration
        :type  config: pulp.plugins.config.PluginCallConfiguration
        """
        # remove the directories that might have been created for this repo/distributor
        dir_list = [repo.working_dir,
                    configuration.get_master_publish_dir(repo.repo_obj, config),
                    configuration.get_web_publish_dir(repo.repo_obj, config)]

        for repo_dir in dir_list:
            # in case repo_dir is None
            # ignore_errors set to True does not cover this.
            if repo_dir:
                shutil.rmtree(repo_dir, ignore_errors=True)
Пример #4
0
 def __init__(self, repo, conduit, config, working_dir=None, **kwargs):
     """
     :param repo: The repository being published.
     :type  repo: pulp.plugins.model.Repository
     :param conduit: Conduit providing access to relative Pulp functionality
     :type  conduit: pulp.plugins.conduits.repo_publish.RepoPublishConduit
     :param config: Pulp configuration for the distributor
     :type  config: pulp.plugins.config.PluginCallConfiguration
     :param working_dir: The temp directory this step should use for processing.
     :type  working_dir: str
     """
     super(WebPublisher,
           self).__init__(step_type=constants.PUBLISH_STEP_WEB_PUBLISHER,
                          repo=repo,
                          conduit=conduit,
                          config=config,
                          working_dir=working_dir,
                          plugin_type=constants.WEB_DISTRIBUTOR_TYPE_ID,
                          **kwargs)
     self.publish_dir = os.path.join(self.get_working_dir(), repo.id)
     atomic_publish = AtomicDirectoryPublishStep(
         self.get_working_dir(),
         [(repo.id, configuration.get_web_publish_dir(
             repo.repo_obj, config))],
         configuration.get_master_publish_dir(repo.repo_obj, config),
         step_type=constants.PUBLISH_STEP_OVER_HTTP)
     atomic_publish.description = _('Making files available via web.')
     main = MainStep(config=config)
     self.add_child(main)
     self.add_child(atomic_publish)
     mkdir(self.publish_dir)
Пример #5
0
 def __init__(self, repo, conduit, config, working_dir=None, **kwargs):
     """
     :param repo: The repository being published.
     :type  repo: pulp.plugins.model.Repository
     :param conduit: Conduit providing access to relative Pulp functionality
     :type  conduit: pulp.plugins.conduits.repo_publish.RepoPublishConduit
     :param config: Pulp configuration for the distributor
     :type  config: pulp.plugins.config.PluginCallConfiguration
     :param working_dir: The temp directory this step should use for processing.
     :type  working_dir: str
     """
     super(WebPublisher, self).__init__(
         step_type=constants.PUBLISH_STEP_WEB_PUBLISHER,
         repo=repo,
         conduit=conduit,
         config=config,
         working_dir=working_dir,
         plugin_type=constants.WEB_DISTRIBUTOR_TYPE_ID,
         **kwargs)
     self.publish_dir = os.path.join(self.get_working_dir(), repo.id)
     atomic_publish = AtomicDirectoryPublishStep(
         self.get_working_dir(),
         [(repo.id, configuration.get_web_publish_dir(repo.repo_obj, config))],
         configuration.get_master_publish_dir(repo.repo_obj, config),
         step_type=constants.PUBLISH_STEP_OVER_HTTP)
     atomic_publish.description = _('Making files available via web.')
     main = MainStep()
     self.add_child(main)
     self.add_child(atomic_publish)
     mkdir(self.publish_dir)
Пример #6
0
    def __init__(self, repo, conduit, config):
        """
        :param repo: Pulp managed Yum repository
        :type  repo: pulp.plugins.model.Repository
        :param conduit: Conduit providing access to relative Pulp functionality
        :type  conduit: pulp.plugins.conduits.repo_publish.RepoPublishConduit
        :param config: Pulp configuration for the distributor
        :type  config: pulp.plugins.config.PluginCallConfiguration
        """
        super(WebPublisher,
              self).__init__(constants.PUBLISH_STEP_WEB_PUBLISHER, repo,
                             conduit, config)

        publish_dir = configuration.get_web_publish_dir(repo, config)
        self.web_working_dir = os.path.join(self.get_working_dir(), repo.id)
        master_publish_dir = configuration.get_master_publish_dir(repo, config)
        atomic_publish = AtomicDirectoryPublishStep(
            self.get_working_dir(), [(repo.id, publish_dir)],
            master_publish_dir,
            step_type=constants.PUBLISH_STEP_OVER_HTTP)

        atomic_publish.description = _('Making files available via web.')

        main = MainStep()
        self.add_child(main)
        self.add_child(atomic_publish)
        mkdir(self.web_working_dir)
Пример #7
0
    def __init__(self, repo, publish_conduit, config):
        """
        :param repo: Pulp managed Yum repository
        :type  repo: pulp.plugins.model.Repository
        :param publish_conduit: Conduit providing access to relative Pulp functionality
        :type  publish_conduit: pulp.plugins.conduits.repo_publish.RepoPublishConduit
        :param config: Pulp configuration for the distributor
        :type  config: pulp.plugins.config.PluginCallConfiguration
        """
        super(WebPublisher, self).__init__(constants.PUBLISH_STEP_WEB_PUBLISHER,
                                           repo, publish_conduit, config)

        publish_dir = configuration.get_web_publish_dir(repo, config)
        self.web_working_dir = os.path.join(self.get_working_dir(), repo.id)
        master_publish_dir = configuration.get_master_publish_dir(repo, config)
        atomic_publish_step = AtomicDirectoryPublishStep(self.get_working_dir(),
                                                         [(repo.id, publish_dir)],
                                                         master_publish_dir,
                                                         step_type=constants.PUBLISH_STEP_OVER_HTTP)
        atomic_publish_step.description = _('Making files available via web.')

        repo = self.get_repo()
        if not repo.content_unit_counts:
            self.add_child(CreateEmptyOSTreeStep())
        else:
            os.makedirs(self.web_working_dir)
            content_step = PublishContentStep(working_dir=self.web_working_dir)
            self.add_child(content_step)
            self.add_child(PublishRefsStep(content_step, working_dir=self.web_working_dir))

        self.add_child(atomic_publish_step)
Пример #8
0
 def test_get_master_publish_dir(self):
     directory = configuration.get_master_publish_dir(self.repo, self.config)
     self.assertEquals(directory, os.path.join(self.publish_dir, 'master', self.repo.id))
Пример #9
0
 def test_get_master_publish_dir(self):
     directory = configuration.get_master_publish_dir(
         self.repo, self.config)
     self.assertEquals(
         directory,
         os.path.join(self.publish_dir, 'master', self.repo.repo_id))