def run(self): """Set up the installation source.""" log.debug("Setting up NFS source: %s", self._url) for mount_point in [self._device_mount, self._iso_mount]: if os.path.ismount(mount_point): raise SourceSetupError("The mount point {} is already in use.".format( mount_point )) options, host, path = parse_nfs_url(self._url) path, image = self._split_iso_from_path(path) try: self._mount_nfs(host, options, path) except PayloadSetupError: raise SourceSetupError("Could not mount NFS url '{}'".format(self._url)) iso_source_path = join_paths(self._device_mount, image) if image else self._device_mount iso_name = find_and_mount_iso_image(iso_source_path, self._iso_mount) if iso_name: log.debug("Using the ISO '%s' mounted at '%s'.", iso_name, self._iso_mount) return self._iso_mount if verify_valid_repository(self._device_mount): log.debug("Using the directory at '%s'.", self._device_mount) return self._device_mount # nothing found unmount the existing device unmount(self._device_mount) raise SourceSetupError( "Nothing useful found for NFS source at {}".format(self._url))
def run(self): """Set up the installation source.""" log.debug("Setting up NFS source: %s", self._url) for mount_point in [self._device_mount, self._iso_mount]: if os.path.ismount(mount_point): raise SourceSetupError( "The mount point {} is already in use.".format( mount_point)) try: self._mount_nfs() except PayloadSetupError: raise SourceSetupError("Could not mount NFS url '{}'".format( self._url)) iso_name = find_and_mount_iso_image(self._device_mount, self._iso_mount) if iso_name: log.debug("Using the ISO '%s' mounted at '%s'.", iso_name, self._iso_mount) return self._iso_mount if verify_valid_installtree(self._device_mount): log.debug("Using the directory at '%s'.", self._device_mount) return self._device_mount # nothing found unmount the existing device unmount(self._device_mount) raise SourceSetupError( "Nothing useful found for NFS source at {}".format(self._url))
def find_and_mount_iso_image_fail_find_test(self, find_first_iso_image_mock,): """Test find_and_mount_iso_image failure to find iso.""" source_path = "/super/cool/secret/base" mount_path = "/less/cool/secret/base" iso_name = find_and_mount_iso_image(source_path, mount_path) find_first_iso_image_mock.assert_called_once_with(source_path) self.assertEqual(iso_name, "")
def run(self): """Run Hard drive installation source setup. Always sets up two mount points: First for the device, and second for the ISO image or a bind for unpacked ISO. These depend on each other, and must be destroyed in the correct order again. :raise: SourceSetupError :return: named tuple with path to the install tree and name of ISO if set or empty string :rtype: SetupHardDriveResult instance """ log.debug("Setting up Hard drive source") for mount_point in [self._device_mount, self._iso_mount]: if os.path.ismount(mount_point): raise SourceSetupError( "The mount point {} is already in use.".format( mount_point)) if not find_and_mount_device(self._partition, self._device_mount): raise SourceSetupError( "Could not mount device specified as {}".format( self._partition)) full_path_on_mounted_device = os.path.normpath("{}/{}".format( self._device_mount, self._directory)) iso_name = find_and_mount_iso_image(full_path_on_mounted_device, self._iso_mount) if iso_name: log.debug("Using the ISO '%s' mounted at '%s'.", iso_name, self._iso_mount) return SetupHardDriveResult(self._iso_mount, iso_name) if verify_valid_repository(full_path_on_mounted_device): log.debug("Using the directory at '%s'.", full_path_on_mounted_device) return SetupHardDriveResult(full_path_on_mounted_device, "") # nothing found unmount the existing device unmount(self._device_mount) raise SourceSetupError( "Nothing useful found for Hard drive ISO source at partition={} directory={}" .format(self._partition, self._directory))
def find_and_mount_iso_image_fail_mount_test( self, mount_mock, find_first_iso_image_mock, ): """Test find_and_mount_iso_image failure to mount iso.""" source_path = "/super/cool/secret/base" mount_path = "/less/cool/secret/base" iso_name = find_and_mount_iso_image(source_path, mount_path) find_first_iso_image_mock.assert_called_once_with(source_path) mount_mock.assert_called_once_with(source_path + "/" + "skynet.iso", mount_path, fstype="iso9660", options="ro") self.assertEqual(iso_name, "")
def test_find_and_mount_iso_image( self, mount_mock, find_first_iso_image_mock, ): """Test find_and_mount_iso_image basic run.""" source_path = "/super/cool/secret/base" mount_path = "/less/cool/secret/base" iso_name = find_and_mount_iso_image(source_path, mount_path) find_first_iso_image_mock.assert_called_once_with(source_path) mount_mock.assert_called_once_with(source_path + "/" + "skynet.iso", mount_path, fstype="iso9660", options="ro") assert iso_name == "skynet.iso"
def run(self): """Run Hard drive installation source setup. Always sets up two mount points: First for the device, and second for the ISO image or a bind for unpacked ISO. These depend on each other, and must be destroyed in the correct order again. :raise: SourceSetupError :return: path to the install tree :rtype: str """ log.debug("Setting up Hard drive source") for mount_point in [self._device_mount, self._iso_mount]: if os.path.ismount(mount_point): raise SourceSetupError( "The mount point {} is already in use.".format( mount_point)) if not find_and_mount_device(self._partition, self._device_mount): raise SourceSetupError( "Could not mount device specified as {}".format( self._partition)) full_path_on_mounted_device = os.path.normpath("{}/{}".format( self._device_mount, self._directory)) if find_and_mount_iso_image(full_path_on_mounted_device, self._iso_mount): return self._iso_mount, True elif verify_valid_installtree(full_path_on_mounted_device): return full_path_on_mounted_device, False raise SourceSetupError( "Nothing useful found for Hard drive ISO source at partition={} directory={}" .format(self._partition, self._directory))