Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
prsunny authored May 23, 2024
2 parents 4d37760 + 425a852 commit 0acbbc8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions orchagent/port/portcnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ class PortConfig final
bool is_set = false;
} description; // Port description

struct {
std::string value;
bool is_set = false;
} subport; // Port subport

std::string key;
std::string op;

Expand Down
31 changes: 31 additions & 0 deletions orchagent/port/porthlpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,30 @@ bool PortHelper::parsePortDescription(PortConfig &port, const std::string &field
return true;
}

bool PortHelper::parsePortSubport(PortConfig &port, const std::string &field, const std::string &value) const
{
SWSS_LOG_ENTER();

if (value.empty())
{
SWSS_LOG_ERROR("Failed to parse field(%s): empty string is prohibited", field.c_str());
return false;
}

try
{
port.subport.value = value;
port.subport.is_set = true;
}
catch (const std::exception &e)
{
SWSS_LOG_ERROR("Failed to parse field(%s): %s", field.c_str(), e.what());
return false;
}

return true;
}

bool PortHelper::parsePortConfig(PortConfig &port) const
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -996,6 +1020,13 @@ bool PortHelper::parsePortConfig(PortConfig &port) const
return false;
}
}
else if (field == PORT_SUBPORT)
{
if (!this->parsePortSubport(port, field, value))
{
return false;
}
}
else
{
SWSS_LOG_WARN("Unknown field(%s): skipping ...", field.c_str());
Expand Down
1 change: 1 addition & 0 deletions orchagent/port/porthlpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ class PortHelper final
bool parsePortRole(PortConfig &port, const std::string &field, const std::string &value) const;
bool parsePortAdminStatus(PortConfig &port, const std::string &field, const std::string &value) const;
bool parsePortDescription(PortConfig &port, const std::string &field, const std::string &value) const;
bool parsePortSubport(PortConfig &port, const std::string &field, const std::string &value) const;
};
1 change: 1 addition & 0 deletions orchagent/port/portschema.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@
#define PORT_ROLE "role"
#define PORT_ADMIN_STATUS "admin_status"
#define PORT_DESCRIPTION "description"
#define PORT_SUBPORT "subport"

0 comments on commit 0acbbc8

Please sign in to comment.