# Path: aodh/evaluator/threshold.py
# LOG = log.getLogger(__name__)
# COMPARATORS = {
#     'gt': operator.gt,
#     'lt': operator.lt,
#     'ge': operator.ge,
#     'le': operator.le,
#     'eq': operator.eq,
#     'ne': operator.ne,
# }
# OPTS = [
#     cfg.IntOpt('additional_ingestion_lag',
#                min=0,
#                default=0,
#                help='The number of seconds to extend the evaluation windows '
#                'to compensate the reporting/ingestion lag.')
# ]
# class InsufficientDataError(Exception):
# class ThresholdEvaluator(evaluator.Evaluator):
#     def __init__(self, reason, statistics):
#     def _bound_duration(self, rule):
#     def _reason_data(disposition, count, most_recent):
#     def _reason(cls, alarm, statistics, state, count):
#     def evaluate_rule(self, alarm_rule):
#         def _compare(value):
#     def _transition_alarm(self, alarm, state, trending_state, statistics,
#                           outside_count, unknown_reason):
#     def evaluate(self, alarm):
# 
# Path: aodh/keystone_client.py
# CFG_GROUP = "service_credentials"
# OPTS = [
#     cfg.StrOpt('region-name',
#                default=os.environ.get('OS_REGION_NAME'),
#                deprecated_name="os-region-name",
#                help='Region name to use for OpenStack service endpoints.'),
#     cfg.StrOpt('interface',
#                default=os.environ.get(
#                    'OS_INTERFACE', os.environ.get('OS_ENDPOINT_TYPE',
#                                                   'public')),
#                deprecated_name="os-endpoint-type",
#                choices=('public', 'internal', 'admin', 'auth', 'publicURL',
#                         'internalURL', 'adminURL'),
#                help='Type of endpoint in Identity service catalog to use for '
#                     'communication with OpenStack services.'),
# ]
# def get_session(conf):
# def get_client(conf):
# def get_trusted_client(conf, trust_id):
# def get_auth_token(client):
# def get_client_on_behalf_user(conf, auth_plugin):
# def create_trust_id(conf, trustor_user_id, trustor_project_id, roles,
#                     auth_plugin):
# def delete_trust_id(conf, trust_id, auth_plugin):
# def url_for(conf, **kwargs):
# def get_heat_client_from_trust(conf, trust_id):
# def register_keystoneauth_opts(conf):


import json
from gnocchiclient import client
from gnocchiclient import exceptions
from oslo_log import log
from aodh.evaluator import threshold
from aodh import keystone_client
#
# Copyright 2015 eNovance
#
# 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.



LOG = log.getLogger(__name__)

# The list of points that Gnocchi API returned is composed
# of tuples with (timestamp, granularity, value)
GRANULARITY = 1
VALUE = 2


class GnocchiBase(threshold.ThresholdEvaluator):
    def __init__(self, conf):
        super(GnocchiBase, self).__init__(conf)
        self._gnocchi_client = client.Client(

# Path: aodh/evaluator/threshold.py
# LOG = log.getLogger(__name__)
# COMPARATORS = {
#     'gt': operator.gt,
#     'lt': operator.lt,
#     'ge': operator.ge,
#     'le': operator.le,
#     'eq': operator.eq,
#     'ne': operator.ne,
# }
# OPTS = [
#     cfg.IntOpt('additional_ingestion_lag',
#                min=0,
#                default=0,
#                help='The number of seconds to extend the evaluation windows '
#                'to compensate the reporting/ingestion lag.')
# ]
# class InsufficientDataError(Exception):
# class ThresholdEvaluator(evaluator.Evaluator):
#     def __init__(self, reason, statistics):
#     def _bound_duration(self, rule):
#     def _reason_data(disposition, count, most_recent):
#     def _reason(cls, alarm, statistics, state, count):
#     def evaluate_rule(self, alarm_rule):
#         def _compare(value):
#     def _transition_alarm(self, alarm, state, trending_state, statistics,
#                           outside_count, unknown_reason):
#     def evaluate(self, alarm):
# 
# Path: aodh/keystone_client.py
# CFG_GROUP = "service_credentials"
# OPTS = [
#     cfg.StrOpt('region-name',
#                default=os.environ.get('OS_REGION_NAME'),
#                deprecated_name="os-region-name",
#                help='Region name to use for OpenStack service endpoints.'),
#     cfg.StrOpt('interface',
#                default=os.environ.get(
#                    'OS_INTERFACE', os.environ.get('OS_ENDPOINT_TYPE',
#                                                   'public')),
#                deprecated_name="os-endpoint-type",
#                choices=('public', 'internal', 'admin', 'auth', 'publicURL',
#                         'internalURL', 'adminURL'),
#                help='Type of endpoint in Identity service catalog to use for '
#                     'communication with OpenStack services.'),
# ]
# def get_session(conf):
# def get_client(conf):
# def get_trusted_client(conf, trust_id):
# def get_auth_token(client):
# def get_client_on_behalf_user(conf, auth_plugin):
# def create_trust_id(conf, trustor_user_id, trustor_project_id, roles,
#                     auth_plugin):
# def delete_trust_id(conf, trust_id, auth_plugin):
# def url_for(conf, **kwargs):
# def get_heat_client_from_trust(conf, trust_id):
# def register_keystoneauth_opts(conf):


# Path: aodh/evaluator/gnocchi.py
import json
from gnocchiclient import client
from gnocchiclient import exceptions
from oslo_log import log
from aodh.evaluator import threshold
from aodh import keystone_client

#
# Copyright 2015 eNovance
#
# 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.



LOG = log.getLogger(__name__)

# The list of points that Gnocchi API returned is composed
# of tuples with (timestamp, granularity, value)
GRANULARITY = 1
VALUE = 2


class GnocchiBase(threshold.ThresholdEvaluator):
    def __init__(self, conf):
        super(GnocchiBase, self).__init__(conf)
        self._gnocchi_client = client.Client(

            '1', keystone_client.get_session(conf),