def validate(self): super(FloatingIP, self).validate() # fixed_ip_address cannot be specified without a port_id if self.properties[self.PORT_ID] is None and self.properties[ self.FIXED_IP_ADDRESS] is not None: raise exception.ResourcePropertyDependency( prop1=self.FIXED_IP_ADDRESS, prop2=self.PORT_ID)
def validate(self): super(Order, self).validate() if self.properties[self.TYPE] != self.CERTIFICATE: if (self.properties[self.ALGORITHM] is None or self.properties[self.BIT_LENGTH] is None): msg = _("Properties %(algorithm)s and %(bit_length)s are " "required for %(type)s type of order.") % { 'algorithm': self.ALGORITHM, 'bit_length': self.BIT_LENGTH, 'type': self.properties[self.TYPE]} raise exception.StackValidationFailed(message=msg) else: if (self.properties[self.PROFILE] and not self.properties[self.CA_ID]): raise exception.ResourcePropertyDependency( prop1=self.PROFILE, prop2=self.CA_ID ) declared_props = sorted([k for k, v in six.iteritems( self.properties) if k != self.TYPE and v is not None]) allowed_props = sorted(self.ALLOWED_PROPERTIES_FOR_TYPE[ self.properties[self.TYPE]]) diff = sorted(set(declared_props) - set(allowed_props)) if diff: msg = _("Unexpected properties: %(unexpected)s. Only these " "properties are allowed for %(type)s type of order: " "%(allowed)s.") % { 'unexpected': ', '.join(diff), 'type': self.properties[self.TYPE], 'allowed': ', '.join(allowed_props)} raise exception.StackValidationFailed(message=msg)
def validate(self): super(Workflow, self).validate() if self.properties.get(self.TYPE) == 'reverse': params = self.properties.get(self.PARAMS) if params is None or not params.get('task_name'): raise exception.StackValidationFailed( error=_('Mistral resource validation error'), path=[ self.name, ('properties' if self.stack.t.VERSION == 'heat_template_version' else 'Properties'), self.PARAMS ], message=_("'task_name' is not assigned in 'params' " "in case of reverse type workflow.")) for task in self.properties.get(self.TASKS): wf_value = task.get(self.WORKFLOW) action_value = task.get(self.ACTION) if wf_value and action_value: raise exception.ResourcePropertyConflict( self.WORKFLOW, self.ACTION) if not wf_value and not action_value: raise exception.PropertyUnspecifiedError( self.WORKFLOW, self.ACTION) if (task.get(self.REQUIRES) is not None and self.properties.get(self.TYPE)) == 'direct': msg = _("task %(task)s contains property 'requires' " "in case of direct workflow. Only reverse workflows " "can contain property 'requires'.") % { 'name': self.name, 'task': task.get(self.TASK_NAME) } raise exception.StackValidationFailed( error=_('Mistral resource validation error'), path=[ self.name, ('properties' if self.stack.t.VERSION == 'heat_template_version' else 'Properties'), self.TASKS, task.get(self.TASK_NAME), self.REQUIRES ], message=msg) if task.get(self.POLICIES) is not None: for task_item in task.get(self.POLICIES): if task.get(task_item) is not None: msg = _('Property %(policies)s and %(item)s cannot be ' 'used both at one time.') % { 'policies': self.POLICIES, 'item': task_item } raise exception.StackValidationFailed(message=msg) if (task.get(self.WITH_ITEMS) is None and task.get(self.CONCURRENCY) is not None): raise exception.ResourcePropertyDependency( prop1=self.CONCURRENCY, prop2=self.WITH_ITEMS)
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')
def validate(self): super(ManilaShareNetwork, self).validate() if (self.properties[self.NEUTRON_NETWORK] and self.properties[self.NOVA_NETWORK]): raise exception.ResourcePropertyConflict(self.NEUTRON_NETWORK, self.NOVA_NETWORK) if (self.properties[self.NOVA_NETWORK] and self.properties[self.NEUTRON_SUBNET]): raise exception.ResourcePropertyConflict(self.NEUTRON_SUBNET, self.NOVA_NETWORK) if self.is_using_neutron() and self.properties[self.NOVA_NETWORK]: msg = _('With Neutron enabled you need to pass Neutron network ' 'and Neutron subnet instead of Nova network') raise exception.StackValidationFailed(message=msg) if (self.properties[self.NEUTRON_NETWORK] and not self.properties[self.NEUTRON_SUBNET]): raise exception.ResourcePropertyDependency( prop1=self.NEUTRON_NETWORK, prop2=self.NEUTRON_SUBNET) if (self.properties[self.NEUTRON_NETWORK] and self.properties[self.NEUTRON_SUBNET]): plg = self.client_plugin('neutron') subnet_id = plg.find_resourceid_by_name_or_id( plg.RES_TYPE_SUBNET, self.properties[self.NEUTRON_SUBNET]) net_id = plg.network_id_from_subnet_id(subnet_id) provided_net_id = plg.find_resourceid_by_name_or_id( plg.RES_TYPE_NETWORK, self.properties[self.NEUTRON_NETWORK]) if net_id != provided_net_id: msg = (_('Provided %(subnet)s does not belong ' 'to provided %(network)s.') % { 'subnet': self.NEUTRON_SUBNET, 'network': self.NEUTRON_NETWORK }) raise exception.StackValidationFailed(message=msg)