[NSXv]: Add conf param for exclusive router edge size
Allows user to specify default exclusive_router_appliance_size in nsx.ini file. If --router-size isn't specified in neutron router-create CLI command; exclusive_router_appliance_size will be picked up DocImpact Change-Id: I010bfdb8c5807bb933085f049326082c8b5782dc
This commit is contained in:
parent
4483fe5006
commit
b538ece323
@ -102,6 +102,7 @@ function neutron_plugin_configure_service {
|
||||
_nsxv_ini_set nova_metadata_ips "$NSXV_NOVA_METADATA_IPS"
|
||||
_nsxv_ini_set metadata_shared_secret "$NSXV_METADATA_SHARED_SECRET"
|
||||
_nsxv_ini_set edge_ha "$NSXV_EDGE_HA"
|
||||
_nsxv_ini_set exclusive_router_appliance_size "$NSXV_EXCLUSIVE_ROUTER_APPLIANCE_SIZE"
|
||||
}
|
||||
|
||||
function neutron_plugin_setup_interface_driver {
|
||||
|
@ -143,6 +143,13 @@
|
||||
|
||||
# (Optional) Deploys NSX Edges in HA mode
|
||||
# edge_ha = False
|
||||
|
||||
# (Optional) Edge appliance size to be used for creating exclusive router.
|
||||
# Valid values: ['compact', 'large', 'xlarge', 'quadlarge']
|
||||
# This exclusive_router_appliance_size will be picked up if --router-size
|
||||
# parameter is not specified while doing neutron router-create
|
||||
# exclusive_router_appliance_size = compact
|
||||
|
||||
# (ListOpt) Ordered list of router_types to allocate as tenant routers.
|
||||
# It limits the router types that the Nsxv can support for tenants:
|
||||
# distributed: router is supported by distributed edge at the backend.
|
||||
|
@ -324,7 +324,14 @@ nsxv_opts = [
|
||||
"initialize the metadata infrastructure")),
|
||||
cfg.BoolOpt('edge_ha',
|
||||
default=False,
|
||||
help=_("Enable HA for NSX Edges"))
|
||||
help=_("Enable HA for NSX Edges")),
|
||||
cfg.StrOpt('exclusive_router_appliance_size',
|
||||
default="compact",
|
||||
help=_("Edge appliance size to be used for creating exclusive "
|
||||
"router. Valid values: ['compact', 'large', 'xlarge', "
|
||||
"'quadlarge']. This edge_appliance_size will be picked "
|
||||
"up if --router-size parameter is not specified while "
|
||||
"doing neutron router-create")),
|
||||
]
|
||||
|
||||
# Register the configuration options
|
||||
|
@ -17,11 +17,11 @@ from neutron.api.v2 import attributes
|
||||
|
||||
|
||||
ROUTER_SIZE = 'router_size'
|
||||
VALID_EDGE_SIZES = ['compact', 'large', 'xlarge', 'quadlarge']
|
||||
EXTENDED_ATTRIBUTES_2_0 = {
|
||||
'routers': {
|
||||
ROUTER_SIZE: {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:values': ['compact', 'large',
|
||||
'xlarge', 'quadlarge']},
|
||||
'validate': {'type:values': VALID_EDGE_SIZES},
|
||||
'default': attributes.ATTR_NOT_SPECIFIED,
|
||||
'is_visible': True},
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ from vmware_nsx.plugins.nsx_v.vshield import vcns_driver
|
||||
LOG = logging.getLogger(__name__)
|
||||
PORTGROUP_PREFIX = 'dvportgroup'
|
||||
ROUTER_SIZE = routersize.ROUTER_SIZE
|
||||
VALID_EDGE_SIZES = routersize.VALID_EDGE_SIZES
|
||||
|
||||
|
||||
class NsxVPluginV2(agents_db.AgentDbMixin,
|
||||
@ -1366,7 +1367,16 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
|
||||
raise n_exc.BadRequest(resource="router", msg=msg)
|
||||
elif r.get(ROUTER_SIZE) == attr.ATTR_NOT_SPECIFIED:
|
||||
if r.get('router_type') == nsxv_constants.EXCLUSIVE:
|
||||
r[ROUTER_SIZE] = nsxv_constants.COMPACT
|
||||
appliance_size = cfg.CONF.nsxv.exclusive_router_appliance_size
|
||||
if appliance_size not in VALID_EDGE_SIZES:
|
||||
msg = (_("Invalid edge size specified in nsx.ini file. "
|
||||
"Specified value: %(specified)s; "
|
||||
"Valid values: %(valid)s") %
|
||||
{'specified': appliance_size,
|
||||
'valid': VALID_EDGE_SIZES})
|
||||
raise n_exc.BadRequest(resource="router", msg=msg)
|
||||
else:
|
||||
r[ROUTER_SIZE] = appliance_size
|
||||
|
||||
def create_router(self, context, router, allow_metadata=True):
|
||||
self._validate_router_size(router)
|
||||
|
@ -1850,6 +1850,30 @@ class TestExclusiveRouterTestCase(L3NatTest, L3NatTestCaseBase,
|
||||
router = self.deserialize(self.fmt, res)
|
||||
self.assertEqual(size, router['router']['router_size'])
|
||||
|
||||
def test_router_create_overriding_default_edge_size(self):
|
||||
data = {'router': {
|
||||
'tenant_id': 'whatever',
|
||||
'name': 'test_router',
|
||||
'router_type': 'exclusive'}}
|
||||
cfg.CONF.set_override('exclusive_router_appliance_size',
|
||||
'xlarge', group='nsxv')
|
||||
router_req = self.new_create_request('routers', data, self.fmt)
|
||||
res = router_req.get_response(self.ext_api)
|
||||
router = self.deserialize(self.fmt, res)
|
||||
self.assertEqual('xlarge', router['router']['router_size'])
|
||||
|
||||
def test_router_create_fails_when_bad_edge_size_specified(self):
|
||||
data = {'router': {
|
||||
'tenant_id': 'whatever',
|
||||
'name': 'test_router',
|
||||
'router_type': 'exclusive'}}
|
||||
cfg.CONF.set_override('exclusive_router_appliance_size',
|
||||
'foobar', group='nsxv')
|
||||
router_req = self.new_create_request('routers', data, self.fmt)
|
||||
res = router_req.get_response(self.ext_api)
|
||||
router = self.deserialize(self.fmt, res)
|
||||
self.assertEqual("BadRequest", router['NeutronError']['type'])
|
||||
|
||||
def test_router_add_gateway_invalid_network_returns_404(self):
|
||||
# NOTE(salv-orlando): This unit test has been overriden
|
||||
# as the nsx plugin support the ext_gw_mode extension
|
||||
|
Loading…
Reference in New Issue
Block a user