Skip to main content

A Python client library for the TrueNAS API

Project description

Lint Build

Python Module for TrueNAS Websocket API

This python module utilizes the TrueNAS Websocket API to get state from a TrueNAS instance.

Installation

pip install aiotruenas-client

Usage

from aiotruenas_client import CachingMachine as TrueNASMachine

machine = await TrueNASMachine.create(
    "hostname.of.machine",
    api_key="someapikey"
)
datasets = await machine.get_datasets()
disks = await machine.get_disks()
jails = await machine.get_jails()
pools = await machine.get_pools()
vms = await machine.get_vms()

Alternatively, a username and password may also be supplied.

Machine

Object representing a TrueNAS instance.

Dataset

Available from machine.datasets, contains information about the datasets on the pools on the machine.

Disk

Available from machine.disks, contains information about the disks attached to the machine.

Jail

Available from machine.jails, contains information about the jails available on the machine.

Pool

Available from machine.pools, contains information about the ZFS pools known to the machine.

VirturalMachine

Available from machine.vms, contains information about the virtural machines available on the machine.

Each instance has the following methods availabe:

  • vm.start
  • vm.stop
  • vm.restart

Development

Setup

python3.8 -m venv .venv
source .venv/bin/activate

# Install Requirements
pip install -r requirements.txt

# Install Dev Requirements
pip install -r requirements-dev.txt

# One-Time Install of Commit Hooks
pre-commit install

Working With Methods & Subscriptions

When adding support for a new object, or updating existing code, it can be useful to see the raw response from the TrueNAS machine from time to time. In order to help do that easily, you can drop a .auth.yaml file in the root of the repository, with the following content:

host: "some.host.name"
api_key: "someapikey"

Use scripts/invoke_method.py to call a method:

python scripts/invoke_method.py disk.query

Use scripts/subscribe.py to subscribe to a topic:

python scripts/subscribe.py reporting.realtime

Run either with -h to see additional options.

Testing

Tests are run with pytest.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiotruenas-client-0.10.0.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

aiotruenas_client-0.10.0-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file aiotruenas-client-0.10.0.tar.gz.

File metadata

  • Download URL: aiotruenas-client-0.10.0.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for aiotruenas-client-0.10.0.tar.gz
Algorithm Hash digest
SHA256 edb35e29cf89f0b94f11ccbd52ac1d029738cb5c6454cb4f309d7ce71ee19728
MD5 fe1b3de35681b8fbda08569f1ee85635
BLAKE2b-256 4d2cdccc5df35587b4afe9f209f37eb606cffc199d71bf9b6d8ba92b41127a92

See more details on using hashes here.

File details

Details for the file aiotruenas_client-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiotruenas_client-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3eccb1ffeca9d01dd4ca4ce0fb8c92490b7c070729d6e1f8c40066f9fa2351d9
MD5 7cb94a18f0820c08336546235e2d375a
BLAKE2b-256 b92e9bb45f42866d4689e96404d7742a402f2e0d71b4271840048d1f2fac6ab2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page