[rancid] exos.pm: patch to gather stack information

James Andrewartha jandrewartha at ccgs.wa.edu.au
Mon Jan 20 05:29:06 UTC 2020


Hi,

On 4/1/20 8:32 am, john heasley wrote:
> Thu, Jan 02, 2020 at 01:39:20PM +0800, James Andrewartha:
>> Hi,
>>
>> The patch below adds extra parsing to ShowVersion in exos.pm, to print
>> out the individual device serial numbers, bootrom and image version.
>> Mostly I wanted the serial number, since the others are normally the
>> same across a stack.
>>
>> Here's two examples of output, for a standalone switch, and a stack:
>>
>> #Switch: Serial 1638N-41359, BootROM 1.0.1.8, IMG 22.6.1.4
>>
>> #Slot-1: Serial 1637N-41621, BootROM 1.0.1.8, IMG 22.6.1.4
>> #Slot-2: Serial 1638N-41448, BootROM 1.0.1.8, IMG 22.6.1.4
>> #Slot-3: Serial 1638N-41354, BootROM 1.0.1.8, IMG 22.6.1.4
>> #Slot-4: Serial 1638N-41318, BootROM 1.0.1.8, IMG 22.6.1.4
>> #Slot-5: Serial 1638N-41357, BootROM 1.0.1.8, IMG 22.6.1.4
>>
>> This patch might be fuzzy since I generated it against upstream but I'm
>> running 3.9-1~bpo9+1 from Debian. Also I only have X440-G2s to test against.
>>
>> --- exos.pm.in  2020-01-02 13:30:04.000000000 +0800
>> +++ /usr/share/perl5/rancid/exos.pm     2020-01-02 12:09:27.000000000 +0800
>> @@ -106,6 +149,9 @@
>>         /^bootrom\s+:\s+(.*)/i &&
>>             ProcessHistory("COMMENTS","keysort","D1","#\n#Bootrom: $1\n")
>>             && next;
>> +    /^(Slot-\d|Switch)\s+:\s+[^\s]+\s+([^\s]+).*BootROM:
>> ([^\s]+)\s+IMG: ([^\s]+)/i &&
>> +        ProcessHistory("COMMENTS","keysort","D2","#$1: Serial $2,
>> BootROM $3, IMG $4\n")
>> +        && next;
> 
> Does this work?
>     /^(?:Slot-\d|Switch)\s+:/i &&
> 	ProcessHistory("COMMENTS","keysort","D2","#$_") && next;
> This seems like it might work for other revisions too; a bit more generic?
> 
>>  #XXX: need to collect this from show vers for ShowSlot where rev #s are
>> excluded
>>  #SLOT 1 :  702005-06  0025S-00877 CPLD Rev <FF>

I went with this (which requires non-spaces after the colon):

    /^(?:Slot-\d|Switch)\s+:\s+[^\s]+/i &&
        ProcessHistory("COMMENTS","keysort","D2","#$_")
        && next;

because otherwise you pick up empty slots as well. The raw output is

Slot-1 dblockr3x.2 # show version
Slot-1          : 800618-00-16 1828N-40693 Rev 16 BootROM: 1.0.1.8
IMG: 30.4.1.2
Slot-2          : 800618-00-16 1828N-40697 Rev 16 BootROM: 1.0.1.8
IMG: 30.4.1.2
Slot-3          :
Slot-4          :
Slot-5          :
Slot-6          :
Slot-7          :
Slot-8          :

which processes down to this with my change:

#Slot-1          : 800618-00-16 1828N-40693 Rev 16 BootROM: 1.0.1.8
IMG: 30.4.1.2
#Slot-2          : 800618-00-16 1828N-40697 Rev 16 BootROM: 1.0.1.8
IMG: 30.4.1.2

Thanks,

-- 
James Andrewartha
Network & Projects Engineer
Christ Church Grammar School
Claremont, Western Australia
Ph. (08) 9442 1757
Mob. 0424 160 877



More information about the Rancid-discuss mailing list