Merge "[NSX-v3]: Fix L2GW connection-create"
This commit is contained in:
commit
be5d8c0508
@ -130,6 +130,11 @@ 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)
|
||||
# One L2 gateway must have only one interface defined.
|
||||
interfaces = devices[0].get(l2gw_const.IFACE_NAME_ATTR)
|
||||
if len(interfaces) > 1:
|
||||
msg = _("Maximum of one interface is supported for one L2 gateway")
|
||||
raise n_exc.InvalidInput(error_message=msg)
|
||||
|
||||
def create_l2_gateway(self, context, l2_gateway):
|
||||
"""Create a logical L2 gateway."""
|
||||
@ -173,8 +178,11 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
|
||||
# connection create. l2gateway_db_mixin makes sure that it is
|
||||
# configured one way or the other.
|
||||
seg_id = gw_connection.get(l2gw_const.SEG_ID)
|
||||
if seg_id is None:
|
||||
seg_id = devices[0]['interfaces'][0].get('segmentation_id')
|
||||
if not seg_id:
|
||||
# Seg-id was not passed as part of connection-create. Retrieve
|
||||
# seg-id from L2 gateway's interface.
|
||||
interface = self._get_l2_gw_interfaces(context, devices[0]['id'])
|
||||
seg_id = interface[0].get(l2gw_const.SEG_ID)
|
||||
self._validate_segment_id(seg_id)
|
||||
try:
|
||||
tags = nsx_utils.build_v3_tags_payload(
|
||||
|
@ -129,6 +129,19 @@ class TestNsxV3L2GatewayDriver(test_l2gw_db.L2GWTestCase,
|
||||
self.driver.create_l2_gateway,
|
||||
self.context, invalid_l2gw_dict)
|
||||
|
||||
def test_create_l2_gateway_multiple_interfaces_fail(self):
|
||||
invalid_l2gw_dict = {
|
||||
"l2_gateway": {
|
||||
"tenant_id": "fake_tenant_id",
|
||||
"name": "invalid_l2gw",
|
||||
"devices": [{"interfaces":
|
||||
[{"name": "interface1"},
|
||||
{"name": "interface2"}],
|
||||
"device_name": "device1"}]}}
|
||||
self.assertRaises(n_exc.InvalidInput,
|
||||
self.driver.create_l2_gateway,
|
||||
self.context, invalid_l2gw_dict)
|
||||
|
||||
def test_create_l2_gateway_invalid_device_name_fail(self):
|
||||
invalid_l2gw_dict = {
|
||||
"l2_gateway": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user