Skip to content
Snippets Groups Projects
Commit 35df3007 authored by Alex ubuntu vm's avatar Alex ubuntu vm
Browse files

switch: adjusted images and building process to new version

parent d55b3d99
No related branches found
No related tags found
1 merge request!2repo: added new directory where utils scripts will be
FROM golang:1.20 AS build
FROM golang:1.21 AS build
WORKDIR /usr/src/l2sm-switch
......
......@@ -10,3 +10,4 @@ fi
go build -v -o "${DEST_DIR}"/l2sm-init ./cmd/l2sm-init
go build -v -o "${DEST_DIR}"/l2sm-vxlans ./cmd/l2sm-vxlans
go build -v -o "${DEST_DIR}"/l2sm-add-port ./cmd/l2sm-add-port
\ No newline at end of file
This diff is collapsed.
......@@ -36,7 +36,7 @@ spec:
# sleep 5;
containers:
- name: l2sm-switch
image: alexdecb/l2sm-switch:2.2
image: alexdecb/l2sm-switch:2.4
#args: ["setup_switch.sh && sleep infinity"]
env:
- name: NODENAME
......
package main
import (
"encoding/json"
"errors"
"flag"
"fmt"
"io/ioutil"
"ovs-switch/pkg/ovs"
)
type Node struct {
Name string `json:"name"`
NodeIP string `json:"nodeIP"`
NeighborNodes []Node `json:"neighborNodes"`
}
// Script that takes two required arguments:
// the first one is the name in the cluster of the node where the script is running
// the second one is the path to the configuration file, in reference to the code.
......@@ -50,49 +42,3 @@ func takeArguments() (string, error) {
return *portName, nil
}
func createTopology(bridge ovs.Bridge, nodes []Node, nodeName string) error {
// Search for the corresponding node in the configuration, according to the first passed parameter.
// Once the node is found, create a bridge for every neighbour node defined.
// The bridge is created with the nodeIp and neighborNodeIP and VNI. The VNI is generated in the l2sm-controller thats why its set to 'flow'.
for _, node := range nodes {
if node.Name == nodeName {
//nodeIP := strings.TrimSpace(node.NodeIP)
connectToNeighbors(bridge, node)
}
}
return nil
}
func readFile(configDir string) ([]Node, error) {
/// Read file and save in memory the JSON info
data, err := ioutil.ReadFile(configDir)
if err != nil {
fmt.Println("No input file was found.", err)
return nil, err
}
var nodes []Node
err = json.Unmarshal(data, &nodes)
if err != nil {
return nil, err
}
return nodes, nil
}
func connectToNeighbors(bridge ovs.Bridge, node Node) error {
for vxlanNumber, neighbor := range node.NeighborNodes {
vxlanId := fmt.Sprintf("vxlan%d", vxlanNumber)
err := bridge.CreateVxlan(ovs.Vxlan{VxlanId: vxlanId, LocalIp: node.NodeIP, RemoteIp: neighbor.NodeIP, UdpPort: "7000"})
if err != nil {
return fmt.Errorf("could not create vxlan between node %s and node %s", node.Name, neighbor)
} else {
fmt.Printf("Created vxlan between node %s and node %s.\n", node.Name, neighbor)
}
}
return nil
}
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