def initialize(self): """ Initialize the metadata contexts """ self.redirect_context = RedirectFileContext( self.parent.get_working_dir(), self.get_conduit(), self.parent.config, self.get_repo()) self.redirect_context.initialize()
def initialize(self): """ Initialize the metadata contexts """ self.redirect_context = RedirectFileContext( self.parent.get_working_dir(), self.get_conduit(), self.parent.config, self.get_repo() ) self.redirect_context.initialize()
class PublishImagesStep(UnitModelPluginStep): """ Publish Images """ def __init__(self, repo_content_unit_q=None): super(PublishImagesStep, self).__init__(step_type=constants.PUBLISH_STEP_IMAGES, model_classes=[models.Image], repo_content_unit_q=repo_content_unit_q) self.context = None self.redirect_context = None self.description = _('Publishing Image Files.') def initialize(self): """ Initialize the metadata contexts """ self.redirect_context = RedirectFileContext(self.parent.get_working_dir(), self.get_conduit(), self.parent.config, self.get_repo()) self.redirect_context.initialize() def process_main(self, item): """ Link the unit to the image content directory and the package_dir :param item: The Image to process :type item: pulp_docker.common.models.Image """ self.redirect_context.add_unit_metadata(item) target_base = os.path.join(self.get_web_directory(), item.unit_key['image_id']) files = ['ancestry', 'json', 'layer'] for file_name in files: misc.create_symlink(os.path.join(item.storage_path, file_name), os.path.join(target_base, file_name)) def finalize(self): """ Close & finalize each the metadata context """ if self.redirect_context: self.redirect_context.finalize() def get_web_directory(self): """ Get the directory where the files published to the web have been linked """ return os.path.join(self.parent.get_working_dir(), 'web')
class PublishImagesStep(UnitModelPluginStep): """ Publish Images """ def __init__(self, repo_content_unit_q=None): super(PublishImagesStep, self).__init__(step_type=constants.PUBLISH_STEP_IMAGES, model_classes=[models.Image], repo_content_unit_q=repo_content_unit_q) self.context = None self.redirect_context = None self.description = _('Publishing Image Files.') def initialize(self): """ Initialize the metadata contexts """ self.redirect_context = RedirectFileContext( self.parent.get_working_dir(), self.get_conduit(), self.parent.config, self.get_repo()) self.redirect_context.initialize() def process_main(self, item): """ Link the unit to the image content directory and the package_dir :param item: The Image to process :type item: pulp_docker.common.models.Image """ self.redirect_context.add_unit_metadata(item) target_base = os.path.join(self.get_web_directory(), item.unit_key['image_id']) files = ['ancestry', 'json', 'layer'] for file_name in files: misc.create_symlink(os.path.join(item.storage_path, file_name), os.path.join(target_base, file_name)) def finalize(self): """ Close & finalize each the metadata context """ if self.redirect_context: self.redirect_context.finalize() def get_web_directory(self): """ Get the directory where the files published to the web have been linked """ return os.path.join(self.parent.get_working_dir(), 'web')
class PublishImagesStep(UnitPublishStep): """ Publish Images """ def __init__(self): super(PublishImagesStep, self).__init__(constants.PUBLISH_STEP_IMAGES, constants.IMAGE_TYPE_ID) self.context = None self.redirect_context = None self.description = _("Publishing Image Files.") def initialize(self): """ Initialize the metadata contexts """ self.redirect_context = RedirectFileContext( self.parent.get_working_dir(), self.get_conduit(), self.parent.config, self.get_repo() ) self.redirect_context.initialize() def process_unit(self, unit): """ Link the unit to the image content directory and the package_dir :param unit: The unit to process :type unit: pulp_docker.common.models.Image """ self.redirect_context.add_unit_metadata(unit) target_base = os.path.join(self.get_web_directory(), unit.unit_key["image_id"]) files = ["ancestry", "json", "layer"] for file_name in files: self._create_symlink(os.path.join(unit.storage_path, file_name), os.path.join(target_base, file_name)) def finalize(self): """ Close & finalize each the metadata context """ if self.redirect_context: self.redirect_context.finalize() def get_web_directory(self): """ Get the directory where the files published to the web have been linked """ return os.path.join(self.parent.get_working_dir(), "web")
class PublishImagesStep(PluginStep): """ Publish Images """ def __init__(self): super(PublishImagesStep, self).__init__(constants.PUBLISH_STEP_IMAGES) self.context = None self.redirect_context = None self.description = _('Publishing Image Files.') def initialize(self): """ Initialize the metadata contexts """ self.redirect_context = RedirectFileContext(self.get_working_dir(), self.get_conduit(), self.parent.config, self.get_repo()) self.redirect_context.initialize() def get_total(self): """ Get the total number of images to publish. The value returned should not change during the processing of the step. :returns: The total number of images to publish :rtype: int """ repo = self.get_repo() return repo.content_unit_counts.get(constants.IMAGE_TYPE_ID, 0) def get_iterator(self): """ This method returns a generator to loop over items. The items created by this generator will be iterated over by the process_main method. :return: a list or other iterable :rtype: iterator of pulp_docker.plugins.db.models.DockerImage """ return repo_controller.find_repo_content_units( self.get_repo(), repo_content_unit_q=Q(unit_type_id=constants.IMAGE_TYPE_ID), yield_content_unit=True) def process_main(self, item=None): """ Link the unit to the image content directory and the package_dir :param item: The unit to process :type item: pulp_docker.plugins.db.models.DockerImage """ self.redirect_context.add_unit_metadata(item) target_base = os.path.join(self.get_web_directory(), item.image_id) files = ['ancestry', 'json', 'layer'] for file_name in files: plugin_utils.create_symlink(os.path.join(item.storage_path, file_name), os.path.join(target_base, file_name)) def finalize(self): """ Close & finalize each the metadata context """ if self.redirect_context: self.redirect_context.finalize() def get_web_directory(self): """ Get the directory where the files published to the web have been linked """ return os.path.join(self.get_working_dir(), 'web')