我目前正在检查代码存储库的魅力,而不签入lib/charmhelpers。在我签出魅力之后,我需要运行脚本/ charm _helpers_sync.py,然后才能将魅力部署到机器上,以便填充lib/ charm _helpers目录。有什么办法在我把文件打包并推送到机器之前,让巨珠帮我完成这个任务吗?
发布于 2015-05-16 19:48:37
由于您希望每次部署魅力时都运行charm_helpers_sync.py,因此我怀疑您希望始终拥有最新版本的python-charmhelpers。要做到这一点,有一种更容易的方法:
自动安装charmhelpers
下面的函数使用存储库和python安装charmhelpers。
def install_charmhelpers():
"""
Install the charmhelpers library, if not present.
"""
try:
import charmhelpers # noqa
except ImportError:
import subprocess
subprocess.check_call(['apt-get', 'install', '-y', 'python-pip'])
subprocess.check_call(['pip', 'install', 'charmhelpers'])在您的钩子脚本顶部调用此函数,在魅力助手导入之上。Juju的python魅力模板展示了一种干净的方法。
如果您真的希望Juju下载charmhelpers代码并将其包含在魅力中,那么您必须编写一个Juju插件。
https://askubuntu.com/questions/621274
复制相似问题