This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jython script to retrieve properties for all Datasources  RSS feed

Ashvin Kumar
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!