<commit_before># Copyright (c) 2014 Intel
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from cinder import db
from cinder.openstack.common import log as logging
from cinder.openstack.common.scheduler import filters


LOG = logging.getLogger(__name__)


class GeoTagsFilter(filters.BaseHostFilter):
    """GeoTags Filter."""

    def host_passes(self, host_state, filter_properties):
        """Return True if host has sufficient capacity."""
        #(licostan): Add geotag data to the host_state instead of
        #querying it...
        #TODO: add scheduler hints to cinder.
        metadata_hints = filter_properties.get('metadata') or {}
        gt_hints = metadata_hints.get('geo_tags', None)
        context = filter_properties['context']

        geo_tag = db.geo_tag_get_by_node_name(context, host_state.host)
        if not geo_tag:
            LOG.info('NO GEO TAG FOUND FOR %s' % host_state.host)
            return True
        #do other geotags check here based on gt-hints
        if geo_tag.valid_invalid.lower() == 'valid':
            LOG.info('GEO TAG FOUND FOR %s' % host_state.host)
            return True

        LOG.info('GEO TAG INVALID FOR  %s' % host_state.host)
        return False<commit_msg>fix geotag access - not an obj<commit_after># Copyright (c) 2014 Intel
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from cinder import db
from cinder.openstack.common import log as logging
from cinder.openstack.common.scheduler import filters


LOG = logging.getLogger(__name__)


class GeoTagsFilter(filters.BaseHostFilter):
    """GeoTags Filter."""

    def host_passes(self, host_state, filter_properties):
        """Return True if host has sufficient capacity."""
        #(licostan): Add geotag data to the host_state instead of
        #querying it...
        #TODO: add scheduler hints to cinder.
        metadata_hints = filter_properties.get('metadata') or {}
        gt_hints = metadata_hints.get('geo_tags', None)
        context = filter_properties['context']

        geo_tag = db.geo_tag_get_by_node_name(context, host_state.host)
        if not geo_tag:
            LOG.info('NO GEO TAG FOUND FOR %s' % host_state.host)
            return True
        #do other geotags check here based on gt-hints
        if geo_tag['valid_invalid'].lower() == 'valid':
            LOG.info('GEO TAG FOUND FOR %s' % host_state.host)
            return True

        LOG.info('GEO TAG INVALID FOR  %s' % host_state.host)
        return False
{'fraction_non_alphanumeric': 0.08459383753501401, 'fraction_numerical': 0.004481792717086834, 'mean_word_length': 2.972191323692992, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4928555', 'n_tokens_mistral': 1033, 'n_tokens_neox': 1000, 'n_words': 372}