1.1 --- a/imiptools/handlers/scheduling/__init__.py Fri Apr 22 20:30:51 2016 +0200
1.2 +++ b/imiptools/handlers/scheduling/__init__.py Fri Apr 22 20:33:51 2016 +0200
1.3 @@ -34,6 +34,9 @@
1.4 Apply the scheduling functions for the current object of the given
1.5 'handler'. This function starts a transaction that should be finalised using
1.6 the 'finish_scheduling' function.
1.7 +
1.8 + Return a tuple containing the scheduling decision and any accompanying
1.9 + description.
1.10 """
1.11
1.12 # First, lock the resources to be used.
1.13 @@ -47,24 +50,26 @@
1.14 # Then, invoke the scheduling functions.
1.15
1.16 response = "ACCEPTED"
1.17 + description = None
1.18
1.19 for fn, args in schedulers:
1.20
1.21 # NOTE: Should signal an error for incorrectly configured resources.
1.22
1.23 if not fn:
1.24 - return "DECLINED"
1.25 + return "DECLINED", None
1.26
1.27 # Keep evaluating scheduling functions, stopping only if one
1.28 # declines or gives a null response.
1.29
1.30 else:
1.31 result = fn(handler, args)
1.32 + result, description = result or ("DECLINED", None)
1.33
1.34 # Return a negative result immediately.
1.35
1.36 - if not result or result == "DECLINED":
1.37 - return result
1.38 + if result == "DECLINED":
1.39 + return result, description
1.40
1.41 # Modify the eventual response from acceptance if a countering
1.42 # result is obtained.
1.43 @@ -72,7 +77,7 @@
1.44 elif response == "ACCEPTED":
1.45 response = result
1.46
1.47 - return response
1.48 + return response, description
1.49
1.50 def confirm_scheduling(handler):
1.51