-
Notifications
You must be signed in to change notification settings - Fork 1
/
extract-datasources-info.py
155 lines (123 loc) · 5.83 KB
/
extract-datasources-info.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import re
import jarray
import traceback
domain = 'intosbd'
def quote(text):
if text or text == '':
return "\"" + str(text).replace("\"", "\"\"") + "\""
else:
return ""
def retrieve_target_list(wlst_name):
cd(wlst_name)
nn = ls('Targets', returnMap='true')
target = []
target_type = []
for token_target in nn:
target.append(token_target)
cd(wlst_name + '/Targets/' + token_target)
target_type.append(get('Type'))
return target, target_type
def add_index_entry(file_handle, values):
print >>file_handle, ";".join(map(quote, values))
m = ls('/JDBCSystemResources',returnMap='true')
f = open("/tmp/DataSources.out", "w")
for token in m:
print '___'+token+'___'
cd('/JDBCSystemResources/'+token + '/JDBCResource/' + token)
# check for MultiDatasource
cd('/JDBCSystemResources/' + token + '/JDBCResource/' + token + '/JDBCDataSourceParams/' + token )
dataSourceList = get('DataSourceList')
if dataSourceList is None:
cd('/JDBCSystemResources/' + token + '/JDBCResource/' + token + '/JDBCDriverParams/' + token )
url = get('Url')
driver = get('DriverName')
usexa = str(get('UseXaDataSourceInterface'))
cd('/JDBCSystemResources/' + token + '/JDBCResource/' + token + '/JDBCConnectionPoolParams/' + token )
maxcapacity = get('MaxCapacity')
initialcapacity = get('InitialCapacity')
if not (initialcapacity):
initialcapacity = '0'
mincapacity = get('MinCapacity')
if not (mincapacity):
mincapacity = '0'
statementcachesize = get('StatementCacheSize')
if not (statementcachesize):
statementcachesize = '0'
testconnectionsonreserve = str(get('TestConnectionsOnReserve'))
inactiveconnectiontimeoutseconds = get('InactiveConnectionTimeoutSeconds')
if not (inactiveconnectiontimeoutseconds):
inactiveconnectiontimeoutseconds = '0'
connectionreservetimeoutseconds = get('ConnectionReserveTimeoutSeconds')
if not (connectionreservetimeoutseconds):
connectionreservetimeoutseconds = '0'
shrinkfrequencyseconds = str(get('ShrinkFrequencySeconds'))
secondstotrustidlepoolconnection = str(get('SecondsToTrustAnIdlePoolConnection'))
testfrequency = get('TestFrequencySeconds')
connectioncreationretryfrequency = str(get('ConnectionCreationRetryFrequencySeconds'))
initsql = str(get('InitSql'))
if get('WrapTypes'):
wrapdatatypes = '1'
else:
wrapdatatypes = '0'
if get('RemoveInfectedConnections'):
removeinfectedconnections = '1'
else:
removeinfectedconnections = '0'
cd('/JDBCSystemResources/' + token + '/JDBCResource/' + token + '/JDBCDataSourceParams/' + token )
jndinames = get('JNDINames')
rowprefetchenabled = str(get('RowPrefetch'))
rowprefetchsize = str(get('RowPrefetchSize'))
cd('/JDBCSystemResources/' + token + '/JDBCResource/' + token + '/JDBCConnectionPoolParams/' + token )
testTableName = get('TestTableName')
try:
cd('/JDBCSystemResources/' + token + '/JDBCResource/' + token + '/JDBCDriverParams/' + token + '/Properties/' + token + '/Properties/user')
user = get('Value')
except:
user = ''
cd('/JDBCSystemResources/' + token + '/JDBCResource/' + token + '/JDBCDataSourceParams/' + token)
globalTransactionsProtocol = get('GlobalTransactionsProtocol')
try:
cd('/JDBCSystemResources/' + token + '/JDBCResource/' + token + '/JDBCOracleParams/' + token )
fanenabled = str(get('FanEnabled'))
onsnodelist = get('OnsNodeList')
except:
# In Case any Datasource Type does not include JDBCOracleParams
fanenabled = '0'
onsnodelist = ''
p = ls('/JDBCSystemResources/' + token + '/JDBCResource/' + token + '/JDBCDriverParams/' + token + '/Properties/' + token + '/Properties',returnMap='true')
properties = []
for token3 in p:
if not token3 == 'user':
cd('/JDBCSystemResources/' + token + '/JDBCResource/' + token + '/JDBCDriverParams/' + token + '/Properties/' + token + '/Properties/'+token3)
properties.append(token3+"="+str(get('Value')))
if usexa == '1':
xapropertiesCur = ''
cd('/JDBCSystemResources/' + token + '/JDBCResource/' + token + '/JDBCXAParams/' + token)
xapropertiesarray = ls('', returnMap='true')
for xaproperty in xapropertiesarray:
try:
val = str(get(xaproperty))
if xaproperty == 'isSet' or xaproperty == 'unSet':
break
elif len(xapropertiesCur) == len(xapropertiesarray) -1:
xapropertiesCur += xaproperty + '=' + val
else:
xapropertiesCur += xaproperty + '=' + val + ','
except AttributeError:
print "%s is not a valid attribute type" % (xaproperty)
else:
xapropertiesCur = ''
target, targetType = retrieve_target_list('/SystemResources/'+token)
tagged = []
i = ls('/Servers/', returnMap='true')
for token4 in i:
notes = get('/Servers/'+token4+'/Notes')
if notes:
if token in notes:
for i in ls('/Clusters/', returnMap='true'):
if i in notes:
tagged.append(i)
else:
tagged.append(token4)
add_index_entry(f, [domain+'/'+token,','.join(target),','.join(targetType),driver,','.join(jndinames),url,user,testTableName,','.join(properties)])
f.close()