use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class InterfaceManagerTest method testGetInterfacesByVlan.
@Test
public void testGetInterfacesByVlan() throws Exception {
VlanId vlanId = VlanId.vlanId((short) 1);
Set<Interface> byVlan = Collections.singleton(createInterface(1));
assertEquals(byVlan, interfaceManager.getInterfacesByVlan(vlanId));
}
use of org.onosproject.net.intf.Interface 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();
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class InterfaceCodec method decode.
@Override
public Interface decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
String name = nullIsIllegal(json.findValue(NAME), NAME + MISSING_NAME_MESSAGE).asText();
ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(nullIsIllegal(json.findValue(CONNECT_POINT), CONNECT_POINT + MISSING_CONNECT_POINT_MESSAGE).asText());
List<InterfaceIpAddress> ipAddresses = Lists.newArrayList();
if (json.findValue(IPS) != null) {
json.findValue(IPS).forEach(ip -> {
ipAddresses.add(InterfaceIpAddress.valueOf(ip.asText()));
});
}
MacAddress macAddr = json.findValue(MAC) == null ? null : MacAddress.valueOf(json.findValue(MAC).asText());
VlanId vlanId = json.findValue(VLAN) == null ? VlanId.NONE : VlanId.vlanId(Short.parseShort(json.findValue(VLAN).asText()));
Interface inter = new Interface(name, connectPoint, ipAddresses, macAddr, vlanId);
return inter;
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class VplsIntentTest method tenInterfacesConfiguredHostsPresent.
/**
* Ten ports are configured with VLANs and ten hosts are registered by the
* HostService.
*
* The first three ports have an interface configured on VPLS 1,
* the other three on VPLS 2, two on VPLS3 and two on VPLS4.
*
* The number of intents expected is twenty: six
* for VPLS 1, six for VPLS 2. four for VPLS 3, four for VPLS 4.
* That is ten sp2mp intents, ten mp2sp intents. For VPLS 1
* IPs are added to demonstrate this doesn't influence the number of intents
* created. Checks if the number of intents submitted to the intent
* framework is equal to the number of intents expected and if all intents
* are equivalent.
*/
@Test
public void tenInterfacesConfiguredHostsPresent() {
hostsAvailable.addAll(AVAILABLE_HOSTS);
List<Intent> expectedIntents = Lists.newArrayList();
Set<FilteredConnectPoint> fcPoints;
Set<Host> hosts;
Set<Interface> interfaces;
VplsData vplsData;
Set<Intent> brcIntents;
Set<Intent> uniIntents;
interfaces = ImmutableSet.of(V100H1, V200H1, V300H1);
fcPoints = buildFCPoints(interfaces);
hosts = ImmutableSet.of(V100HOST1, V200HOST1, V300HOST1);
vplsData = createVplsData(VPLS1, VLAN, interfaces);
brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
brcIntents.forEach(intentService::submit);
uniIntents.forEach(intentService::submit);
expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS1, VLAN));
expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS1, VLAN));
interfaces = ImmutableSet.of(V100H2, V200H2, V300H2);
fcPoints = buildFCPoints(interfaces);
hosts = ImmutableSet.of(V100HOST2, V200HOST2, V300HOST2);
vplsData = createVplsData(VPLS2, NONE, interfaces);
brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
brcIntents.forEach(intentService::submit);
uniIntents.forEach(intentService::submit);
expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS2, NONE));
expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS2, NONE));
interfaces = ImmutableSet.of(VNONEH1, VNONEH2);
fcPoints = buildFCPoints(interfaces);
hosts = ImmutableSet.of(VNONEHOST1, VNONEHOST2);
vplsData = createVplsData(VPLS3, NONE, interfaces);
brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
brcIntents.forEach(intentService::submit);
uniIntents.forEach(intentService::submit);
expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS3, NONE));
expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS3, NONE));
interfaces = ImmutableSet.of(V400H1, VNONEH3);
fcPoints = buildFCPoints(interfaces);
hosts = ImmutableSet.of(V400HOST1, VNONEHOST3);
vplsData = createVplsData(VPLS4, NONE, interfaces);
brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
uniIntents = VplsIntentUtility.buildUniIntents(vplsData, hosts, APPID);
brcIntents.forEach(intentService::submit);
uniIntents.forEach(intentService::submit);
expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS4, NONE));
expectedIntents.addAll(generateVplsUni(fcPoints, hosts, VPLS4, NONE));
checkIntents(expectedIntents);
}
use of org.onosproject.net.intf.Interface in project onos by opennetworkinglab.
the class VplsIntentTest method activateNoHosts.
/**
* Seven ports are configured with VLANs, while three ports are not. No hosts are
* registered by the HostService.
*
* The first three ports have an interface configured on VPLS 1,
* the other three on VPLS 2. Two ports are defined for VPLS 3, while
* the two remaining ports are configured on VPLS 4.
*
* The number of intents expected is 10: three for VPLS 1, three for VPLS 2,
* two for VPLS 3, two for VPLS 4. Eight MP2SP intents.
* Checks if the number of intents submitted to the intent framework is
* equal to the number of intents expected and if all intents are equivalent.
*/
@Test
public void activateNoHosts() {
List<Intent> expectedIntents = Lists.newArrayList();
Set<FilteredConnectPoint> fcPoints;
Set<Interface> interfaces;
interfaces = ImmutableSet.of(V100H1, V200H1, V300H1);
VplsData vplsData = createVplsData(VPLS1, VLAN, interfaces);
Set<Intent> brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
brcIntents.forEach(intentService::submit);
fcPoints = buildFCPoints(interfaces);
expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS1, VLAN));
checkIntents(expectedIntents);
interfaces = ImmutableSet.of(V100H2, V200H2, V300H2);
vplsData = createVplsData(VPLS2, NONE, interfaces);
brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
brcIntents.forEach(intentService::submit);
fcPoints = buildFCPoints(interfaces);
expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS2, NONE));
checkIntents(expectedIntents);
interfaces = ImmutableSet.of(VNONEH1, VNONEH2);
vplsData = createVplsData(VPLS3, NONE, interfaces);
brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
brcIntents.forEach(intentService::submit);
fcPoints = buildFCPoints(interfaces);
expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS3, NONE));
checkIntents(expectedIntents);
interfaces = ImmutableSet.of(V400H1, VNONEH3);
vplsData = createVplsData(VPLS4, NONE, interfaces);
brcIntents = VplsIntentUtility.buildBrcIntents(vplsData, APPID);
brcIntents.forEach(intentService::submit);
fcPoints = buildFCPoints(interfaces);
expectedIntents.addAll(generateVplsBrc(fcPoints, VPLS4, NONE));
checkIntents(expectedIntents);
}
Aggregations