]> git.apps.os.sepia.ceph.com Git - ceph-ci.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)
committerMohamad Gebai <mgebai@suse.com>
Fri, 12 Apr 2019 16:54:08 +0000 (12:54 -0400)
Signed-off-by: Mohamad Gebai <mgebai@suse.com>
src/ceph-volume/ceph_volume/api/lvm.py

index 1e4567d3a631e6fea4aaadb3d8174b5ad304ee7d..58676b89685b3150e4964404bbc1f9cba27f2393 100644 (file)
@@ -1160,9 +1160,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):
         """
@@ -1178,22 +1178,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(
             [