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

added better error logs and bug fix

parent 5ff66975
No related branches found
No related tags found
1 merge request!2repo: added new directory where utils scripts will be
...@@ -8,7 +8,9 @@ RUN go build -v -o /usr/local/bin/l2sm-br ./... ...@@ -8,7 +8,9 @@ RUN go build -v -o /usr/local/bin/l2sm-br ./...
FROM ubuntu:latest 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/ COPY ./vswitch.ovsschema /tmp/
...@@ -16,12 +18,11 @@ RUN apt-get update && \ ...@@ -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 && \ 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 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/ mkdir /etc/l2sm/
WORKDIR /usr/local/bin
CMD [ "./setup_switch.sh" ] CMD [ "./setup_switch.sh" ]
\ No newline at end of file
...@@ -25,14 +25,15 @@ func main() { ...@@ -25,14 +25,15 @@ func main() {
configDir, vhostNumber, nodeName, controllerIP, err := takeArguments() configDir, vhostNumber, nodeName, controllerIP, err := takeArguments()
if err != nil { if err != nil {
fmt.Println("Error:", err) fmt.Println("Error with the arguments. Error:", err)
return return
} }
fmt.Println("initializing switch, connected to controller: ", controllerIP)
err = initializeSwitch(controllerIP) err = initializeSwitch(controllerIP)
if err != nil { if err != nil {
fmt.Println("Error:", err) fmt.Println("Could not initialize switch. Error:", err)
return return
} }
...@@ -51,7 +52,7 @@ func main() { ...@@ -51,7 +52,7 @@ func main() {
err = createVxlans(configDir, nodeName) err = createVxlans(configDir, nodeName)
if err != nil { if err != nil {
fmt.Println("Error:", err) fmt.Println("Vxlans not created. Error:", err)
return return
} }
} }
...@@ -84,19 +85,19 @@ func initializeSwitch(controllerIP string) error { ...@@ -84,19 +85,19 @@ func initializeSwitch(controllerIP string) error {
err = exec.Command("ovs-vsctl", "add-br", "brtun").Run() err = exec.Command("ovs-vsctl", "add-br", "brtun").Run()
if err != nil { if err != nil {
return err return errors.New("Could not create brtun interface")
} }
err = exec.Command("ip", "link", "set", "brtun", "up").Run() err = exec.Command("ip", "link", "set", "brtun", "up").Run()
if err != nil { 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 { if err != nil {
return err return errors.New("Couldnt set brtun messaing protocol to OpenFlow13")
} }
target := fmt.Sprintf("tcp:%s:6633", controllerIP) target := fmt.Sprintf("tcp:%s:6633", controllerIP)
...@@ -104,7 +105,7 @@ func initializeSwitch(controllerIP string) error { ...@@ -104,7 +105,7 @@ func initializeSwitch(controllerIP string) error {
err = exec.Command("ovs-vsctl", "set-controller", "brtun", target).Run() err = exec.Command("ovs-vsctl", "set-controller", "brtun", target).Run()
if err != nil { if err != nil {
return err return errors.New("Could not connect to controller")
} }
return nil return nil
} }
......
[ [
{ {
"name": "l2sm1", "name": "l2sm1",
"nodeIP": "10.1.14.46", "nodeIP": "10.1.14.48",
"neighborNodes": ["l2sm2"] "neighborNodes": ["l2sm2"]
}, },
{ {
"name": "l2sm2", "name": "l2sm2",
"nodeIP": "10.1.72.79", "nodeIP": "10.1.72.108",
"neighborNodes": ["l2sm1"] "neighborNodes": ["l2sm1"]
}, },
{ {
......
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