Fix CreateNetwork

This commit is contained in:
Jack O'Sullivan 2019-08-23 14:48:49 +01:00
parent 895e9aa9c4
commit 06e9809b0c

View File

@ -10,6 +10,7 @@ from flask import request, jsonify
from . import app from . import app
OPTS_KEY = 'com.docker.network.generic'
BRIDGE_OPT = 'devplayer0.net-dhcp.bridge' BRIDGE_OPT = 'devplayer0.net-dhcp.bridge'
logger = logging.getLogger('gunicorn.error') logger = logging.getLogger('gunicorn.error')
@ -47,10 +48,11 @@ def net_get_capabilities():
@app.route('/NetworkDriver.CreateNetwork', methods=['POST']) @app.route('/NetworkDriver.CreateNetwork', methods=['POST'])
def create_net(): def create_net():
if BRIDGE_OPT not in request.json['Options']: req = request.get_json(force=True)
if BRIDGE_OPT not in req['Options'][OPTS_KEY]:
return jsonify({'Err': 'No bridge provided'}), 400 return jsonify({'Err': 'No bridge provided'}), 400
desired = request.json[BRIDGE_OPT] desired = req['Options'][OPTS_KEY][BRIDGE_OPT]
bridges = get_bridges() bridges = get_bridges()
if desired not in bridges: if desired not in bridges:
return jsonify({'Err': f'Bridge "{desired}" not found (or the specified bridge is already used by Docker)'}), 400 return jsonify({'Err': f'Bridge "{desired}" not found (or the specified bridge is already used by Docker)'}), 400
@ -58,8 +60,9 @@ def create_net():
if request.json['IPv6Data']: if request.json['IPv6Data']:
return jsonify({'Err': 'IPv6 is currently unsupported'}), 400 return jsonify({'Err': 'IPv6 is currently unsupported'}), 400
logger.info(f'Creating network "{req["NetworkID"]}" (using bridge "{desired}")')
return jsonify({}) return jsonify({})
@app.route('/NetworkDriver.DeleteNetwork', methods=['POST']) @app.route('/NetworkDriver.DeleteNetwork', methods=['POST'])
def delete_net(): def delete_net():
return jsonify({}) return jsonify({})