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 {
}
message ADDresult {
- string error = 2;
- string stdOut = 3;
+ string error = 1;
+ string stdOut = 2;
}
message CNIcheckMsg {
repeated CNIcapArgs capArgs = 6;
}
+message CHECKresult {
+ string error = 1;
+}
+
message CNIdelMsg {
string conf =1;
string containerID = 2;
repeated CNIcapArgs capArgs = 6;
}
+message DELresult {
+ string error = 1;
+ string stdOut = 2;
+}
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)
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
+}
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