def setupTopology(): topology = topologyParser.Topology('topology.xml') hostList = topology.getHost() for host in hostList: cmd.lxcStart(host) openflowSwitchList = topology.getOpenflowSwitch() ipList = topology.getInterfaceIp() ipList = list(set(ipList)) dpidlist = cmd.getDpidList() openflowSwitchList = topology.getOpenflowSwitch() for openflowSwitch in openflowSwitchList: interfaceList = topology.getOpenflowSwitchInterface(openflowSwitch) cmd.ovsOpenflowd(openflowSwitch, '210.25.137.243', 6633) for interface in interfaceList: cmd.ovsDpctl(openflowSwitch, interface) i=0 for openflowSwitch in openflowSwitchList: interfaceList = topology.getOpenflowSwitchInterface(openflowSwitch) inportList = cmd.getPort(dpidlist[i]) for interface in interfaceList: for ip in ipList: cmd.addFlowSpace(dpidlist[i],'20','in_port='+ inportList[interface]+',nw_src='+ip,'Slice:rfSlice=4') i=i+1
def startOVS(): # dictFile = open('/switchDict','wb') # pickle.dump(openflowSwitchDict,dictFile) # dictFile.close() for openflowSwitch in openflowSwitchList: cmd.ovsOpenflowd(openflowSwitch, '127.0.0.1', 6633)
def setupTopology(): topology = topologyParser.Topology() hostList = topology.getHost() for host in hostList: cmd.lxcStart(host) openflowSwitchList = topology.getOpenflowSwitch() for openflowSwitch in openflowSwitchList: interfaceList = topology.getOpenflowSwitchInterface(openflowSwitch) cmd.ovsOpenflowd(openflowSwitch, '127.0.0.1', 6633) for interface in interfaceList: cmd.ovsDpctl(openflowSwitch, interface)
def setupControlPlane(): cmd.lxcStart('router1') cmd.lxcStart('router2') cmd.ovsOpenflowd('dp0', '127.0.0.1', 6633, 'rfovs') cmd.ifconfig('dp0', 'up') cmd.ovsOpenflowd('br0', '127.0.0.1', 6363) cmd.ifconfig('br0', 'up', '192.168.1.1', '255.255.255.0') dp0Interface = ['router1.1', 'router1.2', 'router2.1', 'router2.2'] for interface in dp0Interface: cmd.ovsDpctl('dp0', interface) br0Interface = ['router1.0', 'router2.0'] for interface in br0Interface: cmd.ovsDpctl('br0', interface)
cmd.createDaemons(lxc,topology["nodes"][lxc]["attrs"]["protocol"]) if(topology["nodes"][lxc]["attrs"]["protocol"]=="rip"): cmd.createRipd(lxc,vmInterfaceList,vmInterfaceDict) elif(topology["nodes"][lxc]["attrs"]["protocol"]=="ospf"): cmd.createOspf(lxc,vmInterfaceList,vmInterfaceDict,address) address+=1 #else #start rf cmd.startNox("switch","6363") cmd.startNox("routeflowc","6666") cmd.startRf() for lxc in lxcList: cmd.lxcStart(lxc) cmd.ovsOpenflowd('dp0', '127.0.0.1', 6666, 'rfovs') cmd.ifconfig('dp0', 'up') cmd.ovsOpenflowd('br0', '127.0.0.1', 6363) cmd.ifconfig('br0', 'up', '192.168.1.1', '255.255.255.0') for lxc in lxcList: vmInterfaceList=topology["nodes"][lxc]["interface"].keys() for vmInterface in vmInterfaceList: cmd.ovsDpctl("dp0",vmInterface) for lxc in lxcList: cmd.ovsDpctl("br0",lxc+".0")
def startOVS(): for openflowSwitch in openflowSwitchList: cmd.ovsOpenflowd(openflowSwitch, '127.0.0.1', 6633)