From: Michael Cambria Date: Tue, 16 Apr 2019 21:49:52 +0000 (-0400) Subject: Added cni config path and binary path X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=4f2905d37afa96c828a5598d6c220a1481085a79;p=demo-grpc.git Added cni config path and binary path --- diff --git a/api/api.proto b/api/api.proto index 11dc5af..f925f2a 100644 --- a/api/api.proto +++ b/api/api.proto @@ -25,13 +25,20 @@ message CNIargs { string value = 2; } +message ConfPath { + string netDir = 1; + string netConf = 2; +} + message CNImsg { - CmdType cmd = 1; - string containerID = 2; - string netNS = 3; - string ifName = 4; - repeated CNIargs args = 5; - string stdIn = 6; + ConfPath configPath = 1; + string binPath = 8; + CmdType cmd = 2; + string containerID = 3; + string netNS = 4; + string ifName = 5; + repeated CNIargs args = 6; + string stdIn = 7; } message CNIresult { diff --git a/api/handler.go b/api/handler.go index 07023cb..0a62665 100644 --- a/api/handler.go +++ b/api/handler.go @@ -12,7 +12,12 @@ type CNIServer struct { // CNIop generates result to a CNImsg func (s *CNIServer) CNIop(ctx context.Context, in *CNImsg) (*CNIresult, error) { - log.Printf("Receive message Cmd: %s", in.Cmd) + + confPath := in.ConfigPath + + log.Printf("Receive message NetDir: %s", confPath.NetDir) + log.Printf("Receive message NetConf: %s", confPath.NetConf) + log.Printf("Receive message ContainerID: %s", in.ContainerID) log.Printf("Receive message NetNS: %s", in.NetNS) log.Printf("Receive message IfName: %s", in.IfName) diff --git a/client/main.go b/client/main.go index a2fc3db..522d167 100644 --- a/client/main.go +++ b/client/main.go @@ -53,7 +53,19 @@ func main() { // CNI Test cni := api.NewCNIserverClient(conn) + /// + cniPath := api.ConfPath { + NetDir: "/home/mcambria/go/src/github.com/containernetworking", + NetConf: "firewall-mcc1-range-chain", + } + // + cniMsg := api.CNImsg{ + //ConfigPath: { + //NetDir: "/home/mcambria/go/src/github.com/containernetworking", + //NetConf: "firewall-mcc1-range-chain", + //}, + ConfigPath: &cniPath, Cmd: api.CmdType_ADD, ContainerID: "containerOne", NetNS: "mcc-test-0", diff --git a/server/main.go b/server/main.go index 658e889..ffdb8ad 100644 --- a/server/main.go +++ b/server/main.go @@ -117,8 +117,7 @@ func startRESTServer(address, grpcAddress, certFile string) error { // Setup the client gRPC options opts := []grpc.DialOption{grpc.WithTransportCredentials(creds)} - // Register ping - //err = api.RegisterPingHandlerFromEndpoint(ctx, mux, grpcAddress, opts) + // Register CNIserver err = api.RegisterCNIserverHandlerFromEndpoint(ctx, mux, grpcAddress, opts) if err != nil { return fmt.Errorf("could not register service CNI: %s", err)