1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__ = """CommandParser
15
16 CommandParser parses the output of a command to return a datamap
17
18 $Id: CiscoDhcpHelperAddress.py,v 1.3 2003/10/02 19:05:28 edahl Exp $"""
19
20 __version__ = '$Revision: 1.3 $'[11:-2]
21
22 import re
23
24 from Products.ZenModel.IpAddress import findIpAddress
25
26 from CommandParser import CommandParser
27
29
30 command = 'show run | include helper-address'
31
34
35
36 - def parse(self, device, results, log):
37 dhcpips = {}
38 findip = re.compile('(\d+\.\d+\.\d+\.\d+)$').search
39 for line in results.split('\n'):
40 m = findip(line)
41 if m:
42 ip = m.group(1)
43 dhcpips[ip] = 1
44 om = self.newObjectMap()
45 om['setDhcpHelpers'] = dhcpips.keys()
46 return om
47
48
50 return "Collect dhcp helper servers that a UBR uses"
51