Operating System - HP-UX
1751907 Members
5018 Online
108783 Solutions
New Discussion юеВ

Re: indexing in a file and maybe arrays

 
SOLVED
Go to solution
lawrenzo_1
Super Advisor

indexing in a file and maybe arrays

Hi all,

This question is IBM hardware related however is a general scripting question, I have been tasked with rebuildng the network configuration on a backup server in case of DR.

I gather all information from the active server in the following format:

ADAPT:ent0:100_Full_Duplex:U789D.001.DQD46NN-P1-C5-T1
ADAPT:ent1:100_Full_Duplex:U789D.001.DQD46NN-P1-C5-T2
ADAPT:ent2:100_Full_Duplex:U789D.001.DQD46NN-P1-C5-T3
ADAPT:ent3:100_Full_Duplex:U789D.001.DQD46NN-P1-C5-T4
ADAPT:ent4:100_Full_Duplex:U789D.001.DQD47TT-P1-C5-T1
ADAPT:ent5:100_Full_Duplex:U789D.001.DQD47TT-P1-C5-T2
ADAPT:ent6:100_Full_Duplex:U789D.001.DQD47TT-P1-C5-T3
ADAPT:ent7:100_Full_Duplex:U789D.001.DQD47TT-P1-C5-T4
VIRT:ent8:U9117.MMA.06063E4-V3-C11-T1
VIRT:ent9:U9117.MMA.06063E4-V3-C12-T1
ETHC:ent10:ent1:ent5:8023ad
SEAC:ent11:ent8:ent8:406:auto:ent9

on the standby machine the configuration is identical ie same number of ADAPT (physical adapters) and VIRT (virtual adapters) however the ent* number may not be the same but the last field will be because this is the phsyical or virtual slot ID.

I want to be able to recreate the ETHC and SEAC devices using the below configs and referencing the slot ID to decide which is the correct adapter - below is the output from an unconfigured machine - in this case it is identical to the previous out but as mentioned it may not be.

ADAPT:ent0:100_Full_Duplex:U789D.001.DQD46NN-P1-C5-T1
ADAPT:ent1:Auto_Negotiation:U789D.001.DQD46NN-P1-C5-T2
ADAPT:ent2:Auto_Negotiation:U789D.001.DQD46NN-P1-C5-T3
ADAPT:ent3:Auto_Negotiation:U789D.001.DQD46NN-P1-C5-T4
ADAPT:ent4:Auto_Negotiation:U789D.001.DQD47TT-P1-C5-T1
ADAPT:ent5:Auto_Negotiation:U789D.001.DQD47TT-P1-C5-T2
ADAPT:ent6:Auto_Negotiation:U789D.001.DQD47TT-P1-C5-T3
ADAPT:ent7:Auto_Negotiation:U789D.001.DQD47TT-P1-C5-T4
VIRT:ent8:U9117.MMA.06063E4-V3-C11-T1
VIRT:ent9:U9117.MMA.06063E4-V3-C12-T1

so .....

I want to create a device and from the original scan I have

ETHC:ent10:ent1:ent5:8023ad

ETH is an etherchanel device, ent10 is the configured adapter on the active server, ent1 is the physical adapter to use for the network and ent5 is the failover adapter

ADAPT:ent1:100_Full_Duplex:U789D.001.DQD46NN-P1-C5-T2
ADAPT:ent5:100_Full_Duplex:U789D.001.DQD47TT-P1-C5-T2


I need a way to read in

ETHC:ent10:ent1:ent5:8023ad and reference the physical slot id for ent1 and ent 5 then store them in an array (I think) so I can use the information to use the correct adapter from file2 so I recreate the ETHC device on the same physical adapters although the ent may be different.

confusing I know so please any idea's will be greatly valued !!

Thanks

Chris,
hello
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: indexing in a file and maybe arrays

Hi Chris:

This snippet shows how you might grab, parse and reference a line matched by "ETHC":

# awk '/^ETHC/ {a[ETHC]=$0};END{split(a[ETHC],aa,":");print aa[3],aa[4]}' file
ent1 ent5

Regards!

...JRF...
lawrenzo_1
Super Advisor

Re: indexing in a file and maybe arrays

Thanks James.
hello
lawrenzo_1
Super Advisor

Re: indexing in a file and maybe arrays

.
hello