Add minimalistic REST framework using klein, and a health check REST API to start with
diff --git a/requirements.txt b/requirements.txt
index 486202b..3d312e2 100755
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,6 +3,7 @@
decorator>=3.4.0
flake8>=2.5.1
fluent-logger>=0.4.3
+klein>=15.3.1
nose>=1.3.7
mock>=1.3.0
netifaces>=0.10.4
diff --git a/voltha/main.py b/voltha/main.py
index f18a21d..679dbb5 100755
--- a/voltha/main.py
+++ b/voltha/main.py
@@ -24,6 +24,7 @@
from structlog_setup import setup_logging
from coordinator import Coordinator
+from northbound.rest.healt_check import init_site
defs = dict(
@@ -117,6 +118,7 @@
external_host_address=args.external_host_address,
instance_id=args.instance_id,
consul=args.consul)
+ init_site()
log.info('started-internal-services')
diff --git a/voltha/northbound/__init__.py b/voltha/northbound/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/voltha/northbound/__init__.py
diff --git a/voltha/northbound/rest/__init__.py b/voltha/northbound/rest/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/voltha/northbound/rest/__init__.py
diff --git a/voltha/northbound/rest/healt_check.py b/voltha/northbound/rest/healt_check.py
new file mode 100644
index 0000000..bd54b9d
--- /dev/null
+++ b/voltha/northbound/rest/healt_check.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 the original author or authors.
+#
+# 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.
+#
+
+""" Rest API to check health of Voltha instance """
+
+from klein import Klein
+from twisted.internet import endpoints
+from twisted.internet import reactor
+from twisted.web.server import Site
+
+
+class HealthCheck(object):
+
+ app = Klein()
+
+ @app.route('/health')
+ def health_check(self, request):
+ # TODO this is just a placeholder, very crude health check
+ return '{"status": "ok"}'
+
+ def get_site(self):
+ return Site(self.app.resource())
+
+
+def init_site(): # TODO need to be moved to a shared file across all resources
+ hc = HealthCheck()
+ endpoint = endpoints.TCP4ServerEndpoint(reactor, 8880)
+ endpoint.listen(hc.get_site())