Skip to content

Commit 3796a9a

Browse files
committed
Remove the port_config.ini dependency from portsyncd
portsyncd will rely on configDB port table, not from port_config.ini port_config.ini is used when we convert minigraph to configDB, then everything should come from configDB. Also for the DPB feature, we are going to deprecate port_config.ini Signed-off-by: Zhenggen Xu <[email protected]>
1 parent 731a8f5 commit 3796a9a

File tree

1 file changed

+7
-104
lines changed

1 file changed

+7
-104
lines changed

portsyncd/portsyncd.cpp

Lines changed: 7 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ bool g_init = false;
3535

3636
void usage()
3737
{
38-
cout << "Usage: portsyncd [-p port_config.ini]" << endl;
39-
cout << " -p port_config.ini: import port lane mapping" << endl;
40-
cout << " use configDB data if not specified" << endl;
38+
cout << "Usage: portsyncd" << endl;
39+
cout << " port lane mapping is from configDB" << endl;
40+
cout << " this program will exit if configDB does not contain that info" << endl;
4141
}
4242

4343
void handlePortConfigFile(ProducerStateTable &p, string file, bool warm);
@@ -50,16 +50,12 @@ int main(int argc, char **argv)
5050
{
5151
Logger::linkToDbNative("portsyncd");
5252
int opt;
53-
string port_config_file;
5453
map<string, KeyOpFieldsValuesTuple> port_cfg_map;
5554

56-
while ((opt = getopt(argc, argv, "p:v:h")) != -1 )
55+
while ((opt = getopt(argc, argv, "v:h")) != -1 )
5756
{
5857
switch (opt)
5958
{
60-
case 'p':
61-
port_config_file.assign(optarg);
62-
break;
6359
case 'h':
6460
usage();
6561
return 1;
@@ -91,11 +87,9 @@ int main(int argc, char **argv)
9187
if (!handlePortConfigFromConfigDB(p, cfgDb, warm))
9288
{
9389
// if port config is missing in ConfigDB
94-
// attempt to use port_config.ini
95-
if (!port_config_file.empty())
96-
{
97-
handlePortConfigFile(p, port_config_file, warm);
98-
}
90+
// program will exit with failure
91+
SWSS_LOG_THROW("ConfigDB does not have port information, existing...");
92+
return EXIT_FAILURE;
9993
}
10094

10195
LinkSync sync(&appl_db, &state_db);
@@ -222,97 +216,6 @@ bool handlePortConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb, boo
222216
return true;
223217
}
224218

225-
void handlePortConfigFile(ProducerStateTable &p, string file, bool warm)
226-
{
227-
cout << "Read port configuration file..." << endl;
228-
229-
ifstream infile(file);
230-
if (!infile.is_open())
231-
{
232-
usage();
233-
throw runtime_error("Port configuration file not found!");
234-
}
235-
236-
list<string> header = {"name", "lanes", "alias", "speed", "autoneg", "fec"};
237-
string line;
238-
while (getline(infile, line))
239-
{
240-
if (line.at(0) == '#')
241-
{
242-
// Take this line as column header line
243-
istringstream iss_hdr(line.substr(1));
244-
string hdr;
245-
246-
header.clear();
247-
while (! iss_hdr.eof()) {
248-
iss_hdr >> hdr;
249-
cout << "Adding column header '" << hdr << "'" << endl;
250-
header.push_back(hdr);
251-
}
252-
253-
continue;
254-
}
255-
256-
istringstream iss(line);
257-
map<string, string> entry;
258-
259-
/* Read port configuration entry */
260-
for (auto column : header)
261-
{
262-
iss >> entry[column];
263-
}
264-
265-
if (!warm)
266-
{
267-
/* If port has no alias, then use its name as alias */
268-
string alias;
269-
if ((entry.find("alias") != entry.end()) && (entry["alias"] != ""))
270-
{
271-
alias = entry["alias"];
272-
}
273-
else
274-
{
275-
alias = entry["name"];
276-
}
277-
278-
FieldValueTuple lanes_attr("lanes", entry["lanes"]);
279-
FieldValueTuple alias_attr("alias", alias);
280-
281-
vector<FieldValueTuple> attrs;
282-
attrs.push_back(lanes_attr);
283-
attrs.push_back(alias_attr);
284-
285-
if ((entry.find("speed") != entry.end()) && (entry["speed"] != ""))
286-
{
287-
FieldValueTuple speed_attr("speed", entry["speed"]);
288-
attrs.push_back(speed_attr);
289-
}
290-
291-
if ((entry.find("autoneg") != entry.end()) && (entry["autoneg"] != ""))
292-
{
293-
FieldValueTuple autoneg_attr("autoneg", entry["autoneg"]);
294-
attrs.push_back(autoneg_attr);
295-
}
296-
297-
if ((entry.find("fec") != entry.end()) && (entry["fec"] != ""))
298-
{
299-
FieldValueTuple fec_attr("fec", entry["fec"]);
300-
attrs.push_back(fec_attr);
301-
}
302-
303-
p.set(entry["name"], attrs);
304-
}
305-
306-
g_portSet.insert(entry["name"]);
307-
}
308-
309-
infile.close();
310-
if (!warm)
311-
{
312-
notifyPortConfigDone(p);
313-
}
314-
}
315-
316219
void handlePortConfig(ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map)
317220
{
318221

0 commit comments

Comments
 (0)