def process_main(self): """ Publish a directory from to a tar file """ image_size = self.get_config().get(constants.ISO_SIZE_KEYWORD) image_prefix = self.get_config().get(constants.ISO_PREFIX_KEYWORD) or self.get_repo().id generate_iso.create_iso(self.content_dir, self.output_dir, image_prefix, image_size)
def publish_isos(working_dir, image_prefix, http_dir=None, https_dir=None, image_size=None, progress_callback=None): """ Generate one or more ISO images containing the given working_dir, and then publish them to the given http and https directories. Not passing a http or https directory means the ISOs won't be published using that method. :param working_dir: The full path to the directory to wrap in ISOs :type working_dir: str :param image_prefix: The prefix of the image filename :type image_prefix: str :param http_dir: The full path to the http export directory. The default base path can be found in pulp_rpm.common.constants and should be suffixed by the group or repo id :type http_dir: str :param https_dir: The full path to the https export directory. The default base path can be found in pulp_rpm.common.constants and should be suffixed by the group or repo id :type https_dir: str :param image_size: The size of the ISO image in megabytes (defaults to dvd sized iso) :type image_size: int :param progress_callback: callback to report progress info to publish_conduit. This is expected to take the following parameters: a string to use as the key in a dictionary, and the second parameter is assigned to it. :type progress_callback: function """ # TODO: Move the ISO output directory # Right now the ISOs live in the working directory because there isn't a better place for them. # When that changes, the output directory argument should be changed here. generate_iso.create_iso(working_dir, working_dir, image_prefix, image_size, progress_callback) # Create the directories, if necessary if https_dir is not None and not os.path.isdir(https_dir): os.makedirs(https_dir) if http_dir is not None and not os.path.isdir(http_dir): os.makedirs(http_dir) # Clean up the working directory, leaving the ISOs. This should change when exported ISOs get # a new home. for root, dirs, files in os.walk(working_dir): for name in dirs: shutil.rmtree(os.path.join(root, name), ignore_errors=True) # Now link the files to the https and http directories, if they exist for name in files: if https_dir: os.symlink(os.path.join(root, name), os.path.join(https_dir, name)) set_progress( "publish_https", {constants.PROGRESS_STATE_KEY: constants.STATE_COMPLETE}, progress_callback ) else: set_progress( "publish_https", {constants.PROGRESS_STATE_KEY: constants.STATE_SKIPPED}, progress_callback ) if http_dir: os.symlink(os.path.join(root, name), os.path.join(http_dir, name)) set_progress( "publish_http", {constants.PROGRESS_STATE_KEY: constants.STATE_COMPLETE}, progress_callback ) else: set_progress("publish_http", {constants.PROGRESS_STATE_KEY: constants.STATE_SKIPPED}, progress_callback)
def test_create_iso(self): """ Test that the create_iso method calls its helpers correctly """ # Assert all the helper methods were called correctly generate_iso.create_iso("/target/dir", "/output/dir", "prefix") generate_iso._get_dir_file_list_and_size.assert_called_once_with("/target/dir") generate_iso._compute_image_files.assert_called_once_with(["files"], generate_iso.DVD_ISO_SIZE * 1024 * 1024) self.assertEqual("list", generate_iso._make_iso.call_args[0][0]) self.assertEqual("/target/dir", generate_iso._make_iso.call_args[0][1]) self.assertEqual("/output/dir", generate_iso._make_iso.call_args[0][2])
def test_create_iso(self): """ Test that the create_iso method calls its helpers correctly """ # Assert all the helper methods were called correctly generate_iso.create_iso('/target/dir', '/output/dir', 'prefix') generate_iso._get_dir_file_list_and_size.assert_called_once_with( '/target/dir') generate_iso._compute_image_files.assert_called_once_with( ['files'], generate_iso.DVD_ISO_SIZE * 1024 * 1024) self.assertEqual('list', generate_iso._make_iso.call_args[0][0]) self.assertEqual('/target/dir', generate_iso._make_iso.call_args[0][1]) self.assertEqual('/output/dir', generate_iso._make_iso.call_args[0][2])