use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.
the class ExternalNetworkManagerTest method testAllocateReleaseIp.
@Test
public void testAllocateReleaseIp() {
IpPrefix cidr = IpPrefix.valueOf("192.168.200.0/24");
target.registerNetwork(cidr);
IpAddress ip = target.allocateIp(cidr);
assertEquals(251, target.getAllIps(cidr).size());
target.releaseIp(cidr, ip);
assertEquals(252, target.getAllIps(cidr).size());
}
use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.
the class ExternalNetworkManagerTest method testObtainGatewayIp.
/**
* Checks if creating and removing a config work well with proper events.
*/
@Test
public void testObtainGatewayIp() {
IpPrefix cidr = IpPrefix.valueOf("192.168.200.0/24");
target.registerNetwork(cidr);
assertEquals(target.getGatewayIp(cidr), IpAddress.valueOf("192.168.200.1"));
}
use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.
the class KubevirtSecurityGroupRuleJsonMatcher method matchesSafely.
@Override
protected boolean matchesSafely(JsonNode jsonNode, Description description) {
// check rule ID
String jsonId = jsonNode.get(ID).asText();
String id = rule.id();
if (!jsonId.equals(id)) {
description.appendText("Rule ID was " + jsonId);
return false;
}
// check security group ID
String jsonSecurityGroupId = jsonNode.get(SECURITY_GROUP_ID).asText();
String securityGroupId = rule.securityGroupId();
if (!jsonSecurityGroupId.equals(securityGroupId)) {
description.appendText("Security group ID was " + jsonSecurityGroupId);
return false;
}
// check direction
String jsonDirection = jsonNode.get(DIRECTION).asText();
String direction = rule.direction();
if (!jsonDirection.equals(direction)) {
description.appendText("Direction was " + jsonDirection);
return false;
}
// check ether type
JsonNode jsonEtherType = jsonNode.get(ETHER_TYPE);
if (jsonEtherType != null) {
String etherType = rule.etherType();
if (!jsonEtherType.asText().equals(etherType)) {
description.appendText("EtherType was " + jsonEtherType);
return false;
}
}
// check port range max
JsonNode jsonPortRangeMax = jsonNode.get(PORT_RANGE_MAX);
if (jsonPortRangeMax != null) {
int portRangeMax = rule.portRangeMax();
if (portRangeMax != jsonPortRangeMax.asInt()) {
description.appendText("PortRangeMax was " + jsonPortRangeMax);
return false;
}
}
// check port range min
JsonNode jsonPortRangeMin = jsonNode.get(PORT_RANGE_MIN);
if (jsonPortRangeMin != null) {
int portRangeMin = rule.portRangeMin();
if (portRangeMin != jsonPortRangeMin.asInt()) {
description.appendText("PortRangeMin was " + jsonPortRangeMin);
return false;
}
}
// check protocol
JsonNode jsonProtocol = jsonNode.get(PROTOCOL);
if (jsonProtocol != null) {
String protocol = rule.protocol();
if (!jsonProtocol.asText().equals(protocol)) {
description.appendText("Protocol was " + jsonProtocol);
return false;
}
}
// check remote IP prefix
JsonNode jsonRemoteIpPrefix = jsonNode.get(REMOTE_IP_PREFIX);
if (jsonRemoteIpPrefix != null) {
IpPrefix remoteIpPrefix = rule.remoteIpPrefix();
if (!jsonRemoteIpPrefix.asText().equals(remoteIpPrefix.toString())) {
description.appendText("Remote IP prefix was " + jsonRemoteIpPrefix);
return false;
}
}
// check remote group ID
JsonNode jsonRemoteGroupId = jsonNode.get(REMOTE_GROUP_ID);
if (jsonRemoteGroupId != null) {
String remoteGroupId = rule.remoteGroupId();
if (!jsonRemoteGroupId.asText().equals(remoteGroupId)) {
description.appendText("Remote group ID was " + jsonRemoteGroupId);
return false;
}
}
return true;
}
use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.
the class DefaultMappingTreatmentTest method testIllegalMulticastTypeConstruction.
/**
* Tests illegal multicast type instruction construction.
*/
@Test(expected = IllegalArgumentException.class)
public void testIllegalMulticastTypeConstruction() {
IpPrefix ip = IpPrefix.valueOf(IP_ADDRESS_1);
MappingAddress address = MappingAddresses.ipv4MappingAddress(ip);
DefaultMappingTreatment.builder().withAddress(address).setMulticastPriority(10).setMulticastWeight(10).setMulticastPriority(20).build();
}
use of org.onlab.packet.IpPrefix in project onos by opennetworkinglab.
the class DefaultMappingTreatmentTest method testEquals.
/**
* Tests equals() method.
*/
@Test
public void testEquals() {
IpPrefix ip1 = IpPrefix.valueOf(IP_ADDRESS_1);
MappingAddress address1 = MappingAddresses.ipv4MappingAddress(ip1);
MappingTreatment treatment1 = DefaultMappingTreatment.builder().withAddress(address1).setUnicastPriority(10).setUnicastWeight(10).build();
MappingTreatment sameAsTreatment1 = DefaultMappingTreatment.builder().withAddress(address1).setUnicastPriority(10).setUnicastWeight(10).build();
IpPrefix ip2 = IpPrefix.valueOf(IP_ADDRESS_2);
MappingAddress address2 = MappingAddresses.ipv4MappingAddress(ip2);
MappingTreatment treatment2 = DefaultMappingTreatment.builder().withAddress(address2).setMulticastPriority(20).setMulticastWeight(20).build();
new EqualsTester().addEqualityGroup(treatment1, sameAsTreatment1).addEqualityGroup(treatment2).testEquals();
}
Aggregations