def process_main(self): """ Gets an iterable of units that were downloaded from the parent step, moves their files into permanent storage, and then saves the unit into the database and into the repository. """ _logger.debug(self.description) for unit_key in self.parent.step_get_local_units.units_to_download: image_id = unit_key['image_id'] with open(os.path.join(self.working_dir, image_id, 'json')) as json_file: metadata = json.load(json_file) # at least one old docker image did not have a size specified in # its metadata size = metadata.get('Size') # an older version of docker used a lowercase "p" parent = metadata.get('parent', metadata.get('Parent')) model = DockerImage(image_id, parent, size) unit = self.get_conduit().init_unit(model.TYPE_ID, model.unit_key, model.unit_metadata, model.relative_path) self.move_files(unit) _logger.debug('saving image %s' % image_id) self.get_conduit().save_unit(unit) _logger.debug('updating tags for repo %s' % self.get_repo().id) tags.update_tags(self.get_repo().id, self.parent.tags)
def update_tags(repo_id, tarfile_path): """ Gets the current scratchpad's tags and updates them with the tags contained in the tarfile. :param repo_id: unique ID of a repository :type repo_id: basestring :param tarfile_path: full path to a tarfile that is the product of "docker save" :type tarfile_path: basestring """ new_tags = tarutils.get_tags(tarfile_path) tags.update_tags(repo_id, new_tags)