(2.10) Return link_name in blockdev_assemble rpc
authorDimitris Aragiorgis <dimara@grnet.gr>
Wed, 9 Oct 2013 14:45:34 +0000 (17:45 +0300)
committerDimitris Aragiorgis <dimara@grnet.gr>
Tue, 17 Dec 2013 10:46:33 +0000 (12:46 +0200)
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: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

cmdlib unittest do not exist in stable-2.8

Conflicts:
test/py/cmdlib/instance_migration_unittest.py
test/py/cmdlib/instance_unittest.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

lib/backend.py

index 4c7fcad..575c048 100644 (file)
@@ -1915,23 +1915,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, bdev.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):