Exemple #1
0
    def validate(self):
        super(Subnet, self).validate()
        subnetpool = self.properties[self.SUBNETPOOL]
        prefixlen = self.properties[self.PREFIXLEN]
        cidr = self.properties[self.CIDR]
        if subnetpool and cidr:
            raise exception.ResourcePropertyConflict(self.SUBNETPOOL,
                                                     self.CIDR)
        if not subnetpool 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)
Exemple #2
0
 def validate(self):
     super(Router, self).validate()
     is_distributed = self.properties[self.DISTRIBUTED]
     l3_agent_id = self.properties[self.L3_AGENT_ID]
     l3_agent_ids = self.properties[self.L3_AGENT_IDS]
     is_ha = self.properties[self.HA]
     if l3_agent_id and l3_agent_ids:
         raise exception.ResourcePropertyConflict(self.L3_AGENT_ID,
                                                  self.L3_AGENT_IDS)
     # do not specific l3 agent when creating a distributed router
     if is_distributed and (l3_agent_id or l3_agent_ids):
         raise exception.ResourcePropertyConflict(
             self.DISTRIBUTED,
             "/".join([self.L3_AGENT_ID, self.L3_AGENT_IDS]))
     if is_ha and is_distributed:
         raise exception.ResourcePropertyConflict(self.DISTRIBUTED, self.HA)
     if not is_ha and l3_agent_ids and len(l3_agent_ids) > 1:
         msg = _('Non HA routers can only have one L3 agent.')
         raise exception.StackValidationFailed(message=msg)
Exemple #3
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)
    def validate_assignment_properties(self):
        if self.properties.get(self.ROLES) is not None:
            for role_assignment in self.properties.get(self.ROLES):
                project = role_assignment.get(self.PROJECT)
                domain = role_assignment.get(self.DOMAIN)

                if project is not None and domain is not None:
                    raise exception.ResourcePropertyConflict(
                        self.PROJECT, self.DOMAIN)

                if project is None and domain is None:
                    msg = _('Either project or domain must be specified for'
                            ' role %s') % role_assignment.get(self.ROLE)
                    raise exception.StackValidationFailed(message=msg)
Exemple #5
0
    def validate(self):
        """Validate any of the provided params."""
        res = super(Instance, self).validate()
        if res:
            return res

        # check validity of security groups vs. network interfaces
        security_groups = self._get_security_groups()
        network_interfaces = self.properties.get(self.NETWORK_INTERFACES)
        if security_groups and network_interfaces:
            raise exception.ResourcePropertyConflict(
                '/'.join([self.SECURITY_GROUPS, self.SECURITY_GROUP_IDS]),
                self.NETWORK_INTERFACES)

        # check bdm property
        # now we don't support without snapshot_id in bdm
        bdm = self.properties.get(self.BLOCK_DEVICE_MAPPINGS)
        if bdm:
            for mapping in bdm:
                ebs = mapping.get(self.EBS)
                if ebs:
                    snapshot_id = ebs.get(self.SNAPSHOT_ID)
                    if not snapshot_id:
                        msg = _("SnapshotId is missing, this is required "
                                "when specifying BlockDeviceMappings.")
                        raise exception.StackValidationFailed(message=msg)
                else:
                    msg = _("Ebs is missing, this is required "
                            "when specifying BlockDeviceMappings.")
                    raise exception.StackValidationFailed(message=msg)

        subnet_id = self.properties.get(self.SUBNET_ID)
        if network_interfaces and subnet_id:
            # consider the old templates, we only to log to warn user
            # NetworkInterfaces has higher priority than SubnetId
            LOG.warning(
                _LW('"%(subnet)s" will be ignored if specified '
                    '"%(net_interfaces)s". So if you specified the '
                    '"%(net_interfaces)s" property, '
                    'do not specify "%(subnet)s" property.'), {
                        'subnet': self.SUBNET_ID,
                        'net_interfaces': self.NETWORK_INTERFACES
                    })