Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

txjuju provides twisted-based tools for interacting with Juju. This includes both an API client and a CLI wrapper. The library is limited to Python 2, but does support both Juju 1.x and 2.x. Support for Python 3 is on the radar.

Note that only a portion of Juju’s capability is exposed in txjuju. This is because the code originates in the Landscape project and did not grow much beyond the needs of Landscape. The official Python bindings for Juju (python-libjuju) will usually offer a better experience. At some point python-libjuju may entirely supercede txjuju.

Key Components

Here are the essential classes of txjuju:

Additionally, txjuju.prepare_for_bootstrap() is especially useful.

For more information see DOC.rst.

Example Usage

API Client

from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks
from txjuju.api import Endpoint

endpoint = Endpoint(reactor, "ec2-1-2-3-4.compute-1.amazonaws.com")
deferred = endpoint.connect()

@inlineCallbacks
def connected(client):
    yield client.login("user-admin", "54830489236383334d1d9fd84adae72c")
    yield client.setAnnotations("unit", "1", {"foo": "bar"})

deferred.addCallback(connected)

reactor.run()

CLI Wrapper

import pprint
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks, returnValue
from txjuju import prepare_for_bootstrap
from txjuju.cli import BootstrapSpec, Juju1CLI

cfgdir = "/tmp/my-juju"
spec = BootstrapSpec("my-env", "lxd")
cli = Juju1CLI(cfgdir)

@inlineCallbacks
def bootstrap():
    prepare_for_bootstrap(spec, "1.25.6", cfgdir)
    yield cli.boostrap(spec.name, "0")
    raw = yield cli.api_info(spec.name)
    returnValue(raw)

deferred = bootstrap()
deferred.addCallback(lambda v: pprint.pprint(v))

reactor.run()

Contributing

If you’d like to contribute to txjuju, feel free to open an issue or send us a pull request. As far as borrowing from txjuju goes, the code is LGPLv3-licensed.

Packaging

A Python package may be created using python2 setup.py sdist. For building a debian package see BUILD and build.sh.

Style

The txjuju code follows PEP 8. It is a good idea to frequently run something like flake8 when making changes. Other txjuju-specific guidelines:

  • use double quotes for strings

  • test methods should have docstrings

Testing

To run the test suite, run make test or python2 -m unittest txjuju.tests.test_XXX.

Metadata

Release files for txjuju 0.9.0a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for txjuju 0.9.0a2
File Size Uploaded
txjuju-0.9.0a2.tar.gz 41.1 kB Details

Release files / txjuju-0.9.0a2.tar.gz

Download URL txjuju-0.9.0a2.tar.gz
Size 41.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c1d33b23ac0faf3386ad35f1c66fec12ac58a3e103663b097510a529fe9a13dc
BLAKE2b-256 checksum
How to use checksums
ec0022038c507789d93188393e0f1032927bee21aaebb3b2e4c40e5720a50541
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.9.0a2 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page