Skip to content

Commit

Permalink
Add synchronous switch to orch agent (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored and lguohan committed Jul 25, 2019
1 parent dde876d commit e1f4403
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ int gBatchSize = DEFAULT_BATCH_SIZE;
bool gSairedisRecord = true;
bool gSwssRecord = true;
bool gLogRotate = false;
bool gSyncMode = false;

ofstream gRecordOfs;
string gRecordFile;

void usage()
{
cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-b batch_size] [-m MAC]" << endl;
cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-b batch_size] [-m MAC] [-s]" << endl;
cout << " -h: display this message" << endl;
cout << " -r record_type: record orchagent logs with type (default 3)" << endl;
cout << " 0: do not record logs" << endl;
Expand All @@ -62,6 +64,7 @@ void usage()
cout << " -d record_location: set record logs folder location (default .)" << endl;
cout << " -b batch_size: set consumer table pop operation batch size (default 128)" << endl;
cout << " -m MAC: set switch MAC address" << endl;
cout << " -s: enable synchronous mode" << endl;
}

void sighup_handler(int signo)
Expand Down Expand Up @@ -118,7 +121,7 @@ int main(int argc, char **argv)

string record_location = ".";

while ((opt = getopt(argc, argv, "b:m:r:d:h")) != -1)
while ((opt = getopt(argc, argv, "b:m:r:d:hs")) != -1)
{
switch (opt)
{
Expand Down Expand Up @@ -163,6 +166,11 @@ int main(int argc, char **argv)
case 'h':
usage();
exit(EXIT_SUCCESS);
case 's':
gSyncMode = true;
SWSS_LOG_NOTICE("Enabling synchronous mode");
break;

default: /* '?' */
exit(EXIT_FAILURE);
}
Expand Down Expand Up @@ -220,6 +228,14 @@ int main(int argc, char **argv)
}
SWSS_LOG_NOTICE("Create a switch");

if (gSyncMode)
{
attr.id = SAI_REDIS_SWITCH_ATTR_SYNC_MODE;
attr.value.booldata = true;

sai_switch_api->set_switch_attribute(gSwitchId, &attr);
}

/* Get switch source MAC address if not provided */
if (!gMacAddress)
{
Expand Down

0 comments on commit e1f4403

Please sign in to comment.