Merlijn Sebrechts Asked: 2015-12-09 08:30:08 +0800 CST2015-12-09 08:30:08 +0800 CST 2015-12-09 08:30:08 +0800 CST How to get unit name in hook? 772 How can a hook script get the unit id and the service name? Please give me an example in Python and in Bash. juju 1 Answers Voted Best Answer Merlijn Sebrechts 2015-12-09T08:30:08+08:002015-12-09T08:30:08+08:00 Python from charmhelpers.core import hookenv unit_name = hookenv.local_unit() service_name = hookenv.local_unit().split('/')[0] Bash UNIT_NAME=$JUJU_UNIT_NAME
Python
Bash