files/providers/wls_datasource/modify.py.erb
# check the domain else we need to skip this (done in wls_access.rb)
real_domain='<%= domain %>'
name = '<%= datasource_name %>'
password = '<%= password %>'
target = '<%= target %>'
targettype = '<%= targettype %>'
drivername = '<%= drivername %>'
datasourcetype = '<%= datasourcetype %>'
jndinames = '<%= jndinames %>'
url = '<%= url %>'
usexa = '<%= usexa %>'
user = '<%= user %>'
testtablename = '<%= testtablename %>'
globaltransactionsprotocol = '<%= globaltransactionsprotocol %>'
extraproperties = '<%= extraproperties %>'
maxcapacity = '<%= maxcapacity %>'
initialcapacity = '<%= initialcapacity %>'
fanenabled = '<%= fanenabled %>'
onsnodelist = '<%= onsnodelist %>'
xaproperties = '<%= xaproperties %>'
mincapacity = '<%= mincapacity %>'
statementcachetype = '<%= statementcachetype %>'
statementcachesize = '<%= statementcachesize %>'
testconnectionsonreserve = '<%= testconnectionsonreserve %>'
secondstotrustidlepoolconnection = '<%= secondstotrustidlepoolconnection %>'
testfrequency = '<%= testfrequency %>'
connectioncreationretryfrequency = '<%= connectioncreationretryfrequency %>'
rowprefetchenabled = '<%= rowprefetchenabled %>'
rowprefetchsize = '<%= rowprefetchsize %>'
initsql = "<%= (initsql||'').gsub('"','\"') %>"
shrinkfrequencyseconds = '<%= shrinkfrequencyseconds %>'
wrapdatatypes = '<%= wrapdatatypes %>'
inactiveconnectiontimeoutseconds = '<%= inactiveconnectiontimeoutseconds %>'
connectionreservetimeoutseconds = '<%= connectionreservetimeoutseconds %>'
edit()
startEdit()
try:
cd('/')
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name)
cmo.setName(name)
try:
set_attribute_value('DatasourceType', datasourcetype, use_default_value_when_empty)
except:
print "skip probably not 12.2 version"
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCDataSourceParams/' + name )
if jndinames:
jndis = String(jndinames).split(",")
set('JNDINames', jarray.array(jndis, String))
set_attribute_value('RowPrefetch', rowprefetchenabled, use_default_value_when_empty)
set_attribute_value('RowPrefetchSize', rowprefetchsize, use_default_value_when_empty)
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCDriverParams/' + name )
set_attribute_value('Url', url, use_default_value_when_empty)
set_attribute_value('DriverName', drivername, use_default_value_when_empty)
set_attribute_value('UseXaDataSourceInterface', usexa, use_default_value_when_empty)
auto_typed_set('Password', password)
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCConnectionPoolParams/' + name )
set_attribute_value('MaxCapacity', maxcapacity, use_default_value_when_empty)
set_attribute_value('InitialCapacity', initialcapacity, use_default_value_when_empty)
set_attribute_value('MinCapacity', mincapacity, use_default_value_when_empty)
set_attribute_value('StatementCacheType', statementcachetype, use_default_value_when_empty)
set_attribute_value('StatementCacheSize', statementcachesize, use_default_value_when_empty)
set_attribute_value('TestConnectionsOnReserve', testconnectionsonreserve, use_default_value_when_empty)
set_attribute_value('SecondsToTrustAnIdlePoolConnection', secondstotrustidlepoolconnection, use_default_value_when_empty)
set_attribute_value('TestFrequencySeconds', testfrequency, use_default_value_when_empty)
set_attribute_value('InactiveConnectionTimeoutSeconds', inactiveconnectiontimeoutseconds, use_default_value_when_empty)
set_attribute_value('ConnectionReserveTimeoutSeconds', connectionreservetimeoutseconds, use_default_value_when_empty)
set_attribute_value('ConnectionCreationRetryFrequencySeconds', connectioncreationretryfrequency)
set_attribute_value('InitSql', initsql, use_default_value_when_empty)
set_attribute_value('ShrinkFrequencySeconds', shrinkfrequencyseconds, use_default_value_when_empty)
set_attribute_value('WrapTypes', wrapdatatypes, use_default_value_when_empty)
<% unless removeinfectedconnections.nil? -%>
set('RemoveInfectedConnections', <% if removeinfectedconnections == :true -%>True<% else %>False<% end %>)
<% end -%>
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCConnectionPoolParams/' + name )
set_attribute_value('TestTableName', testtablename, use_default_value_when_empty)
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCDriverParams/' + name + '/Properties/' + name + '/Properties/user')
cmo.setValue(user)
# Extra Properties
# Remove Existing Properties First
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCDriverParams/' + name + '/Properties/' + name + '/Properties/')
existing_properties = ls('', returnMap='true')
for existing_prop in existing_properties:
if existing_prop.lower() != 'user':
cmo.destroyProperty(cmo.lookupProperty(existing_prop))
if extraproperties:
properties = String(extraproperties).split(",")
for property in properties:
propname, val = property.split("=")
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCDriverParams/' + name + '/Properties/' + name )
try:
cmo.createProperty(propname)
except:
print "already exists"
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCDriverParams/' + name + '/Properties/' + name + '/Properties/'+propname)
cmo.setValue(val)
# XA Properties
if usexa == '1':
# Remove Existing XA Properties First (resets them to default)
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCXAParams/' + name)
valid_xa_properties = ls('', returnMap='true')
for existing_prop in valid_xa_properties:
cmo.unSet(existing_prop)
# Set Them Dynamically
if xaproperties:
xapropertiesarray = String(xaproperties).split(",")
for xaproperty in xapropertiesarray:
propname, val = xaproperty.split("=")
# Converts to integer (for numbers and booleans too)
if val.isnumeric():
val = int(val)
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCXAParams/' + name )
try:
methodToCall = getattr(cmo, 'set' + propname)
methodToCall(val)
except AttributeError:
print "%s is not a valid attribute type" % (propname)
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCDataSourceParams/' + name)
set_attribute_value('GlobalTransactionsProtocol', globaltransactionsprotocol)
try:
cd('/JDBCSystemResources/' + name + '/JDBCResource/' + name + '/JDBCOracleParams/' + name )
set_attribute_value('FanEnabled', fanenabled)
set_attribute_value('OnsNodeList', onsnodelist)
except:
print "Datasource Driver %s does not support ONS parameters." % drivername
cd('/SystemResources/' + name)
targets = String(target).split(",")
targettypes = String(targettype).split(",")
targetList = []
if 'inherited' in targets:
tagged = []
taggedtype = []
i = ls('/Servers/', returnMap='true')
for token4 in i:
notes = get('/Servers/' + token4 + '/Notes')
if notes:
if name in notes:
for i in ls('/Clusters/', returnMap='true'):
if i in notes:
tagged.append(i)
taggedtype.append('Cluster')
else:
tagged.append(token4)
taggedtype.append('Server')
for i in range(len(tagged)):
print "target " + tagged[i] + " " + taggedtype[i]
targetList.append(ObjectName('com.bea:Name=' + tagged[i] + ',Type=' + taggedtype[i]))
else:
for i in range(len(targets)):
print "target " + targets[i] + " " + targettypes[i]
targetList.append(ObjectName('com.bea:Name=' + targets[i] + ',Type=' + targettypes[i]))
set('Targets', jarray.array(targetList, ObjectName))
save()
activate()
report_back_success()
except:
report_back_error()