--- virtinst/urlfetcher.py | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/virtinst/urlfetcher.py b/virtinst/urlfetcher.py index 1288668a..5369a985 100644 --- a/virtinst/urlfetcher.py +++ b/virtinst/urlfetcher.py @@ -302,14 +302,7 @@ class _MountedURLFetcher(_LocalURLFetcher): mountcmd = "/bin/mount" logging.debug("Preparing mount at " + self._srcdir) - if self.location.startswith("nfs:"): - cmd = [mountcmd, "-o", "ro", self.location[4:], self._srcdir] - else: - if stat.S_ISBLK(os.stat(self.location)[stat.ST_MODE]): - mountopt = "ro" - else: - mountopt = "ro,loop" - cmd = [mountcmd, "-o", mountopt, self.location, self._srcdir] + cmd = [mountcmd, "-o", "ro", self.location[4:], self._srcdir] logging.debug("mount cmd: %s", cmd) if not self._in_test_suite: @@ -338,6 +331,38 @@ class _MountedURLFetcher(_LocalURLFetcher): self._mounted = False +class _ISOURLFetcher(_URLFetcher): + _cache_file_list = None + + def _make_full_url(self, filename): + return "/" + filename + + def _grabber(self, url): + """ + Use isoinfo to grab the file + """ + cmd = ["isoinfo", "-J", "-i", self.location, "-x", url] + + logging.debug("Running isoinfo: %s", cmd) + output = subprocess.check_output(cmd) + + return io.BytesIO(output), len(output) + + def _hasFile(self, filename): + """ + Use isoinfo to list and search for the file + """ + if not self._cache_file_list: + cmd = ["isoinfo", "-J", "-i", self.location, "-f"] + + logging.debug("Running isoinfo: %s", cmd) + output = subprocess.check_output(cmd) + + self._cache_file_list = output.splitlines(False) + + return filename in self._cache_file_list + + def fetcherForURI(uri, *args, **kwargs): if uri.startswith("http://") or uri.startswith("https://"): fclass = _HTTPURLFetcher @@ -349,8 +374,8 @@ def fetcherForURI(uri, *args, **kwargs): # Pointing to a local tree fclass = _LocalURLFetcher else: - # Pointing to a path, like an .iso to mount - fclass = _MountedURLFetcher + # Pointing to a path (e.g. iso), or a block device (e.g. /dev/cdrom) + fclass = _ISOURLFetcher return fclass(uri, *args, **kwargs) -- 2.14.1 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list