source: people/peter.buschman/backup_monitoring/parsing/parsers/nbemmcmd/_nbemmcmd.py@ 976

Last change on this file since 976 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.6 KB
Line 
1import re
2
3import time
4import datetime
5import pytz
6
7from ....builtins import *
8
9from ...exceptions import *
10from ...expressions import *
11from ...autotype import *
12from ...streams import *
13
14##
15## nbemmcmd feeds have records separated by blank lines
16##
17def stream(stream, format='nbemmcmd -machinealias -getaliases'):
18
19 if format in ['nbemmcmd -machinealias -getaliases']:
20 return BlankLineStream(stream, header=0)
21 else:
22 raise ParseError, 'Unknown format %s' % (format)
23
24
25##
26## Parse a nbemmcmd record
27##
28## nbemmcmd -L
29##
30def parse(record, format='nbemmcmd -machinealias -getaliases', version=None, tz=None):
31
32 if format == 'nbemmcmd -machinealias -getaliases':
33
34 aliases = []
35
36 try:
37
38 #
39 # strip header
40 #
41 # NBEMMCMD, Version:6.5.4
42 #
43 record.pop(0)
44
45 #
46 # get alias name
47 #
48 try:
49 alias = re.compile('^The following aliases were found for the alias: "(.+)"$').match(record.pop(0)).group(1)
50 except:
51 raise ParseError, 'No alias name found on line 2 of record!'
52
53 for line in record:
54
55 if line == 'Command completed successfully.':
56 continue
57
58 aliases.append(line)
59
60 return alias, aliases
61
62 except Exception, e:
63
64 for line in record:
65 print line
66
67 raise ParseError, e
68
69 else:
70
71 raise ParseError, 'Unknown format %s' % (format)
72
Note: See TracBrowser for help on using the repository browser.