It is possible to use the TCP-API directly in the test script for user management:
#!/usr/bin/env python3'''If you want the script to login and reserve a license automaticallyadd a configuration file called credentials.json in the current folderusing the following format: { "username": "YOUR USERNAME", "password": "YOUR PASSWORD" }Alternatively you can set the environment variables OTII_USERNAME and OTII_PASSWORD.'''from otii_tcp_client import otii_client# Connect and login to Otii 3client = otii_client.OtiiClient()with client.connect()as otii:# INSERT TEST CODE HERE
The client.connect() is used to connect, login and reserve licenses. It works like this:
If the TCP server isn't already logged in, the credentials will be read from a credentials.json file in the current directory, or from the environment variable OTII_USERNAME and OTII_PASSWORD.
If there is no Automation Toolbox license reserved and there is a license available, it will automatically be reserved.
By default the system will only try to reserve an Automation Toolbox license. If you need to reserve another Toolbox as well add all the licenses you need to the licensesparameter:
When disconnecting from Otii all licenses that were implicitly reserved will be returned, and if the connect method logged in to the system, it will log out again.
If you want to manually reserve a specific license, you use an empty array for the licenses parameter:
#!/usr/bin/env python3from otii_tcp_client import otii_client# Connect and login to Otii 3client = otii_client.OtiiClient()with client.connect(licenses = [])as otii:# List all licenses licenses = otii.get_licenses()forlicensein licenses:print(f'{license["id"]:4d}{license["type"]:12}{license["reserved_to"]:15}{license["hostname"]}')# Reserve a license otii.reserve_license(licenses[0])# INSERT TEST CODE HERE# Return license otii.return_license(licenses[0])
User management | Python tool
You can do the user management from the command line using our python module. You install the module with:
python3 -m pip install otii_tcp_client
You can then use the otii_control tool for user management:
python3 -m otii_tcp_client.otii_control --help
usage: otii_control.py [-h] {login,logout,list-licenses,reserve-license,return-license} ...
Otii Control
options:
-h, --help show this help message and exit
commands:
{login,logout,list-licenses,reserve-license,return-license}
login Log in to Qoitech server
logout Log out from Qoitech server
list-licenses List all available licenses
reserve-license Reserve license
return-license Return license