Search code examples
webspherewsadmin

How to changing WebSphere Application Server datasource URL by wsadmin?


Is possible to change Websphere datasource IP address? I've tried this script but it doesn't work

def updateDataSourceIP(newIP):
    datasources = AdminConfig.getid('/DataSource:/').splitlines()
      for datasource in datasources:
    propertySet = AdminConfig.showAttribute(t1, 'propertySet')
    propertyList = AdminConfig.list('J2EEResourceProperty', propertySet).splitlines()
    for prop in propertyList:
      if (AdminConfig.showAttribute(prop, 'name') == 'serverName'):
        oldip = AdminConfig.showAttribute(prop, 'value')
        print "Updating serverName attribute of datasource '" + datasource + "' from " + oldip + " to " + sys.argv[0]
        AdminConfig.modify(prop, '[[value ' + newIP + ']]')
        AdminConfig.reset();

Solution

  • In your example code, you are using

    AdminConfig.reset()
    

    at the end of the script, which discards all changes. Try switching to

    AdminConfig.save()