-
Notifications
You must be signed in to change notification settings - Fork 2
/
create-data-sources.py
76 lines (54 loc) · 2.36 KB
/
create-data-sources.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
# create data sources from the config file
import sys
# check a config file was specified
config_file = sys.argv[1]
if (config_file == None):
raise Error("must specify the config file")
exit()
# read the config file
data_file = open(config_file, 'r')
data = eval(data_file.read())
# look for the data sources
if (data["datasources"] == None):
print ("No data sources in the config file.. nothing to do")
exit()
# connect to weblogic
readDomain('/u01/oracle/domains/base_domain')
for datasource in data["datasources"]:
dsname = datasource["name"]
dsjndiname = datasource["jndiName"]
dsurl = datasource["url"]
dsusername = datasource["user"]
dspassword = datasource["password"]
dsdriver = "oracle.jdbc.xa.client.OracleXADataSource"
print ('Creating Data Source')
cd('/')
create(dsname, 'JDBCSystemResource')
cd('/JDBCSystemResources/' + dsname)
set('Target','AdminServer')
cd('/JDBCSystemResources/' + dsname + '/JdbcResource/' + dsname)
cmo.setName(dsname)
create('myJdbcDataSourceParams','JDBCDataSourceParams')
cd('/JDBCSystemResources/' + dsname + '/JdbcResource/' + dsname + '/JDBCDataSourceParams/NO_NAME_0')
set('JNDIName', dsjndiname)
set('GlobalTransactionsProtocol', 'TwoPhaseCommit')
cd('/JDBCSystemResources/' + dsname + '/JdbcResource/' + dsname)
create('myJdbcDriverParams','JDBCDriverParams')
cd('/JDBCSystemResources/' + dsname + '/JdbcResource/' + dsname + '/JDBCDriverParams/NO_NAME_0')
set('URL', dsurl)
set('DriverName', dsdriver)
set('PasswordEncrypted', dspassword)
cd('/JDBCSystemResources/' + dsname + '/JdbcResource/' + dsname)
create('myJdbcConnectionPoolParams','JDBCConnectionPoolParams')
cd('/JDBCSystemResources/' + dsname + '/JdbcResource/' + dsname + '/JDBCConnectionPoolParams/NO_NAME_0')
set('TestTableName', 'SQL SELECT 1 FROM DUAL')
cd('/JDBCSystemResources/' + dsname + '/JdbcResource/' + dsname + '/JDBCDriverParams/NO_NAME_0')
create('myProperties','Properties')
cd('/JDBCSystemResources/' + dsname + '/JdbcResource/' + dsname + '/JDBCDriverParams/NO_NAME_0/Properties/NO_NAME_0')
create('user', 'Property')
cd('/JDBCSystemResources/' + dsname + '/JdbcResource/' + dsname + '/JDBCDriverParams/NO_NAME_0/Properties/NO_NAME_0/Property/user')
set('Value', dsusername)
# disconnect
updateDomain()
closeDomain()
exit()