Skip to content
Snippets Groups Projects
Commit cf6d28d6 authored by Alejandro Tjaarda's avatar Alejandro Tjaarda
Browse files

operator: added overlays CR functionalty

parent 8f6bdefa
No related branches found
No related tags found
1 merge request!2repo: added new directory where utils scripts will be
package nedinterface
func GetConnectionInfo() (string, string) {
return "", ""
}
...@@ -95,7 +95,7 @@ func (c *InternalClient) AttachPodToNetwork(networkType l2smv1.NetworkType, conf ...@@ -95,7 +95,7 @@ func (c *InternalClient) AttachPodToNetwork(networkType l2smv1.NetworkType, conf
if err != nil { if err != nil {
return err return err
} }
response, err := c.Session.Post(fmt.Sprintf("%s/api/port", networkType), jsonData) response, err := c.Session.Post(fmt.Sprintf("/%s/api/port", networkType), jsonData)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -3,6 +3,7 @@ package utils ...@@ -3,6 +3,7 @@ package utils
import ( import (
"bytes" "bytes"
"crypto/sha1" "crypto/sha1"
"crypto/sha256"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"strings" "strings"
...@@ -82,3 +83,23 @@ func GetPortNumberFromNetAttachDef(netAttachName string) (string, error) { ...@@ -82,3 +83,23 @@ func GetPortNumberFromNetAttachDef(netAttachName string) (string, error) {
return portNumber, nil return portNumber, nil
} }
// generateDatapathID generates a datapath ID from the switch name
func GenerateDatapathID(switchName string) string {
// Create a new SHA256 hash object
hash := sha256.New()
// Write the switch name to the hash object
hash.Write([]byte(switchName))
// Get the hashed bytes
hashedBytes := hash.Sum(nil)
// Take the first 8 bytes of the hash to create a 64-bit ID
dpidBytes := hashedBytes[:8]
// Convert the bytes to a hexadecimal string
dpid := hex.EncodeToString(dpidBytes)
return dpid
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment