forked from pvelder/wlst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrDS.old.py
106 lines (75 loc) · 4.32 KB
/
crDS.old.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
# Who: Tony van Esch
#What: create datasources
#When: friday. Hackday
# to do: abstract SOA part to make it domain generic
import sys
import traceback
from java.io import FileInputStream
# get commandline args
print "Usage crDS_balbla.py adminuser adminpassword env"
print 'args:' + str(sys.argv)
if len(sys.argv) != 6:
print "ERROR. Invalid Arguments: " + str(sys.argv)
print " Usage crDS_zms.py adminuser adminpassword env DatasourceName schemaName"
print " env=[dev|tst|acc|prd]"
print " env-var is used to get $env.properties file"
print " schemaName will be forced to UPPERCASE. Make sure your references in propfile are UPPERCASE"
exit()
username=sys.argv[1]
password=sys.argv[2]
env=sys.argv[3]
DatasourceName=sys.argv[4]
schemaName=sys.argv[5].upper() #force uppercase
# setup properties file
propInputStream = FileInputStream(env + ".properties")
configProps = Properties()
configProps.load(propInputStream)
#get env specific props for DS
DBPassword=configProps.get(schemaName + '.Password')
DatabaseServiceName=configProps.get(schemaName + ".DatabaseServiceName")
DatabaseHost=configProps.get(schemaName + ".DatabaseHost")
Targets=configProps.get(schemaName + ".Targets")
TargetType=configProps.get(schemaName + ".TargetType")
if not DatabaseServiceName:
print "Something went wrong reading the datasource properties with prefix " + schemaName + " from file " + env + ".properties"
exit()
print "Settings from properties file"
print "DBService=" + DatabaseServiceName
print "DBHost=" + DatabaseHost
print "Targets=" + Targets
print "TargetType=" + TargetType
#get connect url and connect
DomainURL=configProps.get("SOADomainURL")
connect(username,password,DomainURL)
edit()
startEdit()
cd('/')
cmo.createJDBCSystemResource(DatasourceName)
cd('/JDBCSystemResources/' + DatasourceName + '/JDBCResource/'+ DatasourceName)
cmo.setName(DatasourceName)
cd('/JDBCSystemResources/' + DatasourceName + '/JDBCResource/' + DatasourceName + '/JDBCDataSourceParams/' + DatasourceName)
set('JNDINames',jarray.array([String('jdbc/' + DatasourceName)], String))
cd('/JDBCSystemResources/' + DatasourceName + '/JDBCResource/' + DatasourceName + '/JDBCDriverParams/' + DatasourceName)
cmo.setUrl('jdbc:oracle:thin:@(description=(RETRY_COUNT=20)(CONNECT_TIMEOUT=15)(TRANSPORT_CONNECT_TIMEOUT=10)(ADDRESS_LIST=(FAILOVER=on)(ADDRESS=(PROTOCOL=tcp)(HOST=' + DatabaseHost + ')(PORT=1521)(PROTOCOL=tcp)(HOST=' + DatabaseHost + ')(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=' + DatabaseServiceName + ')(failover=yes)(FAILOVER_MODE=(TYPE=session)(METHOD=basic)(RETRIES=20)(DELAY=15))))')
cmo.setDriverName('oracle.jdbc.OracleDriver')
cmo.setPassword(DBPassword)
cd('/JDBCSystemResources/' + DatasourceName + '/JDBCResource/' + DatasourceName + '/JDBCConnectionPoolParams/' + DatasourceName)
cmo.setTestTableName('SQL SELECT 1 FROM DUAL\r\n')
cd('/JDBCSystemResources/' + DatasourceName + '/JDBCResource/' + DatasourceName + '/JDBCDriverParams/' + DatasourceName + '/Properties/' + DatasourceName)
cmo.createProperty('oracle.jdbc.ReadTimeout')
cd('/JDBCSystemResources/' + DatasourceName + '/JDBCResource/' + DatasourceName + '/JDBCDriverParams/' + DatasourceName + '/Properties/' + DatasourceName + '/Properties/oracle.jdbc.ReadTimeout')
cmo.setValue('10000')
cd('/JDBCSystemResources/' + DatasourceName + '/JDBCResource/' + DatasourceName + '/JDBCDriverParams/' + DatasourceName + '/Properties/' + DatasourceName)
cmo.createProperty('user')
cd('/JDBCSystemResources/' + DatasourceName + '/JDBCResource/' + DatasourceName + '/JDBCDriverParams/' + DatasourceName + '/Properties/' + DatasourceName + '/Properties/user')
cmo.setValue('zms')
cd('/JDBCSystemResources/' + DatasourceName + '/JDBCResource/' + DatasourceName + '/JDBCDriverParams/' + DatasourceName + '/Properties/' + DatasourceName)
cmo.createProperty('oracle.net.CONNECT_TIMEOUT')
cd('/JDBCSystemResources/' + DatasourceName + '/JDBCResource/' + DatasourceName + '/JDBCDriverParams/' + DatasourceName + '/Properties/' + DatasourceName + '/Properties/oracle.net.CONNECT_TIMEOUT')
cmo.setValue('10000')
cd('/JDBCSystemResources/' + DatasourceName + '/JDBCResource/' + DatasourceName + '/JDBCDataSourceParams/' + DatasourceName)
cmo.setGlobalTransactionsProtocol('None')
cd('/SystemResources/' + DatasourceName)
set('Targets',jarray.array([ObjectName('com.bea:Name=' + Targets + ',Type=' + TargetType )], ObjectName))
save()
activate()