基于twisted的Juju客户端。
项目描述
txjuju提供了twisted基础工具,用于与Juju交互。这包括API客户端和CLI包装器。该库仅限于Python 2,但支持Juju 1.x和2.x。Python 3的支持正在计划中。
请注意,txjuju只公开了Juju的部分功能。这是因为代码起源于Landscape项目,并且没有超出Landscape的需求。Juju的官方Python绑定(python-libjuju)通常提供更好的体验。在某个时刻,python-libjuju可能会完全取代txjuju。
关键组件
以下是txjuju的基本类
此外,txjuju.prepare_for_bootstrap()特别有用。
更多信息请参阅DOC.rst。
示例使用
API客户端
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包装器
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()
贡献
如果您想为txjuju做出贡献,请随意打开一个问题或向我们发送pull请求。就txjuju的借用而言,代码是LGPLv3许可的。
打包
可以使用python2 setup.py sdist创建Python包。有关构建deb包的信息,请参阅BUILD和build.sh。
风格
txjuju代码遵循PEP 8。在做出更改时经常运行类似flake8的东西是个好主意。其他txjuju特定指南
使用双引号字符串
测试方法应包含文档字符串
测试
要运行测试套件,请运行make test或python2 -m unittest txjuju.tests.test_XXX。
项目详情
关闭
txjuju-0.9.0a2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c1d33b23ac0faf3386ad35f1c66fec12ac58a3e103663b097510a529fe9a13dc |
|
MD5 | 5e428fc681850cf4f959bc9f015eaf07 |
|
BLAKE2b-256 | ec0022038c507789d93188393e0f1032927bee21aaebb3b2e4c40e5720a50541 |