16 package org.openkilda.floodlight.switchmanager;
33 import net.floodlightcontroller.core.IOFSwitch;
34 import net.floodlightcontroller.core.IOFSwitchListener;
35 import net.floodlightcontroller.core.PortChangeType;
36 import net.floodlightcontroller.core.internal.IOFSwitchService;
37 import net.floodlightcontroller.core.module.FloodlightModuleContext;
38 import net.floodlightcontroller.core.module.FloodlightModuleException;
39 import net.floodlightcontroller.core.module.IFloodlightModule;
40 import net.floodlightcontroller.core.module.IFloodlightService;
41 import org.projectfloodlight.openflow.protocol.OFFlowStatsReply;
42 import org.projectfloodlight.openflow.protocol.OFPortDesc;
43 import org.projectfloodlight.openflow.types.DatapathId;
44 import org.projectfloodlight.openflow.types.OFPort;
45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory;
48 import java.util.ArrayList;
49 import java.util.Collection;
50 import java.util.HashMap;
56 private IOFSwitchService switchService;
60 private String topoDiscoTopic;
108 final IOFSwitch sw = switchService.getSwitch(switchId);
109 logger.info(
"ACTIVATING SWITCH: {}", switchId);
132 logger.error(
"Could not activate switch={}", switchId, e);
144 return !(
p.equals(OFPort.LOCAL)
145 ||
p.equals(OFPort.ALL)
146 ||
p.equals(OFPort.CONTROLLER)
147 ||
p.equals(OFPort.ANY)
148 ||
p.equals(OFPort.FLOOD)
149 ||
p.equals(OFPort.ZERO)
150 ||
p.equals(OFPort.NO_MASK)
151 ||
p.equals(OFPort.IN_PORT)
152 ||
p.equals(OFPort.NORMAL)
153 ||
p.equals(OFPort.TABLE));
164 kafkaProducer.
postMessage(topoDiscoTopic, message);
175 kafkaProducer.
postMessage(topoDiscoTopic, message);
190 kafkaProducer.
postMessage(topoDiscoTopic, message);
198 Collection<Class<? extends IFloodlightService>> services =
new ArrayList<>(1);
207 public Map<Class<? extends IFloodlightService>, IFloodlightService>
getServiceImpls() {
208 Map<Class<? extends IFloodlightService>, IFloodlightService> map =
new HashMap<>();
218 Collection<Class<? extends IFloodlightService>> services =
new ArrayList<>(3);
219 services.add(IOFSwitchService.class);
229 public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
230 switchService = context.getServiceImpl(IOFSwitchService.class);
247 public void startUp(FloodlightModuleContext context)
throws FloodlightModuleException {
249 switchService.addOFSwitchListener(
this);
260 private Message buildExtendedSwitchMessage(
final IOFSwitch sw,
final SwitchState eventType,
261 OFFlowStatsReply flowStats) {
284 final String unknown =
"unknown";
287 unknown, unknown, unknown, unknown);
311 null, toJsonType(
type));
325 null, toJsonType(
type));
void installDefaultRules(final DatapathId dpid)
void sendSwitchActivate(final IOFSwitch sw)
String getTopoDiscoTopic()
void init(FloodlightModuleContext context)
static Message buildSwitchMessage(final DatapathId switchId, final SwitchState eventType)
void switchAdded(final DatapathId switchId)
static Message buildSwitchMessage(final IOFSwitch sw, final SwitchState eventType)
static SwitchInfoExtendedData buildSwitchInfoDataExtended(IOFSwitch sw, SwitchState eventType, OFFlowStatsReply flowStats)
Collection< Class<? extends IFloodlightService > > getModuleDependencies()
void switchPortChanged(final DatapathId switchId, final OFPortDesc port, final PortChangeType type)
static SwitchInfoData buildSwitchInfoData(IOFSwitch sw, SwitchState eventType)
static Message buildPortMessage(final DatapathId switchId, final OFPort port, final PortChangeType type)
static boolean isPhysicalPort(OFPort p)
void switchDeactivated(final DatapathId switchId)
Collection< Class<? extends IFloodlightService > > getModuleServices()
static ConfigurationProvider of(FloodlightModuleContext moduleContext, IFloodlightModule module)
void switchRemoved(final DatapathId switchId)
void startUp(FloodlightModuleContext context)
void sendPortUpEvents(final IOFSwitch sw)
void switchActivated(final DatapathId switchId)
void postMessage(final String topic, final Message message)
ConnectModeRequest.Mode connectMode(final ConnectModeRequest.Mode mode)
void startSafeMode(final DatapathId dpid)
static Message buildMessage(final InfoData data)
Map< Class<? extends IFloodlightService >, IFloodlightService > getServiceImpls()
void switchChanged(final DatapathId switchId)
void stopSafeMode(final DatapathId dpid)