Skip to content

Commit

Permalink
[scripts] Adds support for management (1.0) commands (#745)
Browse files Browse the repository at this point in the history
Add utility to translate text output of syseeprom dump into JSON, for
consumption by new management (1.0) command.

Signed-off-by: Howard Persh <[email protected]>
  • Loading branch information
hpersh authored and abdosi committed Dec 31, 2019
1 parent 3c41ace commit 4a89485
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions scripts/syseeprom-to-json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/awk -f

BEGIN { print "{"; n = 0 }

function sep()
{
if (n > 0) print ", ";
++n;
}

/Product Name/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Part Number/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Serial Number/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Base MAC Address/ { sep(); print "\"" $1 " " $2 " " $3 "\": \"" $6 "\""; }
/Manufacture Date/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Device Version/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Label Revision/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Platform Name/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/ONIE Version/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/MAC Addresses/ { sep(); print "\"" $1 " " $2 "\": " $5; }
/Manfacturer/ { sep(); print "\"" $1 "\": \"" $4 "\""; }
/Manfacture Country/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Vendor Name/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Diag Version/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Service Tag/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Hardware Version/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Software Version/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Manfacture Date/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }
/Model Name/ { sep(); print "\"" $1 " " $2 "\": \"" $5 "\""; }

END { print "}" }
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
'scripts/route_check.py',
'scripts/route_check_test.sh',
'scripts/sfpshow',
'scripts/syseeprom-to-json',
'scripts/teamshow',
'scripts/warm-reboot',
'scripts/watermarkstat',
Expand Down

0 comments on commit 4a89485

Please sign in to comment.