summaryrefslogtreecommitdiffhomepage
path: root/server/grpc_server.go
diff options
context:
space:
mode:
authorNaoto Hanaue <hanaue.naoto@po.ntts.co.jp>2015-06-16 19:55:34 +0900
committerNaoto Hanaue <hanaue.naoto@po.ntts.co.jp>2015-06-17 13:41:31 +0900
commit3f845ad08fbc24e2db2eb8572a2955091853e3bf (patch)
tree7a1fbef89611621ab864f0b840961eb7013d3833 /server/grpc_server.go
parent4db834afe35306ede35a73aeb4486844da264920 (diff)
cli: add community subcommand to policy conditions and actions
Diffstat (limited to 'server/grpc_server.go')
-rw-r--r--server/grpc_server.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/server/grpc_server.go b/server/grpc_server.go
index 8f2ca497..ef850dbf 100644
--- a/server/grpc_server.go
+++ b/server/grpc_server.go
@@ -68,6 +68,11 @@ const (
REQ_POLICY_ROUTEPOLICY_ADD
REQ_POLICY_ROUTEPOLICY_DELETE
REQ_POLICY_ROUTEPOLICIES_DELETE
+ REQ_POLICY_COMMUNITY
+ REQ_POLICY_COMMUNITIES
+ REQ_POLICY_COMMUNITY_ADD
+ REQ_POLICY_COMMUNITY_DELETE
+ REQ_POLICY_COMMUNITIES_DELETE
)
const GRPC_PORT = 8080
@@ -389,6 +394,17 @@ func (s *Server) modPolicy(arg *api.PolicyArguments, stream interface{}) error {
default:
return fmt.Errorf("unsupported operation: %s", arg.Operation)
}
+ case api.Resource_POLICY_COMMUNITY:
+ switch arg.Operation {
+ case api.Operation_ADD:
+ reqType = REQ_POLICY_COMMUNITY_ADD
+ case api.Operation_DEL:
+ reqType = REQ_POLICY_COMMUNITY_DELETE
+ case api.Operation_DEL_ALL:
+ reqType = REQ_POLICY_COMMUNITIES_DELETE
+ default:
+ return fmt.Errorf("unsupported operation: %s", arg.Operation)
+ }
case api.Resource_POLICY_ROUTEPOLICY:
switch arg.Operation {
case api.Operation_ADD:
@@ -400,6 +416,8 @@ func (s *Server) modPolicy(arg *api.PolicyArguments, stream interface{}) error {
default:
return fmt.Errorf("unsupported operation: %s", arg.Operation)
}
+ default:
+ return fmt.Errorf("unsupported resource type: %v", arg.Resource)
}
req := NewGrpcRequest(reqType, "", rf, arg.PolicyDefinition)
s.bgpServerCh <- req
@@ -428,6 +446,8 @@ func (s *Server) GetPolicyRoutePolicies(arg *api.PolicyArguments, stream api.Grp
reqType = REQ_POLICY_NEIGHBORS
case api.Resource_POLICY_ASPATH:
reqType = REQ_POLICY_ASPATHS
+ case api.Resource_POLICY_COMMUNITY:
+ reqType = REQ_POLICY_COMMUNITIES
case api.Resource_POLICY_ROUTEPOLICY:
reqType = REQ_POLICY_ROUTEPOLICIES
default:
@@ -457,6 +477,8 @@ func (s *Server) GetPolicyRoutePolicy(ctx context.Context, arg *api.PolicyArgume
reqType = REQ_POLICY_NEIGHBOR
case api.Resource_POLICY_ASPATH:
reqType = REQ_POLICY_ASPATH
+ case api.Resource_POLICY_COMMUNITY:
+ reqType = REQ_POLICY_COMMUNITY
case api.Resource_POLICY_ROUTEPOLICY:
reqType = REQ_POLICY_ROUTEPOLICY
default: