From 2d3ca7527ef3ab85ddfe529351460659ddf811bc Mon Sep 17 00:00:00 2001
From: Alejandro Tjaarda <alexdecb@yahoo.es>
Date: Fri, 27 Sep 2024 19:06:23 +0000
Subject: [PATCH] switch: added ned image

This new image has differences with the previous l2sm-switch
---
 build/build_images.sh   | 6 +++++-
 src/switch/README.md    | 2 +-
 src/switch/go.sum       | 1 +
 src/switch/setup_ned.sh | 9 +++++++++
 4 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 src/switch/setup_ned.sh

diff --git a/build/build_images.sh b/build/build_images.sh
index 00136bf..94c6eef 100755
--- a/build/build_images.sh
+++ b/build/build_images.sh
@@ -2,7 +2,7 @@
 set -e
 
 # Set environment variables
-export VERSION="2.6"
+export VERSION="2.7.1"
 export DOCKERHUB_REPO="alexdecb"
 
 # Function to build image
@@ -25,6 +25,7 @@ push_image() {
 # Option 1: Build image
 if [ "$1" == "build" ]; then
   build_image "l2sm-switch" "switch"
+  build_image "l2sm-ned" "ned"
   build_image "l2sm-controller" "controller"
   build_image "l2sm-operator" "operator"
   echo "Images have been built successfully."
@@ -32,6 +33,7 @@ if [ "$1" == "build" ]; then
 # Option 2: Push image
 elif [ "$1" == "push" ]; then
   push_image "l2sm-switch"
+  push_image "l2sm-ned"
   push_image "l2sm-controller"
   push_image "l2sm-operator"
   echo "Images have been pushed successfully."
@@ -40,6 +42,8 @@ elif [ "$1" == "push" ]; then
 elif [ "$1" == "build_push" ]; then
   build_image "l2sm-switch" "switch"
   push_image "l2sm-switch"
+  build_image "l2sm-ned" "ned"
+  push_image "l2sm-ned"
   build_image "l2sm-controller" "controller"
   push_image "l2sm-controller"
   build_image "l2sm-operator" "operator"
diff --git a/src/switch/README.md b/src/switch/README.md
index ea76469..1ae1787 100644
--- a/src/switch/README.md
+++ b/src/switch/README.md
@@ -1,5 +1,5 @@
 1. Modify the api/v1/ned.proto 
 2. Generate protofiles:
 ```bash
-protoc -I=api/v1 --go_out=paths=source_relative:./pkg/nedpb api/v1/ned.proto
+protoc -I=api/v1 --go_out=paths=source_relative:./pkg/nedpb --go-grpc_out=paths=source_relative:./pkg/nedpb api/v1/ned.proto
 ```
\ No newline at end of file
diff --git a/src/switch/go.sum b/src/switch/go.sum
index ba494d1..fbab6e6 100644
--- a/src/switch/go.sum
+++ b/src/switch/go.sum
@@ -27,6 +27,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
 golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
 golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/src/switch/setup_ned.sh b/src/switch/setup_ned.sh
new file mode 100644
index 0000000..f6959b7
--- /dev/null
+++ b/src/switch/setup_ned.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+ovsdb-server --remote=punix:/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --pidfile=/var/run/openvswitch/ovsdb-server.pid --detach 
+
+ovs-vsctl --db=unix:/var/run/openvswitch/db.sock --no-wait init 
+
+ovs-vswitchd --pidfile=/var/run/openvswitch/ovs-vswitchd.pid --detach 
+
+ned-server --node_name=$NODENAME --controller_ip=$CONTROLLERIP --provider_name=$PROVIDERNAME /etc/l2sm/topology.json
\ No newline at end of file
-- 
GitLab