From ffbac2a3634a7af5421b28df7c5d9884198f1f1c Mon Sep 17 00:00:00 2001 From: Abhinandan Prativadi Date: Fri, 28 Jul 2017 10:32:10 -0700 Subject: [PATCH] Changing the get network request to return swarm scope predefined networks Starting 17.06 swarm service create supports service creates with predefined networks like host and bridge. Due to the nature of the feature, swarm manager has a swarm scope predefined networks in addition to local scoped predefined networks on all nodes. However network inspects for swarm scoped predefined networks was not possible. The fix adds support for network inspect for swarm scoped predefined networks. Signed-off-by: Abhinandan Prativadi (cherry picked from commit 5bfefb2d3662fa066ddf0d0e10cac93ee70f7ae8) Signed-off-by: Abhinandan Prativadi --- api/server/router/network/network_routes.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/server/router/network/network_routes.go b/api/server/router/network/network_routes.go index bff3561523f..d6283ddb203 100644 --- a/api/server/router/network/network_routes.go +++ b/api/server/router/network/network_routes.go @@ -127,6 +127,15 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r } } + nwk, err := n.cluster.GetNetwork(term) + if err == nil { + // If the get network is passed with a specific network ID / partial network ID + // return the network. + if strings.HasPrefix(nwk.ID, term) { + return httputils.WriteJSON(w, http.StatusOK, nwk) + } + } + nr, _ := n.cluster.GetNetworks() for _, network := range nr { if network.ID == term {