Add constants
This patch adds constants.py and separate the shared response data from controllers. Change-Id: Ia64eca2591e6617265debfa664e647f81edba416 Signed-off-by: Taku Fukushima <f.tac.mac@gmail.com>
This commit is contained in:
parent
8f734e65fd
commit
3de2404d92
51
kuryr/constants.py
Normal file
51
kuryr/constants.py
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
|
TYPES = {
|
||||||
|
# NEXTHOP indicates a StaticRoute with an IP next hop.
|
||||||
|
"NEXTHOP": 0,
|
||||||
|
# CONNECTED indicates a StaticRoute with a interface for directly connected
|
||||||
|
# peers.
|
||||||
|
"CONNECTED": 1
|
||||||
|
}
|
||||||
|
|
||||||
|
SCHEMA = {
|
||||||
|
"PLUGIN_ACTIVATE": {"Implements": ["NetworkDriver"]},
|
||||||
|
# TODO(tfukushima): This is mocked and should be replaced with real data.
|
||||||
|
"CREATE_ENDPOINT": {
|
||||||
|
"Interfaces": [{
|
||||||
|
"ID": 1,
|
||||||
|
"Address": "192.168.1.42/24",
|
||||||
|
"AddressIPv6": "fe80::f816:3eff:fe20:57c3/64",
|
||||||
|
"MacAddress": "fa:16:3e:20:57:c3",
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
# TODO(tfukushima): This is mocked and should be replaced with real data.
|
||||||
|
"ENDPOINT_OPER_INFO": {"Value": {}},
|
||||||
|
# TODO(tfukushima): This is mocked and should be replaced with real data.
|
||||||
|
"JOIN": {
|
||||||
|
"InterfaceNames": [{
|
||||||
|
"SrcName": "foobar",
|
||||||
|
"DstPrefix": ""
|
||||||
|
}],
|
||||||
|
"Gateway": "192.168.1.1/24",
|
||||||
|
"GatewayIPv6": "fe80::f816:3eff:fe20:57c1/64",
|
||||||
|
"StaticRoutes": [{
|
||||||
|
"Destination": "192.168.1.42",
|
||||||
|
"RouteType": TYPES['CONNECTED'],
|
||||||
|
"NextHop": "",
|
||||||
|
"InterfaceID": 0
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
"SUCCESS": {}
|
||||||
|
}
|
@ -13,73 +13,44 @@
|
|||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
|
|
||||||
from kuryr import app
|
from kuryr import app
|
||||||
|
from kuryr.constants import SCHEMA
|
||||||
|
|
||||||
# NEXTHOP indicates a StaticRoute with an IP next hop.
|
|
||||||
NEXTHOP = 0
|
|
||||||
# CONNECTED indicates a StaticRoute with a interface for directly connected
|
|
||||||
# peers.
|
|
||||||
CONNECTED = 1
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/Plugin.Activate', methods=['POST'])
|
@app.route('/Plugin.Activate', methods=['POST'])
|
||||||
def plubin_activate():
|
def plugin_activate():
|
||||||
return jsonify({"Implements": ["NetworkDriver"]})
|
return jsonify(SCHEMA['PLUGIN_ACTIVATE'])
|
||||||
|
|
||||||
|
|
||||||
@app.route('/NetworkDriver.CreateNetwork', methods=['POST'])
|
@app.route('/NetworkDriver.CreateNetwork', methods=['POST'])
|
||||||
def network_driver_create_network():
|
def network_driver_create_network():
|
||||||
return jsonify({})
|
return jsonify(SCHEMA['SUCCESS'])
|
||||||
|
|
||||||
|
|
||||||
@app.route('/NetworkDriver.DeleteNetwork', methods=['POST'])
|
@app.route('/NetworkDriver.DeleteNetwork', methods=['POST'])
|
||||||
def network_driver_delete_network():
|
def network_driver_delete_network():
|
||||||
return jsonify({})
|
return jsonify(SCHEMA['SUCCESS'])
|
||||||
|
|
||||||
|
|
||||||
@app.route('/NetworkDriver.CreateEndpoint', methods=['POST'])
|
@app.route('/NetworkDriver.CreateEndpoint', methods=['POST'])
|
||||||
def network_driver_create_endpoint():
|
def network_driver_create_endpoint():
|
||||||
# TODO(tfukushima): This is mocked and should be replaced with real data.
|
return jsonify(SCHEMA['CREATE_ENDPOINT'])
|
||||||
return jsonify({
|
|
||||||
"Interfaces": [{
|
|
||||||
"ID": 1,
|
|
||||||
"Address": "192.168.1.42/24",
|
|
||||||
"AddressIPv6": "fe80::f816:3eff:fe20:57c3/64",
|
|
||||||
"MacAddress": "fa:16:3e:20:57:c3",
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/NetworkDriver.EndpointOperInfo', methods=['POST'])
|
@app.route('/NetworkDriver.EndpointOperInfo', methods=['POST'])
|
||||||
def network_driver_endpoint_operational_info():
|
def network_driver_endpoint_operational_info():
|
||||||
# TODO(tfukushima): This is mocked and should be replaced with real data.
|
return jsonify(SCHEMA['ENDPOINT_OPER_INFO'])
|
||||||
return jsonify({"Value": {}})
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/NetworkDriver.DeleteEndpoint', methods=['POST'])
|
@app.route('/NetworkDriver.DeleteEndpoint', methods=['POST'])
|
||||||
def network_driver_delete_endpoint():
|
def network_driver_delete_endpoint():
|
||||||
return jsonify({})
|
return jsonify(SCHEMA['SUCCESS'])
|
||||||
|
|
||||||
|
|
||||||
@app.route('/NetworkDriver.Join', methods=['POST'])
|
@app.route('/NetworkDriver.Join', methods=['POST'])
|
||||||
def network_driver_join():
|
def network_driver_join():
|
||||||
# TODO(tfukushima): This is mocked and should be replaced with real data.
|
return jsonify(SCHEMA['JOIN'])
|
||||||
return jsonify({
|
|
||||||
"InterfaceNames": [{
|
|
||||||
"SrcName": "foobar",
|
|
||||||
"DstPrefix": ""
|
|
||||||
}],
|
|
||||||
"Gateway": "192.168.1.1/24",
|
|
||||||
"GatewayIPv6": "fe80::f816:3eff:fe20:57c1/64",
|
|
||||||
"StaticRoutes": [{
|
|
||||||
"Destination": "192.168.1.42",
|
|
||||||
"RouteType": CONNECTED,
|
|
||||||
"NextHop": "",
|
|
||||||
"InterfaceID": 0
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/NetworkDriver.Leave', methods=['POST'])
|
@app.route('/NetworkDriver.Leave', methods=['POST'])
|
||||||
def network_driver_leave():
|
def network_driver_leave():
|
||||||
return jsonify({})
|
return jsonify(SCHEMA['SUCCESS'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user