-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnbu_library.py
More file actions
55 lines (43 loc) · 1.37 KB
/
nbu_library.py
File metadata and controls
55 lines (43 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import subprocess
import re
def run_process(cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,shell=True)
return p.stdout.read()#.decode('ascii','ignore')
def get_ret_table():
CMD = ('bpretlevel','-U')
rt = run_process(CMD).split()
new_rt = {}
i = 0
for v in ret_list:
if v == 'infinity':
new_rt[ret_list[i-2]] = ret_list[i]
if v in ('week', 'weeks', 'month', 'months', 'year', 'years'):
new_rt[ret_list[i-3]] = ret_list[i-2]
i+=1
return new_rt
def get_client_info(clnt):
CMD = ('bpgetconfig','-g',clnt,'-L')
CMD2 = ('bpclntcmd','-hn', clnt)
cip = run_process(CMD2)
cd = run_process(CMD)
cd = re.split('= |\r\n',cd)
list = ('NetBackup Client Platform',
'NetBackup Client Protocol Level',
'Product',
'Version Name',
'Version Number',
'NetBackup Installation Path',
'Client OS/Release')
new_cd = {}
i = 3
for v in list:
try:
new_cd[v] = cd[i]
i+=2
except IndexError as ierr:
new_cd['Data'] = 'No data fetched'
for x in cip.split():
found = re.match('\d+\.\d+\.\d+\.\d+',x)
if found:
new_cd['Client IP'] = found.group()
return new_cd