The attached patch adds virtinst support for building logical pools and volumes. Sort of. This will allow creating new volumes, but not creating pools (aka volume groups) from a specified set of physical disks. I believe libvirt supports this, but I haven't tried it yet. However this does allow the user to point at an existing lvm volume group and have it recognized as a storage pool which will be by far the common case. The nice thing about this is that it will all become immediately available in the virt-manager UI (posted previously). One thing I've encountered with this though: does a volume's target path have any significance upon creation? File volumes just seem to create a file based on the passed 'name', not target path. Disk volumes ignore both when creating. Logical vols also only use the name, but try to validate the target path after creation, which we shouldn't need passed (the result should simply be vgpath + "/" + volname). So it seems like target path has no real meaning when defining a volume. Am I missing something? Thanks, Cole
# HG changeset patch # User "Cole Robinson <crobinso@xxxxxxxxxx>" # Date 1218585852 14400 # Node ID 7fbcac9b8c71f985d013907f3654fccb8a1c36d7 # Parent 8d65c4b70cbf7db2730e4aa86b641a9eea653828 virtinst: Allow creating logical volumes and pools diff -r 8d65c4b70cbf -r 7fbcac9b8c71 virtinst/Storage.py --- a/virtinst/Storage.py Tue Aug 12 16:16:45 2008 -0400 +++ b/virtinst/Storage.py Tue Aug 12 20:04:12 2008 -0400 @@ -543,10 +543,33 @@ class LogicalPool(StoragePool): """ - Create a logical (lvm volume group, ...) storage pool + Create a logical (lvm volume group) storage pool """ - def __init__(self, *args, **kwargs): - raise RuntimeError, "Not implemented" + def get_volume_class(): + return LogicalVolume + get_volume_class = staticmethod(get_volume_class) + + # Register applicable property methods from parent class + perms = property(StorageObject.get_perms, StorageObject.set_perms) + + def __init__(self, conn, name, target_path=None, uuid=None, perms=None): + StoragePool.__init__(self, name=name, type=StoragePool.TYPE_LOGICAL, + target_path=target_path, uuid=uuid, conn=conn) + if perms: + self.perms = perms + + def _get_default_target_path(self): + return DEFAULT_LVM_TARGET_BASE + self.name + + def _get_target_xml(self): + xml = " <path>%s</path>\n" % escape(self.target_path) + \ + "%s" % self._get_perms_xml() + return xml + + def _get_source_xml(self): + return "" + + class DiskPool(StoragePool): """ Create a raw disk storage pool @@ -559,8 +582,6 @@ """ def __init__(self, *args, **kwargs): raise RuntimeError, "Not implemented" - - class StorageVolume(StorageObject): @@ -843,3 +864,38 @@ def _get_source_xml(self): return "" + +class DiskVolume(StorageVolume): + """ + Build and install xml for use on disk device pools + """ + def __init__(self, *args, **kwargs): + raise RuntimeError ("Not Implemented") + +class LogicalVolume(StorageVolume): + """ + Build and install logical volumes for lvm pools + """ + + # Register applicable property methods from parent class + perms = property(StorageObject.get_perms, StorageObject.set_perms) + + def __init__(self, name, capacity, pool=None, pool_name=None, conn=None, + allocation=None, perms=None): + StorageVolume.__init__(self, name=name, pool=pool, pool_name=pool_name, + target_path=None, allocation=allocation, + capacity=capacity, conn=conn) + if perms: + self.perms = perms + + def _get_default_target_path(self): + poolpath = util.get_xml_path(self.pool.XMLDesc(0), + "/pool/target/path") + return poolpath + "/" + self.name + + def _get_target_xml(self): + return " <path>%s</path>\n" % escape(self.target_path) + \ + "%s" % self._get_perms_xml() + + def _get_source_xml(self): + return ""
_______________________________________________ et-mgmt-tools mailing list et-mgmt-tools@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/et-mgmt-tools