From f96e3c4f756dfbe4cd63f77d5a5d06a7ae09be2b Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 13 Jan 2009 15:20:25 +0000
Subject: [PATCH] backend: rename AttachOrAssemble to Assemble

Since now the Assemble function is different than Attach, we rename this
backend function to show that the intent is to fully assemble the device
(and it's always allowed to modify the device).

Reviewed-by: ultrotter
---
 lib/backend.py |  2 +-
 lib/bdev.py    | 16 +++++++---------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index c896875c5..c57eeafb8 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -1117,7 +1117,7 @@ def _RecursiveAssembleBD(disk, owner, as_primary):
       children.append(cdev)
 
   if as_primary or disk.AssembleOnSecondary():
-    r_dev = bdev.AttachOrAssemble(disk.dev_type, disk.physical_id, children)
+    r_dev = bdev.Assemble(disk.dev_type, disk.physical_id, children)
     r_dev.SetSyncSpeed(constants.SYNC_SPEED)
     result = r_dev
     if as_primary or disk.OpenOnSecondary():
diff --git a/lib/bdev.py b/lib/bdev.py
index e119bd4a8..14f1e5cc6 100644
--- a/lib/bdev.py
+++ b/lib/bdev.py
@@ -1680,22 +1680,20 @@ def FindDevice(dev_type, unique_id, children):
   return device
 
 
-def AttachOrAssemble(dev_type, unique_id, children):
+def Assemble(dev_type, unique_id, children):
   """Try to attach or assemble an existing device.
 
-  This will attach to an existing assembled device or will assemble
-  the device, as needed, to bring it fully up.
+  This will attach to assemble the device, as needed, to bring it
+  fully up. It must be safe to run on already-assembled devices.
 
   """
   if dev_type not in DEV_MAP:
     raise errors.ProgrammerError("Invalid block device type '%s'" % dev_type)
   device = DEV_MAP[dev_type](unique_id, children)
-  if not device.attached:
-    device.Assemble()
-    if not device.attached:
-      raise errors.BlockDeviceError("Can't find a valid block device for"
-                                    " %s/%s/%s" %
-                                    (dev_type, unique_id, children))
+  if not device.Assemble():
+    raise errors.BlockDeviceError("Can't find a valid block device for"
+                                  " %s/%s/%s" %
+                                  (dev_type, unique_id, children))
   return device
 
 
-- 
GitLab