File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
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
Author

Jython script to retrieve properties for all Datasources

Ashvin Kumar
Greenhorn

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/newfile.properties')
# print pool
print dsource_name
datsrce='xpressDataSource1'
x = "DataSource=%s" %datsrce
y = "-configData %s" %x
z = "/home/40709/sampleds3.properties"
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(+hello+)
#AdminTask.extractConfigProperties('%s' ,'%s') % (y , i)
#AdminTask.extractConfigProperties(-configData 'DataSource=%s' %(datsrce) -propertiesFileName /home/40709/sampleds3.properties)


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

# for x in dsources1:
# AdminTask.extractConfigProperties('-configData DataSource=dsource_name -propertiesFileName /home/92188/dsource_name1.properties')
####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)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Jython script to retrieve properties for all Datasources