diff --git a/doc/source/devref/libnetwork_remote_driver_design.rst b/doc/source/devref/libnetwork_remote_driver_design.rst index f49b7d35..dd803156 100644 --- a/doc/source/devref/libnetwork_remote_driver_design.rst +++ b/doc/source/devref/libnetwork_remote_driver_design.rst @@ -297,6 +297,19 @@ visible and editable resource entity attachable to containers from users' perspective. Sandbox manages information exposed by Endpoint behind the scene automatically. + +Notes on implementing the libnetwork remote driver API in Kuryr +--------------------------------------------------------------- + +1. DiscoverNew Notification: + Neutron does not use the informaton related to discovery of new resources such + as new nodes and therefore the implementation of this API method does nothing. + +2. DiscoverDelete Notification: + Neutron does not use the informaton related to discovery of resources such as + nodes being deleted and therefore the implementation of this API method does + nothing. + .. _libnetwork remote network driver: https://github.com/docker/libnetwork/blob/master/docs/remote.md .. _libnetwork IPAM driver: https://github.com/docker/libnetwork/blob/master/docs/ipam.md .. _Neutron: https://wiki.openstack.org/wiki/Neutron diff --git a/kuryr/controllers.py b/kuryr/controllers.py index c423b48e..2d8c7917 100644 --- a/kuryr/controllers.py +++ b/kuryr/controllers.py @@ -306,6 +306,36 @@ def plugin_scope(): return flask.jsonify(capabilities) +@app.route('/NetworkDriver.DiscoverNew', methods=['POST']) +def network_driver_discover_new(): + """The callback function for the DiscoverNew notification. + + The DiscoverNew notification includes the type of the + resource that has been newly discovered and possibly other + information associated with the resource. + + See the following link for more details about the spec: + + https://github.com/docker/libnetwork/blob/master/docs/remote.md#discovernew-notification # noqa + """ + return flask.jsonify(constants.SCHEMA['SUCCESS']) + + +@app.route('/NetworkDriver.DiscoverDelete', methods=['POST']) +def network_driver_discover_delete(): + """The callback function for the DiscoverDelete notification. + + The DiscoverDelete notification includes the type of the + resource that has been deleted and possibly other + information associated with the resource. + + See the following link for more details about the spec: + + https://github.com/docker/libnetwork/blob/master/docs/remote.md#discoverdelete-notification # noqa + """ + return flask.jsonify(constants.SCHEMA['SUCCESS']) + + @app.route('/NetworkDriver.CreateNetwork', methods=['POST']) def network_driver_create_network(): """Creates a new Neutron Network which name is the given NetworkID. diff --git a/kuryr/tests/test_kuryr.py b/kuryr/tests/test_kuryr.py index 5eecae05..46baa3e7 100644 --- a/kuryr/tests/test_kuryr.py +++ b/kuryr/tests/test_kuryr.py @@ -43,6 +43,8 @@ class TestKuryr(base.TestKuryrBase): - POST /NetworkDriver.Leave """ @ddt.data(('/Plugin.Activate', constants.SCHEMA['PLUGIN_ACTIVATE']), + ('/NetworkDriver.DiscoverNew', constants.SCHEMA['SUCCESS']), + ('/NetworkDriver.DiscoverDelete', constants.SCHEMA['SUCCESS']), ('/NetworkDriver.EndpointOperInfo', constants.SCHEMA['ENDPOINT_OPER_INFO'])) @ddt.unpack