virt-install: Fix --disk pool=NETPOOL,size=... creation

This commit is contained in:
Cole Robinson 2014-12-10 12:55:08 -05:00
parent cb124bccbd
commit 9ae3dbe05b
5 changed files with 25 additions and 9 deletions

View File

@ -76,12 +76,19 @@
<source volume="some-rbd-vol" pool="rbd-ceph"/>
<target dev="vdg" bus="virtio"/>
</disk>
<disk type="network" device="disk">
<driver name="qemu"/>
<source protocol="rbd" name="rbd/foobar">
<host name="ceph-mon-1.example.com" port="6789"/>
</source>
<target dev="vdh" bus="virtio"/>
</disk>
<disk type="network" device="disk">
<driver name="qemu"/>
<source protocol="http" name="/path/to/my/file">
<host name="example.com" port="8000"/>
</source>
<target dev="vdh" bus="virtio"/>
<target dev="vdi" bus="virtio"/>
</disk>
<disk type="network" device="disk">
<driver name="qemu"/>
@ -95,7 +102,7 @@
<source protocol="gluster" name="test-volume/test-gluster.qcow2">
<host name="192.168.1.100"/>
</source>
<target dev="vdi" bus="virtio"/>
<target dev="vdj" bus="virtio"/>
</disk>
<disk type="network" device="disk">
<driver name="qemu"/>
@ -109,14 +116,14 @@
<source protocol="http" name="my/path">
<host name="1:2:3:4:1:2:3:4" port="5522"/>
</source>
<target dev="vdj" bus="virtio"/>
<target dev="vdk" bus="virtio"/>
</disk>
<disk type="network" device="disk">
<driver name="qemu" type="raw"/>
<source protocol="gluster" name="test-volume/test-gluster.raw" startupPolicy="optional">
<host name="192.168.1.100"/>
</source>
<target dev="vdk" bus="virtio"/>
<target dev="vdl" bus="virtio"/>
</disk>
<disk type="dir" device="floppy">
<driver name="qemu"/>

View File

@ -530,6 +530,7 @@ c.add_compare(""" \
--disk /dev/default-pool/iso-vol \
--disk /dev/default-pool/iso-vol,format=qcow2 \
--disk source_pool=rbd-ceph,source_volume=some-rbd-vol,size=.1 \
--disk pool=rbd-ceph,size=.1 \
--disk source_protocol=http,source_host_name=example.com,source_host_port=8000,source_name=/path/to/my/file \
--disk source_protocol=nbd,source_host_transport=unix,source_host_socket=/tmp/socket,bus=scsi \
--disk gluster://192.168.1.100/test-volume/test-gluster.qcow2 \

View File

@ -630,6 +630,7 @@ class VirtualDisk(VirtualDevice):
path += poolxml.source_name + "/"
path += volxml.name
self.source_name = path
self.type = "network"
def _set_network_source_from_backend(self):
if (self._storage_backend.get_vol_object() or

View File

@ -233,11 +233,17 @@ class _StorageCreator(_StorageBase):
if self._vol_install and not self._path:
xmlobj = StoragePool(self._conn,
parsexml=self._vol_install.pool.XMLDesc(0))
self._path = (xmlobj.target_path + "/" + self._vol_install.name)
if self.get_dev_type() == "network":
self._path = self._vol_install.name
else:
self._path = (xmlobj.target_path + "/" +
self._vol_install.name)
return self._path
def get_vol_install(self):
return self._vol_install
def get_vol_xml(self):
return self._vol_install
def get_size(self):
if self._size is None:
@ -250,6 +256,9 @@ class _StorageCreator(_StorageBase):
if self._vol_install:
if self._vol_install.file_type == libvirt.VIR_STORAGE_VOL_FILE:
self._dev_type = "file"
elif (self._vol_install.file_type ==
libvirt.VIR_STORAGE_VOL_NETWORK):
self._dev_type = "network"
else:
self._dev_type = "block"
else:
@ -287,8 +296,6 @@ class _StorageCreator(_StorageBase):
return True
def get_vol_object(self):
return None
def get_vol_xml(self):
return None
def get_parent_pool(self):
if self._vol_install:
return self._vol_install.pool

View File

@ -547,8 +547,8 @@ class StorageVolume(_StorageObject):
TYPE_FILE = getattr(libvirt, "VIR_STORAGE_VOL_FILE", 0)
TYPE_BLOCK = getattr(libvirt, "VIR_STORAGE_VOL_BLOCK", 1)
TYPE_DIR = getattr(libvirt, "VIR_STORAGE_VOL_DIR", 2)
TYPE_NETWORK = getattr(libvirt, "VIR_STORAGE_VOL_DIR", 3)
TYPE_NETDIR = getattr(libvirt, "VIR_STORAGE_VOL_DIR", 4)
TYPE_NETWORK = getattr(libvirt, "VIR_STORAGE_VOL_NETWORK", 3)
TYPE_NETDIR = getattr(libvirt, "VIR_STORAGE_VOL_NETDIR", 4)
def __init__(self, *args, **kwargs):