@@ -35,9 +35,9 @@ bool g_init = false;
35
35
36
36
void usage ()
37
37
{
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;
41
41
}
42
42
43
43
void handlePortConfigFile (ProducerStateTable &p, string file, bool warm);
@@ -50,16 +50,12 @@ int main(int argc, char **argv)
50
50
{
51
51
Logger::linkToDbNative (" portsyncd" );
52
52
int opt;
53
- string port_config_file;
54
53
map<string, KeyOpFieldsValuesTuple> port_cfg_map;
55
54
56
- while ((opt = getopt (argc, argv, " p: v:h" )) != -1 )
55
+ while ((opt = getopt (argc, argv, " v:h" )) != -1 )
57
56
{
58
57
switch (opt)
59
58
{
60
- case ' p' :
61
- port_config_file.assign (optarg);
62
- break ;
63
59
case ' h' :
64
60
usage ();
65
61
return 1 ;
@@ -91,11 +87,9 @@ int main(int argc, char **argv)
91
87
if (!handlePortConfigFromConfigDB (p, cfgDb, warm))
92
88
{
93
89
// 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;
99
93
}
100
94
101
95
LinkSync sync (&appl_db, &state_db);
@@ -222,97 +216,6 @@ bool handlePortConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb, boo
222
216
return true ;
223
217
}
224
218
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
-
316
219
void handlePortConfig (ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map)
317
220
{
318
221
0 commit comments