diff --git a/CHANGES b/CHANGES index 2fa72da5..cb9db772 100644 --- a/CHANGES +++ b/CHANGES @@ -56,6 +56,7 @@ gcf 2.9: * Results from all calls are combined into a single return message and structure. * APIv2 results will be keyed by AM URL and have the value of True or False usually, but sometimes a struct. * This is useful when a circuit was reserved using `-V3` and some AMs spoke APIv2 only. + * Fix handling of return when tried to delete at an AM with no resources. (#823) * scs.py now honors `--timeout` to set the SSL connection timeout. (#785) * For `--fixedEndpoint` calls, avoid adding the fake interface to links with no stitching path, such as for a LAN within a single AM. (#790) diff --git a/src/gcf/omnilib/stitch/objects.py b/src/gcf/omnilib/stitch/objects.py index e0a33992..4ea5c757 100644 --- a/src/gcf/omnilib/stitch/objects.py +++ b/src/gcf/omnilib/stitch/objects.py @@ -3978,7 +3978,7 @@ def deleteReservation(self, opts, slicename): omniargs = ['-V%d' % self.api_version,'--raise-error-on-v2-amapi-error', '-o', '-a', self.url, opName, slicename] # Raw omni call results, for returning - text = None + text = "" result = None self.logger.info("Doing %s at %s...", opName, self) @@ -4050,13 +4050,21 @@ def deleteReservation(self, opts, slicename): val = "" if ae.returnstruct.has_key("value"): val = ae.returnstruct["value"] + #self.logger.debug("%s at %s gave code %d, output: '%s', value: '%s'", opName, self, code, msg, val) if code == 12 and (amcode == 12 or amcode is None): # This counts as success self.logger.info(" ... but this error means there was nothing to delete") noError = True + if self.nick: + text = "Success: Nothing to delete at %s" % self.nick + else: + text = "Success: Nothing to delete at %s" % self.urn + else: + text = "Failed to %s at %s: code %d: %s %s" % (opName, self, code, msg, val) except Exception, e2: # Failed to parse the error code. self.logger.debug("Failed to parse return code out of error doing %s at %s: parsing %s gave %s", opName, self, ae, e2) + text = "Unknown error doing %s at %s: %s" % (opName, self, e) if not noError: self.logger.error("Failed to %s at %s: %s", opName, self, e) raise StitchingError(e) # FIXME: Right way to re-raise? diff --git a/src/gcf/omnilib/stitchhandler.py b/src/gcf/omnilib/stitchhandler.py index 469cd563..0b631bb3 100644 --- a/src/gcf/omnilib/stitchhandler.py +++ b/src/gcf/omnilib/stitchhandler.py @@ -2042,15 +2042,19 @@ def deleteAllReservations(self, launcher): try: (text, result) = am.deleteReservation(self.opts, self.slicename) self.logger.info("Deleted reservation at %s.", am) - if retText != "": - retText += "\n %s" % text - else: - retText = text + if text is not None and text.strip() != "": + if retText != "": + retText += "\n %s" % text + else: + retText = text if am.api_version < 3 or not isinstance(result, dict): if not (isinstance(result, tuple) and isinstance(result[0], list)): - # Some kind of error - self.logger.debug("Struct result from delete or deletesliver unknown from %s: %s", am, result) - retStruct[am.url] = result + if result is None and text.startswith("Success"): + retStruct[am.url] = True + else: + # Some kind of error + self.logger.debug("Struct result from delete or deletesliver unknown from %s: %s", am, result) + retStruct[am.url] = result else: (succ, fail) = result # FIXME: Do the handler_utils tricks for comparing URLs?