Merge "NSX-mh: allow names with underscore for l2gw transport"
This commit is contained in:
commit
41380abaaa
@ -65,6 +65,11 @@ class L2GatewayAlreadyInUse(n_exc.Conflict):
|
||||
message = _("Gateway Service %(gateway)s is already in use")
|
||||
|
||||
|
||||
class InvalidTransportType(NsxPluginException):
|
||||
message = _("The transport type %(transport_type)s is not recognized "
|
||||
"by the backend")
|
||||
|
||||
|
||||
class InvalidSecurityCertificate(NsxPluginException):
|
||||
message = _("An invalid security certificate was specified for the "
|
||||
"gateway device. Certificates must be enclosed between "
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
from neutron.i18n import _LE
|
||||
from oslo_log import log
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
@ -121,8 +122,15 @@ def _build_gateway_device_body(tenant_id, display_name, neutron_id,
|
||||
utils.NetworkTypes.GRE: "GREConnector",
|
||||
utils.NetworkTypes.BRIDGE: "BridgeConnector",
|
||||
'ipsec%s' % utils.NetworkTypes.STT: "IPsecSTT",
|
||||
'ipsec%s' % utils.NetworkTypes.GRE: "IPsecGRE"}
|
||||
'ipsec%s' % utils.NetworkTypes.GRE: "IPsecGRE",
|
||||
'ipsec_%s' % utils.NetworkTypes.STT: "IPsecSTT",
|
||||
'ipsec_%s' % utils.NetworkTypes.GRE: "IPsecGRE"}
|
||||
nsx_connector_type = connector_type_mappings.get(connector_type)
|
||||
if connector_type and not nsx_connector_type:
|
||||
LOG.error(_LE("There is no NSX mapping for connector type %s"),
|
||||
connector_type)
|
||||
raise nsx_exc.InvalidTransportType(transport_type=connector_type)
|
||||
|
||||
body = {"display_name": utils.check_and_truncate(display_name),
|
||||
"tags": utils.get_tags(os_tid=tenant_id,
|
||||
q_gw_dev_id=neutron_id),
|
||||
|
@ -19,6 +19,7 @@ from neutron.tests.unit.api.v2 import test_base
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
from vmware_nsx.neutron.plugins.vmware.api_client import exception
|
||||
from vmware_nsx.neutron.plugins.vmware.common import exceptions as nsx_exc
|
||||
from vmware_nsx.neutron.plugins.vmware.common import utils as nsx_utils
|
||||
from vmware_nsx.neutron.plugins.vmware import nsxlib
|
||||
from vmware_nsx.neutron.plugins.vmware.nsxlib import l2gateway as l2gwlib
|
||||
@ -195,6 +196,18 @@ class L2GatewayTestCase(base.NsxlibTestCase):
|
||||
jsonutils.dumps(expected_req_body, sort_keys=True),
|
||||
cluster=self.fake_cluster)
|
||||
|
||||
def test_create_gw_device_with_invalid_transport_type_raises(self):
|
||||
display_name = 'fake-device'
|
||||
neutron_id = 'whatever'
|
||||
connector_type = 'foo'
|
||||
connector_ip = '1.1.1.1'
|
||||
client_certificate = 'this_should_be_a_certificate'
|
||||
self.assertRaises(nsx_exc.InvalidTransportType,
|
||||
l2gwlib.create_gateway_device,
|
||||
self.fake_cluster, 'fake_tenant', display_name,
|
||||
neutron_id, 'fake_tz_uuid', connector_type,
|
||||
connector_ip, client_certificate)
|
||||
|
||||
def test_update_gw_device(self):
|
||||
# NOTE(salv-orlando): This unit test mocks backend calls rather than
|
||||
# leveraging the fake NSX API client
|
||||
|
Loading…
x
Reference in New Issue
Block a user