Exemplo n.º 1
0
 def setUp(self):
     super(TestGetAncestry, self).setUp()
     self.working_dir = tempfile.mkdtemp()
     self.config = DownloaderConfig()
     self.repo = registry.V1Repository('pulp/crane', self.config,
                                       'http://pulpproject.org/',
                                       self.working_dir)
Exemplo n.º 2
0
    def test_init(self):
        config = DownloaderConfig()
        repo = registry.V1Repository('pulp/crane', config, 'http://pulpproject.org/', '/a/b/c')

        self.assertEqual(repo.name, 'pulp/crane')
        self.assertEqual(repo.registry_url, 'http://pulpproject.org/')
        self.assertEqual(repo.working_dir, '/a/b/c')
        self.assertTrue(isinstance(repo.downloader, HTTPThreadedDownloader))
Exemplo n.º 3
0
    def __init__(self, repo=None, conduit=None, config=None):
        """
        This method initializes the SyncStep. It first validates the config to ensure that the
        required keys are present. It then constructs some needed items (such as a download config),
        and determines whether the feed URL is a Docker v2 registry or not. If it is, it
        instantiates child tasks that are appropriate for syncing a v2 registry, and if it is not it
        raises a NotImplementedError.

        :param repo:        repository to sync
        :type  repo:        pulp.plugins.model.Repository
        :param conduit:     sync conduit to use
        :type  conduit:     pulp.plugins.conduits.repo_sync.RepoSyncConduit
        :param config:      config object for the sync
        :type  config:      pulp.plugins.config.PluginCallConfiguration
        """
        super(SyncStep, self).__init__(
            step_type=constants.SYNC_STEP_MAIN, repo=repo, conduit=conduit, config=config,
            plugin_type=constants.IMPORTER_TYPE_ID)
        self.description = _('Syncing Docker Repository')

        self._validate(config)
        download_config = nectar_config.importer_config_to_nectar_config(config.flatten())
        upstream_name = config.get(constants.CONFIG_KEY_UPSTREAM_NAME)
        url = config.get(importer_constants.KEY_FEED)
        # The DownloadMetadataSteps will set these to a list of Manifests and Blobs
        self.available_manifests = []
        self.available_blobs = []

        # Unit keys, populated by v1_sync.GetMetadataStep
        self.v1_available_units = []
        # populated by v1_sync.GetMetadataStep
        self.v1_tags = {}

        # Create a Repository object to interact with.
        self.index_repository = registry.V2Repository(
            upstream_name, download_config, url, self.get_working_dir())
        self.v1_index_repository = registry.V1Repository(upstream_name, download_config, url,
                                                         self.get_working_dir())

        # determine which API versions are supported and add corresponding steps
        v2_enabled = config.get(constants.CONFIG_KEY_ENABLE_V2, default=True)
        v1_enabled = config.get(constants.CONFIG_KEY_ENABLE_V1, default=False)
        if not v2_enabled:
            _logger.debug(_('v2 API skipped due to config'))
        if not v1_enabled:
            _logger.debug(_('v1 API skipped due to config'))
        v2_found = v2_enabled and self.index_repository.api_version_check()
        v1_found = v1_enabled and self.v1_index_repository.api_version_check()
        if v2_found:
            _logger.debug(_('v2 API found'))
            self.add_v2_steps(repo, conduit, config)
        if v1_found:
            _logger.debug(_('v1 API found'))
            self.add_v1_steps(repo, config)
        if not any((v1_found, v2_found)):
            raise PulpCodedException(error_code=error_codes.DKR1008, registry=url)
Exemplo n.º 4
0
 def setUp(self):
     super(TestGetSinglePath, self).setUp()
     self.config = DownloaderConfig()
     self.repo = registry.V1Repository('pulp/crane', self.config,
                                       'http://pulpproject.org/', '/a/b/c')
Exemplo n.º 5
0
 def setUp(self):
     super(TestAddAuthHeader, self).setUp()
     self.config = DownloaderConfig()
     self.repo = registry.V1Repository('pulp/crane', self.config,
                                       'http://pulpproject.org/', '/a/b/')
     self.request = DownloadRequest('http://pulpproject.org', '/a/b/c')
Exemplo n.º 6
0
 def setUp(self):
     super(TestAPIVersionCheck, self).setUp()
     self.config = DownloaderConfig()
     self.repo = registry.V1Repository('pulp/crane', self.config,
                                       'http://pulpproject.org/', '/a/b/c')