diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-04 21:48:45 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-09 23:04:26 +0900 |
commit | e832aeaf9b2b942ff39c36c85b736b13531af36f (patch) | |
tree | 29fdb92a9a031907088969034351d8a2d5e40d15 /server/grpc_server.go | |
parent | 840755be18f226b202759aea8318de20ccc32057 (diff) |
cli: add command to show global policy
$ gobgp global policy
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/grpc_server.go')
-rw-r--r-- | server/grpc_server.go | 11 |
1 files changed, 10 insertions, 1 deletions
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 |