source: people/peter.buschman/backup_monitoring/parsing/parsers/vmoprcmd/_vmoprcmd.py@ 1258

Last change on this file since 1258 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: 3.7 KB
Line 
1
2import re
3import struct
4
5from ....builtins import *
6
7from ...exceptions import *
8from ...expressions import *
9from ...streams import *
10
11def vmoprcmd_validate(data):
12
13 for line in data:
14 if re.compile(r'^\s+PENDING REQUESTS\s+$').match(line):
15 return True
16 if re.compile(r'^\s+DRIVE STATUS\s+$').match(line):
17 return True
18 if re.compile(r'^\s+ADDITIONAL DRIVE STATUS\s+$').match(line):
19 return True
20
21 return false
22
23def vmoprcmd_split(data):
24
25 pending_requests = []
26 drive_status = []
27 additional_drive_status = []
28 lines = []
29 current_section = None
30
31 i = 0
32 j = len(data)
33
34 while( i < j ):
35 line = data[i]
36 i += 1
37 if re.compile(r'^\s+PENDING REQUESTS\s+$').match(line):
38 print 'PROCESSING PENDING REQUESTS'
39 current_section = 'PENDING REQUESTS'
40 lines = pending_requests
41 continue
42 if re.compile(r'^\s+DRIVE STATUS\s+$').match(line):
43 print 'PROCESSING DRIVE STATUS'
44 current_section = 'DRIVE STATUS'
45 lines = drive_status
46 continue
47 if re.compile(r'^\s+ADDITIONAL DRIVE STATUS\s+$').match(line):
48 print 'PROCESSING ADDITIONAL DRIVE STATUS'
49 current_section = 'ADDITIONAL DRIVE STATUS'
50 lines = additional_drive_status
51 continue
52 if re.compile(r'^$').match(line):
53 continue
54 if current_section == 'PENDING REQUESTS' and re.compile(r'^\s+<NONE>\s+$').match(line):
55 continue
56 if current_section == 'DRIVE STATUS' and re.compile(r'^Drv').search(line):
57 continue
58 if current_section == 'ADDITIONAL DRIVE STATUS' and re.compile(r'^Drv').search(line):
59 continue
60 lines.append(line)
61 return (pending_requests, drive_status, additional_drive_status)
62
63
64def drive_status_parse(data):
65
66 ds = {}
67
68 for line in data:
69 line = line[:-1]
70 print line
71 (drv, type, control, user, label, recmid, extmid, ready, wrenbl, reqid) = struct.unpack('3sx6sx8sx9sx6sx7sx7sx7sx9sx5s', line)
72 ds['drv' ] = drv
73 ds['type' ] = type
74 ds['control'] = control
75 ds['user' ] = user
76 ds['label' ] = label
77 ds['recmid' ] = recmid
78 ds['extmid' ] = extmid
79 ds['ready' ] = ready
80 ds['wrenbl' ] = wrenbl
81 ds['reqid' ] = reqid
82 for key in ds.keys():
83 ds[key] = ds[key].lstrip().rstrip()
84 if ds[key] == '' or ds[key] == '-':
85 ds[key] = None
86 print 'Drv Type Control User Label RecMID ExtMID Ready Wr.Enbl. ReqId'
87 print '%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|' % (ds['drv'], ds['type'], ds['control'], ds['user'], ds['label'], ds['recmid'], ds['extmid'], ds['ready'], ds['wrenbl'], ds['reqid'])
88
89
90
91
92def additional_drive_status_parse(data):
93
94 ds = {}
95
96 for line in data:
97 line = line[:-1]
98 print line
99 (drv, drivename, shared, assigned, comment) = struct.unpack('3sx20sx9sx15sx26s', line)
100 ds['drv' ] = drv
101 ds['drivename' ] = drivename
102 ds['shared' ] = shared
103 ds['assigned' ] = assigned
104 ds['comment' ] = comment
105 for key in ds.keys():
106 ds[key] = ds[key].lstrip().rstrip()
107 if ds[key] == '' or ds[key] == '-':
108 ds[key] = None
109 print 'Drv DriveName Shared Assigned Comment'
110 print '%s|%s|%s|%s|%s|' % (ds['drv'], ds['drivename'], ds['shared'], ds['assigned'], ds['comment'])
111
Note: See TracBrowser for help on using the repository browser.