Search in sources :

Example 1 with KildaCore

use of org.openkilda.floodlight.KildaCore in project open-kilda by telstra.

the class IngressServer42FlowInstallCommandTest method createCommand.

private IngressServer42FlowInstallCommand createCommand(int outerVlan, int innerVlan, FlowTransitEncapsulation encapsulation, boolean multiTable) throws Exception {
    FlowSegmentMetadata metadata = new FlowSegmentMetadata(FLOW_ID, COOKIE, multiTable);
    IngressServer42FlowInstallCommand command = new IngressServer42FlowInstallCommand(new MessageContext(), UUID.randomUUID(), metadata, INGRESS_SWITCH_ID, CUSTOMER_PORT, outerVlan, innerVlan, EGRESS_SWITCH_ID, ISL_PORT, encapsulation, SERVER_42_PORT, SERVER_42_MAC_ADDRESS);
    FloodlightModuleContext context = new FloodlightModuleContext();
    IOFSwitchService switchServiceMock = mock(IOFSwitchService.class);
    expect(switchServiceMock.getActiveSwitch(anyObject())).andReturn(getOfSwitch()).anyTimes();
    context.addService(IOFSwitchService.class, switchServiceMock);
    FeatureDetectorService featureDetectorServiceMock = mock(FeatureDetectorService.class);
    expect(featureDetectorServiceMock.detectSwitch(anyObject())).andReturn(FEATURES).anyTimes();
    context.addService(FeatureDetectorService.class, featureDetectorServiceMock);
    Properties properties = new Properties();
    properties.setProperty(SERVER_42_UPD_PORT_OFFSET_PROPERTY, Integer.toString(SERVER_42_UPD_PORT_OFFSET));
    PropertiesBasedConfigurationProvider provider = new PropertiesBasedConfigurationProvider(properties);
    KildaCore kildaCoreMock = mock(KildaCore.class);
    expect(kildaCoreMock.getConfig()).andReturn(provider.getConfiguration(KildaCoreConfig.class)).anyTimes();
    context.addService(KildaCore.class, kildaCoreMock);
    replay(switchServiceMock, featureDetectorServiceMock, kildaCoreMock);
    command.setup(context);
    return command;
}
Also used : IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) PropertiesBasedConfigurationProvider(org.openkilda.config.provider.PropertiesBasedConfigurationProvider) MessageContext(org.openkilda.messaging.MessageContext) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) Properties(java.util.Properties) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) KildaCore(org.openkilda.floodlight.KildaCore)

Example 2 with KildaCore

use of org.openkilda.floodlight.KildaCore in project open-kilda by telstra.

the class IngressFlowLoopSegmentInstallCommandTest method createCommand.

private IngressFlowLoopSegmentInstallCommand createCommand(int outerVlan, int innerVlan, boolean multiTable) throws Exception {
    FlowSegmentMetadata metadata = new FlowSegmentMetadata(FLOW_ID, COOKIE, multiTable);
    FlowEndpoint endpoint = FlowEndpoint.builder().switchId(SWITCH_ID_1).portNumber(PORT_1).outerVlanId(outerVlan).innerVlanId(innerVlan).build();
    IngressFlowLoopSegmentInstallCommand command = new IngressFlowLoopSegmentInstallCommand(new MessageContext(), UUID.randomUUID(), metadata, endpoint);
    FloodlightModuleContext context = new FloodlightModuleContext();
    IOFSwitchService switchServiceMock = mock(IOFSwitchService.class);
    expect(switchServiceMock.getActiveSwitch(anyObject())).andReturn(getOfSwitch()).anyTimes();
    context.addService(IOFSwitchService.class, switchServiceMock);
    FeatureDetectorService featureDetectorServiceMock = mock(FeatureDetectorService.class);
    expect(featureDetectorServiceMock.detectSwitch(anyObject())).andReturn(FEATURES).anyTimes();
    context.addService(FeatureDetectorService.class, featureDetectorServiceMock);
    PropertiesBasedConfigurationProvider provider = new PropertiesBasedConfigurationProvider(new Properties());
    KildaCore kildaCoreMock = mock(KildaCore.class);
    expect(kildaCoreMock.getConfig()).andReturn(provider.getConfiguration(KildaCoreConfig.class)).anyTimes();
    context.addService(KildaCore.class, kildaCoreMock);
    replay(switchServiceMock, featureDetectorServiceMock, kildaCoreMock);
    command.setup(context);
    return command;
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) PropertiesBasedConfigurationProvider(org.openkilda.config.provider.PropertiesBasedConfigurationProvider) MessageContext(org.openkilda.messaging.MessageContext) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) Properties(java.util.Properties) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) KildaCore(org.openkilda.floodlight.KildaCore)

Example 3 with KildaCore

use of org.openkilda.floodlight.KildaCore in project open-kilda by telstra.

the class SwitchManagerTest method setUp.

