Commit ff5def9b authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Thomas Thrainer

Return link_name in blockdev_assemble rpc

Until now this RPC returned only dev_path. Since we use it in
hotplug we have to know the simlink of the device so that we
pass it to the corresponding hypervisor command and include it
in block_devices entry in runtime files.

Fix unittest to be aware of changed rpc
Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent c5708931
......@@ -2255,23 +2255,28 @@ def BlockdevAssemble(disk, owner, as_primary, idx):
This is a wrapper over _RecursiveAssembleBD.
@rtype: str or boolean
@return: a C{/dev/...} path for primary nodes, and
C{True} for secondary nodes
@return: a tuple with the C{/dev/...} path and the created symlink
for primary nodes, and (C{True}, C{True}) for secondary nodes
"""
try:
result = _RecursiveAssembleBD(disk, owner, as_primary)
if isinstance(result, BlockDev):
# pylint: disable=E1103
result = result.dev_path
dev_path = result.dev_path
link_name = None
if as_primary:
_SymlinkBlockDev(owner, result, idx)
link_name = _SymlinkBlockDev(owner, dev_path, idx)
elif result:
return result, result
else:
_Fail("Unexpected result from _RecursiveAssembleBD")
except errors.BlockDeviceError, err:
_Fail("Error while assembling disk: %s", err, exc=True)
except OSError, err:
_Fail("Error while symlinking disk: %s", err, exc=True)
return result
return dev_path, link_name
def BlockdevShutdown(disk):
......
......@@ -128,7 +128,7 @@ class TestLUInstanceFailover(CmdlibTestCase):
.CreateSuccessfulNodeResult(self.master, True)
self.rpc.call_blockdev_assemble.return_value = \
self.RpcResultsBuilder() \
.CreateSuccessfulNodeResult(self.snode, True)
.CreateSuccessfulNodeResult(self.snode, ("/dev/mock", "/var/mock"))
self.rpc.call_instance_start.return_value = \
self.RpcResultsBuilder() \
.CreateSuccessfulNodeResult(self.snode, True)
......
......@@ -1491,7 +1491,8 @@ class TestLUInstanceMove(CmdlibTestCase):
self.rpc.call_blockdev_assemble.return_value = \
self.RpcResultsBuilder() \
.CreateSuccessfulNodeResult(self.node, "/dev/mocked_path")
.CreateSuccessfulNodeResult(self.node, ("/dev/mocked_path",
"/var/run/ganeti/instance-disks/mocked_d"))
self.rpc.call_blockdev_export.return_value = \
self.RpcResultsBuilder() \
.CreateSuccessfulNodeResult(self.master, "")
......@@ -1607,7 +1608,7 @@ class TestLUInstanceRename(CmdlibTestCase):
def testFileInstance(self):
self.rpc.call_blockdev_assemble.return_value = \
self.RpcResultsBuilder() \
.CreateSuccessfulNodeResult(self.master, None)
.CreateSuccessfulNodeResult(self.master, (None, None))
self.rpc.call_blockdev_shutdown.return_value = \
self.RpcResultsBuilder() \
.CreateSuccessfulNodeResult(self.master, None)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment