source: people/peter.buschman/backup_monitoring/parsing/parsers/puredisk_status/_puredisk_status.py

Last change on this file was 976, checked in by peter, on Dec 6, 2011 at 10:19:33 AM

Raw checkin of current NetBackup / TSM parsing code.

File size: 1.1 KB
Line 
1import re
2
3from ....builtins import *
4
5from ...exceptions import *
6from ...expressions import *
7from ...streams import *
8
9re_status = re.compile('^Checking for (.*) \.\.(.*)$')
10
11##
12## puredisk status has one record per-stream
13##
14def stream(stream, format='puredisk status'):
15
16 if format in ['puredisk status']:
17 return SingleRecordStream(stream)
18 else:
19 raise ParseError, 'Unknown format %s' % (format)
20
21
22##
23## Parse a puredisk status record
24##
25## /etc/init.d/puredisk status
26##
27def parse(record, format='puredisk status', version=None, tz=None):
28
29 status = ExtendedDict()
30
31 if format in ['puredisk status']:
32
33 try:
34
35 for line in record:
36
37 match = re_status.match(line)
38
39 if match:
40
41 service = match.group(1)
42 state = match.group(2)
43
44 status[service] = state
45
46 return status
47
48 except Exception, e:
49
50 raise ParseError, e
51
52 else:
53
54 raise ParseError, 'Unknown format %s' % (format)
Note: See TracBrowser for help on using the repository browser.