@Before
public void setUp() throws FloodlightModuleException {
    JdkProxyStaticConfigurationFactory factory = new JdkProxyStaticConfigurationFactory();
    config = factory.createConfiguration(SwitchManagerConfig.class, new MapConfigurationSource(emptyMap()));
    ofSwitchService = createMock(IOFSwitchService.class);
    restApiService = createMock(IRestApiService.class);
    featureDetectorService = createMock(FeatureDetectorService.class);
    switchFlowFactory = new SwitchFlowFactory();
    iofSwitch = createMock(IOFSwitch.class);
    switchDescription = createMock(SwitchDescription.class);
    dpid = DatapathId.of(SWITCH_ID.toLong());
    PathVerificationServiceConfig config = EasyMock.createMock(PathVerificationServiceConfig.class);
    expect(config.getVerificationBcastPacketDst()).andReturn("00:26:E1:FF:FF:FF").anyTimes();
    replay(config);
    PathVerificationService pathVerificationService = EasyMock.createMock(PathVerificationService.class);
    expect(pathVerificationService.getConfig()).andReturn(config).anyTimes();
    replay(pathVerificationService);
    KildaCore kildaCore = EasyMock.createMock(KildaCore.class);
    FloodlightModuleConfigurationProvider provider = FloodlightModuleConfigurationProvider.of(context, KildaCore.class);
    KildaCoreConfig coreConfig = provider.getConfiguration(KildaCoreConfig.class);
    expect(kildaCore.getConfig()).andStubReturn(coreConfig);
    EasyMock.replay(kildaCore);
    context.addService(KildaCore.class, kildaCore);
    SwitchTrackingService switchTracking = createMock(SwitchTrackingService.class);
    switchTracking.setup(context);
    replay(switchTracking);
    context.addService(SwitchTrackingService.class, switchTracking);
    IFloodlightProviderService floodlightProvider = createMock(IFloodlightProviderService.class);
    floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.ERROR), EasyMock.anyObject(SwitchManager.class));
    replay(floodlightProvider);
    context.addService(IFloodlightProviderService.class, floodlightProvider);
    context.addService(IRestApiService.class, restApiService);
    context.addService(IOFSwitchService.class, ofSwitchService);
    context.addService(FeatureDetectorService.class, featureDetectorService);
    context.addService(SwitchFlowFactory.class, switchFlowFactory);
    context.addService(IPathVerificationService.class, pathVerificationService);
    switchManager = new SwitchManager();
    context.addService(ISwitchManager.class, switchManager);
    switchManager.init(context);
    switchManager.startUp(context);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) PathVerificationServiceConfig(org.openkilda.floodlight.pathverification.PathVerificationServiceConfig) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) IFloodlightProviderService(net.floodlightcontroller.core.IFloodlightProviderService) KildaCore(org.openkilda.floodlight.KildaCore) FloodlightModuleConfigurationProvider(org.openkilda.floodlight.config.provider.FloodlightModuleConfigurationProvider) IRestApiService(net.floodlightcontroller.restserver.IRestApiService) PathVerificationService(org.openkilda.floodlight.pathverification.PathVerificationService) IPathVerificationService(org.openkilda.floodlight.pathverification.IPathVerificationService) JdkProxyStaticConfigurationFactory(com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory) MapConfigurationSource(com.sabre.oss.conf4j.source.MapConfigurationSource) KildaCoreConfig(org.openkilda.floodlight.KildaCoreConfig) SwitchDescription(net.floodlightcontroller.core.SwitchDescription) SwitchFlowFactory(org.openkilda.floodlight.switchmanager.factory.SwitchFlowFactory) Before(org.junit.Before)

Example 4 with KildaCore

use of org.openkilda.floodlight.KildaCore in project open-kilda by telstra.

