use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project netvirt by opendaylight.
the class NeutronvpnUtils method getIPPrefixFromPort.
// TODO Clean up the exception handling and the console output
@SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:RegexpSinglelineJava" })
protected Short getIPPrefixFromPort(Port port) {
try {
Uuid subnetUUID = port.getFixedIps().get(0).getSubnetId();
SubnetKey subnetkey = new SubnetKey(subnetUUID);
InstanceIdentifier<Subnet> subnetidentifier = InstanceIdentifier.create(Neutron.class).child(Subnets.class).child(Subnet.class, subnetkey);
Optional<Subnet> subnet = read(LogicalDatastoreType.CONFIGURATION, subnetidentifier);
if (subnet.isPresent()) {
String cidr = String.valueOf(subnet.get().getCidr().getValue());
// Extract the prefix length from cidr
String[] parts = cidr.split("/");
if (parts.length == 2) {
return Short.valueOf(parts[1]);
} else {
LOG.trace("Could not retrieve prefix from subnet CIDR");
}
} else {
LOG.trace("Unable to read on subnet datastore");
}
} catch (Exception e) {
LOG.error("Failed to retrieve IP prefix from port for port {}", port.getUuid().getValue(), e);
}
LOG.error("Failed for port {}", port.getUuid().getValue());
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project openflowplugin by opendaylight.
the class ArpSourceTransportAddressEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final Layer3Match layer3Match = builder.getLayer3Match();
final Ipv4Prefix prefix = readPrefix(message, hasMask);
if (Objects.isNull(layer3Match)) {
builder.setLayer3Match(new ArpMatchBuilder().setArpSourceTransportAddress(prefix).build());
} else if (ArpMatch.class.isInstance(layer3Match) && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpSourceTransportAddress())) {
builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match)).setArpSourceTransportAddress(prefix).build());
} else {
throwErrorOnMalformed(builder, "layer3Match", "arpSourceTransportAddress");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project openflowplugin by opendaylight.
the class AbstractMatchEntryDeserializer method readPrefix.
/**
* Read Ipv4Prefix from message.
* @param message buffered message
* @param hasMask determines if prefix has mask or not
* @return IPv4 prefix
*/
protected static Ipv4Prefix readPrefix(ByteBuf message, boolean hasMask) {
final Ipv4Address address = ByteBufUtils.readIetfIpv4Address(message);
int mask = 32;
if (hasMask) {
mask = IpConversionUtil.countBits(OxmDeserializerHelper.convertMask(message, EncodeConstants.GROUPS_IN_IPV4_ADDRESS));
}
return IpConversionUtil.createPrefix(address, mask);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createMatch1.
private static MatchBuilder createMatch1() {
final MatchBuilder match = new MatchBuilder();
final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
final Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);
ipv4Match.setIpv4Destination(prefix);
final Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
final EthernetMatchBuilder eth = new EthernetMatchBuilder();
final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createMatch2.
private static MatchBuilder createMatch2() {
final MatchBuilder match = new MatchBuilder();
final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
ipv4Match.setIpv4Source(prefix);
final Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
final EthernetMatchBuilder eth = new EthernetMatchBuilder();
final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
return match;
}
Aggregations