[controller] move post config part out of init()
This commit is contained in:
parent
8d4402a0e5
commit
e92742f9c0
1 changed files with 5 additions and 7 deletions
|
@ -35,7 +35,6 @@ class L2Controller(object):
|
||||||
self.v4_routes['base'].append({ "net": "10.0.42.0/24", "port": "4"})
|
self.v4_routes['base'].append({ "net": "10.0.42.0/24", "port": "4"})
|
||||||
|
|
||||||
self.init_boilerplate(sw_name)
|
self.init_boilerplate(sw_name)
|
||||||
self.init()
|
|
||||||
|
|
||||||
def init_boilerplate(self, sw_name):
|
def init_boilerplate(self, sw_name):
|
||||||
self.topo = Topology(db="topology.db")
|
self.topo = Topology(db="topology.db")
|
||||||
|
@ -44,17 +43,15 @@ class L2Controller(object):
|
||||||
self.cpu_port = self.topo.get_cpu_port_index(self.sw_name)
|
self.cpu_port = self.topo.get_cpu_port_index(self.sw_name)
|
||||||
self.controller = SimpleSwitchAPI(self.thrift_port)
|
self.controller = SimpleSwitchAPI(self.thrift_port)
|
||||||
self.intf = str(self.topo.get_cpu_port_intf(self.sw_name).replace("eth0", "eth1"))
|
self.intf = str(self.topo.get_cpu_port_intf(self.sw_name).replace("eth0", "eth1"))
|
||||||
|
|
||||||
def init(self):
|
|
||||||
self.controller.reset_state()
|
self.controller.reset_state()
|
||||||
self.fill_tables()
|
|
||||||
self.config_hosts()
|
|
||||||
self.add_mirror()
|
|
||||||
|
|
||||||
def add_mirror(self):
|
|
||||||
if self.cpu_port:
|
if self.cpu_port:
|
||||||
self.controller.mirroring_add(100, self.cpu_port)
|
self.controller.mirroring_add(100, self.cpu_port)
|
||||||
|
|
||||||
|
def config(self):
|
||||||
|
self.fill_tables()
|
||||||
|
self.config_hosts()
|
||||||
|
|
||||||
def fill_tables(self):
|
def fill_tables(self):
|
||||||
for v6route in self.v6_routes[self.mode]:
|
for v6route in self.v6_routes[self.mode]:
|
||||||
self.controller.table_add("v6_routing", "set_egress_port", [v6route['net']], [v6route['port']])
|
self.controller.table_add("v6_routing", "set_egress_port", [v6route['net']], [v6route['port']])
|
||||||
|
@ -130,4 +127,5 @@ if __name__ == "__main__":
|
||||||
controller = L2Controller(sw_name)
|
controller = L2Controller(sw_name)
|
||||||
|
|
||||||
controller.commandline()
|
controller.commandline()
|
||||||
|
controller.config()
|
||||||
controller.run_cpu_port_loop()
|
controller.run_cpu_port_loop()
|
||||||
|
|
Loading…
Reference in a new issue