Re: Assertion in Python



At Thursday 5/10/2006 04:09, vmalhotra wrote:

Now the problem which i am facing is how to do assertion from that
output. e.g output is something like this

eth0 is up
OSPF not enabled on this interface
eth1 is up
Internet Address 192.168.1.2/24, Area 0.0.0.0
Router ID 192.168.1.2, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.1.2, Interface Address 192.168.1.2
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:00
Neighbor Count is 0, Adjacent neighbor count is 0
eth2 is up
OSPF not enabled on this interface
eth3 is down
OSPF not enabled on this interface
lo is up
OSPF not enabled on this interface
sit0 is down
OSPF not enabled on this interface

In this i want to check Designated Router (ID) 192.168.1.2.

This is the idea (assuming you have already read and split the output on lines):

for line in output:
line = line.strip()
if line.startswith('Designated Router (ID)'):
ipReadStr = line[line.find('(ID)')+4:] # just before the IP starts
ipReadStr = ipReadStr.split(',',1)[0].strip() # up to the next ","
assertEqual(ipReadStr, ipExpected)
break
else:
fail('"Designated Router (ID)" not found')


Gabriel Genellina
Softlab SRL





__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! http://www.yahoo.com.ar/respuestas

.



Relevant Pages

  • FreeBSD/zebraOSPF not updating routingtables
    ... I am trying to get OSPF working but it won't work. ... but no routing tables are updated. ... description dummy/loopback interface ... OSPF Routing Process, Router ID: ...
    (comp.unix.bsd.freebsd.misc)
  • Re: ospf network statement - correct use (long)
    ... network statement for OSPF should be used with subnets on which you ... another router. ... Snippets of the basic interface config for each router are as follows: ... The only routes that are "internal" are those where OSPF is running on the ...
    (comp.dcom.sys.cisco)
  • Re: Kernel drops UDP datagrams between interface and process
    ... |> How does OSPF select which interface when both have the same IP address? ... |> the router to reconfigure it or pull down stats, ... it would seem that going over the 1000Mbps LAN would be preferred. ... And the situation is the same if it's only interface on one end ...
    (comp.os.linux.development.system)
  • Assertion in Python
    ... Telnet to one router. ... command show interface and saved the output in one file. ... OSPF not enabled on this interface ... No backup designated router on this network ...
    (comp.lang.python)
  • Re: which router should i set as ospf dr router ?
    ... i have four router. ... to C router, and C router is conneted to D router, which has connection ... D should be OSPF DR router.. ... The designated router is elected when the current DR is lost - and the ...
    (comp.dcom.sys.cisco)