diff options
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip')
4 files changed, 48 insertions, 84 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java index bd2360317..2cec90695 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizer.java @@ -27,6 +27,7 @@ import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv4; @@ -37,8 +38,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev14061 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.address.subnet.PrefixLength; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -125,39 +124,28 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer @Nonnull final String interfaceName, final int interfaceIndex, @Nonnull final Address address, @Nonnull final Netmask subnet) throws WriteFailedException { - try { - LOG.debug("Setting Subnet(subnet-mask) for interface: {}(id={}). Subnet: {}, address: {}", - interfaceName, interfaceIndex, subnet, address); - - final DottedQuad netmask = subnet.getNetmask(); - checkNotNull(netmask, "netmask value should not be null"); - - final byte subnetLength = getSubnetMaskLength(netmask.getValue()); - addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(), subnetLength); - } catch (VppBaseCallException e) { - LOG.warn("Failed to set Subnet(subnet-mask) for interface: {}(id={}). Subnet: {}, address: {}", - interfaceName, interfaceIndex, subnet, address); - throw new WriteFailedException(id, "Unable to handle subnet of type " + subnet.getClass(), e); - } + + LOG.debug("Setting Subnet(subnet-mask) for interface: {}(id={}). Subnet: {}, address: {}", + interfaceName, interfaceIndex, subnet, address); + + final DottedQuad netmask = subnet.getNetmask(); + checkNotNull(netmask, "netmask value should not be null"); + + final byte subnetLength = getSubnetMaskLength(netmask.getValue()); + addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(), subnetLength); } private void setPrefixLengthSubnet(final boolean add, @Nonnull final InstanceIdentifier<Address> id, @Nonnull final String interfaceName, final int interfaceIndex, @Nonnull final Address address, @Nonnull final PrefixLength subnet) throws WriteFailedException { - try { - LOG.debug("Setting Subnet(prefix-length) for interface: {}(id={}). Subnet: {}, address: {}", - interfaceName, interfaceIndex, subnet, address); - - addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(), - subnet.getPrefixLength().byteValue()); - - LOG.debug("Subnet(prefix-length) set successfully for interface: {}(id={}). Subnet: {}, address: {}", - interfaceName, interfaceIndex, subnet, address); - } catch (VppBaseCallException e) { - LOG.warn("Failed to set Subnet(prefix-length) for interface: {}(id={}). Subnet: {}, address: {}", - interfaceName, interfaceIndex, subnet, address); - throw new WriteFailedException(id, "Unable to handle subnet of type " + subnet.getClass(), e); - } + LOG.debug("Setting Subnet(prefix-length) for interface: {}(id={}). Subnet: {}, address: {}", + interfaceName, interfaceIndex, subnet, address); + + addDelAddress(getFutureJVpp(), add, id, interfaceIndex, address.getIp(), + subnet.getPrefixLength().byteValue()); + + LOG.debug("Subnet(prefix-length) set successfully for interface: {}(id={}). Subnet: {}, address: {}", + interfaceName, interfaceIndex, subnet, address); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java index 4bcbf126f..be4ef28cf 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizer.java @@ -27,18 +27,16 @@ import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; import io.fd.honeycomb.translate.vpp.util.NamingContext; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.Ipv4; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Neighbor; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.NeighborKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,13 +73,9 @@ public class Ipv4NeighbourCustomizer extends FutureJVppCustomizer "Mapping does not contains mapping for provider interface name ".concat(interfaceName)); LOG.debug("Parent interface index found"); - try { - addDelNeighbourAndReply(id, true, - interfaceContext.getIndex(interfaceName, mappingContext), dataAfter); - LOG.info("Neighbour successfully written"); - } catch (VppBaseCallException e) { - throw new WriteFailedException.CreateFailedException(id, dataAfter, e); - } + addDelNeighbourAndReply(id, true, + interfaceContext.getIndex(interfaceName, mappingContext), dataAfter); + LOG.info("Neighbour successfully written"); } @Override @@ -107,18 +101,14 @@ public class Ipv4NeighbourCustomizer extends FutureJVppCustomizer "Mapping does not contains mapping for provider interface name %s", interfaceName); LOG.debug("Parent interface[{}] index found", interfaceName); - try { - addDelNeighbourAndReply(id, false, - interfaceContext.getIndex(interfaceName, mappingContext), dataBefore); - LOG.info("Neighbour {} successfully deleted", id); - } catch (VppBaseCallException e) { - throw new WriteFailedException.DeleteFailedException(id, e); - } + + addDelNeighbourAndReply(id, false, + interfaceContext.getIndex(interfaceName, mappingContext), dataBefore); + LOG.info("Neighbour {} successfully deleted", id); } private void addDelNeighbourAndReply(InstanceIdentifier<Neighbor> id, boolean add, int parentInterfaceIndex, - Neighbor data) - throws VppBaseCallException, WriteTimeoutException { + Neighbor data) throws WriteFailedException { IpNeighborAddDel request = new IpNeighborAddDel(); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4Writer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4Writer.java index c823e77b1..788deab3b 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4Writer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4Writer.java @@ -22,16 +22,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; import io.fd.honeycomb.translate.vpp.util.Ipv4Translator; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; -import io.fd.honeycomb.translate.vpp.util.WriteTimeoutException; +import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddress; +import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddressReply; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.concurrent.CompletionStage; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddress; -import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddressReply; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; /** * Utility class providing Ipv4 CUD support. @@ -46,7 +45,7 @@ public interface Ipv4Writer extends ByteDataTranslator, Ipv4Translator, JvppRepl final InstanceIdentifier<?> id, @Nonnegative final int ifaceId, @Nonnull final Ipv4AddressNoZone address, @Nonnegative final byte prefixLength) - throws VppBaseCallException, WriteTimeoutException { + throws WriteFailedException { checkArgument(prefixLength > 0, "Invalid prefix length"); checkNotNull(address, "address should not be null"); diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java index eb8525949..9b786917d 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizer.java @@ -24,6 +24,7 @@ import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.honeycomb.translate.vpp.util.SubInterfaceUtils; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; @@ -36,8 +37,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.ipv4.address.subnet.Netmask; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.ip4.attributes.ipv4.address.subnet.PrefixLength; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -105,40 +104,28 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer @Nonnull final String subInterfaceName, final int subInterfaceIndex, @Nonnull final Address address, @Nonnull final Netmask subnet) throws WriteFailedException { - try { - LOG.debug("Setting Subnet(subnet-mask) for sub-interface: {}(id={}). Subnet: {}, address: {}", - subInterfaceName, subInterfaceIndex, subnet, address); - final DottedQuad netmask = subnet.getNetmask(); - checkNotNull(netmask, "netmask value should not be null"); + LOG.debug("Setting Subnet(subnet-mask) for sub-interface: {}(id={}). Subnet: {}, address: {}", + subInterfaceName, subInterfaceIndex, subnet, address); - final byte subnetLength = getSubnetMaskLength(netmask.getValue()); - addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(), subnetLength); + final DottedQuad netmask = subnet.getNetmask(); + checkNotNull(netmask, "netmask value should not be null"); - } catch (VppBaseCallException e) { - LOG.warn("Failed to set Subnet(subnet-mask) for sub-interface: {}(id={}). Subnet: {}, address: {}", - subInterfaceName, subInterfaceIndex, subnet, address); - throw new WriteFailedException(id, "Unable to handle subnet of type " + subnet.getClass(), e); - } + final byte subnetLength = getSubnetMaskLength(netmask.getValue()); + addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(), subnetLength); } private void setPrefixLengthSubnet(final boolean add, @Nonnull final InstanceIdentifier<Address> id, @Nonnull final String subInterfaceName, final int subInterfaceIndex, @Nonnull final Address address, @Nonnull final PrefixLength subnet) throws WriteFailedException { - try { - LOG.debug("Setting Subnet(prefix-length) for sub-interface: {}(id={}). Subnet: {}, address: {}", - subInterfaceName, subInterfaceIndex, subnet, address); - - addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(), - subnet.getPrefixLength().byteValue()); - - LOG.debug("Subnet(prefix-length) set successfully for sub-interface: {}(id={}). Subnet: {}, address: {}", - subInterfaceName, subInterfaceIndex, subnet, address); - } catch (VppBaseCallException e) { - LOG.warn("Failed to set Subnet(prefix-length) for sub-interface: {}(id={}). Subnet: {}, address: {}", - subInterfaceName, subInterfaceIndex, subnet, address); - throw new WriteFailedException(id, "Unable to handle subnet of type " + subnet.getClass(), e); - } + LOG.debug("Setting Subnet(prefix-length) for sub-interface: {}(id={}). Subnet: {}, address: {}", + subInterfaceName, subInterfaceIndex, subnet, address); + + addDelAddress(getFutureJVpp(), add, id, subInterfaceIndex, address.getIp(), + subnet.getPrefixLength().byteValue()); + + LOG.debug("Subnet(prefix-length) set successfully for sub-interface: {}(id={}). Subnet: {}, address: {}", + subInterfaceName, subInterfaceIndex, subnet, address); } } |