示例#1
0
文件: subnet.py 项目: zzjeric/heat
    def validate(self):
        super(Subnet, self).validate()
        subnetpool = self.properties[self.SUBNETPOOL]
        prefixlen = self.properties[self.PREFIXLEN]
        cidr = self.properties[self.CIDR]
        if subnetpool is not None and cidr:
            raise exception.ResourcePropertyConflict(self.SUBNETPOOL,
                                                     self.CIDR)
        if subnetpool is None and not cidr:
            raise exception.PropertyUnspecifiedError(self.SUBNETPOOL,
                                                     self.CIDR)
        if prefixlen and cidr:
            raise exception.ResourcePropertyConflict(self.PREFIXLEN, self.CIDR)
        ra_mode = self.properties[self.IPV6_RA_MODE]
        address_mode = self.properties[self.IPV6_ADDRESS_MODE]

        if (self.properties[self.IP_VERSION] == 4) and (ra_mode
                                                        or address_mode):
            msg = _('ipv6_ra_mode and ipv6_address_mode are not supported '
                    'for ipv4.')
            raise exception.StackValidationFailed(message=msg)
        if ra_mode and address_mode and (ra_mode != address_mode):
            msg = _('When both ipv6_ra_mode and ipv6_address_mode are set, '
                    'they must be equal.')
            raise exception.StackValidationFailed(message=msg)

        gateway_ip = self.properties.get(self.GATEWAY_IP)
        if (gateway_ip and gateway_ip not in ['~', '']
                and not netutils.is_valid_ip(gateway_ip)):
            msg = (_('Gateway IP address "%(gateway)s" is in '
                     'invalid format.'), gateway_ip)
            raise exception.StackValidationFailed(message=msg)
示例#2
0
文件: pool.py 项目: zzjeric/heat
    def validate(self):
        super(Pool, self).validate()
        if (self.properties[self.LISTENER] is None
                and self.properties[self.LOADBALANCER] is None):
            raise exception.PropertyUnspecifiedError(self.LISTENER,
                                                     self.LOADBALANCER)

        if self.properties[self.SESSION_PERSISTENCE] is not None:
            session_p = self.properties[self.SESSION_PERSISTENCE]
            persistence_type = session_p[self.SESSION_PERSISTENCE_TYPE]
            if persistence_type == self.APP_COOKIE:
                if not session_p.get(self.SESSION_PERSISTENCE_COOKIE_NAME):
                    msg = (_('Property %(cookie)s is required when %(sp)s '
                             'type is set to %(app)s.') %
                           {
                               'cookie': self.SESSION_PERSISTENCE_COOKIE_NAME,
                               'sp': self.SESSION_PERSISTENCE,
                               'app': self.APP_COOKIE
                           })
                    raise exception.StackValidationFailed(message=msg)
            elif persistence_type == self.SOURCE_IP:
                if session_p.get(self.SESSION_PERSISTENCE_COOKIE_NAME):
                    msg = (_('Property %(cookie)s must NOT be specified when '
                             '%(sp)s type is set to %(ip)s.') %
                           {
                               'cookie': self.SESSION_PERSISTENCE_COOKIE_NAME,
                               'sp': self.SESSION_PERSISTENCE,
                               'ip': self.SOURCE_IP
                           })
                    raise exception.StackValidationFailed(message=msg)
示例#3
0
    def _validate_depr_property_required(properties, prop_key, depr_prop_key):
        prop_value = properties.get(prop_key)
        depr_prop_value = properties.get(depr_prop_key)

        if prop_value and depr_prop_value:
            raise exception.ResourcePropertyConflict(prop_key, depr_prop_key)
        if not prop_value and not depr_prop_value:
            raise exception.PropertyUnspecifiedError(prop_key, depr_prop_key)
示例#4
0
文件: quota.py 项目: ii0/heat
 def validate(self):
     super(CinderQuota, self).validate()
     if sum(1 for p in self.properties.values() if p is not None) <= 1:
         raise exception.PropertyUnspecifiedError(self.GIGABYTES,
                                                  self.SNAPSHOTS,
                                                  self.VOLUMES,
                                                  self.BACKUPS,
                                                  self.BACKUPS_GIGABYTES)
示例#5
0
    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)
示例#6
0
    def validate(self):
        """Validate any of the provided params."""
        super(RouterInterface, self).validate()

        prop_subnet_exists = self._validate_deprecated_keys(
            self.properties, self.SUBNET, self.SUBNET_ID)
        if not self._validate_deprecated_keys(self.properties, self.ROUTER,
                                              self.ROUTER_ID):
            raise exception.PropertyUnspecifiedError(self.ROUTER,
                                                     self.ROUTER_ID)

        prop_port_exists = self._validate_deprecated_keys(
            self.properties, self.PORT, self.PORT_ID)

        if prop_subnet_exists and prop_port_exists:
            raise exception.ResourcePropertyConflict(self.SUBNET, self.PORT)

        if not prop_subnet_exists and not prop_port_exists:
            raise exception.PropertyUnspecifiedError(self.SUBNET, self.PORT)
