diff --git a/operator/src/switch/Dockerfile b/operator/src/switch/Dockerfile index 4f6fef8b86e21e1f89f83da4fb9fc9e379b4bd6f..38374b6bee9b61f13f66c8513e3c0014333168f4 100644 --- a/operator/src/switch/Dockerfile +++ b/operator/src/switch/Dockerfile @@ -8,7 +8,9 @@ RUN go build -v -o /usr/local/bin/l2sm-br ./... FROM ubuntu:latest -COPY --from=build /usr/src/bin/ /usr/src/bin/ +WORKDIR /usr/local/bin + +COPY --from=build /usr/local/bin/ . COPY ./vswitch.ovsschema /tmp/ @@ -16,12 +18,11 @@ RUN apt-get update && \ apt-get install -y net-tools iproute2 netcat-openbsd dnsutils curl iputils-ping iptables nmap tcpdump openvswitch-switch && \ mkdir /var/run/openvswitch && mkdir -p /etc/openvswitch && ovsdb-tool create /etc/openvswitch/conf.db /tmp/vswitch.ovsschema -COPY ./setup_switch.sh /usr/local/bin/ +COPY ./setup_switch.sh . -RUN chmod +x /usr/local/bin/setup_switch.sh && \ +RUN chmod +x ./setup_switch.sh && \ mkdir /etc/l2sm/ -WORKDIR /usr/local/bin CMD [ "./setup_switch.sh" ] \ No newline at end of file diff --git a/operator/src/switch/main.go b/operator/src/switch/main.go index e77d61da4cabac28dbb14a7998b5ab0690fa95f5..9169f9ff4840814104b9f98e593df87613b83c6b 100644 --- a/operator/src/switch/main.go +++ b/operator/src/switch/main.go @@ -25,14 +25,15 @@ func main() { configDir, vhostNumber, nodeName, controllerIP, err := takeArguments() if err != nil { - fmt.Println("Error:", err) + fmt.Println("Error with the arguments. Error:", err) return } + fmt.Println("initializing switch, connected to controller: ", controllerIP) err = initializeSwitch(controllerIP) if err != nil { - fmt.Println("Error:", err) + fmt.Println("Could not initialize switch. Error:", err) return } @@ -51,7 +52,7 @@ func main() { err = createVxlans(configDir, nodeName) if err != nil { - fmt.Println("Error:", err) + fmt.Println("Vxlans not created. Error:", err) return } } @@ -84,19 +85,19 @@ func initializeSwitch(controllerIP string) error { err = exec.Command("ovs-vsctl", "add-br", "brtun").Run() if err != nil { - return err + return errors.New("Could not create brtun interface") } err = exec.Command("ip", "link", "set", "brtun", "up").Run() if err != nil { - return err + return errors.New("Could not set brtun interface up") } - err = exec.Command("ovs-vsctl", "set", "bridge", "brtun", "OpenFlow13").Run() + err = exec.Command("ovs-vsctl", "set", "bridge", "brtun", "protocols=OpenFlow13").Run() if err != nil { - return err + return errors.New("Couldnt set brtun messaing protocol to OpenFlow13") } target := fmt.Sprintf("tcp:%s:6633", controllerIP) @@ -104,7 +105,7 @@ func initializeSwitch(controllerIP string) error { err = exec.Command("ovs-vsctl", "set-controller", "brtun", target).Run() if err != nil { - return err + return errors.New("Could not connect to controller") } return nil } diff --git a/operator/src/switch/sampleFile.json b/operator/src/switch/sampleFile.json index 7c3af852bf0a0b2f5d12c880d56a7c6088947bc3..48a444c1fde093c944bec652b54e309b8958696c 100644 --- a/operator/src/switch/sampleFile.json +++ b/operator/src/switch/sampleFile.json @@ -1,12 +1,12 @@ [ { "name": "l2sm1", - "nodeIP": "10.1.14.46", + "nodeIP": "10.1.14.48", "neighborNodes": ["l2sm2"] }, { "name": "l2sm2", - "nodeIP": "10.1.72.79", + "nodeIP": "10.1.72.108", "neighborNodes": ["l2sm1"] }, {