Search in sources :

Example 6 with InterfaceConfig

use of org.onosproject.net.config.basics.InterfaceConfig in project trellis-control by opennetworkinglab.

the class IcmpHandlerTest method setUp.

@Before
public void setUp() {
    // Init
    ObjectMapper mapper = new ObjectMapper();
    ConfigApplyDelegate delegate = config -> {
    };
    // Setup configuration for app
    SegmentRoutingAppConfig appConfig = new SegmentRoutingAppConfig();
    JsonNode appTree = mapper.createObjectNode();
    appConfig.init(testApplicationId, "icmp-handler-test", appTree, mapper, delegate);
    appConfig.setSuppressSubnet(Collections.emptySet());
    // Setup configuration for the devices
    SegmentRoutingDeviceConfig remoteLeafConfig = new SegmentRoutingDeviceConfig();
    JsonNode remoteLeafTree = mapper.createObjectNode();
    remoteLeafConfig.init(REMOTE_LEAF, "icmp-handler-test", remoteLeafTree, mapper, delegate);
    remoteLeafConfig.setNodeSidIPv4(REMOTE_LEAF_SID4).setNodeSidIPv6(REMOTE_LEAF_SID6).setRouterIpv4(REMOTE_LEAF_LB4).setRouterIpv6(REMOTE_LEAF_LB6).setIsEdgeRouter(true).setRouterMac(REMOTE_MAC.toString());
    SegmentRoutingDeviceConfig localLeafConfig = new SegmentRoutingDeviceConfig();
    JsonNode localLeafTree = mapper.createObjectNode();
    localLeafConfig.init(LOCAL_LEAF, "icmp-handler-test", localLeafTree, mapper, delegate);
    localLeafConfig.setNodeSidIPv4(LOCAL_LEAF_SID4).setRouterIpv4(LOCAL_LEAF_LB4).setNodeSidIPv6(LOCAL_LEAF_SID6).setRouterIpv6(LOCAL_LEAF_LB6).setIsEdgeRouter(true).setRouterMac(LOCAL_MAC.toString());
    SegmentRoutingDeviceConfig localLeaf1Config = new SegmentRoutingDeviceConfig();
    JsonNode localLeaf1Tree = mapper.createObjectNode();
    localLeaf1Config.init(LOCAL_LEAF1, "icmp-handler-test", localLeaf1Tree, mapper, delegate);
    localLeaf1Config.setNodeSidIPv4(LOCAL_LEAF1_SID4).setRouterIpv4(LOCAL_LEAF1_LB4).setNodeSidIPv6(LOCAL_LEAF1_SID6).setRouterIpv6(LOCAL_LEAF1_LB6).setIsEdgeRouter(true).setRouterMac(LOCAL_MAC1.toString()).setPairDeviceId(LOCAL_LEAF2).setPairLocalPort(P3);
    SegmentRoutingDeviceConfig localLeaf2Config = new SegmentRoutingDeviceConfig();
    JsonNode localLeaf2Tree = mapper.createObjectNode();
    localLeaf2Config.init(LOCAL_LEAF2, "icmp-handler-test", localLeaf2Tree, mapper, delegate);
    localLeaf2Config.setNodeSidIPv4(LOCAL_LEAF2_SID4).setRouterIpv4(LOCAL_LEAF2_LB4).setNodeSidIPv6(LOCAL_LEAF2_SID6).setRouterIpv6(LOCAL_LEAF2_LB6).setIsEdgeRouter(true).setRouterMac(LOCAL_MAC2.toString()).setPairDeviceId(LOCAL_LEAF1).setPairLocalPort(P3);
    // Setup configuration for ports
    InterfaceConfig remoteLeafPorts1Config = new InterfaceConfig();
    ArrayNode remoteLeafPorts1Tree = mapper.createArrayNode();
    remoteLeafPorts1Config.init(CP12, "icmp-handler-test", remoteLeafPorts1Tree, mapper, delegate);
    remoteLeafPorts1Config.addInterface(INTF1);
    InterfaceConfig remoteLeafPorts2Config = new InterfaceConfig();
    ArrayNode remoteLeafPorts2Tree = mapper.createArrayNode();
    remoteLeafPorts2Config.init(CP13, "icmp-handler-test", remoteLeafPorts2Tree, mapper, delegate);
    remoteLeafPorts2Config.addInterface(INTF2);
    InterfaceConfig localLeafPortsConfig = new InterfaceConfig();
    ArrayNode localLeafPortsTree = mapper.createArrayNode();
    localLeafPortsConfig.init(CP1011, "icmp-handler-test", localLeafPortsTree, mapper, delegate);
    localLeafPortsConfig.addInterface(INTF111);
    InterfaceConfig localLeaf1PortsConfig = new InterfaceConfig();
    ArrayNode localLeaf1PortsTree = mapper.createArrayNode();
    localLeaf1PortsConfig.init(CP2011, "icmp-handler-test", localLeaf1PortsTree, mapper, delegate);
    localLeaf1PortsConfig.addInterface(INTF211);
    InterfaceConfig localLeaf2Ports1Config = new InterfaceConfig();
    ArrayNode localLeaf2Ports1Tree = mapper.createArrayNode();
    localLeaf2Ports1Config.init(CP2021, "icmp-handler-test", localLeaf2Ports1Tree, mapper, delegate);
    localLeaf2Ports1Config.addInterface(INTF212);
    InterfaceConfig localLeaf2Ports2Config = new InterfaceConfig();
    ArrayNode localLeaf2Ports2Tree = mapper.createArrayNode();
    localLeaf2Ports2Config.init(CP2024, "icmp-handler-test", localLeaf2Ports2Tree, mapper, delegate);
    localLeaf2Ports2Config.addInterface(INTF213);
    // Apply config
    MockNetworkConfigRegistry mockNetworkConfigRegistry = new MockNetworkConfigRegistry();
    mockNetworkConfigRegistry.applyConfig(remoteLeafConfig);
    mockNetworkConfigRegistry.applyConfig(remoteLeafPorts1Config);
    mockNetworkConfigRegistry.applyConfig(remoteLeafPorts2Config);
    mockNetworkConfigRegistry.applyConfig(localLeafConfig);
    mockNetworkConfigRegistry.applyConfig(localLeafPortsConfig);
    mockNetworkConfigRegistry.applyConfig(localLeaf1Config);
    mockNetworkConfigRegistry.applyConfig(localLeaf1PortsConfig);
    mockNetworkConfigRegistry.applyConfig(localLeaf2Config);
    mockNetworkConfigRegistry.applyConfig(localLeaf2Ports1Config);
    mockNetworkConfigRegistry.applyConfig(localLeaf2Ports2Config);
    segmentRoutingManager = new SegmentRoutingManager();
    segmentRoutingManager.appId = testApplicationId;
    packetService = new MockPacketService();
    segmentRoutingManager.packetService = packetService;
    segmentRoutingManager.cfgService = mockNetworkConfigRegistry;
    segmentRoutingManager.neighbourResolutionService = new MockNeighbourResolutionService();
    segmentRoutingManager.interfaceService = new MockInterfaceService(ImmutableSet.of(INTF1, INTF2, INTF111, INTF211, INTF212, INTF213));
    segmentRoutingManager.deviceConfiguration = new DeviceConfiguration(segmentRoutingManager);
    segmentRoutingManager.ipHandler = new IpHandler(segmentRoutingManager);
    segmentRoutingManager.deviceService = createMock(DeviceService.class);
    segmentRoutingManager.routeService = new MockRouteService(ROUTE_STORE);
    segmentRoutingManager.hostService = new MockHostService(Collections.emptySet());
    icmpHandler = new IcmpHandler(segmentRoutingManager);
}
Also used : ICMP6(org.onlab.packet.ICMP6) TestApplicationId(org.onosproject.TestApplicationId) InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) DeviceService(org.onosproject.net.device.DeviceService) SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) Ethernet(org.onlab.packet.Ethernet) SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig) ApplicationId(org.onosproject.core.ApplicationId) Is.is(org.hamcrest.core.Is.is) JsonNode(com.fasterxml.jackson.databind.JsonNode) Before(org.junit.Before) ImmutableSet(com.google.common.collect.ImmutableSet) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) ICMP(org.onlab.packet.ICMP) EasyMock(org.easymock.EasyMock) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) IPv6(org.onlab.packet.IPv6) IPv4(org.onlab.packet.IPv4) ECHO_REPLY(org.onlab.packet.ICMP6.ECHO_REPLY) MPLS(org.onlab.packet.MPLS) Assert(org.junit.Assert) TestUtils(org.onosproject.segmentrouting.TestUtils) Collections(java.util.Collections) SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) SegmentRoutingAppConfig(org.onosproject.segmentrouting.config.SegmentRoutingAppConfig) DeviceService(org.onosproject.net.device.DeviceService) JsonNode(com.fasterxml.jackson.databind.JsonNode) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 7 with InterfaceConfig

