Browse Source

Initial commit

changes/67/134467/1
Dmitry Tantsur 8 years ago
commit
ea8e321f77
  1. 2
      .gitignore
  2. 8
      Makefile
  3. 31
      discoverd.py
  4. 2
      requirements.txt

2
.gitignore vendored

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

8
Makefile

@ -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

@ -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

@ -0,0 +1,2 @@
Flask
python-ironicclient
Loading…
Cancel
Save