use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class InterfaceManagerTest method testGetInterfacesByPort.
@Test
public void testGetInterfacesByPort() throws Exception {
ConnectPoint cp = ConnectPoint.deviceConnectPoint("of:0000000000000001/1");
Set<Interface> byPort = Collections.singleton(createInterface(1));
assertEquals(byPort, interfaceManager.getInterfacesByPort(cp));
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class InterfaceManagerTest method testUpdateInterface.
@Test
public void testUpdateInterface() throws Exception {
ConnectPoint cp = createConnectPoint(1);
// Create an interface that is the same as the existing one, but adds a
// new IP address
Interface intf = createInterface(1);
List<InterfaceIpAddress> addresses = Lists.newArrayList(intf.ipAddressesList());
addresses.add(InterfaceIpAddress.valueOf("192.168.100.1/24"));
intf = new Interface(Interface.NO_INTERFACE_NAME, intf.connectPoint(), addresses, intf.mac(), intf.vlan());
// Create a new interface on the same connect point as the existing one
InterfaceIpAddress newAddr = InterfaceIpAddress.valueOf("192.168.101.1/24");
Interface newIntf = new Interface(Interface.NO_INTERFACE_NAME, cp, Collections.singletonList(newAddr), MacAddress.valueOf(101), VlanId.vlanId((short) 101));
Set<Interface> interfaces = Sets.newHashSet(intf, newIntf);
// New interface config updates the existing interface and adds a new
// interface to the same connect point
InterfaceConfig oldIc = new TestInterfaceConfig(cp, Sets.newHashSet(intf));
InterfaceConfig ic = new TestInterfaceConfig(cp, interfaces);
configs.put(cp, ic);
NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_UPDATED, cp, ic, oldIc, CONFIG_CLASS);
// Send in the event signalling the interfaces for this connect point
// have been updated
listener.event(event);
assertEquals(NUM_INTERFACES + 1, interfaceManager.getInterfaces().size());
assertEquals(interfaces, interfaceManager.getInterfacesByPort(cp));
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class InterfaceManagerTest method testGetInterfacesByIp.
@Test
public void testGetInterfacesByIp() throws Exception {
IpAddress ip = Ip4Address.valueOf("192.168.2.1");
Set<Interface> byIp = Collections.singleton(createInterface(2));
assertEquals(byIp, interfaceManager.getInterfacesByIp(ip));
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class InterfaceManagerTest method testAddInterface.
@Test
public void testAddInterface() throws Exception {
// Create a new InterfaceConfig which will get added
VlanId vlanId = VlanId.vlanId((short) 1);
ConnectPoint cp = ConnectPoint.deviceConnectPoint("of:0000000000000001/2");
Interface newIntf = new Interface(Interface.NO_INTERFACE_NAME, cp, Collections.emptyList(), MacAddress.valueOf(100), vlanId);
InterfaceConfig ic = new TestInterfaceConfig(cp, Collections.singleton(newIntf));
subjects.add(cp);
configs.put(cp, ic);
interfaces.add(newIntf);
NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_ADDED, cp, ic, null, CONFIG_CLASS);
assertEquals(NUM_INTERFACES, interfaceManager.getInterfaces().size());
// Send in a config event containing a new interface config
listener.event(event);
// Check the new interface exists in the InterfaceManager's inventory
assertEquals(interfaces, interfaceManager.getInterfaces());
assertEquals(NUM_INTERFACES + 1, interfaceManager.getInterfaces().size());
// There are now two interfaces with vlan ID 1
Set<Interface> byVlan = Sets.newHashSet(createInterface(1), newIntf);
assertEquals(byVlan, interfaceManager.getInterfacesByVlan(vlanId));
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class ReactiveRoutingConfiguration method setUpConfiguration.
/**
* Set up reactive routing information from configuration.
*/
private void setUpConfiguration() {
ReactiveRoutingConfig config = configService.getConfig(coreService.registerApplication(ReactiveRoutingConfigurationService.REACTIVE_ROUTING_APP_ID), ReactiveRoutingConfigurationService.CONFIG_CLASS);
if (config == null) {
log.warn("No reactive routing config available!");
return;
}
for (LocalIpPrefixEntry entry : config.localIp4PrefixEntries()) {
localPrefixTable4.put(createBinaryString(entry.ipPrefix()), entry);
gatewayIpAddresses.add(entry.getGatewayIpAddress());
log.info("adding local IPv4 entry: {} {}", entry.ipPrefix(), entry.getGatewayIpAddress());
}
for (LocalIpPrefixEntry entry : config.localIp6PrefixEntries()) {
localPrefixTable6.put(createBinaryString(entry.ipPrefix()), entry);
gatewayIpAddresses.add(entry.getGatewayIpAddress());
log.info("adding local IPv6 entry: {} {}", entry.ipPrefix(), entry.getGatewayIpAddress());
}
virtualGatewayMacAddress = config.virtualGatewayMacAddress();
log.info("virtual gateway MAC: {}", virtualGatewayMacAddress);
// Setup BGP peer connect points
ApplicationId routerAppId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
if (routerAppId == null) {
log.info("Router application ID is null!");
return;
}
BgpConfig bgpConfig = configService.getConfig(routerAppId, BgpConfig.class);
if (bgpConfig == null) {
log.info("BGP config is null!");
return;
} else {
bgpPeerConnectPoints = bgpConfig.bgpSpeakers().stream().flatMap(speaker -> speaker.peers().stream()).map(peer -> interfaceService.getMatchingInterface(peer)).filter(Objects::nonNull).map(Interface::connectPoint).collect(Collectors.toSet());
}
}
Aggregations