Initial commit
This commit is contained in:
commit
ea8e321f77
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.*.swp
|
||||
.env
|
8
Makefile
Normal file
8
Makefile
Normal 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
31
discoverd.py
Normal 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
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Flask
|
||||
python-ironicclient
|
Loading…
Reference in New Issue
Block a user