From 32f1b3fe518c071a1a70dc4dcde215b3f33a70d9 Mon Sep 17 00:00:00 2001 From: Mohammad Banikazemi Date: Mon, 16 Nov 2015 15:45:56 -0500 Subject: [PATCH] Adding support for Discovery calls Support for the DiscoveryNew and DiscoverDelete methods as defined in the libnetwork released with Docker 1.9.0 is added. Neutron does not require using such informaton. Nor is it capable of using such information with its current API. Change-Id: Icca7858e2f0f5c686a841f4611b9e2cfc9a47368 --- .../libnetwork_remote_driver_design.rst | 13 ++++++++ kuryr/controllers.py | 30 +++++++++++++++++++ kuryr/tests/test_kuryr.py | 2 ++ 3 files changed, 45 insertions(+) diff --git a/doc/source/devref/libnetwork_remote_driver_design.rst b/doc/source/devref/libnetwork_remote_driver_design.rst index 38183122..7d0d76a8 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 cc7a7866..2c79eaa8 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