[WIP] Adding hook support - #456
Open
gbenhaim wants to merge 1 commit into
Open
Conversation
mykaul
reviewed
Feb 26, 2017
mykaul
left a comment
There was a problem hiding this comment.
What's the use case for the hooks? It was not mentioned in the commit message.
| @@ -0,0 +1,254 @@ | |||
| # coding=utf-8 | |||
| import functools | |||
| import os | |||
There was a problem hiding this comment.
Do we care about import order, alphabetically or something?
| hooks = Hooks(prefix.paths.hooks()) | ||
| hooks.run_pre_hooks(cmd) | ||
| result = func(*args, **kwargs) | ||
| hooks.run_post_hooks(cmd) |
There was a problem hiding this comment.
The hooks run regardless of the result, and are not aware of the result. Perhaps worth passing it to them?
Member
Author
There was a problem hiding this comment.
- Post hook won't run if 'func' throws an exception, do we want to change this behavior ?
- When passing 'result' to the post hook I need to assume that it is a string, or can be evaluated to a meaningful string, I'm not sure that I can take this assumption.
| try: | ||
| with utils.DirLockWithTimeout(cmd_dir): | ||
| self._run_hooks( | ||
| sorted([path.join(hook_dir, hook) for hook in hooks]) |
Member
Author
There was a problem hiding this comment.
I want to preserve the order in which the hooks were mentioned in the init file, but now I realize that I didn't prefix them with an index. will fix.
Contributor
|
Contributor
|
Some possible use-cases of VM hooks:
Some possible use-cases of Host hooks:
|
1. The hooks are defined in the init file and can be any type of script (shell, python...). 2. The hooks will be run on the host which runs Lago. 3. Hooks will be only supported for functions that were decorated with "hooks.with_hooks" (for now just start / stop) Signed-off-by: gbenhaim <galbh2@gmail.com>
gbenhaim
force-pushed
the
adding_hooks
branch
from
February 27, 2017 14:23
6f7c05a to
ab667df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The hooks are defined in the init file and
can be any type of script (shell, python...).
The hooks will be run on the host which runs Lago.
Hooks will be only supported for functions that were
decorated with "hooks.with_hooks" (for now just start / stop)
Signed-off-by: gbenhaim galbh2@gmail.com