[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:
Amey Bhide 2015-09-24 15:45:02 -07:00
parent 4483fe5006
commit b538ece323
6 changed files with 53 additions and 4 deletions

View File

@ -102,6 +102,7 @@ function neutron_plugin_configure_service {
_nsxv_ini_set nova_metadata_ips "$NSXV_NOVA_METADATA_IPS" _nsxv_ini_set nova_metadata_ips "$NSXV_NOVA_METADATA_IPS"
_nsxv_ini_set metadata_shared_secret "$NSXV_METADATA_SHARED_SECRET" _nsxv_ini_set metadata_shared_secret "$NSXV_METADATA_SHARED_SECRET"
_nsxv_ini_set edge_ha "$NSXV_EDGE_HA" _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 { function neutron_plugin_setup_interface_driver {

View File

@ -143,6 +143,13 @@
# (Optional) Deploys NSX Edges in HA mode # (Optional) Deploys NSX Edges in HA mode
# edge_ha = False # 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. # (ListOpt) Ordered list of router_types to allocate as tenant routers.
# It limits the router types that the Nsxv can support for tenants: # It limits the router types that the Nsxv can support for tenants:
# distributed: router is supported by distributed edge at the backend. # distributed: router is supported by distributed edge at the backend.

View File

@ -324,7 +324,14 @@ nsxv_opts = [
"initialize the metadata infrastructure")), "initialize the metadata infrastructure")),
cfg.BoolOpt('edge_ha', cfg.BoolOpt('edge_ha',
default=False, 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 # Register the configuration options

View File

@ -17,11 +17,11 @@ from neutron.api.v2 import attributes
ROUTER_SIZE = 'router_size' ROUTER_SIZE = 'router_size'
VALID_EDGE_SIZES = ['compact', 'large', 'xlarge', 'quadlarge']
EXTENDED_ATTRIBUTES_2_0 = { EXTENDED_ATTRIBUTES_2_0 = {
'routers': { 'routers': {
ROUTER_SIZE: {'allow_post': True, 'allow_put': False, ROUTER_SIZE: {'allow_post': True, 'allow_put': False,
'validate': {'type:values': ['compact', 'large', 'validate': {'type:values': VALID_EDGE_SIZES},
'xlarge', 'quadlarge']},
'default': attributes.ATTR_NOT_SPECIFIED, 'default': attributes.ATTR_NOT_SPECIFIED,
'is_visible': True}, 'is_visible': True},
} }

View File

@ -80,6 +80,7 @@ from vmware_nsx.plugins.nsx_v.vshield import vcns_driver
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
PORTGROUP_PREFIX = 'dvportgroup' PORTGROUP_PREFIX = 'dvportgroup'
ROUTER_SIZE = routersize.ROUTER_SIZE ROUTER_SIZE = routersize.ROUTER_SIZE
VALID_EDGE_SIZES = routersize.VALID_EDGE_SIZES
class NsxVPluginV2(agents_db.AgentDbMixin, class NsxVPluginV2(agents_db.AgentDbMixin,
@ -1366,7 +1367,16 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
raise n_exc.BadRequest(resource="router", msg=msg) raise n_exc.BadRequest(resource="router", msg=msg)
elif r.get(ROUTER_SIZE) == attr.ATTR_NOT_SPECIFIED: elif r.get(ROUTER_SIZE) == attr.ATTR_NOT_SPECIFIED:
if r.get('router_type') == nsxv_constants.EXCLUSIVE: 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): def create_router(self, context, router, allow_metadata=True):
self._validate_router_size(router) self._validate_router_size(router)

View File

@ -1850,6 +1850,30 @@ class TestExclusiveRouterTestCase(L3NatTest, L3NatTestCaseBase,
router = self.deserialize(self.fmt, res) router = self.deserialize(self.fmt, res)
self.assertEqual(size, router['router']['router_size']) 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): def test_router_add_gateway_invalid_network_returns_404(self):
# NOTE(salv-orlando): This unit test has been overriden # NOTE(salv-orlando): This unit test has been overriden
# as the nsx plugin support the ext_gw_mode extension # as the nsx plugin support the ext_gw_mode extension