Example #1
0
    def _passes_filters(self, dict_to_check, filter_dict):
        """Applies a set of regex filters to a dictionary.

        If no filter keys are supplied, the data passes unfiltered and
        the method returns True.  Otherwise, each key in the filter
        (filter_dict) must be present in the data (dict_to_check)
        and the filter values are applied as regex expressions to
        the data values.  If any of the filter values fail to match
        their corresponding data values, the method returns False.
        But if all filters match, the method returns True.
        """
        if not filter_dict:
            return True

        for filter_key, filter_value in filter_dict.items():
            if filter_key not in dict_to_check:
                return False
            if filter_key == 'capabilities':
                if not scheduler_utils.capabilities_satisfied(
                        dict_to_check.get(filter_key), filter_value):
                    return False
            elif not re.match(filter_value, dict_to_check.get(filter_key)):
                return False

        return True
Example #2
0
    def _passes_filters(self, dict_to_check, filter_dict):
        """Applies a set of regex filters to a dictionary.

        If no filter keys are supplied, the data passes unfiltered and
        the method returns True.  Otherwise, each key in the filter
        (filter_dict) must be present in the data (dict_to_check)
        and the filter values are applied as regex expressions to
        the data values.  If any of the filter values fail to match
        their corresponding data values, the method returns False.
        But if all filters match, the method returns True.
        """
        if not filter_dict:
            return True

        for filter_key, filter_value in filter_dict.items():
            if filter_key not in dict_to_check:
                return False
            if filter_key == 'capabilities':
                if not scheduler_utils.capabilities_satisfied(
                        dict_to_check.get(filter_key), filter_value):
                    return False
            elif not re.match(filter_value, dict_to_check.get(filter_key)):
                return False

        return True
Example #3
0
    def _satisfies_extra_specs(self, capabilities, resource_type):
        """Compare capabilities against extra specs.

        Check that the capabilities provided by the services satisfy
        the extra specs associated with the resource type.
        """
        extra_specs = resource_type.get('extra_specs', [])
        if not extra_specs:
            return True

        return utils.capabilities_satisfied(capabilities, extra_specs)
Example #4
0
    def _satisfies_extra_specs(self, capabilities, resource_type):
        """Compare capabilities against extra specs.

        Check that the capabilities provided by the services satisfy
        the extra specs associated with the resource type.
        """
        extra_specs = resource_type.get('extra_specs', [])
        if not extra_specs:
            return True

        return utils.capabilities_satisfied(capabilities, extra_specs)