User management

A note to users of Otii 2

Otii 2 was shipped with otiicli that was used to run Lua-scripts, act as a server and handle user management.

The CLI tool in Otii 3 - otii_server, dows only act as a server. Otii 3 does not support Lua and the user management must be done from the test scripts.

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: [-h] {login,logout,list-licenses,reserve-license,return-license} ...

Otii Control

  -h, --help            show this help message and exit

    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

And here is an example bash script:

#!/usr/bin/env bash

python3 -m otii_tcp_client.otii_control login --username johndoe --password mypassword
python3 -m otii_tcp_client.otii_control reserve-license --id 1234
python3 -m otii_tcp_client.otii_control return-license --id 1234
python3 -m otii_tcp_client.otii_control logout

User management | Test script

It is also possible to use the TCP-API directly in the test script for user management:

#!/usr/bin/env python3
from otii_tcp_client import otii_connection, otii as otii_application

# Connect to Otii 3
connection = otii_connection.OtiiConnection("localhost", 1905)
response = connection.connect_to_server()
if response["type"] == "error":
    raise Exception("Error code: " + response["errorcode"] + ", Description: " + response["payload"]["message"])
otii = otii_application.Otii(connection)

# Login, list licenses, and reserve a license (gets username and password from config.json)
with open("config.json", encoding="utf-8") as file:
    config = json.load(file)
otii.login(config["username"], config["password"])
licenses = otii.get_licenses()
for license in licenses:
    print(f'{license["id"]:4d} {license["type"]:12} {license["reserved_to"]:15} {license["hostname"]}')
    for addon in license["addons"]:
        print(f'     - {addon["id"]}')



# Return license

Last updated