From 85459a7f9bfe1a0e625063571db5eea417579b32 Mon Sep 17 00:00:00 2001 From: Roey Chen Date: Mon, 5 Dec 2016 01:26:08 -0800 Subject: [PATCH] NSXv3: Do not allow empty tag values on resources Change-Id: I1a02672675565b239e1c1ae538f63d4fc12e2c65 --- vmware_nsxlib/v3/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vmware_nsxlib/v3/utils.py b/vmware_nsxlib/v3/utils.py index e5e2dec0..3c71755b 100644 --- a/vmware_nsxlib/v3/utils.py +++ b/vmware_nsxlib/v3/utils.py @@ -48,9 +48,13 @@ def update_v3_tags(current_tags, tags_update): current_scopes = set([tag['scope'] for tag in current_tags]) updated_scopes = set([tag['scope'] for tag in tags_update]) + # All tags scopes which are either completley new or arleady defined on the + # resource are left in place, unless the tag value is empty, in that case + # it is ignored. tags = [{'scope': tag['scope'], 'tag': tag['tag']} for tag in (current_tags + tags_update) - if tag['scope'] in (current_scopes ^ updated_scopes)] + if tag['tag'] and + tag['scope'] in (current_scopes ^ updated_scopes)] modified_scopes = current_scopes & updated_scopes for tag in tags_update: