Add health resource for ucp-integration API convention
It is a UCP API convention to include a health resource in order for other components to access and validate Deckhand's health status [0]. As such, this PS accomplishes that goal. Also add uwsgi.ini file to instantiate the webserver using a more complex configuration that can be overriden more easily. [0] https://github.com/att-comdev/ucp-integration/blob/master/docs/api-conventions.md#health-check-api Change-Id: Ice24cec6d0b98c16af62d9436925083d4092a032
This commit is contained in:
parent
8aec0390f8
commit
cdec6356a5
30
README.rst
30
README.rst
@ -23,37 +23,37 @@ Getting Started
|
||||
|
||||
To generate a configuration file automatically::
|
||||
|
||||
$ tox -e genconfig
|
||||
$ tox -e genconfig
|
||||
|
||||
Resulting deckhand.conf.sample file is output to
|
||||
:path:etc/deckhand/deckhand.conf.sample
|
||||
|
||||
Copy the config file to a directory discoverably by ``oslo.conf``::
|
||||
|
||||
$ cp etc/deckhand/deckhand.conf.sample ~/deckhand.conf
|
||||
$ cp etc/deckhand/deckhand.conf.sample ~/deckhand.conf
|
||||
|
||||
To setup an in-memory database for testing:
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
[database]
|
||||
[database]
|
||||
|
||||
#
|
||||
# From oslo.db
|
||||
#
|
||||
#
|
||||
# From oslo.db
|
||||
#
|
||||
|
||||
# The SQLAlchemy connection string to use to connect to the database.
|
||||
# (string value)
|
||||
connection = sqlite:///:memory:
|
||||
# The SQLAlchemy connection string to use to connect to the database.
|
||||
# (string value)
|
||||
connection = sqlite:///:memory:
|
||||
|
||||
To run locally in a development environment::
|
||||
|
||||
$ sudo pip install uwsgi
|
||||
$ virtualenv -p python3 /var/tmp/deckhand
|
||||
$ . /var/tmp/deckhand/bin/activate
|
||||
$ sudo pip install .
|
||||
$ sudo python setup.py install
|
||||
$ uwsgi --http :9000 -w deckhand.cmd --callable deckhand_callable --enable-threads -L
|
||||
$ sudo pip install uwsgi
|
||||
$ virtualenv -p python3 /var/tmp/deckhand
|
||||
$ . /var/tmp/deckhand/bin/activate
|
||||
$ sudo pip install .
|
||||
$ sudo python setup.py install
|
||||
$ uwsgi --ini uwsgi.ini
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
26
deckhand/control/health.py
Normal file
26
deckhand/control/health.py
Normal file
@ -0,0 +1,26 @@
|
||||
# Copyright 2017 AT&T Intellectual Property. All other 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.
|
||||
|
||||
import falcon
|
||||
|
||||
from deckhand.control.base import BaseResource
|
||||
|
||||
|
||||
class HealthResource(BaseResource):
|
||||
"""A resource that allows other UCP components to access and validate
|
||||
Deckhand's health status. The response must be returned within 30 seconds
|
||||
for Deckhand to be deemed "healthy".
|
||||
"""
|
||||
def on_get(self, req, resp):
|
||||
resp.status = falcon.HTTP_204
|
@ -18,6 +18,7 @@ from oslo_log import log
|
||||
|
||||
from deckhand.control import base
|
||||
from deckhand.control import buckets
|
||||
from deckhand.control import health
|
||||
from deckhand.control import middleware
|
||||
from deckhand.control import revision_diffing
|
||||
from deckhand.control import revision_documents
|
||||
@ -35,6 +36,7 @@ def configure_app(app, version=''):
|
||||
|
||||
v1_0_routes = [
|
||||
('bucket/{bucket_name}/documents', buckets.BucketsResource()),
|
||||
('health', health.HealthResource()),
|
||||
('revisions', revisions.RevisionsResource()),
|
||||
('revisions/{revision_id}', revisions.RevisionsResource()),
|
||||
('revisions/{revision_id}/diff/{comparison_revision_id}',
|
||||
|
@ -19,6 +19,7 @@ import mock
|
||||
|
||||
from deckhand.control import api
|
||||
from deckhand.control import buckets
|
||||
from deckhand.control import health
|
||||
from deckhand.control import revision_diffing
|
||||
from deckhand.control import revision_documents
|
||||
from deckhand.control import revision_tags
|
||||
@ -35,7 +36,7 @@ class TestApi(test_base.DeckhandTestCase):
|
||||
def setUp(self):
|
||||
super(TestApi, self).setUp()
|
||||
# Mock the API resources.
|
||||
for resource in (buckets, revision_diffing, revision_documents,
|
||||
for resource in (buckets, health, revision_diffing, revision_documents,
|
||||
revision_tags, revisions, rollback, validations,
|
||||
versions):
|
||||
class_names = self._get_module_class_names(resource)
|
||||
@ -75,6 +76,7 @@ class TestApi(test_base.DeckhandTestCase):
|
||||
mock_falcon_api.add_route.assert_has_calls([
|
||||
mock.call('/api/v1.0/bucket/{bucket_name}/documents',
|
||||
self.buckets_resource()),
|
||||
mock.call('/api/v1.0/health', self.health_resource()),
|
||||
mock.call('/api/v1.0/revisions', self.revisions_resource()),
|
||||
mock.call('/api/v1.0/revisions/{revision_id}',
|
||||
self.revisions_resource()),
|
||||
|
@ -97,8 +97,6 @@ function gen_paste {
|
||||
function gen_policy {
|
||||
log_section Creating policy file with liberal permissions
|
||||
|
||||
oslopolicy-sample-generator --config-file=etc/deckhand/policy-generator.conf
|
||||
|
||||
policy_file='etc/deckhand/policy.yaml.sample'
|
||||
policy_pattern="deckhand\:"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user