Nope .. the back-ticks should just indicate that this is a command you have to run in the wsadmin script which calls the function to export the DataSource properties.
Original Message:
Sent: Thu July 13, 2023 02:09 PM
From: Christos Chorattides
Subject: WAS ND, change Data sources in resources.xml
Hi Hermann,
thank you for the script. This approach requires more knowledge on WAS scripting, (which I don't have).
I created a script file and named it rtvWmInfo. I then tried to run it at wsadmin prompt but I got error at the last parameter.
I hope that the backticks don't mean that I have to run it at Unix prompt.
BR
------------------------------
Christos Chorattides
Datatech
------------------------------
Original Message:
Sent: Thu July 13, 2023 06:05 AM
From: Hermann Huebler
Subject: WAS ND, change Data sources in resources.xml
Hello Christos,
as you are obviously trying to use properties export / import (which makes perfectly sense) maybe the follwing function helps (using that on one of my scripts):
def rtvWmInfo(wcvObjType, wcvObjNamesList, wcvOutDir, wcvCompareAttribute="name"): wmInfoList=AdminConfig.list(wcvObjType) wmInfoList = wmInfoList.replace("\r\n", "\n").split("\n") for wmInfo in wmInfoList: if (wmInfo != ''): wmName = AdminConfig.showAttribute(wmInfo, wcvCompareAttribute) if ((wmName in wcvObjNamesList) or ((len(wcvObjNamesList) == 1) and (wcvObjNamesList[0] == "*"))): print "Exporting %s object %s" % (wcvObjType, wmName) fileName = os.path.join(wcvOutDir, wcvObjType + "_" + wmName + ".props") AdminTask.extractConfigProperties(wmInfo, ['-propertiesFileName', fileName, "-options", [["PortablePropertiesFile", "true"]]])
You should be able to call that like: `rtvWmInfo("DataSource", "*", "/tmp")`. This should create .props files in /tmp with the exported DataSources which you can modify and then import again.
------------------------------
Hermann Huebler
2innovate IT Consulting GmbH
Vienna
Austria
#IBMChampion
Original Message:
Sent: Thu July 13, 2023 03:48 AM
From: Christos Chorattides
Subject: WAS ND, change Data sources in resources.xml
Hi Gabriel,
I was expecting a higher level reply. :)
But, a detailed one is most welcome!
Thank you for spending so much time to provide such comprehensive guide!
I will try it on a test server asap.
Thank you so much!
BR
------------------------------
Christos Chorattides
Datatech
Original Message:
Sent: Thu July 13, 2023 03:21 AM
From: Gabriel Aberasturi
Subject: WAS ND, change Data sources in resources.xml
Christos,
Open a command prompt or terminal and navigate to the <WAS_HOME>/bin directory. Replace <WAS_HOME> with the actual installation directory of your WebSphere Application Server.
Start the wsadmin tool by running the following command:
On Windows:
wsadmin.bat -lang jython
On Unix/Linux:
./wsadmin.sh -lang jython
Once the wsadmin prompt appears, execute the following commands to connect to the WebSphere Application Server profile:
# Connect to the WebSphere Application Server profile
host = '<hostname>'
port = '<admin_console_port>'
username = '<username>'
password = '<password>'
connectionType = '<SOAP|SOAP_SSL|SSL|NONE>'
securityEnabled = '<true|false>'
AdminTask.createAdminTask()
AdminTask.validate()
AdminTask.getDatabaseConfiguration(['-type', 'JDBCProvider', '-scope', 'Node=<node_name>,Server=<server_name>'])
Replace the placeholders within angle brackets (< >) with the appropriate values specific to your environment:
<hostname>: The hostname or IP address of the WebSphere Application Server.
<admin_console_port>: The port number of the WebSphere Application Server administrative console.
<username>: The username of an administrative user.
<password>: The password of the administrative user.
<SOAP|SOAP_SSL|SSL|NONE>: The connection type for the administrative connection.
<true|false>: Indicates whether security is enabled or not.
<node_name> and <server_name> in the -scope parameter specify the target node and server where the JDBC provider is configured. Replace them with the appropriate values for your environment.
To save the output to a file, you can redirect the output of the AdminTask.getDatabaseConfiguration command to a file. For example:
AdminTask.getDatabaseConfiguration(['-type', 'JDBCProvider', '-scope', 'Cell=<cell_name>']) > 'datasource_config.txt'
Replace 'datasource_config.txt' with the desired file path and name.
Open the extracted properties file in a text editor and make the necessary changes to the datasource configuration.
Save the modified properties file.
AdminTask.applyConfigProperties('[-propertiesFileName "<file_path>"]')
Replace <file_path> with the path to the modified properties file.
Save the changes and synchronize the nodes by executing the following commands:
AdminConfig.save()
AdminNodeManagement.syncActiveNodes()
This command saves the configuration changes and synchronizes the changes across the active nodes in the cell.
Finally, execute the command to disconnect from the WebSphere Application Server:
AdminConfig.reset()
AdminTask.clearTaskLists()
This command resets the configuration and clears the administrative task lists.
Hope this helps.
Regards.
------------------------------
Gabriel Aberasturi
Versia Sistemas TI
Original Message:
Sent: Thu July 13, 2023 03:15 AM
From: Christos Chorattides
Subject: WAS ND, change Data sources in resources.xml
Hi Gabriel,
thank you for your input.
This is a wsadmin approach and as it is fully supported, I am tempted to try it.
I need some clarifications as I am not very experienced with WebSphere.
- When starting wasadmin, how do I make sure, that it will connect to Dmgr and not a server?
- Is there an option to extract Datasources only, or do I get the entire configuration?
- "Apply changes" means using applyConfigProperties?
BR
------------------------------
Christos Chorattides
Datatech
Original Message:
Sent: Thu July 13, 2023 02:44 AM
From: Gabriel Aberasturi
Subject: WAS ND, change Data sources in resources.xml
Hi Christos
My suggestion is to make tha change using properties file base management.
https://www.ibm.com/docs/en/was-nd/8.5.5?topic=wsadmin-using-properties-files-manage-system-configuration
1. Extract all datasources information to file.
2. Replace URL
3. Apply changes.
4. Synchronice the cell
Hope this helps. Tell us if you need more support.
Regards
------------------------------
Gabriel Aberasturi
Versia Sistemas TI