"Fossies" - the Fresh Open Source Software Archive

Member "zaqar-10.0.0/zaqar/transport/wsgi/v1_1/health.py" (13 May 2020, 1271 Bytes) of package /linux/misc/openstack/zaqar-10.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "health.py": 9.0.0_vs_10.0.0.

    1 # Copyright (c) 2014 Rackspace, Inc.
    2 # Copyright 2014 Catalyst IT Ltd.
    3 #
    4 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
    5 # use this file except in compliance with the License.  You may obtain a copy
    6 # of the License at
    7 #
    8 #    http://www.apache.org/licenses/LICENSE-2.0
    9 #
   10 # Unless required by applicable law or agreed to in writing, software
   11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   13 # License for the specific language governing permissions and limitations under
   14 # the License.
   15 
   16 from oslo_log import log as logging
   17 
   18 from zaqar.i18n import _
   19 from zaqar.transport import utils
   20 from zaqar.transport.wsgi import errors as wsgi_errors
   21 
   22 LOG = logging.getLogger(__name__)
   23 
   24 
   25 class Resource(object):
   26 
   27     __slots__ = ('_driver',)
   28 
   29     def __init__(self, driver):
   30         self._driver = driver
   31 
   32     def on_get(self, req, resp, **kwargs):
   33         try:
   34             resp_dict = self._driver.health()
   35             resp.body = utils.to_json(resp_dict)
   36         except Exception:
   37             description = _(u'Health status could not be read.')
   38             LOG.exception(description)
   39             raise wsgi_errors.HTTPServiceUnavailable(description)