From: Tony Mack Date: Tue, 20 Nov 2007 20:19:05 +0000 (+0000) Subject: -fix bug: users can properly update slice description/url if slice has none X-Git-Tag: PLCAPI-4.2-0~26 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=69e72e78ebbbbe135267d2ff0b0f10a0cf4937ac;p=plcapi.git -fix bug: users can properly update slice description/url if slice has none --- diff --git a/PLC/Methods/UpdateSlice.py b/PLC/Methods/UpdateSlice.py index de4a023..901ecbc 100644 --- a/PLC/Methods/UpdateSlice.py +++ b/PLC/Methods/UpdateSlice.py @@ -77,16 +77,22 @@ class UpdateSlice(Method): if 'admin' not in self.caller['roles'] and slice_fields['expires'] > max_expires: raise PLCInvalidArgument, "Cannot renew a slice beyond 8 weeks from now" + # XXX Make this a configurable policy + if slice['description'] is None or not slice['description'].strip(): + if 'description' not in slice_fields or slice_fields['description'] is None or \ + not slice_fields['description'].strip(): + raise PLCInvalidArgument, "Cannot renew a slice with an empty description or URL" + + if slice['url'] is None or not slice['url'].strip(): + if 'url' not in slice_fields or slice_fields['url'] is None or \ + not slice_fields['url'].strip(): + raise PLCInvalidArgument, "Cannot renew a slice with an empty description or URL" + if 'max_nodes' in slice_fields and slice_fields['max_nodes'] != slice['max_nodes']: if 'admin' not in self.caller['roles'] and \ 'pi' not in self.caller['roles']: raise PLCInvalidArgument, "Only admins and PIs may update max_nodes" - # XXX Make this a configurable policy - if slice['description'] is None or not slice['description'].strip() or \ - slice['url'] is None or not slice['url'].strip(): - raise PLCInvalidArgument, "Cannot renew a slice with an empty description or URL" - # Make requested associations for field in related_fields: if field in slice_fields: