Adam Litke has uploaded a new change for review. Change subject: FakeLVM: Add changeLVTags ......................................................................
FakeLVM: Add changeLVTags Change-Id: I169fffbc5d865bc987897655a1081b979910c589 Signed-off-by: Adam Litke <ali...@redhat.com> --- M tests/storagefakelib.py M tests/storagefakelibTests.py 2 files changed, 46 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/46/49546/1 diff --git a/tests/storagefakelib.py b/tests/storagefakelib.py index bd098c1..7d6092c 100644 --- a/tests/storagefakelib.py +++ b/tests/storagefakelib.py @@ -141,6 +141,26 @@ raise se.MissingTagOnLogicalVolume("%s/%s" % (vg, lv), tag) lv_md['tags'] += (tag,) + def changeLVTags(self, vg, lv, delTags=(), addTags=()): + try: + lv_md = self.lvmd[(vg, lv)] + except KeyError: + raise se.LogicalVolumeReplaceTagError("LV %s does not exist", + "%s/%s" % (vg, lv)) + + lvTags = set(lv_md['tags']) + delTags = set(delTags) + addTags = set(addTags) + if delTags & addTags: + raise se.LogicalVolumeReplaceTagError( + "Cannot add and delete the same tag lv: `%s` tags: `%s`" % + (lv, ", ".join(delTags.intersection(addTags)))) + + # Adding an existing tag or removing a nonexistent tag are ignored + lvTags |= addTags + lvTags -= delTags + lv_md['tags'] = tuple(lvTags) + def lvPath(self, vgName, lvName): return os.path.join(self.root, "dev", vgName, lvName) diff --git a/tests/storagefakelibTests.py b/tests/storagefakelibTests.py index 3af4d54..dcdfd19 100644 --- a/tests/storagefakelibTests.py +++ b/tests/storagefakelibTests.py @@ -232,6 +232,31 @@ lv = lvm.getLV(self.VG_NAME, self.LV_NAME) self.assertEqual((blockVolume.TAG_VOL_UNINIT, "FOO"), lv.tags) + def test_changelvtags(self): + """ + Create a logical volume with an initial tag and replace it. + """ + with self.base_config() as lvm: + lvm.createLV(self.VG_NAME, self.LV_NAME, str(self.LV_SIZE_MB), + initialTags=(blockVolume.TAG_VOL_UNINIT,)) + deltags = (blockVolume.TAG_VOL_UNINIT,) + addtags = ("FOO",) + lvm.changeLVTags(self.VG_NAME, self.LV_NAME, + delTags=deltags, addTags=addtags) + lv = lvm.getLV(self.VG_NAME, self.LV_NAME) + self.assertEqual(addtags, lv.tags) + + def test_changelvtags_add_and_delete_same_tag(self): + """ + Test that adding and removing the same tag is forbidden. + + """ + with self.base_config() as lvm: + lvm.createLV(self.VG_NAME, self.LV_NAME, str(self.LV_SIZE_MB)) + self.assertRaises(se.LogicalVolumeReplaceTagError, + lvm.changeLVTags, self.VG_NAME, self.LV_NAME, + delTags=("FOO",), addTags=("FOO",)) + def test_activatelv(self): """ Create an inactive LV and then activate it. @@ -281,6 +306,7 @@ [se.CannotCreateLogicalVolume, 'createLV', ['vg', 'lv', '1024']], [se.LogicalVolumeDoesNotExistError, 'getLV', ['vg', 'lv']], [se.InaccessiblePhysDev, 'getPV', ['pv']], + [se.LogicalVolumeReplaceTagError, 'changeLVTags', ['vg', 'lv']], ]) def test_bad_args(self, exception, fn, args): with namedTemporaryDir() as tmpdir: -- To view, visit https://gerrit.ovirt.org/49546 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I169fffbc5d865bc987897655a1081b979910c589 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke <ali...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches