From 776d485af8b6225fd4059952df36e40ef0ad12b4 Mon Sep 17 00:00:00 2001 From: Mohamad Gebai Date: Sun, 31 Mar 2019 13:06:23 -0400 Subject: [PATCH] ceph-volume: add clear_tag function for LVs Signed-off-by: Mohamad Gebai --- src/ceph-volume/ceph_volume/api/lvm.py | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py index 1e4567d3a63..58676b89685 100644 --- a/src/ceph-volume/ceph_volume/api/lvm.py +++ b/src/ceph-volume/ceph_volume/api/lvm.py @@ -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( [ -- 2.39.5