blob: 401b7fae5e0a84a888a010d1ec510084ec484315 [file] [log] [blame]
Masayoshi Kobayashia9020b32013-04-09 21:42:08 +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
21 url = ""
22 for idx in sys.argv[1:]:
23 url += "tcp:%s:6633" % socket.gethostbyname(controllers[int(idx)-1]) + " "
24
25 print url[:-1]
26
27 switches = os.popen("sudo ovs-vsctl list-br").read().split("\n");
28 switches.remove('')
29 for s in switches:
30 print "set switch %s controller %s" % (s, url)
31 os.popen("sudo ovs-vsctl set-controller %s %s" % (s, url) )