cubewise-code / rushti

Smooth parallelization of TI Processes with TM1py
https://code.cubewise.com/tm1py-help-content/run-processes-in-parallel-using-only-connection
MIT License
9 stars 13 forks source link

Implementation Question - Calling RushTI locally to run on Cloud #55

Closed nicolasbisurgi closed 2 years ago

nicolasbisurgi commented 2 years ago

Hi, Context: I'm currently working with a client that is moving to IBM cloud and needs to replace bash scripts that launch TI processes in a local TM1 Server in a controlled fashion (i.e.: with dependencies and monitoring of each thread). I thought on RushTI as a substitute since we can have it in a local box and launch processes on IBM's cloud as they do now.

Issue: The client uses CyberArk to store important credentials (such as the non-interactive accounts) so having a config.ini file with the passwords is not going to work. I know the password has to be encoded in the file, but that doesn't meet the level of security that's expected.

Questions is it possible to have RushTI open up a session from a file? As that file has no exposed passwords.

Example:

Step 1: Create a session

from TM1py.Services import TM1Service

password=getpass.from.vault(user=non_interactive_user) # --> this is made up code to reflect that the pass is stored in a secur vault and retrieved on demand

tm1params_cloud = { "base_url"='https://mycompany.planning-analytics.ibmcloud.com/tm1/api/tm1/', "user"="non_interactive_user", "namespace"="LDAP", "password"=password "ssl"=True, "verify"=True, "async_requests_mode"=True } tm1 = TM1Service(tm1params_cloud)

Step 2: Dump the sessions to a file

tm1.save_to_file('tm1srv01.connection')

Step 3: create a task_file.txt where the instance field is a reference to the connection file created above

instance="tm1srv01.connection" process="}bedrock.server.wait" pWaitSec=1

Step 4: call RushTI with this task file

python RushTI.py task_file.txt 16 norm 2

Probably you have a better idea on how to go about this, but it's Friday end of day so my brain can only work that much.

Please let me know your thoughts.

nico

MariusWirtz commented 2 years ago

Hi,

It should work if you create the config.ini with base_url and session_id in a pre-processing script that runs before rushti runs.

Kinda like in this sample. Just make RushTI read the two arguments from the config.ini instead.

from TM1py import TM1Service

BASE_URL = "https://localhost:12354"
tm1 = TM1Service(base_url=BASE_URL, user="admin", password="apple")

session_id = tm1.connection.session_id

new_tm1 = TM1Service(base_url=BASE_URL, session_id=session_id, verify=True, async_requests_mode=True)

print(new_tm1.server.get_server_name())
nicolasbisurgi commented 2 years ago

Thanks, @MariusWirtz ! I'll try that approach then.