Hi Sarah,

thank you for your patch, I'll have a look. For which Ganeti version is the patch targetted?

Before we can accept it, you'll need to sign our Contributor License Agreement, see
https://code.google.com/p/ganeti/wiki/DeveloperGuidelines#Contributor_License_Agreement_(CLA)

  Best regards,
  Petr

On Wed, Jun 03, 2015 at 06:06:06PM -0700, [email protected] wrote:
From: Sarah Newman <[email protected]>

This addresses issue 1086 where adopted LVs are not tagged.

Signed-off-by: Sarah Newman <[email protected]>
---
lib/backend.py                 | 6 +++++-
lib/cmdlib/instance.py         | 7 ++++---
lib/cmdlib/instance_storage.py | 5 +++--
lib/rpc_defs.py                | 1 +
lib/server/noded.py            | 3 ++-
5 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index ef386d2..d9e0589 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -3391,13 +3391,16 @@ def RemoveExport(export):
    _Fail("Error while removing the export: %s", err, exc=True)


-def BlockdevRename(devlist):
+def BlockdevRename(devlist, info):
  """Rename a list of block devices.

  @type devlist: list of tuples
  @param devlist: list of tuples of the form  (disk, new_unique_id); disk is
      an L{objects.Disk} object describing the current disk, and new
      unique_id is the name we rename it to
+  @type info: string
+  @param info: string that will be sent to the physical device
+      creation, used for example to set (LVM) tags on LVs
  @rtype: boolean
  @return: True if all renames succeeded, False otherwise

@@ -3412,6 +3415,7 @@ def BlockdevRename(devlist):
      continue
    try:
      old_rpath = dev.dev_path
+      dev.SetInfo(info)
      dev.Rename(unique_id)
      new_rpath = dev.dev_path
      if old_rpath != new_rpath:
diff --git a/lib/cmdlib/instance.py b/lib/cmdlib/instance.py
index 5bb47db..d6945aa 100644
--- a/lib/cmdlib/instance.py
+++ b/lib/cmdlib/instance.py
@@ -1353,13 +1353,14 @@ class LUInstanceCreate(LogicalUnit):
      if self.op.disk_template == constants.DT_PLAIN:
        # rename LVs to the newly-generated names; we need to construct
        # 'fake' LV disks with the old data, plus the new unique_id
+        info = GetInstanceInfoText(iobj)
        tmp_disks = [objects.Disk.FromDict(v.ToDict()) for v in disks]
        rename_to = []
        for t_dsk, a_dsk in zip(tmp_disks, self.disks):
          rename_to.append(t_dsk.logical_id)
          t_dsk.logical_id = (t_dsk.logical_id[0], a_dsk[constants.IDISK_ADOPT])
        result = self.rpc.call_blockdev_rename(self.pnode.uuid,
-                                               zip(tmp_disks, rename_to))
+                                               zip(tmp_disks, rename_to), info)
        result.Raise("Failed to rename adoped LVs")
    else:
      feedback_fn("* creating instance disks...")
@@ -3240,7 +3241,7 @@ class LUInstanceSetParams(LogicalUnit):
    feedback_fn("Renaming original volumes...")
    rename_list = [(o, n.children[0].logical_id)
                   for (o, n) in zip(self.instance.disks, new_disks)]
-    result = self.rpc.call_blockdev_rename(pnode_uuid, rename_list)
+    result = self.rpc.call_blockdev_rename(pnode_uuid, rename_list, info)
    result.Raise("Failed to rename original LVs")

    feedback_fn("Initializing DRBD devices...")
@@ -3257,7 +3258,7 @@ class LUInstanceSetParams(LogicalUnit):
                  " renaming back original volumes...")
      rename_back_list = [(n.children[0], o.logical_id)
                          for (n, o) in zip(new_disks, self.instance.disks)]
-      result = self.rpc.call_blockdev_rename(pnode_uuid, rename_back_list)
+      result = self.rpc.call_blockdev_rename(pnode_uuid, rename_back_list, 
info)
      result.Raise("Failed to rename LVs back after error %s" % str(e))
      raise

diff --git a/lib/cmdlib/instance_storage.py b/lib/cmdlib/instance_storage.py
index bb4e60e..fe39208 100644
--- a/lib/cmdlib/instance_storage.py
+++ b/lib/cmdlib/instance_storage.py
@@ -2375,9 +2375,10 @@ class TLReplaceDisks(Tasklet):
          # device exists
          rename_old_to_new.append((to_ren, ren_fn(to_ren, temp_suffix)))

+      info = GetInstanceInfoText(self.instance)
      self.lu.LogInfo("Renaming the old LVs on the target node")
      result = self.rpc.call_blockdev_rename(self.target_node_uuid,
-                                             rename_old_to_new)
+                                             rename_old_to_new, info)
      result.Raise("Can't rename old LVs on node %s" %
                   self.cfg.GetNodeName(self.target_node_uuid))

@@ -2386,7 +2387,7 @@ class TLReplaceDisks(Tasklet):
      rename_new_to_old = [(new, old.logical_id)
                           for old, new in zip(old_lvs, new_lvs)]
      result = self.rpc.call_blockdev_rename(self.target_node_uuid,
-                                             rename_new_to_old)
+                                             rename_new_to_old, info)
      result.Raise("Can't rename new LVs on node %s" %
                   self.cfg.GetNodeName(self.target_node_uuid))

diff --git a/lib/rpc_defs.py b/lib/rpc_defs.py
index 200c97c..7f8ea9a 100644
--- a/lib/rpc_defs.py
+++ b/lib/rpc_defs.py
@@ -443,6 +443,7 @@ _BLOCKDEV_CALLS = [
    ], None, None, "Export a given disk to another node"),
  ("blockdev_rename", SINGLE, None, constants.RPC_TMO_NORMAL, [
    ("devlist", ED_BLOCKDEV_RENAME, None),
+    ("info", None, None),
    ], None, None, "Request rename of the given block devices"),
  ("blockdev_find", SINGLE, None, constants.RPC_TMO_NORMAL, [
    ("disk", ED_SINGLE_DISK_DICT_DP, None),
diff --git a/lib/server/noded.py b/lib/server/noded.py
index 0540a96..60883e6 100644
--- a/lib/server/noded.py
+++ b/lib/server/noded.py
@@ -256,7 +256,8 @@ class NodeRequestHandler(http.server.HttpServerHandler):

    """
    devlist = [(objects.Disk.FromDict(ds), uid) for ds, uid in params[0]]
-    return backend.BlockdevRename(devlist)
+    info = params[1]
+    return backend.BlockdevRename(devlist, info)

  @staticmethod
  def perspective_blockdev_assemble(params):
--
1.9.1

Reply via email to