I have a charm where I'd like to be able to call a small Python script in one of the hooks as part of its execution. Where do I put that helper script? Can I put it in the hooks directory and get it included? Then, once it is transfered to the remote machine, where is it located so that I can execute it?
Asked
Active
Viewed 232 times
1 Answers
3
The entire directory of the charm (the root being the dir with metadata.yaml) is bundled and unpacked on the service unit including permission bits (ownership is always transferred to root:root). Hooks are always run with the charm root as current working directory, and saved in $CHARM_DIR.
So, you can put the scripts wherever you want. There's no agreement yet on the best practice for this. Some people feel that only hooks should be in the hooks dir, and external scripts should be in a different dir off the root. Others just put everything in hooks.
SpamapS
- 19,570
- 4
- 31
- 49
-
Thanks for the answer, I'm trying it now but it seems my Openstack setup just broke. Hopefully I'll be able to verify here real soon! – Ted Gould Jun 11 '12 at 18:53
-
Great! Works here. I made a separate helpers directory and executed my script with $CHARM_DIR/helpers/myhelper. Thanks! – Ted Gould Jun 12 '12 at 03:27