the class PathVerificationPacketInTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    cntx = new FloodlightContext();
    mockFloodlightProvider = getMockFloodlightProvider();
    swFeatures = factory.buildFeaturesReply().setNBuffers(1000).build();
    swDescription = factory.buildDescStatsReply().build();
    FloodlightModuleContext fmc = new FloodlightModuleContext();
    fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
    fmc.addService(IOFSwitchService.class, getMockSwitchService());
    fmc.addService(InputService.class, inputService);
    fmc.addService(IKafkaProducerService.class, producerService);
    fmc.addService(FeatureDetectorService.class, featureDetectorService);
    KildaCore kildaCore = EasyMock.createMock(KildaCore.class);
    fmc.addService(CommandProcessorService.class, new CommandProcessorService(kildaCore, commandContextFactory));
    inputService.setup(fmc);
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    packetInBuilder.setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build()).setData(pkt).setReason(OFPacketInReason.NO_MATCH);
    pktIn = packetInBuilder.build();
    System.out.print(Hex.encodeHexString(pktIn.getData()));
    pvs = new PathVerificationService();
    fmc.addConfigParam(pvs, "isl_bandwidth_quotient", "0.0");
    fmc.addConfigParam(pvs, "hmac256-secret", "secret");
    fmc.addConfigParam(pvs, "bootstrap-servers", "");
    pvs.init(fmc);
    srcIpTarget = new InetSocketAddress("192.168.10.1", 200);
    dstIpTarget = new InetSocketAddress("192.168.10.101", 100);
    sw1HwAddrTarget = "11:22:33:44:55:66";
    sw2HwAddrTarget = "AA:BB:CC:DD:EE:FF";
    OFPortDesc sw1Port1 = EasyMock.createMock(OFPortDesc.class);
    expect(sw1Port1.getHwAddr()).andReturn(MacAddress.of(sw1HwAddrTarget)).anyTimes();
    expect(sw1Port1.getVersion()).andReturn(OFVersion.OF_12).anyTimes();
    expect(sw1Port1.getCurrSpeed()).andReturn(100000L).anyTimes();
    OFPortDesc sw2Port1 = EasyMock.createMock(OFPortDesc.class);
    expect(sw2Port1.getHwAddr()).andReturn(MacAddress.of(sw2HwAddrTarget)).anyTimes();
    expect(sw2Port1.getVersion()).andReturn(OFVersion.OF_12).anyTimes();
    expect(sw2Port1.getCurrSpeed()).andReturn(400000L).anyTimes();
    replay(sw1Port1);
    replay(sw2Port1);
    sw1 = buildMockIoFSwitch(1L, sw1Port1, factory, swDescription, srcIpTarget);
    sw2 = buildMockIoFSwitch(2L, sw2Port1, factory, swDescription, dstIpTarget);
    replay(sw1);
    replay(sw2);
}
Also used : OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) CommandProcessorService(org.openkilda.floodlight.service.CommandProcessorService) InetSocketAddress(java.net.InetSocketAddress) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) KildaCore(org.openkilda.floodlight.KildaCore) Before(org.junit.Before)

Example 5 with KildaCore

use of org.openkilda.floodlight.KildaCore in project open-kilda by telstra.

the class ZooKeeperService method setup.

@Override
public void setup(FloodlightModuleContext moduleContext) throws FloodlightModuleException {
    KafkaChannel kafkaChannel = moduleContext.getServiceImpl(KafkaUtilityService.class).getKafkaChannel();
    region = kafkaChannel.getRegion();
    KildaCore kildaCore = moduleContext.getServiceImpl(KildaCore.class);
    String connectionString = kafkaChannel.getConfig().getZooKeeperConnectString();
    long reconnectDelayMs = kafkaChannel.getConfig().getZooKeeperReconnectDelayMs();
    zkWriter = ZkWriter.builder().id(region).serviceName(ZK_COMPONENT_NAME).connectionString(connectionString).reconnectDelayMs(reconnectDelayMs).expectedState(getExpectedState(kildaCore.getConfig().getRole())).build();
    zooKeeperStateTracker = new ZkStateTracker(zkWriter);
    watchDog = ZkWatchDog.builder().id(region).serviceName(ZK_COMPONENT_NAME).reconnectDelayMs(reconnectDelayMs).connectionString(connectionString).build();
    watchDog.subscribe(this);
    initZookeeper();
}
Also used : ZkStateTracker(org.openkilda.bluegreen.ZkStateTracker) KafkaChannel(org.openkilda.floodlight.KafkaChannel) KafkaUtilityService(org.openkilda.floodlight.service.kafka.KafkaUtilityService) KildaCore(org.openkilda.floodlight.KildaCore)

Aggregations

KildaCore (org.openkilda.floodlight.KildaCore)8 FeatureDetectorService (org.openkilda.floodlight.service.FeatureDetectorService)5 IOFSwitchService (net.floodlightcontroller.core.internal.IOFSwitchService)4 FloodlightModuleContext (net.floodlightcontroller.core.module.FloodlightModuleContext)3 Before (org.junit.Before)3 Properties (java.util.Properties)2 PropertiesBasedConfigurationProvider (org.openkilda.config.provider.PropertiesBasedConfigurationProvider)2 KildaCoreConfig (org.openkilda.floodlight.KildaCoreConfig)2 FloodlightModuleConfigurationProvider (org.openkilda.floodlight.config.provider.FloodlightModuleConfigurationProvider)2 FlowSegmentMetadata (org.openkilda.floodlight.model.FlowSegmentMetadata)2 IPathVerificationService (org.openkilda.floodlight.pathverification.IPathVerificationService)2 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)2 MessageContext (org.openkilda.messaging.MessageContext)2 JdkProxyStaticConfigurationFactory (com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory)1 MapConfigurationSource (com.sabre.oss.conf4j.source.MapConfigurationSource)1 InetSocketAddress (java.net.InetSocketAddress)1 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)1 IFloodlightProviderService (net.floodlightcontroller.core.IFloodlightProviderService)1 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)1