示例#7
0
    def validate(self):
        """Validate any of the provided params."""
        super(RouterInterface, self).validate()

        prop_subnet_exists = self.properties.get(self.SUBNET) is not None

        prop_port_exists = self.properties.get(self.PORT) is not None

        if prop_subnet_exists and prop_port_exists:
            raise exception.ResourcePropertyConflict(self.SUBNET, self.PORT)

        if not prop_subnet_exists and not prop_port_exists:
            raise exception.PropertyUnspecifiedError(self.SUBNET, self.PORT)
示例#8
0
    def validate(self):
        super(Listener, self).validate()
        if (self.properties[self.LOADBALANCER] is None
                and self.properties[self.DEFAULT_POOL] is None):
            raise exception.PropertyUnspecifiedError(self.LOADBALANCER,
                                                     self.DEFAULT_POOL)

        if self.properties[self.PROTOCOL] == self.TERMINATED_HTTPS:
            if self.properties[self.DEFAULT_TLS_CONTAINER_REF] is None:
                msg = (_('Property %(ref)s required when protocol is '
                       '%(term)s.') % {'ref': self.DEFAULT_TLS_CONTAINER_REF,
                                       'term': self.TERMINATED_HTTPS})
                raise exception.StackValidationFailed(message=msg)
示例#9
0
    def _validate_network(self, network):
        net_id = network.get(self.NETWORK_ID)
        port = network.get(self.NETWORK_PORT)
        fixed_ip = network.get(self.NETWORK_FIXED_IP)

        if net_id is None and port is None:
            raise exception.PropertyUnspecifiedError(self.NETWORK_ID,
                                                     self.NETWORK_PORT)

        # Don't allow specify ip and port at the same time
        if fixed_ip and port is not None:
            raise exception.ResourcePropertyConflict(
                ".".join([self.NETWORKS, self.NETWORK_FIXED_IP]),
                ".".join([self.NETWORKS, self.NETWORK_PORT]))
示例#10
0
    def validate(self):
        '''
        Validate any of the provided params
        '''
        super(RouterInterface, self).validate()

        prop_subnet_exists = self._validate_depr_subnet_keys(
            self.properties, self.SUBNET, self.SUBNET_ID)

        port_id = self.properties.get(self.PORT_ID)
        if prop_subnet_exists and port_id:
            raise exception.ResourcePropertyConflict(self.SUBNET,
                                                     self.PORT_ID)
        if not prop_subnet_exists and not port_id:
            raise exception.PropertyUnspecifiedError(self.SUBNET,
                                                     self.PORT_ID)
示例#11
0
 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)
示例#12
0
 def validate(self):
     """Validate any of the provided parameters."""
     super(ElasticIpAssociation, self).validate()
     eip = self.properties[self.EIP]
     allocation_id = self.properties[self.ALLOCATION_ID]
     instance_id = self.properties[self.INSTANCE_ID]
     ni_id = self.properties[self.NETWORK_INTERFACE_ID]
     # to check EIP and ALLOCATION_ID, should provide one of
     if bool(eip) == bool(allocation_id):
         msg = _("Either 'EIP' or 'AllocationId' must be provided.")
         raise exception.StackValidationFailed(message=msg)
     # to check if has EIP, also should specify InstanceId
     if eip and not instance_id:
         msg = _("Must specify 'InstanceId' if you specify 'EIP'.")
         raise exception.StackValidationFailed(message=msg)
     # to check InstanceId and NetworkInterfaceId, should provide
     # at least one
     if not instance_id and not ni_id:
         raise exception.PropertyUnspecifiedError('InstanceId',
                                                  'NetworkInterfaceId')
示例#13
0
 def validate(self):
     super(NovaQuota, self).validate()
     if sum(1 for p in self.properties.values() if p is not None) <= 1:
         raise exception.PropertyUnspecifiedError(
             *sorted(set(self.PROPERTIES) - {self.PROJECT}))
示例#14
0
 def validate(self):
     super(CronTrigger, self).validate()
     if not (self.properties[self.PATTERN]
             or self.properties[self.FIRST_TIME]):
         raise exception.PropertyUnspecifiedError(self.PATTERN,
                                                  self.FIRST_TIME)
示例#15
0
 def validate(self):
     super(CinderQuota, self).validate()
     if len(self.properties.data) == 1:
         raise exception.PropertyUnspecifiedError(self.GIGABYTES,
                                                  self.SNAPSHOTS,
                                                  self.VOLUMES)
示例#16
0
 def validate(self):
     super(NovaQuota, self).validate()
     if len(self.properties.data) == 1:
         raise exception.PropertyUnspecifiedError(
             *sorted(set(self.PROPERTIES) - {self.PROJECT}))