Пример #1
0
    def distributor_removed(self, repo_transfer, 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_transfer: metadata describing the repository
        :type  repo_transfer: pulp.plugins.model.Repository

        :param config: plugin configuration
        :type  config: pulp.plugins.config.PluginCallConfiguration
        """
        repo = model.Repository.objects.get_repo_or_missing_resource(repo_id=repo_transfer.id)

        # Remove the published app file & directory links
        file_list = [os.path.join(configuration.get_export_repo_directory(config),
                                  configuration.get_export_repo_filename(repo, config))]

        for file_name in file_list:
            try:
                os.unlink(file_name)
            except OSError:
                # It's fine if this file doesn't exist
                pass
Пример #2
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]
        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)

        # Remove the published app file & directory links
        file_list = [os.path.join(configuration.get_export_repo_directory(config, "v1"),
                                  configuration.get_export_repo_directory(config, "v2"),
                                  configuration.get_export_repo_filename(repo, config))]

        for file_name in file_list:
            try:
                os.unlink(file_name)
            except OSError:
                # It's fine if this file doesn't exist
                pass
Пример #3
0
 def test_get_export_repo_file_with_path_default(self):
     result = configuration.get_export_repo_file_with_path(self.repo, self.config, 'v1')
     expected_result = os.path.join(configuration.get_export_repo_directory(self.config, 'v1'),
                                    configuration.get_export_repo_filename(self.repo,
                                                                           self.config))
     self.assertEquals(result, expected_result)
Пример #4
0
 def test_get_export_repo_filename(self):
     filename = configuration.get_export_repo_filename(self.repo, self.config)
     self.assertEquals(filename, "foo.tar")