devicedisk: fix source name attribute for gluster volumes

(crobinso: Small code tweak, and add test cases)
This commit is contained in:
Anatoly Belikov 2015-01-27 16:10:12 +03:00 committed by Cole Robinson
parent a1d82a162c
commit e44b95149b
4 changed files with 14 additions and 10 deletions

View File

@ -98,8 +98,8 @@
<target dev="sdb" bus="scsi"/>
</disk>
<disk type="network" device="disk">
<driver name="qemu" type="qcow2"/>
<source protocol="gluster" name="test-volume/test-gluster.qcow2">
<driver name="qemu"/>
<source protocol="gluster" name="test-volume/some/dir/test-gluster.qcow2">
<host name="192.168.1.100"/>
</source>
<target dev="vdj" bus="virtio"/>
@ -120,7 +120,7 @@
</disk>
<disk type="network" device="disk">
<driver name="qemu" type="raw"/>
<source protocol="gluster" name="test-volume/test-gluster.raw" startupPolicy="optional">
<source protocol="gluster" name="test-volume/some/dir/test-gluster.raw" startupPolicy="optional">
<host name="192.168.1.100"/>
</source>
<target dev="vdl" bus="virtio"/>

View File

@ -534,7 +534,7 @@ c.add_compare(""" \
--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 \
--disk gluster://192.168.1.100/test-volume/some/dir/test-gluster.qcow2 \
--disk qemu+nbd:///var/foo/bar/socket,bus=usb,removable=on \
--disk path=http://[1:2:3:4:1:2:3:4]:5522/my/path?query=foo \
--disk vol=gluster-pool/test-gluster.raw,startup_policy=optional \

View File

@ -1859,17 +1859,17 @@ ba</description>
<available unit='bytes'>475283320832</available>
<source>
<host name='192.168.1.100'/>
<dir path='/'/>
<dir path='/some/dir'/>
<name>test-volume</name>
</source>
<volume type='network'>
<name>test-gluster.raw</name>
<key>gluster://192.168.1.100/test-volume/test-gluster.raw</key>
<key>gluster://192.168.1.100/test-volume/some/dir/test-gluster.raw</key>
<capacity unit='bytes'>10737418240</capacity>
<allocation unit='bytes'>2489327616</allocation>
<target>
<path>gluster://192.168.1.100/test-volume/test-gluster.raw</path>
<path>gluster://192.168.1.100/test-volume/some/dir/test-gluster.raw</path>
<format type='raw'/>
<permissions>
<mode>0666</mode>
@ -1881,11 +1881,11 @@ ba</description>
<volume type='network'>
<name>test-gluster2.raw</name>
<key>gluster://192.168.1.100/test-volume/test-gluster2.raw</key>
<key>gluster://192.168.1.100/test-volume/some/dir/test-gluster2.raw</key>
<capacity unit='bytes'>10737418240</capacity>
<allocation unit='bytes'>2489327616</allocation>
<target>
<path>gluster://192.168.1.100/test-volume/test-gluster2.raw</path>
<path>gluster://192.168.1.100/test-volume/some/dir/test-gluster2.raw</path>
<format type='raw'/>
<permissions>
<mode>0666</mode>

View File

@ -633,7 +633,11 @@ class VirtualDisk(VirtualDevice):
path = ""
if poolxml.source_name:
path += poolxml.source_name + "/"
path += poolxml.source_name
if poolxml.source_path:
path += poolxml.source_path
if not path.endswith('/'):
path += "/"
path += volxml.name
self.source_name = path
self.type = "network"