Test Data Manager

 View Only
  • 1.  Triggering python script from CA TDM Portal (tile)

    Posted Jun 07, 2021 06:38 PM
    Edited by Prasad Raghu Jun 07, 2021 06:40 PM

    Hi,

    I would like to know how to execute python script .py from CA TDM portal as post publish action. I created an post publish action in datapool (code type: HOST) and provided the following code - cmd /c "py D:\Path\MergeFiles.py SIT 0101 CD" in datamaker. When I publish this datapool this python script gets executed. However when create a tile using this datapool and execute from CA TDM portal, it doesnt execute the python script. I verified that the environment variables, python.exe location is added in PATH variable and .py is added in PATHEXT variable.
    I am not sure it wouldnt work from CA TDM portal.

    I have tried both cmd /c "py D:\Path\MergeFiles.py SIT 0101 CD" as well as py D:\Path\MergeFiles.py SIT 0101 CD.

    Kindly help.

    ------------------------------

    Thanks,
    Prasad
    ------------------------------


  • 2.  RE: Triggering python script from CA TDM Portal (tile)

    Broadcom Employee
    Posted Jun 08, 2021 02:51 AM
    Hi Prasad,

    As the portal runs as a service, you should run your python script under the same service account as the portal. By default, the portal uses the System service account. 

    You can use the windows scheduler to start your python script to test and  run it under a Service account (maybe a user rather than a system account). When you confirm that it works then you can use TDM.

    Regards, Dahman


    This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.





  • 3.  RE: Triggering python script from CA TDM Portal (tile)

    Posted Jun 08, 2021 12:03 PM
    Edited by Prasad Raghu Jun 08, 2021 12:05 PM
    Hi Dahman,

    As you mentioned I am running CA TDM portal service using my logon id. (Restarted service after adding my logon id). My id has complete privileges to execute python script. I also verified using windows task scheduler using my id and the script was executed successfully. Here are the screenshots of the changes made.

    I also verified the application.properties file as suggested by Cihan to see if tdmweb.enableHostActions was set to True. It is set to True as shown below.


    Could you please let me know what else can be tried to execute Python script from CA TDM portal?

    ------------------------------
    Thanks,
    Prasad
    ------------------------------



  • 4.  RE: Triggering python script from CA TDM Portal (tile)

    Broadcom Employee
    Posted Jun 08, 2021 12:09 PM

    I would suggest that you put your commands into a batch file and call the batch file.

    now that the portal is running in a user context and you have enabled the host action this should in their work.

    Make sure to enable debug mode in your logs to get more details should it not work.



    ------------------------------
    Gene Howard
    Principal Support Engineer
    Broadcom
    ------------------------------



  • 5.  RE: Triggering python script from CA TDM Portal (tile)

    Posted Jun 08, 2021 12:35 PM
    Hi Gene,

    I shall try out what you have suggested i.e. to use a batch file. However since we have to reference this python code in multiple datapools using different arguments for each datapool, I was looking to directly update in the action - code window. This would be easier rather than creating multiple batch files for each datapool (from maintainence perspective).


    ------------------------------
    Thanks,
    Prasad
    ------------------------------



  • 6.  RE: Triggering python script from CA TDM Portal (tile)

    Broadcom Employee
    Posted Jun 08, 2021 12:40 PM
    For complex things such as that, I usually suggest clients look at using a javelin flow in the post process action rather than command lines as the portal runs as a service and this special User Session can have issues such as you are experiencing.


    ------------------------------
    Gene Howard
    Principal Support Engineer
    Broadcom
    ------------------------------



  • 7.  RE: Triggering python script from CA TDM Portal (tile)

    Broadcom Employee
    Posted Jun 08, 2021 01:16 PM
    Can you check if python is called at all by creating a batch file and see if there are issues with the python not being in the path when run from the service account

    You can also call python providing the full path and use a simple python script like hello world

    Regards, Dahman

    This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.





  • 8.  RE: Triggering python script from CA TDM Portal (tile)

    Posted Jun 08, 2021 05:05 PM
    Hi Dahman,

    I created a batch file which would call a simple python file "Hello World". This python file would print "hello world" infinitely. When I executed the tile, I could see cmd.exe , py.exe and python.exe getting launched in windows task manager. So i guess its working with a simple python file.  But when i trigger the actual python script which have few arguments its not working. I dont see any py.exe or python.exe getting launched in task manager. This program is supposed to merge N number of spreadsheets in a specific folder, add/rearrange columns, sort a particular column and finally write it to XL and CSV files. I dont see these files getting generated when tile is executed. But this program works fine when published from datamaker.

    Note that the only difference between Helloworld program and actual program is that I am passing arguments in the later.

    Code in Hello.bat (works) - cmd /c "C:\Windows\py.exe D:\Teller21\Hello.py"

    Code in MergeFile.bat (doesnt work) - cmd /c "C:\Windows\py.exe D:\Teller21\MergeFiles.py SIT 0101 CD"



    ------------------------------
    Thanks,
    Prasad
    ------------------------------



  • 9.  RE: Triggering python script from CA TDM Portal (tile)

    Broadcom Employee
    Posted Jun 08, 2021 07:01 AM
    Hi,

    In addition to that, please check if "tdmweb.enableHostActions" configuration, in "application.properties" was set to enable.

    # Enable or disable publish "host" actions
    tdmweb.enableHostActions=false

    https://techdocs.broadcom.com/us/en/ca-enterprise-software/devops/test-data-management/4-9/provisioning-test-data/generate-synthetic-test-data/generate-data-using-the-ca-tdm-portal/publish-data-using-the-ca-tdm-portal/create-and-manage-publish-and-table-actions.html#concept.dita_2f5bba48fb816efb361453289a6961bd19be4260_enablehostactions

    Best Regards,
    Cihan