From aa013353dffbb8d8019eb7051696a556c7f8b69c Mon Sep 17 00:00:00 2001
From: Gary Kotton <gkotton@vmware.com>
Date: Wed, 31 Jan 2018 01:43:23 -0800
Subject: [PATCH] TVD: ensure that extra attributs are set for router iif they
 exist

Validate that the extra attributes are configured.

Change-Id: I45aad02b6b2855653aef37c0cd9dfeaf7e152bde
---
 vmware_nsx/plugins/nsx_v/plugin.py  | 3 ++-
 vmware_nsx/plugins/nsx_v3/plugin.py | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py
index 0db31507c2..c5f99c4592 100644
--- a/vmware_nsx/plugins/nsx_v/plugin.py
+++ b/vmware_nsx/plugins/nsx_v/plugin.py
@@ -3120,7 +3120,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
 
     def _process_extra_attr_router_create(self, context, router_db, r):
         for extra_attr in l3_attrs_db.get_attr_info().keys():
-            if extra_attr in r:
+            if (extra_attr in r and
+                validators.is_attr_set(r.get(extra_attr))):
                 self.set_extra_attr_value(context, router_db,
                                           extra_attr, r[extra_attr])
 
diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py
index 40ee815a16..5a7ca5deb4 100644
--- a/vmware_nsx/plugins/nsx_v3/plugin.py
+++ b/vmware_nsx/plugins/nsx_v3/plugin.py
@@ -3262,7 +3262,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
 
     def _process_extra_attr_router_create(self, context, router_db, r):
         for extra_attr in l3_attrs_db.get_attr_info().keys():
-            if extra_attr in r:
+            if (extra_attr in r and
+                validators.is_attr_set(r.get(extra_attr))):
                 self.set_extra_attr_value(context, router_db,
                                           extra_attr, r[extra_attr])