storage: test default_source_name
This commit is contained in:
parent
f21d7e4c27
commit
199e9593bf
|
@ -1,7 +1,6 @@
|
|||
<pool type="disk">
|
||||
<name>pool-disk</name>
|
||||
<source>
|
||||
<format type="dos"/>
|
||||
<device path="/some/source/path"/>
|
||||
</source>
|
||||
<target>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<pool type="rbd">
|
||||
<name>pool-rbd</name>
|
||||
<source>
|
||||
<host name="some.random.hostname"/>
|
||||
<name>rbd</name>
|
||||
</source>
|
||||
</pool>
|
|
@ -36,8 +36,9 @@ def createPool(conn, ptype, poolname=None, fmt=None, target_path=None,
|
|||
pool_inst.target_path = target_path or "/some/target/path"
|
||||
if fmt and pool_inst.supports_format():
|
||||
pool_inst.format = fmt
|
||||
if source_name and pool_inst.supports_source_name():
|
||||
pool_inst.source_name = source_name
|
||||
if pool_inst.supports_source_name():
|
||||
pool_inst.source_name = (source_name or
|
||||
pool_inst.default_source_name())
|
||||
if iqn and pool_inst.supports_iqn():
|
||||
pool_inst.iqn = iqn
|
||||
|
||||
|
@ -159,7 +160,7 @@ class TestStorage(unittest.TestCase):
|
|||
def testDiskPool(self):
|
||||
poolobj = createPool(self.conn,
|
||||
StoragePool.TYPE_DISK,
|
||||
"pool-disk", fmt="dos")
|
||||
"pool-disk", fmt="auto")
|
||||
invol = createVol(self.conn, poolobj)
|
||||
createVol(self.conn, poolobj,
|
||||
volname=invol.name() + "input", input_vol=invol)
|
||||
|
@ -186,6 +187,11 @@ class TestStorage(unittest.TestCase):
|
|||
StoragePool.TYPE_GLUSTER, "pool-gluster")
|
||||
removePool(poolobj)
|
||||
|
||||
def testRBDPool(self):
|
||||
poolobj = createPool(self.conn,
|
||||
StoragePool.TYPE_RBD, "pool-rbd")
|
||||
removePool(poolobj)
|
||||
|
||||
def testMisc(self):
|
||||
# Misc coverage testing
|
||||
vol = StorageVolume(self.conn)
|
||||
|
|
|
@ -286,25 +286,21 @@ class StoragePool(_StorageObject):
|
|||
source_path = property(_get_source, _set_source)
|
||||
|
||||
def default_source_name(self):
|
||||
srcname = None
|
||||
|
||||
if not self.supports_source_name():
|
||||
srcname = None
|
||||
elif self.type == StoragePool.TYPE_NETFS:
|
||||
srcname = self.name
|
||||
elif self.type == StoragePool.TYPE_RBD:
|
||||
srcname = "rbd"
|
||||
elif self.type == StoragePool.TYPE_GLUSTER:
|
||||
srcname = "gv0"
|
||||
elif ("target_path" in self._propstore and
|
||||
return None
|
||||
|
||||
if self.type == StoragePool.TYPE_RBD:
|
||||
return "rbd"
|
||||
if self.type == StoragePool.TYPE_GLUSTER:
|
||||
return "gv0"
|
||||
|
||||
if ("target_path" in self._propstore and
|
||||
self.target_path and
|
||||
self.target_path.startswith(_DEFAULT_LVM_TARGET_BASE)):
|
||||
# If there is a target path, parse it for an expected VG
|
||||
# location, and pull the name from there
|
||||
vg = self.target_path[len(_DEFAULT_LVM_TARGET_BASE):]
|
||||
srcname = vg.split("/", 1)[0]
|
||||
|
||||
return srcname
|
||||
return vg.split("/", 1)[0]
|
||||
|
||||
|
||||
##############
|
||||
|
|
Loading…
Reference in New Issue