use of org.onosproject.net.config.basics.InterfaceConfig in project onos by opennetworkinglab.

the class InterfaceManager method add.

@Override
public void add(Interface intf) {
    InterfaceConfig config = configService.addConfig(intf.connectPoint(), CONFIG_CLASS);
    config.addInterface(intf);
    configService.applyConfig(intf.connectPoint(), CONFIG_CLASS, config.node());
}
Also used : InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig)

Example 8 with InterfaceConfig

use of org.onosproject.net.config.basics.InterfaceConfig in project onos by opennetworkinglab.

the class InterfaceManager method activate.

@Activate
public void activate() {
    configService.addListener(listener);
    // TODO address concurrency issues here
    for (ConnectPoint subject : configService.getSubjects(SUBJECT_CLASS, CONFIG_CLASS)) {
        InterfaceConfig config = configService.getConfig(subject, CONFIG_CLASS);
        if (config != null) {
            updateInterfaces(config);
        }
    }
    log.info("Started");
}
Also used : InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) ConnectPoint(org.onosproject.net.ConnectPoint) Activate(org.osgi.service.component.annotations.Activate)

Example 9 with InterfaceConfig

use of org.onosproject.net.config.basics.InterfaceConfig in project onos by opennetworkinglab.

the class InterfaceManagerTest method setUp.

