}
repeated PORTMAPPINGS portMappings = 1;
- //PORTMAPPINGS portMappings = 1;
message FOOMAP {
string thing1 = 1;
}
repeated FOOMAP fooMap = 2;
- //FOOMAP fooMap = 2;
}
message ConfPath {
const (
EnvCNIPath = "CNI_PATH"
EnvNetDir = "NETCONFPATH"
- //EnvCapabilityArgs = "CAP_ARGS"
- //EnvCNIArgs = "CNI_ARGS"
- //EnvCNIIfname = "CNI_IFNAME"
DefaultNetDir = "/etc/cni/net.d"
func cniCommon(conf string, netns string, ifName string, args string, capabilityArgsValue string) (*libcni.NetworkConfigList, *libcni.RuntimeConf, *libcni.CNIConfig, error) {
+ var err error
+
log.Printf("cniCommon Called")
- // TODO
- //netdir := os.Getenv(EnvNetDir)
- netdir := "/home/mcambria/go/src/github.com/containernetworking"
- if netdir == "" {
- netdir = DefaultNetDir
- }
- netconf, err := libcni.LoadConfList(netdir, conf)
- if err != nil {
+ netconf := libcni.NetworkConfigList{}
+ if err = json.Unmarshal([]byte(conf), &netconf); err != nil {
return nil, nil, nil, err
}
capabilityArgs := CNIcapArgs{}
- if err = json.Unmarshal([]byte(capabilityArgsValue), &capabilityArgs); err != nil {
+ if err := json.Unmarshal([]byte(capabilityArgsValue), &capabilityArgs); err != nil {
//if err := proto.Unmarshal([]byte(capabilityArgsValue), &capabilityArgs); err != nil {
return nil, nil, nil, err
}
s := sha512.Sum512([]byte(netns))
containerID := fmt.Sprintf("cnitool-%x", s[:10])
- // TODO
+ // TODO - remove hard coded cniBinPath
//cninet := libcni.NewCNIConfig(filepath.SplitList(os.Getenv(EnvCNIPath)), nil)
cniBinPath := "/home/mcambria/go/src/github.com/mccv1r0/plugins/bin"
cninet := libcni.NewCNIConfig(filepath.SplitList(cniBinPath), nil)
sout = fmt.Sprintf("mcc: rt: %v of type %T \n", rt, rt)
_, _ = f.Write([]byte(sout))
- return netconf, rt, cninet, nil
+ return &netconf, rt, cninet, nil
}
/*
import (
"log"
"context"
- //"encoding/json"
+ "encoding/json"
"fmt"
"os"
"path/filepath"
//proto "github.com/golang/protobuf/proto"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
+
+ "github.com/containernetworking/cni/libcni"
)
const (
os.Exit(1)
}
+ // TODO - remove hard coded path and use EnvNetDir
+ //netdir := os.Getenv(EnvNetDir)
+ netdir := "/home/mcambria/go/src/github.com/containernetworking"
+ if netdir == "" {
+ netdir = DefaultNetDir
+ }
+ netconf, err := libcni.LoadConfList(netdir, os.Args[2])
+ if err != nil {
+ fmt.Fprintf(os.Stderr, " failed to find config %s\n", os.Args[2])
+ return
+ }
+
+ confBytes, err := json.Marshal(&netconf)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, " failed to marshal config bytes\n")
+ return
+ }
+
var capArgs string
//var err error
//capabilityArgs := api.CNIcapArgs{}
switch os.Args[1] {
case CmdAdd:
- gRPCsendAddTcp(os.Args[2], netns, ifName, args, capArgs)
+ gRPCsendAddTcp(string(confBytes), netns, ifName, args, capArgs)
os.Exit(0)
case CmdCheck:
- gRPCsendCheckTcp(os.Args[2], netns, ifName, args, capArgs)
+ gRPCsendCheckTcp(string(confBytes), netns, ifName, args, capArgs)
os.Exit(0)
case CmdDel:
- gRPCsendDelTcp(os.Args[2], netns, ifName, args, capArgs)
+ gRPCsendDelTcp(string(confBytes), netns, ifName, args, capArgs)
os.Exit(0)
}
}
cni := api.NewCNIserverClient(conn)
cniAddMsg := api.CNIaddMsg{
- Conf: os.Args[2],
+ Conf: conf,
NetNS: netns,
IfName: ifName,
CniArgs: args,
cni := api.NewCNIserverClient(conn)
cniCheckMsg := api.CNIcheckMsg{
- Conf: os.Args[2],
+ Conf: conf,
NetNS: netns,
IfName: ifName,
CniArgs: args,
cni := api.NewCNIserverClient(conn)
cniDelMsg := api.CNIdelMsg{
- Conf: os.Args[2],
+ Conf: conf,
NetNS: netns,
IfName: ifName,
CniArgs: args,
cni := api.NewCNIserverClient(conn)
cniAddMsg := api.CNIaddMsg{
- Conf: os.Args[2],
+ Conf: conf,
NetNS: netns,
IfName: ifName,
CniArgs: args,
cni := api.NewCNIserverClient(conn)
cniCheckMsg := api.CNIcheckMsg{
- Conf: os.Args[2],
+ Conf: conf,
NetNS: netns,
IfName: ifName,
CniArgs: args,
cni := api.NewCNIserverClient(conn)
cniDelMsg := api.CNIdelMsg{
- Conf: os.Args[2],
+ Conf: conf,
NetNS: netns,
IfName: ifName,
CniArgs: args,