juju charms加载外部资源的帮助程序
jujuresources的Python项目详细描述
Juju资源
juju resources为charms提供了助手,以便从中加载二进制资源 外部资源,以及用于创建外部资源镜像的工具 用于受网络限制的部署。
这是一个权宜之计,直到Juju获得资源的核心支持, 以及原型需要什么样的功能。
完整的文档可以在网上找到:http://pythonhosted.org/jujuresources/
安装
使用pip安装juju资源:
pip install jujuresources
魅力用法
使用juju资源的charm需要定义一个resources.yaml, 例如:
resources: my_resource: url: http://example.com/path/to/my_resource.tgz hash: b377b7cccdd281bc5e4c4071f80e84a3 hash_type: sha256 my_py: pypi: jujuresources>=0.2 optional_resources: my_optional_resource: url: http://example.com/path/to/my_optional_resource.tgz hash: 476881ef4012262dfc8adc645ee786c4 hash_type: sha256
然后,一旦魔咒安装了Juju资源,它就可以 并验证资源,无论是在python中:
from jujuresources import fetch, verify, install, config_get if not fetch(mirror_url=config_get('resources_mirror')): print "Mandatory resources did not download; check resources_mirror option" sys.exit(1) install('my_py') fetch('my_optional_resource', mirror_url=config_get('resources_mirror')) if verify('my_optional_resource'): install('my_optional_resource', destination='/usr/lib/myres', skip_top_level=True)
或者通过命令行/bash:
if ! juju-resources fetch -u `config-get resources_mirror`; then echo "Mandatory resources did not download; check resources_mirror option" exit 1 fi juju-resources install my_py juju-resources fetch -u `config-get resources_mirror` my_optional_resource if juju-resources verify my_optional_resource; then juju-resources install my_optional_resource -D /usr/lib/myres -s fi
镜像资源
如果需要在网络访问受限的环境中部署charms, 您可以提前创建镜像,也可以在具有访问权限的网关节点上创建镜像:
mkdir local_mirror juju-resources fetch --all -d local_mirror -r http://github.com/me/my-charm/blob/master/resources.yaml juju-resources serve -d local_mirror
然后将运行一个轻量级http服务器,您可以将 charm的resources_mirror(或等效的)配置选项指向, 提供中定义的所有(--all,可选和必需)资源 远程resources.yaml(-r<url-or-file>)缓存在 local_mirror目录(-d local_mirror)。
注意,charms需要能够访问您运行的机器和端口 镜像打开,并且字符必须支持配置选项以指向juju资源 向镜子(以及处理他们的资源可能不 第一次部署时可用)。