コード例 #1
0
    def test_log_save_in_sentinel(self):
        logger = get_logger(__name__,
                            'WARN',
                            space=self.space,
                            series=self.series,
                            sentinel=True)

        logger.info('just for your information!')
        logger.warning('HOI! THIS IS ME TO YOU.... HELLO!')
        logger.error('we have an oopsie!')
        logger.debug('if you\'re here there is an oopsie for sure!')
from esm.controllers.tasks import CreateInstance, DeleteInstance, RetrieveInstance, \
    RetrieveAllInstances, RetrieveInstanceLastOp, BindInstance, UnbindInstance, \
    UpdateInstance, MeasureInstance

from esm.models.binding_response import BindingResponse
from esm.models.empty import Empty
from esm.models.last_operation import LastOperation
from esm.models.service_instance import ServiceInstance
from esm.models.service_request import ServiceRequest
from esm.models.service_response import ServiceResponse
from esm.models.update_operation_response import UpdateOperationResponse
from esm.models.update_request import UpdateRequest

from adapters.log import get_logger

LOG = get_logger(__name__)


def create_service_instance(instance_id, service, accept_incomplete=False):
    """
    Provisions a service instance
    When the broker receives a provision request from a client, it should synchronously take whatever action is
    necessary to create a new service resource for the developer. The result of provisioning varies by service
    type, although there are a few common actions that work for many services. Supports asynchronous operations.'
    :param instance_id: 'The instance_id of a service instance is provided by the client. This ID will be used for
    future requests (bind and deprovision), so the broker must use it to correlate the resource it creates.'
    :type instance_id: str
    :param service: Service information.
    :type service: dict | bytes
    :param accept_incomplete: Indicates that the client is supporting asynchronous operations
    :type accept_incomplete: bool
コード例 #3
0
import logging
import os
import requests
import signal
import flask
import connexion
from connexion.resolver import RestyResolver
import urllib
from healthcheck import HealthCheck, EnvironmentDump
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.wsgi import WSGIContainer

from adapters import log

LOG = log.get_logger(name=__name__)


def add_check_api():
    app = flask.Flask('check_api')
    health = HealthCheck(app, "/healthcheck")
    envdump = EnvironmentDump(app, "/environment")

    def health_check():
        def onem2m_url_ok():
            url = 'http://localhost:8000/onem2m'
            r = requests.response(url)
            return r.status_code == 200

        def mems_url_ok():
            url = 'http://localhost:8000/onem2m/MemsIPE'
コード例 #4
0
#    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.


import time
import requests
import threading

import config
from adapters.log import get_logger
from esm.util import Singleton


LOG = get_logger(__name__, 'WARN', space=config.esm_hc_sen_topic, series=config.esm_hc_sen_series, sentinel=True)


@Singleton
class MeasurerFactory:  # pragma: no cover

    def __init__(self):
        self.measurers = {}

    def start_heartbeat_measurer(self, cache):
        measurer = Measurer(cache)
        measurer.start()
        self.measurers[cache['instance_id']] = measurer

    def stop_heartbeat_measurer(self, instance_id):
        self.measurers[instance_id].stop()