From 77eaf6a051f7272a3217ab199f53aa3fc9d546a6 Mon Sep 17 00:00:00 2001 From: Naoto Hanaue Date: Tue, 12 May 2015 01:06:59 +0900 Subject: cli: add the show command for the routing policy % gobgp -u 10.0.255.1 policy routepolicy PolicyName policy0: StatementName st0: Conditions: PrefixSet: ps0 192.168.0.0/16 16..24 NeighborSet: ns0 10.0.0.2 MatchOption: ALL Actions: REJECT PolicyName policy1: StatementName st1: Conditions: PrefixSet: ps1 192.168.20.0/24 192.168.200.0/24 NeighborSet: ns0 10.0.0.2 MatchOption: ALL Actions: REJECT % gobgp -u 10.0.255.1 policy routepolicy policy0 PolicyName policy0: StatementName st0: Conditions: PrefixSet: ps0 192.168.0.0/16 16..24 NeighborSet: ns0 10.0.0.2 MatchOption: ALL Actions: REJECT --- server/grpc_server.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'server/grpc_server.go') diff --git a/server/grpc_server.go b/server/grpc_server.go index 2965d647..3fd45b83 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -50,6 +50,8 @@ const ( REQ_POLICY_PREFIXES_DELETE REQ_POLICY_NEIGHBOR REQ_POLICY_NEIGHBORS + REQ_POLICY_ROUTEPOLICIES + REQ_POLICY_ROUTEPOLICY ) const GRPC_PORT = 8080 @@ -281,6 +283,8 @@ func (s *Server) getPolicies(reqType int, arg *api.PolicyArguments, stream inter err = stream.(api.Grpc_GetPolicyPrefixesServer).Send(res.Data.(*api.PrefixSet)) case api.Resource_POLICY_NEIGHBOR: err = stream.(api.Grpc_GetPolicyNeighborsServer).Send(res.Data.(*api.NeighborSet)) + case api.Resource_POLICY_ROUTEPOLICY: + err = stream.(api.Grpc_GetPolicyRoutePoliciesServer).Send(res.Data.(*api.PolicyDefinition)) default: return fmt.Errorf("unsupported resource type: %v", arg.Resource) } @@ -299,6 +303,8 @@ func (s *Server) getPolicy(arg *api.PolicyArguments) (interface{}, error) { reqType = REQ_POLICY_PREFIX case api.Resource_POLICY_NEIGHBOR: reqType = REQ_POLICY_NEIGHBOR + case api.Resource_POLICY_ROUTEPOLICY: + reqType = REQ_POLICY_ROUTEPOLICY default: return nil, fmt.Errorf("unsupported resource type: %v", arg.Resource) } @@ -396,6 +402,21 @@ func (s *Server) GetPolicyNeighbor(ctx context.Context, arg *api.PolicyArguments return data.(*api.NeighborSet), nil } +func (s *Server) GetPolicyRoutePolicies(arg *api.PolicyArguments, stream api.Grpc_GetPolicyRoutePoliciesServer) error { + if err := s.getPolicies(REQ_POLICY_ROUTEPOLICIES, arg, stream); err != nil { + return err + } + return nil +} + +func (s *Server) GetPolicyRoutePolicy(ctx context.Context, arg *api.PolicyArguments) (*api.PolicyDefinition, error) { + data, err := s.getPolicy(arg) + if err != nil { + return nil, err + } + return data.(*api.PolicyDefinition), nil +} + type GrpcRequest struct { RequestType int RemoteAddr string -- cgit v1.2.3