[AIM NFV] Limit the number of PPG per PC to 3

PPG: Port Pair Group
PC: Port Chain

We limit the number of services in a chain to three
as suggested by the ACI guidelines

Change-Id: Ibf6cc78a1f0363eb45767a594318e28edd0235ab
This commit is contained in:
Ivar Lazzaro 2018-02-20 16:48:21 -08:00
parent d77da01dcb
commit 5e463d2a5d
3 changed files with 28 additions and 0 deletions

View File

@ -112,3 +112,7 @@ class ConflictingNetworksDetectedInPortChain(exceptions.BadRequest):
class DefaultExternalNetworkNotFound(exceptions.NotFound):
message = _("Default External Network not found for SVI network "
"%(id)s.")
class TooManyPPGsPerChainError(exceptions.BadRequest):
message = _("The max number of PPGs per chain supported is %(maxn)s.")

View File

@ -42,6 +42,7 @@ FLOWC_DST = 'dst'
LOG = logging.getLogger(__name__)
PHYSDOM_TYPE = 'PhysDom'
SUPPORTED_DOM_TYPES = [PHYSDOM_TYPE]
MAX_PPGS_PER_CHAIN = 3
class SfcAIMDriverBase(base.SfcDriverBase):
@ -290,6 +291,8 @@ class SfcAIMDriver(SfcAIMDriverBase):
# can be removed once contract export is implemented.
# TODO(ivar): two different chains cannot share left/right networks
# TODO(ivar): right/left BDs same tenant as provider
if len(ppgs) > MAX_PPGS_PER_CHAIN:
raise exceptions.TooManyPPGsPerChainError(maxn=MAX_PPGS_PER_CHAIN)
vrfs = set()
for flowc in flowcs:
provg = self._get_flowc_provider_group(p_ctx, flowc)

View File

@ -1001,6 +1001,27 @@ class TestPortChain(TestAIMServiceFunctionChainingBase):
self._verify_pc_mapping(pc)
self._verify_pc_delete(pc)
def test_pc_max_ppg_validation(self):
fc = self._create_simple_flowc(src_svi=self.src_svi,
dst_svi=self.dst_svi)
ppg1 = self._create_simple_ppg(pairs=1)
ppg2 = self._create_simple_ppg(pairs=1)
ppg3 = self._create_simple_ppg(pairs=1)
ppg4 = self._create_simple_ppg(pairs=1)
self.create_port_chain(port_pair_groups=[ppg1['id'], ppg2['id'],
ppg3['id'], ppg4['id']],
flow_classifiers=[fc['id']],
expected_res_status=400)
pc = self.create_port_chain(port_pair_groups=[ppg1['id'],
ppg2['id'],
ppg3['id']],
flow_classifiers=[fc['id']],
expected_res_status=201)['port_chain']
self.update_port_chain(pc['id'],
port_pair_groups=[ppg1['id'], ppg2['id'],
ppg3['id'], ppg4['id']],
expected_res_status=500)
class TestPortChainSVI(TestPortChain):