Пример #1
0
    def __init__(self, repo=None, file_path=None, config=None):
        """
        Initialize the UploadStep, configuring the correct children and setting the description.

        :param repo:      repository to sync
        :type  repo:      pulp.plugins.model.Repository
        :param file_path: The path to the tar file uploaded from a 'docker save'
        :type  file_path: str
        """
        super(UploadStep, self).__init__(constants.UPLOAD_STEP, repo=repo,
                                         plugin_type=constants.IMPORTER_TYPE_ID,
                                         config=config, disable_reporting=True)
        self.description = _('Uploading Docker Units')

        self.file_path = file_path

        # populated by ProcessMetadata
        self.metadata = None

        # Units that were part of the uploaded tar file, populated by ProcessMetadata
        self.available_units = []

        # populated by ProcessMetadata
        self.v1_tags = {}

        self.add_child(ProcessMetadata(constants.UPLOAD_STEP_METADATA))
        # save this step so its "units_to_download" attribute can be accessed later
        self.v1_step_get_local_units = GetLocalUnitsStep(constants.IMPORTER_TYPE_ID)
        self.add_child(self.v1_step_get_local_units)
        self.add_child(AddImages(step_type=constants.UPLOAD_STEP_SAVE))
Пример #2
0
 def _handle_image_manifest(self):
     """
     Handles the upload of a v2 s2 docker image
     """
     self.add_child(ProcessManifest(constants.UPLOAD_STEP_IMAGE_MANIFEST))
     self.v2_step_get_local_units = GetLocalUnitsStep(
         constants.IMPORTER_TYPE_ID)
     self.add_child(self.v2_step_get_local_units)
     self.add_child(AddUnits(step_type=constants.UPLOAD_STEP_SAVE))
Пример #3
0
    def _handle_image(self):
        """
        Handles the upload of a v1 docker image
        """

        self.add_child(ProcessMetadata(constants.UPLOAD_STEP_METADATA))
        # save this step so its "units_to_download" attribute can be accessed later
        self.v1_step_get_local_units = GetLocalUnitsStep(
            constants.IMPORTER_TYPE_ID)
        self.add_child(self.v1_step_get_local_units)
        self.add_child(AddImages(step_type=constants.UPLOAD_STEP_SAVE))
Пример #4
0
    def __init__(self, repo, conduit, config, working_dir):
        """
        Initialize the SyncStep and its child steps.

        :param repo:        metadata describing the repository
        :type  repo:        pulp.plugins.model.Repository
        :param conduit:     provides access to relevant Pulp functionality
        :type  conduit:     pulp.plugins.conduits.repo_sync.RepoSyncConduit
        :param config:      plugin configuration
        :type  config:      pulp.plugins.config.PluginCallConfiguration
        :param working_dir: The working directory path that can be used for temporary storage
        :type  working_dir: basestring
        """
        super(SyncStep, self).__init__('sync_step_main', repo, conduit, config,
                                       working_dir, constants.IMPORTER_TYPE_ID)
        self.description = _('Synchronizing %(id)s repository.') % {
            'id': repo.id
        }

        self._validate(config)
        self._feed_url = config.get(importer_constants.KEY_FEED)
        self._project_names = config.get(constants.CONFIG_KEY_PACKAGE_NAMES,
                                         [])
        if self._project_names:
            self._project_names = self._project_names.split(',')

        # Download the json metadata for each project, initialize packages, and place them in the
        # available units list.
        self.available_units = []
        self.add_child(
            DownloadMetadataStep(
                'sync_step_download_metadata',
                repo=repo,
                config=config,
                conduit=conduit,
                working_dir=self.get_working_dir(),
                description=_('Downloading Python metadata.')))

        # Populate a list of `self.get_local_units_step.units_to_download`.
        self.get_local_units_step = GetLocalUnitsStep(
            constants.IMPORTER_TYPE_ID, available_units=self.available_units)
        self.add_child(self.get_local_units_step)

        # Download each package in the units to download list.
        self.add_child(
            DownloadPackagesStep(
                'sync_step_download_packages',
                downloads=self.generate_download_requests(),
                repo=repo,
                config=config,
                conduit=conduit,
                working_dir=self.get_working_dir(),
                description=_('Downloading and processing Python packages.')))
Пример #5
0
 def test_dict_to_unit_not_implemented(self, mock_get_multiple):
     step = GetLocalUnitsStep('fake_importer_type', 'fake_unit_type',
                              ['foo'], '/a/b/c')
     self.assertRaises(NotImplementedError, step._dict_to_unit, {'image_id': 'abc123'})