Initial commit

This commit is contained in:
Dmitry Tantsur 2014-09-29 15:13:25 +02:00
commit ea8e321f77
4 changed files with 43 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.*.swp
.env

8
Makefile Normal file
View File

@ -0,0 +1,8 @@
run:
.env/bin/python discoverd.py
env:
rm -rf .env
virtualenv .env
.env/bin/pip install -r requirements.txt
@echo "Run source .env/bin/activate"

31
discoverd.py Normal file
View File

@ -0,0 +1,31 @@
import logging
import os
import threading
from flask import Flask, request
from ironicclient import client
app = Flask(__name__)
log = logging.getLogger("discoverd")
os_args = dict((k.lower(), v)
for (k, v) in os.environ.items()
if k.startswith('OS_'))
def process(data):
ironic = client.get_client(1, **os_args)
@app.route('/', methods=['POST'])
def post():
data = request.get_json(force=True)
log.debug("Got JSON %s, going into processing thread", data)
threading.Thread(target=process, args=(data,)).start()
return "{}", 202, {"content-type": "application/json"}
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
client.get_client(1, **os_args)
app.run(debug=True, host='0.0.0.0')

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
Flask
python-ironicclient