Browse Source

NSXV: make service edge sizes configurable

Allow configuration of default sizes per edge purpose.

Change-Id: I7a8dcc42144edf064435357fb555f5cbe72c92e6
(cherry picked from commit f96384fc20)
changes/36/777336/1
Kobi Samoray 5 months ago
parent
commit
f82ec9c1fd
  1. 18
      vmware_nsx/common/config.py
  2. 1
      vmware_nsx/common/nsxv_constants.py
  3. 32
      vmware_nsx/plugins/nsx_v/vshield/edge_utils.py
  4. 2
      vmware_nsx/services/lbaas/nsx_v/implementation/loadbalancer_mgr.py
  5. 2
      vmware_nsx/tests/unit/nsx_v/test_edge_loadbalancer_driver_v2.py

18
vmware_nsx/common/config.py

@ -20,6 +20,7 @@ from neutron.conf.db import l3_hamode_db
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsxv_constants
from vmware_nsx.dvs import dvs_utils
from vmware_nsx.extensions import projectpluginmap
from vmware_nsx.extensions import routersize
@ -862,7 +863,13 @@ nsxv_opts = [
default=False,
help=_("Create LBaaS pools with transparent mode on. Use with "
"use_routers_as_lbaas_platform enabled")),
cfg.ListOpt('default_edge_size',
default=[],
help=_("(Optional) Defines the default edge size for router, "
"dhcp and loadbalancer edges with the format: "
"<purpose>:<edge_size>. "
"purpose: router, dhcp, lb. "
"edge_size: compact, large, xlarge, quadlarge")),
]
# define the configuration of each NSX-V availability zone.
@ -1122,6 +1129,15 @@ def validate_nsxv_config_options():
error = _("dvs host/vcenter credentials must be defined to use "
"dvs features")
raise nsx_exc.NsxPluginException(err_msg=error)
for purpose_def in cfg.CONF.nsxv.default_edge_size:
(p, s) = purpose_def.split(':')
if p not in ['lb', 'router', 'dhcp']:
error = _('Invalid service edge purpose %s') % p
raise nsx_exc.NsxPluginException(err_msg=error)
if s not in nsxv_constants.VALID_EDGE_SIZE:
error = _('Invalid service edge size %s') % s
raise nsx_exc.NsxPluginException(err_msg=error)
def validate_nsx_config_options():

1
vmware_nsx/common/nsxv_constants.py

@ -19,6 +19,7 @@ LARGE = 'large'
XLARGE = 'xlarge'
QUADLARGE = 'quadlarge'
VALID_EDGE_SIZE = [COMPACT, LARGE, XLARGE, QUADLARGE]
EXCLUSIVE = "exclusive"

32
vmware_nsx/plugins/nsx_v/vshield/edge_utils.py

@ -67,6 +67,19 @@ SUPPORTED_EDGE_LOG_MODULES = ('routing', 'highavailability',
SUPPORTED_EDGE_LOG_LEVELS = ('none', 'debug', 'info', 'warning', 'error')
def parse_service_edge_size():
edge_size_dict = {}
if cfg.CONF.nsxv.default_edge_size:
for purpose_def in cfg.CONF.nsxv.default_edge_size:
(p, s) = purpose_def.split(':')
edge_size_dict[p] = s
return edge_size_dict
def get_service_edge_size(size_dict, purpose):
return size_dict.get(purpose, vcns_const.SERVICE_SIZE_MAPPING[purpose])
def _get_vdr_transit_network_ipobj():
transit_net = cfg.CONF.nsxv.vdr_transit_network
return netaddr.IPNetwork(transit_net)
@ -193,6 +206,10 @@ class EdgeManager(object):
self.plugin = plugin
self.per_interface_rp_filter = self._get_per_edge_rp_filter_state()
self._check_backup_edge_pools()
self._service_edge_size_dict = parse_service_edge_size()
def get_service_edge_size(self, purpose):
return get_service_edge_size(self._service_edge_size_dict, purpose)
def _parse_backup_edge_pool_opt(self):
"""Parse edge pool opts for all availability zones."""
@ -851,14 +868,16 @@ class EdgeManager(object):
_uuid())[:vcns_const.EDGE_NAME_LEN]
self._allocate_edge_appliance(
context, resource_id, resource_name,
appliance_size=vcns_const.SERVICE_SIZE_MAPPING['dhcp'],
appliance_size=self.get_service_edge_size('dhcp'),
availability_zone=availability_zone,
deploy_metadata=True)
def allocate_lb_edge_appliance(
self, context, resource_id, availability_zone,
appliance_size=vcns_const.SERVICE_SIZE_MAPPING['lb']):
appliance_size=None):
if not appliance_size:
appliance_size = self.get_service_edge_size('lb')
return self._allocate_edge_appliance(
context, resource_id, resource_id,
appliance_size=appliance_size,
@ -893,9 +912,11 @@ class EdgeManager(object):
def create_lrouter(
self, context, lrouter, lswitch=None, dist=False,
appliance_size=vcns_const.SERVICE_SIZE_MAPPING['router'],
appliance_size=None,
availability_zone=None):
"""Create an edge for logical router support."""
if not appliance_size:
appliance_size = self.get_service_edge_size('router')
router_name = self._build_lrouter_name(lrouter['id'], lrouter['name'])
edge_id = self._allocate_edge_appliance(
@ -1254,7 +1275,7 @@ class EdgeManager(object):
def reuse_existing_dhcp_edge(self, context, edge_id, resource_id,
network_id, availability_zone):
app_size = vcns_const.SERVICE_SIZE_MAPPING['dhcp']
app_size = self.get_service_edge_size('dhcp')
# There may be edge cases when we are waiting for edges to deploy
# and the underlying db session may hit a timeout. So this creates
# a new session
@ -2034,7 +2055,8 @@ def create_lrouter(nsxv_manager, context, lrouter, lswitch=None, dist=False,
"""Create an edge for logical router support."""
router_id = lrouter['id']
router_name = lrouter['name'] + '-' + router_id
appliance_size = vcns_const.SERVICE_SIZE_MAPPING['router']
appliance_size = get_service_edge_size(parse_service_edge_size(),
'router')
# store router-edge mapping binding
nsxv_db.add_nsxv_router_binding(
context.session, router_id, None, None,

2
vmware_nsx/services/lbaas/nsx_v/implementation/loadbalancer_mgr.py

@ -46,7 +46,7 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.EdgeLoadbalancerBaseManager):
def _get_lb_flavor_size(self, context, flavor_id):
if not flavor_id:
return vcns_const.SERVICE_SIZE_MAPPING['lb']
return self.core_plugin.edge_manager.get_service_edge_size('lb')
else:
flavor = flavors_plugin.FlavorsPlugin.get_flavor(
self.flavor_plugin, context, flavor_id)

2
vmware_nsx/tests/unit/nsx_v/test_edge_loadbalancer_driver_v2.py

@ -266,7 +266,7 @@ class TestEdgeLbaasV2LoadbalancerOnRtr(BaseTestEdgeLbaasV2):
self.edge_driver.pool.vcns, LB_EDGE_ID, 'accept')
mock_get_edge.assert_called_with(mock.ANY, mock.ANY, LB_ID,
LB_VIP, mock.ANY,
LB_TENANT_ID, 'compact')
LB_TENANT_ID, mock.ANY)
mock_add_vip_fwr.assert_called_with(self.edge_driver.pool.vcns,
LB_EDGE_ID,

Loading…
Cancel
Save