aboutsummaryrefslogtreecommitdiffstats
path: root/internal/pkg/config/config.go
diff options
context:
space:
mode:
authorKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>2020-07-06 16:10:19 -0700
committerKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>2020-09-17 16:25:10 -0700
commitce14abc0128d4c55a7805c52ea199e2ce6159428 (patch)
tree569f74510b497ed44814e931a4667de73d133ab0 /internal/pkg/config/config.go
parent3de63ee756f9d7c0a4524b40a89e92b918a9249f (diff)
Adding node interface, SNAT and OVN Node switch port
- Adding nfn proto for node interface MAC and IP address - Adding node switch ports in NFN Operator - Adding grpc client in nfn agent to get mac and IP address for node interface - Adding feature to create Node interface with OVS internal port - Make sure pod controller requeue the pod request for empty node field in pod spec - Unique node interface name using SHA and maintain 15 charactor for OVS switch port - Adding SNAT for default interface in each node - Adding iptables modules for SNAT rules Signed-off-by: Kuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com> Change-Id: I6cfa36e45007e796eb651345f9f0751329defcf7
Diffstat (limited to 'internal/pkg/config/config.go')
-rw-r--r--internal/pkg/config/config.go30
1 files changed, 20 insertions, 10 deletions
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index e9ad3e1..b8ab825 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -1,16 +1,18 @@
package config
import (
- "encoding/json"
+ "crypto/sha1"
+ "encoding/hex"
+ "encoding/json"
"fmt"
"os"
"path/filepath"
"reflect"
+ "github.com/containernetworking/cni/pkg/types"
+ "github.com/containernetworking/cni/pkg/version"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
- "github.com/containernetworking/cni/pkg/types"
- "github.com/containernetworking/cni/pkg/version"
gcfg "gopkg.in/gcfg.v1"
"k8s.io/client-go/kubernetes"
@@ -288,15 +290,23 @@ func NewClientset(conf *KubernetesConfig) (*kubernetes.Clientset, error) {
}
func ConfigureNetConf(bytes []byte) (*types.NetConf, error) {
- conf := &types.NetConf{}
+ conf := &types.NetConf{}
if err := json.Unmarshal(bytes, conf); err != nil {
return nil, fmt.Errorf("failed to load netconf: %v", err)
}
- if conf.RawPrevResult != nil {
- if err := version.ParsePrevResult(conf); err != nil {
- return nil, err
- }
- }
- return conf, nil
+ if conf.RawPrevResult != nil {
+ if err := version.ParsePrevResult(conf); err != nil {
+ return nil, err
+ }
+ }
+ return conf, nil
+}
+
+func GetNodeIntfName(node string) string {
+ h := sha1.New()
+ h.Write([]byte(node))
+ bs := h.Sum(nil)
+ encodednodeStr := hex.EncodeToString(bs)
+ return fmt.Sprintf("ovn4nfv0-%s", encodednodeStr[:6])
}