Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion cfgmgr/shellcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#define IP_CMD "/sbin/ip"
#define BRIDGE_CMD "/sbin/bridge"
#define ECHO_CMD "/bin/echo"
#define REDIS_CLI_CMD "/usr/bin/redis-cli"
#define XARGS_CMD "/usr/bin/xargs"
#define GREP_CMD "/bin/grep"
#define AWK_CMD "/usr/bin/awk"
Expand Down
26 changes: 15 additions & 11 deletions cfgmgr/vlanmgrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <fstream>
#include <iostream>
#include <mutex>
#include <algorithm>
#include "dbconnector.h"
#include "select.h"
#include "exec.h"
Expand Down Expand Up @@ -46,17 +47,6 @@ int main(int argc, char **argv)

try
{
/*
* swss service starts after interfaces-config.service which will have
* switch_mac set.
* Dynamic switch_mac update is not supported for now.
*/
string switch_mac_str;
stringstream cmd;
cmd << REDIS_CLI_CMD << " -n " << CONFIG_DB << " hget " << " \"DEVICE_METADATA|localhost\" " << " mac";
EXEC_WITH_ERROR_THROW(cmd.str(), switch_mac_str);
gMacAddress = MacAddress(switch_mac_str);

vector<string> cfg_vlan_tables = {
CFG_VLAN_TABLE_NAME,
CFG_VLAN_MEMBER_TABLE_NAME,
Expand All @@ -66,6 +56,20 @@ int main(int argc, char **argv)
DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);

/*
* swss service starts after interfaces-config.service which will have
* switch_mac set.
* Dynamic switch_mac update is not supported for now.
*/
Table table(&cfgDb, "DEVICE_METADATA", CONFIGDB_TABLE_NAME_SEPARATOR);
std::vector<FieldValueTuple> ovalues;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need std::

table.get("localhost", ovalues);
auto it = std::find_if( ovalues.begin(), ovalues.end(), [](const FieldValueTuple& t){ return t.first == "mac";} );
if ( it == ovalues.end() ) {
throw runtime_error("couldn't find MAC address of the device from config DB");
}
gMacAddress = MacAddress(it->second);

VlanMgr vlanmgr(&cfgDb, &appDb, &stateDb, cfg_vlan_tables);

std::vector<Orch *> cfgOrchList = {&vlanmgr};
Expand Down