permaculture playing cards
The moose likes Websphere and the fly likes Jython script to retrieve properties for all Datasources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Jython script to retrieve properties for all Datasources" Watch "Jython script to retrieve properties for all Datasources" New topic

Jython script to retrieve properties for all Datasources

Ashvin Kumar

Joined: Feb 13, 2013
Posts: 1
Hi All,

First of all let me thank everyone here for having a great forum. I've been visiting this forum for the longest time but just recently came upon something that I need to start a new topic for.

I am trying to write a JYTHON script to retrieve datasource properties for all the datasources configured in our UNIT environment so they can be compared to datsources defined in other environments. I believe somewhere in the script I am messing the syntax which makes the script fail.
For ease of understanding (or not) I am posting everything that I tried (most of it is commented out).
All the print statements are working but I can get the AdminTask statement to create the file with all the properties.
For some reason I whatever I try I am not able to send the datasource names as a variable to the "-configData DataSource=" statement. Works fine when I assign and actaul datasource name instead of sending it as a string variable.
I've tried many things and finally decided to seek help from the experts. Thanks for any help I can get!

####Beginning of the script####

# get cell id, just for printing reasons
cell = AdminConfig.list('Cell')

# from cell id, get cell name, again just for printing
cell_name = AdminConfig.showAttribute(cell, 'name')

dsources = AdminConfig.list('DataSource')

dsources1 = dsources.split(lineSeparator)

#for every data source get name
for dsource in dsources1:
dsource_name = AdminConfig.showAttribute(dsource, 'name')
# pool=AdminConfig.showAttribute(dsource,'connectionPool')
# datasrce = dsource_name
# AdminTask.extractConfigProperties('-configData DataSource=itsmdb', '-propertiesFileName /home/92188/')
# print pool
print dsource_name
x = "DataSource=%s" %datsrce
y = "-configData %s" %x
z = "/home/40709/"
i = "-propertiesFileName %s" %z
#hello = "'%s %s'" % (y , i)
hello = '%s %s' % (y , i)
print x
print y
print z
print i
print hello
#print "AdminTask.extractConfigProperties(%s)" % hello
AdminTask.extractConfigProperties(%s) % hello
#AdminTask.extractConfigProperties('%s' ,'%s') % (y , i)
#AdminTask.extractConfigProperties(-configData 'DataSource=%s' %(datsrce) -propertiesFileName /home/40709/

#AdminTask.extractConfigProperties('-configData "DataSource=%s" %(dsource_name) -propertiesFileName /home/92188/')
# AdminTask.extractConfigProperties('-configData DataSource = datasrce', '-propertiesFileName /home/92188/')
# AdminTask.extractConfigProperties('-configData DataSource="eval(datasrce)"', '-propertiesFileName /home/92188/')
# print dsource_name
# print "hello"
#dsource_name2 = dsource_name
#for x in dsource_name2:
# AdminTask.extractConfigProperties('-configData DataSource=dsource -propertiesFileName /home/92188/')

# for x in dsources1:
# AdminTask.extractConfigProperties('-configData DataSource=dsource_name -propertiesFileName /home/92188/')
####Uncomment the lines below for datasources on each node and place them higher up in the script####
# get list of node id's
#nodes = AdminConfig.list('Node')

# format node id's for jython
#nodes1 = nodes.split(lineSeparator)

# for each node, get list of servers etc and format for jython
#for node in nodes1:
# node_name = AdminConfig.showAttribute(node, 'name')
# dsources = AdminConfig.list('DataSource', node)
I agree. Here's the link:
subject: Jython script to retrieve properties for all Datasources
It's not a secret anymore!