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