Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added front panel port prefix regex to schema.h #598

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions common/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,22 @@ 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
itamar-talmon marked this conversation as resolved.
Show resolved Hide resolved
* #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 ")"
Copy link
Contributor

@qiluo-msft qiluo-msft May 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need define a SWP prefix and use |?
Is it possible just change FRONT_PANEL_PORT_PREFIX value? #Closed

Copy link
Author

@itamar-talmon itamar-talmon May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to support few options in the same time (e.g. we will have something like normal_front_panel_ports and special_front_panel_ports) and if we would like to check which of possible options was matched and act differently on it somehow - it would be easier and more maintainable to have something defined to compare it to for each option.

*
* IMPORTANT - now checking for front panel prefixes should only be done using a
* regex library.
* in CPP - import <regex> and use std::regex_match(port_name_str, std::regex(FRONT_PANEL_PORT_REGEX))
* in python - import re and use re.match(swsscommon.FRONT_PANEL_PORT_REGEX, port_name_str)
*/
#define FRONT_PANEL_PORT_PREFIX_REGEX "^(" FRONT_PANEL_PORT_PREFIX ")"
#define FRONT_PANEL_PORT_REGEX FRONT_PANEL_PORT_PREFIX_REGEX "(\\d+)"

#define SET_COMMAND "SET"
#define DEL_COMMAND "DEL"
Expand Down