]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: add clear_tag function for LVs
authorMohamad Gebai <mgebai@suse.com>
Sun, 31 Mar 2019 17:06:23 +0000 (13:06 -0400)
committerJan Fajerski <jfajerski@suse.com>
Tue, 29 Oct 2019 16:37:00 +0000 (17:37 +0100)
Signed-off-by: Mohamad Gebai <mgebai@suse.com>
(cherry picked from commit 776d485af8b6225fd4059952df36e40ef0ad12b4)

src/ceph-volume/ceph_volume/api/lvm.py

index 2ab0d529b5251bf89f1518efe09dfdb1d6304be4..d9aeae97c388c124eaa8a168251d7b36d79441d4 100644 (file)
@@ -1155,9 +1155,9 @@ class Volume(object):
         """
         Removes all tags from the Logical Volume.
         """
-        for k, v in self.tags.items():
-            tag = "%s=%s" % (k, v)
-            process.run(['lvchange', '--deltag', tag, self.lv_path])
+        for k in list(self.tags):
+            self.clear_tag(k)
+
 
     def set_tags(self, tags):
         """
@@ -1173,22 +1173,22 @@ class Volume(object):
         """
         for k, v in tags.items():
             self.set_tag(k, v)
-        # after setting all the tags, refresh them for the current object, use the
-        # lv_* identifiers to filter because those shouldn't change
-        lv_object = get_lv(lv_name=self.lv_name, lv_path=self.lv_path)
-        self.tags = lv_object.tags
+
+
+    def clear_tag(self, key):
+        if self.tags.get(key):
+            current_value = self.tags[key]
+            tag = "%s=%s" % (key, current_value)
+            process.call(['lvchange', '--deltag', tag, self.lv_path])
+            del self.tags[key]
+
 
     def set_tag(self, key, value):
         """
-        Set the key/value pair as an LVM tag. Does not "refresh" the values of
-        the current object for its tags. Meant to be a "fire and forget" type
-        of modification.
+        Set the key/value pair as an LVM tag.
         """
         # remove it first if it exists
-        if self.tags.get(key):
-            current_value = self.tags[key]
-            tag = "%s=%s" % (key, current_value)
-            process.call(['lvchange', '--deltag', tag, self.lv_api['lv_path']])
+        self.clear_tag(key)
 
         process.call(
             [