storage: test default_target_path

This commit is contained in:
Cole Robinson 2019-07-02 20:03:45 -04:00
parent 199e9593bf
commit fd8847c24e
13 changed files with 22 additions and 17 deletions

View File

@ -1,12 +1,12 @@
<volume type="file">
<name>pool-dir-volclone</name>
<key>/some/target/path/pool-dir-vol</key>
<key>/var/lib/libvirt/images/pool-dir/pool-dir-vol</key>
<source>
</source>
<capacity unit="bytes">10737418240</capacity>
<allocation unit="bytes">5368709120</allocation>
<target>
<path>/some/target/path/pool-dir-vol</path>
<path>/var/lib/libvirt/images/pool-dir/pool-dir-vol</path>
<format type="raw"/>
<permissions>
<mode>0700</mode>

View File

@ -1,6 +1,6 @@
<pool type="dir">
<name>pool-dir</name>
<target>
<path>/some/target/path</path>
<path>/var/lib/libvirt/images/pool-dir</path>
</target>
</pool>

View File

@ -1,12 +1,12 @@
<volume type="file">
<name>pool-fs-volclone</name>
<key>/some/target/path/pool-fs-vol</key>
<key>/var/lib/libvirt/images/pool-fs/pool-fs-vol</key>
<source>
</source>
<capacity unit="bytes">10737418240</capacity>
<allocation unit="bytes">5368709120</allocation>
<target>
<path>/some/target/path/pool-fs-vol</path>
<path>/var/lib/libvirt/images/pool-fs/pool-fs-vol</path>
<format type="raw"/>
<permissions>
<mode>0700</mode>

View File

@ -5,6 +5,6 @@
<device path="/some/source/path"/>
</source>
<target>
<path>/some/target/path</path>
<path>/var/lib/libvirt/images/pool-fs</path>
</target>
</pool>

View File

@ -8,6 +8,6 @@
</initiator>
</source>
<target>
<path>/some/target/path</path>
<path>/dev/disk/by-path</path>
</target>
</pool>

View File

@ -5,6 +5,6 @@
<name>vgname</name>
</source>
<target>
<path>/some/target/path</path>
<path>/dev/pool-logical-srcname</path>
</target>
</pool>

View File

@ -1,6 +1,6 @@
<pool type="mpath">
<name>pool-mpath</name>
<target>
<path>/some/target/path</path>
<path>/dev/mapper</path>
</target>
</pool>

View File

@ -1,12 +1,12 @@
<volume type="file">
<name>pool-netfs-volclone</name>
<key>/some/target/path/pool-netfs-vol</key>
<key>/var/lib/libvirt/images/pool-netfs/pool-netfs-vol</key>
<source>
</source>
<capacity unit="bytes">10737418240</capacity>
<allocation unit="bytes">5368709120</allocation>
<target>
<path>/some/target/path/pool-netfs-vol</path>
<path>/var/lib/libvirt/images/pool-netfs/pool-netfs-vol</path>
<format type="raw"/>
<permissions>
<mode>0700</mode>

View File

@ -6,6 +6,6 @@
<dir path="/some/source/path"/>
</source>
<target>
<path>/some/target/path</path>
<path>/var/lib/libvirt/images/pool-netfs</path>
</target>
</pool>

View File

@ -4,6 +4,6 @@
<adapter name="/some/source/path"/>
</source>
<target>
<path>/some/target/path</path>
<path>/dev/disk/by-path</path>
</target>
</pool>

View File

@ -33,7 +33,8 @@ def createPool(conn, ptype, poolname=None, fmt=None, target_path=None,
if pool_inst.supports_source_path():
pool_inst.source_path = source_path or "/some/source/path"
if pool_inst.supports_target_path():
pool_inst.target_path = target_path or "/some/target/path"
pool_inst.target_path = (target_path or
pool_inst.default_target_path())
if fmt and pool_inst.supports_format():
pool_inst.format = fmt
if pool_inst.supports_source_name():
@ -160,7 +161,8 @@ class TestStorage(unittest.TestCase):
def testDiskPool(self):
poolobj = createPool(self.conn,
StoragePool.TYPE_DISK,
"pool-disk", fmt="auto")
"pool-disk", fmt="auto",
target_path="/some/target/path")
invol = createVol(self.conn, poolobj)
createVol(self.conn, poolobj,
volname=invol.name() + "input", input_vol=invol)
@ -209,6 +211,10 @@ class TestStorage(unittest.TestCase):
diskvol.pool = diskpool
self.assertTrue(diskvol.supports_format() is False)
diskpoolxml = StoragePool(fullconn)
diskpoolxml.type = "disk"
self.assertEqual(diskpoolxml.default_target_path(), "/dev")
glusterpool.destroy()
StoragePool.ensure_pool_is_running(glusterpool)

View File

@ -8,6 +8,6 @@
</initiator>
</source>
<target>
<path>/some/target/path</path>
<path>/dev/disk/by-path</path>
</target>
</pool>

View File

@ -268,7 +268,6 @@ class StoragePool(_StorageObject):
return _DEFAULT_SCSI_TARGET
if self.type == self.TYPE_MPATH:
return _DEFAULT_MPATH_TARGET
raise RuntimeError("No default target_path for type=%s" % self.type)
def _type_to_source_prop(self):
if (self.type == self.TYPE_NETFS or