def process_main(self, item=None): """ Pull the metadata out of the tar file :param item: Not used by this Step :type item: None """ # retrieve metadata from the tarball metadata = tarutils.get_metadata(self.parent.file_path) # turn that metadata into a collection of models mask_id = self.get_config().get(constants.CONFIG_KEY_MASK_ID) self.parent.metadata = metadata self.parent.available_units = self.get_models(metadata, mask_id) self.parent.v1_tags = tarutils.get_tags(self.parent.file_path)
def test_get_from_busybox(self): metadata = tarutils.get_metadata(busybox_tar_path) self.assertEqual(set(metadata.keys()), set(busybox_ids)) for i, image_id in enumerate(busybox_ids): data = metadata[image_id] if i == len(busybox_ids) - 1: # make sure the base image has parent set to None self.assertTrue(data['parent'] is None) else: # make sure all other layers have the correct parent self.assertEqual(data['parent'], busybox_ids[i + 1]) self.assertTrue(isinstance(data['size'], int))
def test_get_from_busybox(self): metadata = tarutils.get_metadata(busybox_tar_path) self.assertEqual(set(metadata.keys()), set(busybox_ids)) for i, image_id in enumerate(busybox_ids): data = metadata[image_id] if i == len(busybox_ids) - 1: # make sure the base image has parent set to None self.assertTrue(data['parent'] is None) else: # make sure all other layers have the correct parent self.assertEqual(data['parent'], busybox_ids[i + 1]) # this image does not have a Size attribute in its json if image_id.startswith('511136ea'): self.assertTrue(data['size'] is None) else: self.assertTrue(isinstance(data['size'], int))
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)
def test_with_busybox_light(self): metadata = tarutils.get_metadata(busybox_tar_path) ret = tarutils.get_youngest_children(metadata) self.assertEqual(ret, [busybox_ids[0]])
def test_from_busybox(self): metadata = tarutils.get_metadata(busybox_tar_path) ancestry = tarutils.get_ancestry(busybox_ids[0], metadata) self.assertEqual(ancestry, busybox_ids)
def generate_upload_data(self, checksumtype='sha256'): unit_metadata = tarutils.get_metadata(self.path) unit_key = {'image_id': unit_metadata.keys()[0]} return unit_key, unit_metadata