From e832aeaf9b2b942ff39c36c85b736b13531af36f Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Sun, 4 Oct 2015 21:48:45 +0900 Subject: cli: add command to show global policy $ gobgp global policy Signed-off-by: ISHIDA Wataru --- server/grpc_server.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'server/grpc_server.go') diff --git a/server/grpc_server.go b/server/grpc_server.go index 6d3ddf29..b3da4b3d 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -88,6 +88,7 @@ const ( REQ_VRFS REQ_VRF_MOD REQ_MOD_PATH + REQ_GLOBAL_POLICY ) const GRPC_PORT = 8080 @@ -269,7 +270,15 @@ func (s *Server) ModPath(stream api.GobgpApi_ModPathServer) error { } func (s *Server) GetNeighborPolicy(ctx context.Context, arg *api.Arguments) (*api.ApplyPolicy, error) { - req := NewGrpcRequest(REQ_NEIGHBOR_POLICY, arg.Name, bgp.RouteFamily(arg.Rf), nil) + if arg.Resource != api.Resource_LOCAL && arg.Resource != api.Resource_GLOBAL { + return nil, fmt.Errorf("unsupported resource: %s", arg.Resource) + } + var req *GrpcRequest + if arg.Resource == api.Resource_LOCAL { + req = NewGrpcRequest(REQ_NEIGHBOR_POLICY, arg.Name, bgp.RouteFamily(arg.Rf), nil) + } else { + req = NewGrpcRequest(REQ_GLOBAL_POLICY, "", bgp.RouteFamily(arg.Rf), nil) + } s.bgpServerCh <- req res := <-req.ResponseCh -- cgit v1.2.3