The tapi Command
Available in 7.0.0 and later.
The tapi command is designed to act as an interface to the Tungsten REST APIv2.
tapi [options] [API_call_path]
tapi only supports APIv2 calls at present. Using APIv8 can be enabled by issuing the
--apiver 8 option on all tapi calls, although at present this is only experimental.
The original goal of this script was to provide a way to test and exercise the API which then grew to include additional functionality and convenience options.
tapi Generic Options
| Option | Description | Version | Product |
|---|---|---|---|
--debugAliases: -d | CTTR | ||
--helpAliases: -h | CTTR | ||
--quietAliases: -q | CTTR | ||
--serviceAliases: -s | Specify a service name. Used with --run, --getpolicy, --setpolicy and the --policy NRPE plugin. | CTTR | |
--verboseAliases: -v | CTTR |
tapi CURL related Options
| Option | Description | Version | Product |
|---|---|---|---|
--curl | Specify where to find curl executable (default: curl). | CTTR | |
--get | Set the curl request to GET. | CTTR | |
--host | Specify the host name to connect to. Default: 127.0.0.1 | CTTR | |
--nosslAliases: --http | Specify NON-SSL/http-only connection. Default: https | CTTR | |
--passwordAliases: -p | Specify auth password. | CTTR | |
--port | Specify the port number to connect to. Default: 8090 | CTTR | |
--post | Set the curl request to POST. | CTTR | |
--put | Set the curl request to PUT. | CTTR | |
--request | Specify the curl request method. Default: none | Valid: GET, POST, PUT | CTTR | |
--userAliases: -u | Specify auth user. | CTTR |
tapi Nagios/NRPE/Zabbix related Options
| Option | Description | Version | Product |
|---|---|---|---|
--criticalAliases: -c | Specify the critical threshold value in seconds; used with --latency. | CTTR | |
--latency | Check the replicator for latency as an NRPE plugin. | CTTR | |
--online | Check the manager to see if the datasource is online as an NRPE plugin. | CT | |
--per-replica-perfdataAliases: --allperf | When --per-replica-perfdata is specified with --perf, each service is listed separately; used with --latency. | CTTR | |
--perfAliases: --perfdata | Display additional performance data; used with --latency. | CTTR | |
--policy | Check the manager to see if the cluster is in {autopolidy} policy mode as an NRPE plugin. | CT | |
--progress | Check the replicator to see that it is making progress over time as an NRPE plugin. | CTTR | |
--services | Check the host for running services (Manager, Connector and Replicator) as an NRPE plugin. | CTTR | |
--waitAliases: -w | Specify the time to wait in seconds during the --progress test.Default: 1 | CTTR | |
--warnAliases: -w | Specify the warning threshold value in seconds; used with --latency. | CTTR | |
--zabbixAliases: -z | Use Zabbix-style exit messages which are the same as the exit code, unlike NRPE which outputs a string starting with OK, WARNING or CRITICAL. | CTTR |
tapi Admin related Options
| Option | Description | Version | Product |
|---|---|---|---|
--create | Connect to the specified host and port, then call the createAdminUser path with a special body to instantiate the user. Must supply --create-user and --create-password. | CTTR | |
--create-pass | Sets the password for the APIv2 admin user created using the --create flag. --createand --create-user must also be supplied | CTTR | |
--create-user | Sets the user name for the APIv2 admin user created using the --create flag. --createand --create-pass must also be supplied | CTTR | |
--getds | Display the main Manager dataservice name. | CT | |
--getmain | Display the main Replicator service name. | CTTR | |
--getpolicy | Get the current local policy. If --service [svcname] is specified, then the policy will be displayed for that service. | CT | |
--getports | Display the API default port for each component. | CTTR | |
--getsubs | Display the Replicator sub-service(s). | CTTR | |
--includeServiceName | Output service names. | CTTR | |
--no-connectors | Append '?no-connectors=1' to all API calls to disable the Manager internal status calls to the Connectors. | CT | |
--setauto | Set the current policy to AUTOMATIC. | CT | |
--setmaint | Set the current policy to MAINTENANCE. | CT | |
--setmap | Generate and POST payload to Connector to instantiate the service. Must supply: --service, --node,--role, --state, --resource, --iscomposite, --driver. | 8.0.0 | CTTR |
--setpolicy | Set the current local policy. If --service [svcname] is specified, then the policy will be set for that service.Valid: auto, a, maint, m | CT | |
--topology | Display the main Manager topology. | CT |
tapi Filter related Options
| Option | Description | Version | Product |
|---|---|---|---|
--connectorAliases: -C | Specify the connector path. | CT | |
--filterAliases: -F | Specify [string] to limit the call path (typically used with --listapi. | CTTR | |
--managerAliases: -M | Specify the manager path. | CT | |
--replicatorAliases: -R | Specify the replicator path. | CTTR |
tapi API related Options
| Option | Description | Version | Product |
|---|---|---|---|
--all-aervices | Operate on all available services. Used with --run. | CTTR | |
--apiver | By default, all commands will use APIv2, this option can be used to switch to experiemntal APIv8 by passing --apiver 8. | 8.0.0 | CTTR |
--follow | If the resulting payload type is URIsPayload then call every key in the payload as a sub-item of the original path. | CTTR | |
--listapiAliases: -L | List all available REST API calls by unique key. | CTTR | |
--run | Specify an API call name by unique key. Use --listapi to see all keys/aliases. | CTTR |
tapi Status related Options
| Option | Description | Version | Product |
|---|---|---|---|
--affinity | Display only the affinity-specific values from the /connector/configuration/module/connector path. | CT | |
--allstats | Display all statistics cluster-wide using the Manager API. | CT | |
--clusterstatusAliases: --cs | Use the manager/cluster/status path. | CT | |
--connectorstatus | Use the /connector/configuration/module/connector path. | CT | |
--mgrstatsAliases: --managerstats | Display Manager statistics cluster-wide using the Manager API. | CT | |
--routers | Display Connector statistics cluster-wide using the Manager API. | CT | |
--status | Use the manager/status path. | CT | |
--trstats | Display Replicator statistics cluster-wide using the Manager API. | CT |
tapi Backup & Restore related Options
| Option | Description | Version | Product |
|---|---|---|---|
--backuptimeout | Specify the backup timeout in seconds. | CTTR | |
--mysqldump | Use the mysqldump backup agent. | CTTR | |
--restoretimeout | Specify the restore timeout in seconds. | CTTR | |
--restoreuri | Specify the restore URI. | CTTR | |
--storageagent | Specify the storage agent. | CTTR | |
--xtrabackup | Use the xtrabackup backup. | CTTR | |
--xtrabackupFull | Use the xtrabackupFull backup agent. | CTTR | |
--xtrabackupIncremental | Use the xtrabackupIncremental backup agent. | CTTR |
There are many cli options which invoke the various functions of the tapi script.
With no options specified, the tapi script will construct a curl command to query
the Tungsten Manager API (default https://127.0.0.1:8090) using the [API_call_path] provided on the command line.
Basic Example
Running tapi -M status would result in something like the following:
shell> tapi -M status
Executing: curl -s --user tungsten:secret --insecure --request GET 'https://127.0.0.1:8090/api/v2/manager/status'
{"payloadType":"StatusPayload","payloadVersion":"1","payload":{"dataServiceName":"east","dataSourceName":"db1-demo.continuent.com",
"startTime":"2021-03-25T16:47:50.523 UTC","uptimeSeconds":1909,"state":"ONLINE","isCoordinator":true,"isWitness":false,
"managerPID":4052,"parentPID":4031,"policyMode":"MAINTENANCE","coordinator":"db1-demo.continuent.com"}}
If both --user and --password are defined, curl will use them in the call.
If either or both --user and --password are missing, tapi will attempt to derive the values
using the tpm command.
Simple Admin Command Examples
tapi --getds
tapi --topology
tapi --setmaint
tapi --setauto
tapi --setpolicy maintenance
tapi --setpolicy m
tapi --setpolicy automatic
tapi --setpolicy a
Simple Replicator Command Examples
tapi --getmain
tapi --getsubs
Running API Command Examples
Show all available API calls in four columns: component, unique key, request type, request path:
tapi -R --listapi
Show all available API calls filtered by Manager (-M), Replicator (-R) or Connector (-C):
tapi --listapi -M
tapi --listapi -R
tapi --listapi -C
Execute an API call by unique key per component:
tapi -R --listapi
tapi -R --run ping
tapi -R -v --run offline (like `trepctl offline`)
tapi -R -v --run online (like `trepctl online`)
Backup and Restore Examples
tapi -v -R --run backup --mysqldump
tapi -v -R --run backup --xtrabackupFull
tapi -v -R -j --run restore
tapi -v -R -j --run task d28465a2-6023-47c4-9a4c-20f93514db75
Advanced Connector Provisioning Examples
Using a JSON Payload (MySQL Example)
shell> vi ~/DataServicesMapPayload.txt
{
"payloadType": "DataServicesMapPayload",
"payload": {
"alpha": {
"db1": {
"dataServiceName": "alpha",
"name": "db1",
"isAvailable": true,
"role": "master",
"host": "db1",
"state": "ONLINE",
"url": "jdbc:mysql:thin://db2-demo.continuent.com:13306/
{DBNAME}?jdbcCompliantTruncation=false&zeroDateTimeBehavior=convertToNull&;
tinyInt1isBit=false&allowMultiQueries=true&yearIsDateType=false",
"isComposite": false,
"driver": "org.drizzle.jdbc.DrizzleDriver"
}
}
}
}
shell> tapi -C -r setServicesmap --file ~/DataServicesMapPayload.txt
Using a JSON Payload (PostgreSQL Example)
shell> vi ~/DataServicesMapPayload.txt
{
"payloadType": "DataServicesMapPayload",
"payload": {
"ddg": {
"u4": {
"dataServiceName": "ddg",
"name": "u4",
"isAvailable": true,
"role": "master",
"host": "u4",
"state": "ONLINE",
"url": "jdbc:postgresql://u4:5432/${DBNAME}",
"isComposite": false,
"driver": "org.postgresql.Driver"
}
}
}
}
shell> tapi -C -r setServicesmap --file ~/DataServicesMapPayload.txt
Using Command Line Arguments (MySQL Example)
tapi --setmap --service alpha --node db1 --role master --state ONLINE --resource 'jdbc:mysql:thin://db2-demo.continuent.com:13306/
{DBNAME&}?jdbcCompliantTruncation=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&allowMultiQueries=true&yearIsDateType=false'
--iscomposite false --driver org.drizzle.jdbc.DrizzleDriver
Using Command Line Arguments (PostgreSQL Example)
tapi --setmap --service alpha --node db1 --role master --state ONLINE --resource 'jdbc:postgresql://u4:5432/{DBNAME}' --iscomposite false
--driver org.postgresql.Driver