The following patch updates the relevant installer classes
to deal with storage parameters for cdrom media.
A 'conn' attribute is added to all installer classes so
we can provide proper storage lookup and validation. If
a remote conn is specified and a path (presumably to
cdrom media) is passed to 'location', we can attempt to
determine if the path is managed on the connection. So
passing a connection and a managed path on the remote
host should cause everything to just work.
The other change is that 'location' can now be a (poolname,
volname) tuple that it passes off to VirtualDisk's new
volName init parameter.
Thanks,
Cole
# HG changeset patch
# User "Cole Robinson <[EMAIL PROTECTED]>"
# Date 1217990394 14400
# Node ID 01efca5886ba1ce923c75406b4d28dc26c79ebcc
# Parent b665c19355e8bc1439b5be4ecf51284d78d600cc
Make installer location storage api aware.
Allow 'location' to be a (poolname, volname) tuple, Attempt to look up
volumes if location is a path and a connection has been passed.
diff -r b665c19355e8 -r 01efca5886ba virtinst/DistroManager.py
--- a/virtinst/DistroManager.py Tue Aug 05 21:22:56 2008 -0400
+++ b/virtinst/DistroManager.py Tue Aug 05 22:39:54 2008 -0400
@@ -127,18 +127,28 @@
fetcher.cleanupLocation()
class DistroInstaller(Guest.Installer):
- def __init__(self, type = "xen", location = None, boot = None, extraargs = None, os_type = None):
- Guest.Installer.__init__(self, type, location, boot, extraargs, os_type)
+ def __init__(self, type = "xen", location = None, boot = None,
+ extraargs = None, os_type = None, conn = None):
+ Guest.Installer.__init__(self, type, location, boot, extraargs,
+ os_type, conn=conn)
def get_location(self):
return self._location
def set_location(self, val):
+ voltuple = None
+ path = None
# 'location' is kind of overloaded: it can be a local file or device
- # (for a boot.iso), local directory (for a tree), or an http, ftp, or
+ # path (for a boot.iso), a local directory (for a tree), a
+ # tuple of the form (poolname, volname), or an http, ftp, or
# nfs for an iso or a tree
- if os.path.exists(os.path.abspath(val)):
- val = os.path.abspath(val)
- logging.debug("DistroInstaller location is a local file/path: %s" % val)
+ if type(val) is tuple and len(val) == 2:
+ voltuple = val
+ logging.debug("DistroInstaller location is a (poolname, volname)"
+ " tuple")
+ elif os.path.exists(os.path.abspath(val)):
+ path = os.path.abspath(val)
+ logging.debug("DistroInstaller location is a local "
+ "file/path: %s" % path)
elif val.startswith("nfs://"):
# Convert RFC compliant NFS nfs://server/path/to/distro
# to what mount/anaconda expect nfs:server:/path/to/distro
@@ -152,17 +162,35 @@
if val[index - 1] != ":":
val = val[:index] + ":" + val[index:]
- elif not (val.startswith("http://") or val.startswith("ftp://") or
- val.startswith("nfs:")):
- raise ValueError(_("Install media location must be an NFS, HTTP or FTP network install source, or an existing local file/device"))
+ elif (val.startswith("http://") or val.startswith("ftp://") or
+ val.startswith("nfs:")):
+ logging.debug("DistroInstaller location is a network source.")
+ elif self.conn and util.is_storage_capable(self.conn):
+ # If conn is specified, pass the path to a VirtualDisk object
+ # and see what comes back
+ try:
+ v = VirtualDisk(path=val, type=VirtualDisk.DEVICE_CDROM,
+ conn=self.conn)
+ except Exception, e:
+ raise ValueError(_("Checking installer location failed: %s" %\
+ str(e)))
+ else:
+ raise ValueError(_("Install media location must be an NFS, HTTP "
+ "or FTP network install source, or an existing "
+ "local file/device"))
if os.geteuid() != 0 and val.startswith("nfs:"):
raise ValueError(_("NFS installations are only supported as root"))
+
self._location = val
location = property(get_location, set_location)
def _prepare_cdrom(self, guest, distro, meter):
- if self.location.startswith("/") and os.path.exists(self.location):
+ cdrom = None
+ vol_tuple = None
+ if type(self.location) is tuple:
+ vol_tuple = self.location
+ elif self.location.startswith("/") and os.path.exists(self.location):
# Huzzah, a local file/device
cdrom = self.location
else:
@@ -177,7 +205,9 @@
arch = arch)
self._tmpfiles.append(cdrom)
- self._install_disk = VirtualDisk(cdrom,
+ self._install_disk = VirtualDisk(path=cdrom,
+ conn=guest.conn,
+ volName=vol_tuple,
device=VirtualDisk.DEVICE_CDROM,
readOnly=True,
transient=True)
@@ -283,8 +313,10 @@
class PXEInstaller(Guest.Installer):
- def __init__(self, type = "xen", location = None, boot = None, extraargs = None, os_type = None):
- Guest.Installer.__init__(self, type, location, boot, extraargs, os_type)
+ def __init__(self, type = "xen", location = None, boot = None,
+ extraargs = None, os_type = None, conn = None):
+ Guest.Installer.__init__(self, type, location, boot, extraargs,
+ os_type, conn=conn)
def prepare(self, guest, meter, distro = None):
pass
diff -r b665c19355e8 -r 01efca5886ba virtinst/Guest.py
--- a/virtinst/Guest.py Tue Aug 05 21:22:56 2008 -0400
+++ b/virtinst/Guest.py Tue Aug 05 22:39:54 2008 -0400
@@ -273,12 +273,14 @@
return xml
class Installer(object):
- def __init__(self, type = "xen", location = None, boot = None, extraargs = None, os_type = None):
+ def __init__(self, type = "xen", location = None, boot = None,
+ extraargs = None, os_type = None, conn = None):
self._location = None
self._extraargs = None
self._boot = None
self._cdrom = False
self._os_type = os_type
+ self._conn = conn
self._install_disk = None # VirtualDisk that contains install media
if type is None:
@@ -303,6 +305,10 @@
def get_install_disk(self):
return self._install_disk
install_disk = property(get_install_disk)
+
+ def get_conn(self):
+ return self._conn
+ conn = property(get_conn)
def get_type(self):
return self._type
diff -r b665c19355e8 -r 01efca5886ba virtinst/LiveCDInstaller.py
--- a/virtinst/LiveCDInstaller.py Tue Aug 05 21:22:56 2008 -0400
+++ b/virtinst/LiveCDInstaller.py Tue Aug 05 22:39:54 2008 -0400
@@ -30,15 +30,13 @@
Exception.__init__(self, msg)
class LiveCDInstaller(Guest.Installer):
- def __init__(self, type = "xen", location = None, os_type = None):
+ def __init__(self, type = "xen", location = None, os_type = None,
+ conn = None):
Guest.Installer.__init__(self, type=type, location=location,
- os_type=os_type)
+ os_type=os_type, conn=conn)
def prepare(self, guest, meter, distro = None):
self.cleanup()
-
- if not os.path.exists(self.location):
- raise LiveCDInstallerException(_("LiveCD image '%s' does not exist") % self.location)
capabilities = CapabilitiesParser.parse(guest.conn.getCapabilities())
@@ -51,7 +49,14 @@
if not found:
raise LiveCDInstallerException(_("HVM virtualisation not supported; cannot boot LiveCD"))
- disk = VirtualDisk(self.location,
+ path = None
+ vol_tuple = None
+ if type(self.location) is tuple:
+ vol_tuple = self.location
+ else:
+ path = self.location
+
+ disk = VirtualDisk(path=path, conn=guest.conn, volName=vol_tuple,
device = VirtualDisk.DEVICE_CDROM,
readOnly = True)
guest._install_disks.insert(0, disk)
_______________________________________________
et-mgmt-tools mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/et-mgmt-tools