blob: 88be2f34bd4852e58aee7ff764c014dbfd0728eb [file] [log] [blame]
Pavlin Radoslavova49acaf2013-04-07 06:04:23 +00001#! /usr/bin/env python
2import sys
3import time
4import os
5import re
6import json
7import socket
8
9CONFIG_FILE=os.getenv("HOME") + "/ONOS/web/config.json"
10
11def read_config():
12 global controllers
13 f = open(CONFIG_FILE)
14 conf = json.load(f)
15 controllers = conf['controllers']
16 f.close()
17
18if __name__ == "__main__":
19 read_config()
20 controllers.pop(0)
21 url = ""
22 for c in controllers:
23 url += " " + "tcp:%s:6633" % socket.gethostbyname(c)
24
25 switches = os.popen("sudo ovs-vsctl list-br").read().split("\n");
26 switches.remove('')
27 for s in switches:
28 print "set switch %s controller %s" % (s, url)
29 os.popen("sudo ovs-vsctl set-controller %s %s" % (s, url) )