예제 #1
0
    def test_mask_shared_parents_multiple_leaves(self):
        # Test for metadata having shared parents and multiple leaves
        images = upload.get_models(metadata_shared_parents_multiple_leaves, mask_id='id3')

        self.assertEqual(len(images), 3)
        for i in images:
            self.assertTrue(i.image_id in ['id1', 'id2', 'id4'])
예제 #2
0
    def test_mask_shared_parents_multiple_leaves(self):
        # Test for metadata having shared parents and multiple leaves
        models = upload.get_models(metadata_shared_parents_multiple_leaves,
                                   mask_id='id3')

        self.assertEqual(len(models), 3)
        for m in models:
            self.assertTrue(m.image_id in ['id1', 'id2', 'id4'])
예제 #3
0
    def test_mask(self):
        # Test for simple metadata
        models = upload.get_models(metadata, mask_id='id3')

        self.assertEqual(len(models), 2)
        # make sure this only returns the first two and masks the others
        for m in models:
            self.assertTrue(m.image_id in ['id1', 'id2'])
예제 #4
0
    def test_mask(self):
        # Test for simple metadata
        images = upload.get_models(metadata, mask_id='id3')

        self.assertEqual(len(images), 2)
        # make sure this only returns the first two and masks the others
        for i in images:
            self.assertTrue(i.image_id in ['id1', 'id2'])
예제 #5
0
    def test_full_metadata(self):
        # Test for simple metadata
        models = upload.get_models(metadata)

        self.assertEqual(len(models), len(metadata))
        for m in models:
            self.assertTrue(isinstance(m, DockerImage))
            self.assertTrue(m.image_id in metadata)

        ids = [m.image_id for m in models]
        self.assertEqual(set(ids), set(metadata.keys()))
예제 #6
0
    def test_full_metadata_shared_parents_multiple_leaves(self):
        # Test for metadata having shared parents and multiple leaves
        images = upload.get_models(metadata_shared_parents_multiple_leaves)

        self.assertEqual(len(images), len(metadata_shared_parents_multiple_leaves))
        for i in images:
            self.assertTrue(isinstance(i, models.Image))
            self.assertTrue(i.image_id in metadata_shared_parents_multiple_leaves)

        ids = [i.image_id for i in images]
        self.assertEqual(set(ids), set(metadata_shared_parents_multiple_leaves.keys()))
예제 #7
0
    def test_full_metadata(self):
        # Test for simple metadata
        images = upload.get_models(metadata)

        self.assertEqual(len(images), len(metadata))
        for i in images:
            self.assertTrue(isinstance(i, models.Image))
            self.assertTrue(i.image_id in metadata)

        ids = [i.image_id for i in images]
        self.assertEqual(set(ids), set(metadata.keys()))
예제 #8
0
    def test_full_metadata(self):
        # Test for simple metadata
        models = upload.get_models(metadata)

        self.assertEqual(len(models), len(metadata))
        for m in models:
            self.assertTrue(isinstance(m, DockerImage))
            self.assertTrue(m.image_id in metadata)

        ids = [m.image_id for m in models]
        self.assertEqual(set(ids), set(metadata.keys()))
예제 #9
0
    def test_full_metadata_shared_parents_multiple_leaves(self):
        # Test for metadata having shared parents and multiple leaves
        models = upload.get_models(metadata_shared_parents_multiple_leaves)

        self.assertEqual(len(models),
                         len(metadata_shared_parents_multiple_leaves))
        for m in models:
            self.assertTrue(isinstance(m, DockerImage))
            self.assertTrue(
                m.image_id in metadata_shared_parents_multiple_leaves)

        ids = [m.image_id for m in models]
        self.assertEqual(set(ids),
                         set(metadata_shared_parents_multiple_leaves.keys()))
예제 #10
0
    def upload_unit(self, repo, type_id, unit_key, metadata, file_path, conduit, config):
        """
        Upload a docker image. The file should be the product of "docker save".
        This will import all images in that tarfile into the specified
        repository, each as an individual unit. This will also update the
        repo's tags to reflect the tags present in the tarfile.

        The following is copied from the superclass.

        :param repo:      metadata describing the repository
        :type  repo:      pulp.plugins.model.Repository
        :param type_id:   type of unit being uploaded
        :type  type_id:   str
        :param unit_key:  identifier for the unit, specified by the user
        :type  unit_key:  dict
        :param metadata:  any user-specified metadata for the unit
        :type  metadata:  dict
        :param file_path: path on the Pulp server's filesystem to the temporary location of the
                          uploaded file; may be None in the event that a unit is comprised entirely
                          of metadata and has no bits associated
        :type  file_path: str
        :param conduit:   provides access to relevant Pulp functionality
        :type  conduit:   pulp.plugins.conduits.unit_add.UnitAddConduit
        :param config:    plugin configuration for the repository
        :type  config:    pulp.plugins.config.PluginCallConfiguration
        :return:          A dictionary describing the success or failure of the upload. It must
                          contain the following keys:
                            'success_flag': bool. Indicates whether the upload was successful
                            'summary':      json-serializable object, providing summary
                            'details':      json-serializable object, providing details
        :rtype:           dict
        """
        # retrieve metadata from the tarball
        metadata = tarutils.get_metadata(file_path)
        # turn that metadata into a collection of models
        mask_id = config.get(constants.CONFIG_KEY_MASK_ID)
        models = upload.get_models(metadata, mask_id)
        ancestry = tarutils.get_ancestry(models[0].image_id, metadata)
        # save those models as units in pulp
        upload.save_models(conduit, models, ancestry, file_path)
        upload.update_tags(repo.id, file_path)
예제 #11
0
    def upload_unit(self, repo, type_id, unit_key, metadata, file_path, conduit, config):
        """
        Upload a docker image. The file should be the product of "docker save".
        This will import all images in that tarfile into the specified
        repository, each as an individual unit. This will also update the
        repo's tags to reflect the tags present in the tarfile.

        The following is copied from the superclass.

        :param repo:      metadata describing the repository
        :type  repo:      pulp.plugins.model.Repository
        :param type_id:   type of unit being uploaded
        :type  type_id:   str
        :param unit_key:  identifier for the unit, specified by the user
        :type  unit_key:  dict
        :param metadata:  any user-specified metadata for the unit
        :type  metadata:  dict
        :param file_path: path on the Pulp server's filesystem to the temporary location of the
                          uploaded file; may be None in the event that a unit is comprised entirely
                          of metadata and has no bits associated
        :type  file_path: str
        :param conduit:   provides access to relevant Pulp functionality
        :type  conduit:   pulp.plugins.conduits.unit_add.UnitAddConduit
        :param config:    plugin configuration for the repository
        :type  config:    pulp.plugins.config.PluginCallConfiguration
        :return:          A dictionary describing the success or failure of the upload. It must
                          contain the following keys:
                            'success_flag': bool. Indicates whether the upload was successful
                            'summary':      json-serializable object, providing summary
                            'details':      json-serializable object, providing details
        :rtype:           dict
        """
        # retrieve metadata from the tarball
        metadata = tarutils.get_metadata(file_path)
        # turn that metadata into a collection of models
        mask_id = config.get(constants.CONFIG_KEY_MASK_ID)
        models = upload.get_models(metadata, mask_id)
        ancestry = tarutils.get_ancestry(models[0].image_id, metadata)
        # save those models as units in pulp
        upload.save_models(conduit, models, ancestry, file_path)
        upload.update_tags(repo.id, file_path)