@Before
public void setUp() throws Exception {
    for (int i = 0; i < NUM_INTERFACES; i++) {
        ConnectPoint cp = createConnectPoint(i);
        subjects.add(cp);
        Interface intf = createInterface(i);
        interfaces.add(intf);
        InterfaceConfig ic = new TestInterfaceConfig(cp, Sets.newHashSet(intf));
        configs.put(cp, ic);
    }
    TestNetworkConfigService configService = new TestNetworkConfigService(subjects, configs);
    interfaceManager = new InterfaceManager();
    interfaceManager.configService = configService;
    interfaceManager.activate();
}
Also used : InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) ConnectPoint(org.onosproject.net.ConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint) Interface(org.onosproject.net.intf.Interface) Before(org.junit.Before)

Example 10 with InterfaceConfig

use of org.onosproject.net.config.basics.InterfaceConfig in project trellis-control by opennetworkinglab.

the class DeviceConfigurationTest method setUp.

@Before
public void setUp() throws Exception {
    InterfaceService interfaceService;
    networkConfigService = null;
    NeighbourResolutionService neighbourResolutionService;
    SegmentRoutingManager srManager;
    // Mock device netcfg
    InputStream jsonStream = SegmentRoutingDeviceConfigTest.class.getResourceAsStream("/device.json");
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jsonNode = mapper.readTree(jsonStream);
    SegmentRoutingDeviceConfig srDevConfig = new SegmentRoutingDeviceConfig();
    srDevConfig.init(DEV1, CONFIG_KEY, jsonNode, mapper, config -> {
    });
    BasicDeviceConfig basicDeviceConfig = new BasicDeviceConfig();
    basicDeviceConfig.init(DEV1, DEV1.toString(), JsonNodeFactory.instance.objectNode(), mapper, config -> {
    });
    // Mock interface netcfg
    jsonStream = InterfaceConfig.class.getResourceAsStream("/interface1.json");
    jsonNode = mapper.readTree(jsonStream);
    InterfaceConfig interfaceConfig1 = new InterfaceConfig();
    interfaceConfig1.init(CP1, CONFIG_KEY, jsonNode, mapper, config -> {
    });
    jsonStream = InterfaceConfig.class.getResourceAsStream("/interface2.json");
    jsonNode = mapper.readTree(jsonStream);
    InterfaceConfig interfaceConfig2 = new InterfaceConfig();
    interfaceConfig2.init(CP1, CONFIG_KEY, jsonNode, mapper, config -> {
    });
    jsonStream = BasicHostConfig.class.getResourceAsStream("/host1.json");
    jsonNode = mapper.readTree(jsonStream);
    BasicHostConfig hostConfig1 = new BasicHostConfig();
    hostConfig1.init(ROUTER_HOST, "basic", jsonNode, mapper, config -> {
    });
    networkConfigService = createMock(NetworkConfigRegistry.class);
    expect(networkConfigService.getSubjects(DeviceId.class, SegmentRoutingDeviceConfig.class)).andReturn(Sets.newHashSet(DEV1)).anyTimes();
    expect(networkConfigService.getConfig(DEV1, SegmentRoutingDeviceConfig.class)).andReturn(srDevConfig).anyTimes();
    expect(networkConfigService.addConfig(DEV1, BasicDeviceConfig.class)).andReturn(basicDeviceConfig).anyTimes();
    expect(networkConfigService.getConfig(DEV1, BasicDeviceConfig.class)).andReturn(basicDeviceConfig).anyTimes();
    expect(networkConfigService.getSubjects(ConnectPoint.class, InterfaceConfig.class)).andReturn(Sets.newHashSet(CP1, CP2)).anyTimes();
    expect(networkConfigService.getConfig(CP1, InterfaceConfig.class)).andReturn(interfaceConfig1).anyTimes();
    expect(networkConfigService.getConfig(CP2, InterfaceConfig.class)).andReturn(interfaceConfig2).anyTimes();
    expect(networkConfigService.applyConfig(eq(CP1), eq(InterfaceConfig.class), anyObject())).andReturn(interfaceConfig1).anyTimes();
    expect(networkConfigService.applyConfig(eq(CP2), eq(InterfaceConfig.class), anyObject())).andReturn(interfaceConfig2).anyTimes();
    expect(networkConfigService.getConfig(null, SegmentRoutingAppConfig.class)).andReturn(null).anyTimes();
    expect(networkConfigService.getConfig(ROUTER_HOST, BasicHostConfig.class)).andReturn(hostConfig1).anyTimes();
    expect(networkConfigService.applyConfig(eq(ROUTER_HOST), eq(BasicHostConfig.class), anyObject())).andReturn(hostConfig1).anyTimes();
    replay(networkConfigService);
    interfaceService = createMock(InterfaceService.class);
    expect(interfaceService.getInterfaces()).andReturn(INTERFACES).anyTimes();
    expect(interfaceService.getInterfacesByPort(CP1)).andReturn(Sets.newHashSet(INTF1)).anyTimes();
    expect(interfaceService.getInterfacesByPort(CP2)).andReturn(Sets.newHashSet(INTF2)).anyTimes();
    replay(interfaceService);
    neighbourResolutionService = createMock(NeighbourResolutionService.class);
    neighbourResolutionService.registerNeighbourHandler(anyObject(ConnectPoint.class), anyObject(), anyObject());
    expectLastCall().anyTimes();
    replay(neighbourResolutionService);
    srManager = new SegmentRoutingManager();
    srManager.interfaceService = interfaceService;
    srManager.cfgService = networkConfigService;
    srManager.neighbourResolutionService = neighbourResolutionService;
    devConfig = new DeviceConfiguration(srManager);
    devConfig.addSubnet(CP2, ROUTE1);
}
Also used : InputStream(java.io.InputStream) DeviceId(org.onosproject.net.DeviceId) JsonNode(com.fasterxml.jackson.databind.JsonNode) ConnectPoint(org.onosproject.net.ConnectPoint) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig) BasicHostConfig(org.onosproject.net.config.basics.BasicHostConfig) InterfaceConfig(org.onosproject.net.config.basics.InterfaceConfig) InterfaceService(org.onosproject.net.intf.InterfaceService) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) SegmentRoutingManager(org.onosproject.segmentrouting.SegmentRoutingManager) DeviceConfiguration(org.onosproject.segmentrouting.DeviceConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) NeighbourResolutionService(org.onosproject.net.neighbour.NeighbourResolutionService) Before(org.junit.Before)

Aggregations

InterfaceConfig (org.onosproject.net.config.basics.InterfaceConfig)10 ConnectPoint (org.onosproject.net.ConnectPoint)7 Interface (org.onosproject.net.intf.Interface)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Collections (java.util.Collections)3 Test (org.junit.Test)3 VlanId (org.onlab.packet.VlanId)3 DeviceId (org.onosproject.net.DeviceId)3 ConfigException (org.onosproject.net.config.ConfigException)3 NetworkConfigEvent (org.onosproject.net.config.NetworkConfigEvent)3 InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)3 SegmentRoutingAppConfig (org.onosproject.segmentrouting.config.SegmentRoutingAppConfig)3 SegmentRoutingDeviceConfig (org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 HashMultimap (com.google.common.collect.HashMultimap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Lists (com.google.common.collect.Lists)2 Sets (com.google.common.collect.Sets)2 ArrayList (java.util.ArrayList)2