Mike Kolesnik has posted comments on this change.
Change subject: hooks: Extract function for command execution ......................................................................
Patch Set 1:
(3 comments)
.................................................... File vdsm_hooks/openstacknet/openstacknet_utils.py Line 17: # Make pyflakes happy Line 18: DUMMY_BRIDGE Line 19: Line 20: Line 21: def executeOrExit(command, expectSuccess=True): Yes it is used in later patches, otherwise I wouldn't have added this. Line 22: retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) Line 23: commandFailed = retcode != 0 if expectSuccess else retcode == 0 Line 24: if commandFailed: Line 25: hooking.exit_hook("Failed to execute %s, due to: %s" %
Line 21: def executeOrExit(command, expectSuccess=True): Line 22: retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) Line 23: commandFailed = retcode != 0 if expectSuccess else retcode == 0 Line 24: if commandFailed: Line 25: hooking.exit_hook("Failed to execute %s, due to: %s" % I don't see any hooks code directly raising any kind of exception, and from what I understood the way to exit a hook is by calling hooking.exit_hook().
Can you please suggest how this can be achieved with exception, as this ould be the first of it's kind?
Simply "raise Exception(...)" would do the trick, and be correct for hooking code?
Line 22: retcode, out, err = hooking.execCmd(command, sudo=True, raw=True) Line 23: commandFailed = retcode != 0 if expectSuccess else retcode == 0 Line 24: if commandFailed: Line 25: hooking.exit_hook("Failed to execute %s, due to: %s" % Line 26: (str(command), err)) Done