summaryrefslogtreecommitdiffstats
path: root/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py
diff options
context:
space:
mode:
authorTian Fang <tfang@fb.com>2015-03-09 22:53:57 -0700
committerTian Fang <tfang@fb.com>2015-03-09 22:53:57 -0700
commit2a51b7c1c2165ddb188c511e192b75f0aa0fbead (patch)
treebb42aeac00a8b986c325cd70d5cca6c13bc0c23a /meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py
downloadast2050-yocto-openbmc-2a51b7c1c2165ddb188c511e192b75f0aa0fbead.zip
ast2050-yocto-openbmc-2a51b7c1c2165ddb188c511e192b75f0aa0fbead.tar.gz
Initial open source release of OpenBMC
Diffstat (limited to 'meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py')
-rw-r--r--meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py102
1 files changed, 102 insertions, 0 deletions
diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py
new file mode 100644
index 0000000..6d59fd6
--- /dev/null
+++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py
@@ -0,0 +1,102 @@
+#!/usr/bin/env python
+#
+# Copyright 2014-present Facebook. All Rights Reserved.
+#
+# This program file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program in a file named COPYING; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301 USA
+#
+
+
+from ctypes import *
+from bottle import route, run, template, request, response
+from bottle import abort
+import json
+from rest_fruid import *
+from rest_server import *
+from rest_sensors import *
+from rest_bmc import *
+from rest_gpios import *
+
+# Handler for root resource endpoint
+@route('/api')
+def rest_api():
+ result = {
+ "Information": {
+ "Description": "Wedge RESTful API Entry",
+ },
+ "Actions": [],
+ "Resources": [ "sys"],
+ }
+
+ return result
+
+# Handler for sys resource endpoint
+@route('/api/sys')
+def rest_sys():
+ result = {
+ "Information": {
+ "Description": "Wedge System",
+ },
+ "Actions": [],
+ "Resources": [ "mb", "bmc", "server", "sensors", "gpios"],
+ }
+
+ return result
+
+# Handler for sys/mb resource endpoint
+@route('/api/sys/mb')
+def rest_sys():
+ result = {
+ "Information": {
+ "Description": "System Motherboard",
+ },
+ "Actions": [],
+ "Resources": [ "fruid"],
+ }
+
+ return result
+
+# Handler for sys/mb/fruid resource endpoint
+@route('/api/sys/mb/fruid')
+def rest_fruid():
+ return get_fruid()
+
+# Handler for sys/bmc resource endpoint
+@route('/api/sys/bmc')
+def rest_bmc():
+ return get_bmc()
+
+# Handler for sys/server resource endpoint
+@route('/api/sys/server')
+def rest_bmc():
+ return get_server()
+
+# Handler for uServer resource endpoint
+@route('/api/sys/server', method='POST')
+def rest_server():
+ data = json.load(request.body)
+ return server_action(data)
+
+# Handler for sensors resource endpoint
+@route('/api/sys/sensors')
+def rest_sensors():
+ return get_sensors()
+
+# Handler for sensors resource endpoint
+@route('/api/sys/gpios')
+def rest_gpios():
+ return get_gpios()
+
+run(host = "::", port = 8080)
OpenPOWER on IntegriCloud