From db9ad34821ab4526bc548d44154c37f7d63bbd4d Mon Sep 17 00:00:00 2001 From: Abhishek Raut Date: Thu, 20 Apr 2017 03:42:30 -0700 Subject: [PATCH] Validate L2gateway exists in backend Before creating L2gateway, we must validate whether the bridge cluster exists in the backend. Change-Id: I94c435d486b1fde2432c507de7181e6cdfb94d97 --- vmware_nsx/services/l2gateway/nsx_v3/driver.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vmware_nsx/services/l2gateway/nsx_v3/driver.py b/vmware_nsx/services/l2gateway/nsx_v3/driver.py index d9cfa00761..8b24dff81c 100644 --- a/vmware_nsx/services/l2gateway/nsx_v3/driver.py +++ b/vmware_nsx/services/l2gateway/nsx_v3/driver.py @@ -140,6 +140,15 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin): if not uuidutils.is_uuid_like(devices[0]['device_name']): msg = _("Device name must be configured with a UUID") raise n_exc.InvalidInput(error_message=msg) + # Make sure the L2GW device ID exists as Bridge Cluster on NSX. + try: + self._core_plugin.nsxlib.bridge_cluster.get( + devices[0]['device_name']) + except nsxlib_exc.ResourceNotFound: + msg = _("Could not find Bridge Cluster for L2 gateway device " + "%s on NSX backend") % devices[0]['device_name'] + LOG.error(msg) + raise n_exc.InvalidInput(error_message=msg) # One L2 gateway must have only one interface defined. interfaces = devices[0].get(l2gw_const.IFACE_NAME_ATTR) if len(interfaces) > 1: