Skip to content

Commit

Permalink
Fix initializePort: only set down status if attr missing (sonic-net#555)
Browse files Browse the repository at this point in the history
* Fix initializePort: only set down status if attr missing
* Refine logging
  • Loading branch information
qiluo-msft authored Aug 2, 2018
1 parent 944a80d commit 7724382
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2000,18 +2000,43 @@ bool PortsOrch::initializePort(Port &p)
}
#endif

/* Set default port admin status to DOWN */
/* FIXME: Do we need this? The default port admin status is false */
setPortAdminStatus(p.m_port_id, false);
/* Check warm start states */
vector<FieldValueTuple> tuples;
bool exist = m_portTable->get(p.m_alias, tuples);
string adminStatus, operStatus;
if (exist)
{
for (auto i : tuples)
{
if (fvField(i) == "admin_status")
{
adminStatus = fvValue(i);
}
else if (fvField(i) == "oper_status")
{
operStatus = fvValue(i);
}
}
}
SWSS_LOG_DEBUG("initializePort %s with admin %s and oper %s", p.m_alias.c_str(), adminStatus.c_str(), operStatus.c_str());

/* Set port admin status to DOWN if attr missing */
if (adminStatus != "up")
{
setPortAdminStatus(p.m_port_id, false);
}

/**
* Create default database port oper status as DOWN
* Create database port oper status as DOWN if attr missing
* This status will be updated when receiving port_oper_status_notification.
*/
vector<FieldValueTuple> vector;
FieldValueTuple tuple("oper_status", "down");
vector.push_back(tuple);
m_portTable->set(p.m_alias, vector);
if (operStatus != "up")
{
vector<FieldValueTuple> vector;
FieldValueTuple tuple("oper_status", "down");
vector.push_back(tuple);
m_portTable->set(p.m_alias, vector);
}

return true;
}
Expand Down

0 comments on commit 7724382

Please sign in to comment.