From ce5b35830616c8bc675dc536b85d33080c8f2eed Mon Sep 17 00:00:00 2001 From: Itamar Talmon Date: Mon, 28 Feb 2022 16:04:28 +0200 Subject: [PATCH] Added front panel port prefix regex to schema.h to support different front panel prefixes --- common/schema.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/schema.h b/common/schema.h index 70872a907..389824d00 100644 --- a/common/schema.h +++ b/common/schema.h @@ -447,6 +447,21 @@ namespace swss { #define FRONT_PANEL_PORT_PREFIX "Ethernet" #define PORTCHANNEL_PREFIX "PortChannel" #define VLAN_PREFIX "Vlan" +/* + * In order to support different front panel ports prefix, we will + * add a regex that contains all the possible prefixes and need to be + * adjusted once new front panel prefix is added. + * e.g. if we want to add an "SwitchPort" prefix, we will add a new + * #define FRONT_PANEL_SWP_PORT_PREFIX "SwitchPort" + * and update the regex as follows - + * #define FRONT_PANEL_PORT_PREFIX_REGEX "^(" FRONT_PANEL_PORT_PREFIX "|" FRONT_PANEL_SWP_PORT_PREFIX ")(\\d+)$" + * + * IMPORTANT - now checking for front panel prefixes should only be done using a + * regex library. + * in CPP - import and use std::regex_match(port_name_str, std::regex(FRONT_PANEL_PORT_PREFIX_REGEX)) + * in python - import re and use re.match(swsscommon.FRONT_PANEL_PORT_PREFIX_REGEX, port_name_str) + */ +#define FRONT_PANEL_PORT_PREFIX_REGEX "^(" FRONT_PANEL_PORT_PREFIX ")(\\d+)$" #define SET_COMMAND "SET" #define DEL_COMMAND "DEL"