add CNIcheckMsg and CNIdelMsg
authorMichael Cambria <mcambria@redhat.com>
Wed, 17 Apr 2019 20:48:02 +0000 (16:48 -0400)
committerMichael Cambria <mcambria@redhat.com>
Wed, 17 Apr 2019 20:48:02 +0000 (16:48 -0400)
api/api.proto
api/handler.go
using-curl.txt

index 7578e5d..cb50e81 100644 (file)
@@ -20,6 +20,20 @@ service CNIserver {
       body: "*"
     };  
   }
+
+  rpc CNIcheck (CNIcheckMsg) returns (CHECKresult) {
+    option (google.api.http) = {
+      post: "/1/check"
+      body: "*"
+    };  
+  }
+
+  rpc CNIdel (CNIdelMsg) returns (DELresult) {
+    option (google.api.http) = {
+      post: "/1/del"
+      body: "*"
+    };  
+  }
 }
 
 message CNIerror {
@@ -87,8 +101,8 @@ message CNIaddMsg {
 }
 
 message ADDresult {
-  string error = 2;
-  string stdOut = 3;
+  string error = 1;
+  string stdOut = 2;
 }
 
 message CNIcheckMsg {
@@ -100,6 +114,10 @@ message CNIcheckMsg {
   repeated CNIcapArgs capArgs = 6;
 }
 
+message CHECKresult {
+  string error = 1;
+}
+
 message CNIdelMsg {
   string conf =1;
   string containerID = 2;
@@ -109,3 +127,7 @@ message CNIdelMsg {
   repeated CNIcapArgs capArgs = 6;
 }
 
+message DELresult {
+  string error = 1;
+  string stdOut = 2;
+}
index 4840479..882459d 100644 (file)
@@ -56,7 +56,7 @@ func (s *CNIServer) CNIop(ctx context.Context, in *CNImsg) (*CNIresult, error) {
        return &cniResult, nil
 }
 
-// CNIadd generates result to a CNImsg
+// CNIadd generates result to a CNIaddMsg
 func (s *CNIServer) CNIadd(ctx context.Context, in *CNIaddMsg) (*ADDresult, error) {
 
        log.Printf("Receive message Conf file: %s", in.Conf)
@@ -74,3 +74,38 @@ func (s *CNIServer) CNIadd(ctx context.Context, in *CNIaddMsg) (*ADDresult, erro
        return &cniResult, nil
 }
 
+// CNIcheck generates result to a CNIcheckMsg
+func (s *CNIServer) CNIcheck(ctx context.Context, in *CNIcheckMsg) (*CHECKresult, error) {
+
+       log.Printf("Receive message Conf file: %s", in.Conf)
+
+       log.Printf("Receive message ContainerID: %s", in.ContainerID)
+       log.Printf("Receive message NetNS: %s", in.NetNS)
+       log.Printf("Receive message IfName: %s", in.IfName)
+       log.Printf("Receive message CniArgs: %s", in.CniArgs)
+
+       cniResult := CHECKresult{
+              Error: "",
+       }
+
+       log.Printf("Response from server: %s", cniResult.Error)
+       return &cniResult, nil
+}
+
+// CNIdel generates result to a CNIdelMsg
+func (s *CNIServer) CNIdel(ctx context.Context, in *CNIdelMsg) (*DELresult, error) {
+
+       log.Printf("Receive message Conf file: %s", in.Conf)
+
+       log.Printf("Receive message ContainerID: %s", in.ContainerID)
+       log.Printf("Receive message NetNS: %s", in.NetNS)
+       log.Printf("Receive message IfName: %s", in.IfName)
+       log.Printf("Receive message CniArgs: %s", in.CniArgs)
+
+       cniResult := DELresult{
+              StdOut: "stdOutStringHere",
+       }
+
+       log.Printf("Response from server: %s", cniResult.StdOut)
+       return &cniResult, nil
+}
index e7217f4..fcfa253 100644 (file)
@@ -5,10 +5,10 @@ curl -H "login:john" -H "password:doe" -X POST 'http://localhost:7778/1/cni' -d
 
 Use these:
 
-curl -H "login:john" -H "password:doe" --header "Content-Type: application/json" -X POST 'http://localhost:7778/1/cni' -d @add-cmd.json 
+curl -H "login:john" -H "password:doe" --header "Content-Type: application/json" -X POST 'http://localhost:7778/1/add' -d @add-cmd.json 
 
-curl -H "login:john" -H "password:doe" --header "Content-Type: application/json" -X POST 'http://localhost:7778/1/cni' -d @check-cmd.json 
+curl -H "login:john" -H "password:doe" --header "Content-Type: application/json" -X POST 'http://localhost:7778/1/check' -d @check-cmd.json 
 
-curl -H "login:john" -H "password:doe" --header "Content-Type: application/json" -X POST 'http://localhost:7778/1/cni' -d @del-cmd.json 
+curl -H "login:john" -H "password:doe" --header "Content-Type: application/json" -X POST 'http://localhost:7778/1/del' -d @del-cmd.json