def validate(self): res = super(L7Policy, self).validate() if res: return res if (self.properties[self.ACTION] == self.REJECT and (self.properties[self.REDIRECT_POOL] is not None or self.properties[self.REDIRECT_URL] is not None)): msg = (_('Properties %(pool)s and %(url)s are not required when ' '%(action)s type is set to %(action_type)s.') % { 'pool': self.REDIRECT_POOL, 'url': self.REDIRECT_URL, 'action': self.ACTION, 'action_type': self.REJECT }) raise exception.StackValidationFailed(message=msg) if self.properties[self.ACTION] == self.REDIRECT_TO_POOL: if self.properties[self.REDIRECT_URL] is not None: raise exception.ResourcePropertyValueDependency( prop1=self.REDIRECT_URL, prop2=self.ACTION, value=self.REDIRECT_TO_URL) if self.properties[self.REDIRECT_POOL] is None: msg = (_('Property %(pool)s is required when %(action)s ' 'type is set to %(action_type)s.') % { 'pool': self.REDIRECT_POOL, 'action': self.ACTION, 'action_type': self.REDIRECT_TO_POOL }) raise exception.StackValidationFailed(message=msg) if self.properties[self.ACTION] == self.REDIRECT_TO_URL: if self.properties[self.REDIRECT_POOL] is not None: raise exception.ResourcePropertyValueDependency( prop1=self.REDIRECT_POOL, prop2=self.ACTION, value=self.REDIRECT_TO_POOL) if self.properties[self.REDIRECT_URL] is None: msg = (_('Property %(url)s is required when %(action)s ' 'type is set to %(action_type)s.') % { 'url': self.REDIRECT_URL, 'action': self.ACTION, 'action_type': self.REDIRECT_TO_URL }) raise exception.StackValidationFailed(message=msg)
def _validate_min_adjustment_step(self): adjustment_type = self.properties.get(self.ADJUSTMENT_TYPE) adjustment_step = self.properties.get(self.MIN_ADJUSTMENT_STEP) if (adjustment_type != sc_util.PERCENT_CHANGE_IN_CAPACITY and adjustment_step is not None): raise exception.ResourcePropertyValueDependency( prop1=self.MIN_ADJUSTMENT_STEP, prop2=self.ADJUSTMENT_TYPE, value=sc_util.PERCENT_CHANGE_IN_CAPACITY)
def validate(self): """ Add validation for min_adjustment_step """ super(AutoScalingPolicy, self).validate() adjustment_type = self.properties.get(self.ADJUSTMENT_TYPE) adjustment_step = self.properties.get(self.MIN_ADJUSTMENT_STEP) if (adjustment_type != self.PERCENT_CHANGE_IN_CAPACITY and adjustment_step is not None): raise exception.ResourcePropertyValueDependency( prop1=self.MIN_ADJUSTMENT_STEP, prop2=self.ADJUSTMENT_TYPE, value=self.PERCENT_CHANGE_IN_CAPACITY)
def validate(self): super(Secret, self).validate() if self.properties[self.PAYLOAD_CONTENT_TYPE]: if not self.properties[self.PAYLOAD]: raise exception.ResourcePropertyDependency( prop1=self.PAYLOAD_CONTENT_TYPE, prop2=self.PAYLOAD) if (self.properties[self.PAYLOAD_CONTENT_TYPE] == 'application/octet-stream'): if not self.properties[self.PAYLOAD_CONTENT_ENCODING]: msg = _("Property unspecified. For '%(value)s' value " "of '%(prop1)s' property, '%(prop2)s' property " "must be specified.") % { 'value': self.properties[self.PAYLOAD_CONTENT_TYPE], 'prop1': self.PAYLOAD_CONTENT_TYPE, 'prop2': self.PAYLOAD_CONTENT_ENCODING } raise exception.StackValidationFailed(message=msg) try: base64.b64decode(self.properties[self.PAYLOAD]) except Exception: msg = _("Invalid %(prop1)s for specified '%(value)s' " "value of '%(prop2)s' property.") % { 'prop1': self.PAYLOAD, 'value': self.properties[self.PAYLOAD_CONTENT_ENCODING], 'prop2': self.PAYLOAD_CONTENT_ENCODING } raise exception.StackValidationFailed(message=msg) if (self.properties[self.PAYLOAD_CONTENT_ENCODING] and (not self.properties[self.PAYLOAD_CONTENT_TYPE] or self.properties[self.PAYLOAD_CONTENT_TYPE] == 'text/plain')): raise exception.ResourcePropertyValueDependency( prop1=self.PAYLOAD_CONTENT_ENCODING, prop2=self.PAYLOAD_CONTENT_TYPE, value='application/octet-stream')