diff --git a/src/kubernetes-api/internal/nedinterface/nedinterface.go b/src/kubernetes-api/internal/nedinterface/nedinterface.go new file mode 100644 index 0000000000000000000000000000000000000000..be1ba58898f8bd57744d83b9f1976db234acef11 --- /dev/null +++ b/src/kubernetes-api/internal/nedinterface/nedinterface.go @@ -0,0 +1,5 @@ +package nedinterface + +func GetConnectionInfo() (string, string) { + return "", "" +} diff --git a/src/kubernetes-api/internal/sdnclient/internal_client.go b/src/kubernetes-api/internal/sdnclient/internal_client.go index ae6e1ddfff712c3899186d56f7a96d9137820fd2..4feffcde1b2f862892e504c01cf4c3caf87325c8 100644 --- a/src/kubernetes-api/internal/sdnclient/internal_client.go +++ b/src/kubernetes-api/internal/sdnclient/internal_client.go @@ -95,7 +95,7 @@ func (c *InternalClient) AttachPodToNetwork(networkType l2smv1.NetworkType, conf if err != nil { 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 { return err } diff --git a/src/kubernetes-api/internal/utils/utils.go b/src/kubernetes-api/internal/utils/utils.go index 566c8016f4ef0c8da6702ad894ff7e365f175303..11553e9666d8a2314472df26a5e2243b3c37c17c 100644 --- a/src/kubernetes-api/internal/utils/utils.go +++ b/src/kubernetes-api/internal/utils/utils.go @@ -3,6 +3,7 @@ package utils import ( "bytes" "crypto/sha1" + "crypto/sha256" "encoding/hex" "fmt" "strings" @@ -82,3 +83,23 @@ func GetPortNumberFromNetAttachDef(netAttachName string) (string, error) { 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 +}