From 4a89485861c43978139c796b92ecc5ce2188e13a Mon Sep 17 00:00:00 2001 From: Howard Persh Date: Thu, 19 Dec 2019 12:49:03 -0800 Subject: [PATCH] [scripts] Adds support for management (1.0) commands (#745) Add utility to translate text output of syseeprom dump into JSON, for consumption by new management (1.0) command. Signed-off-by: Howard Persh --- scripts/syseeprom-to-json | 31 +++++++++++++++++++++++++++++++ setup.py | 1 + 2 files changed, 32 insertions(+) create mode 100755 scripts/syseeprom-to-json diff --git a/scripts/syseeprom-to-json b/scripts/syseeprom-to-json new file mode 100755 index 0000000000..89b7256f50 --- /dev/null +++ b/scripts/syseeprom-to-json @@ -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 "}" } diff --git a/setup.py b/setup.py index b2abcc1208..3949ffb555 100644 --- a/setup.py +++ b/setup.py @@ -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',