diff options
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/util/SubInterfaceUtils.java')
-rw-r--r-- | v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/util/SubInterfaceUtils.java | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/util/SubInterfaceUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/util/SubInterfaceUtils.java index c673c1023..7b83aafec 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/util/SubInterfaceUtils.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/util/SubInterfaceUtils.java @@ -16,11 +16,18 @@ package io.fd.hc2vpp.v3po.util; +import static com.google.common.base.Preconditions.checkNotNull; + import java.util.List; import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev170315.sub._interface.base.attributes.Tags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev170315.sub._interface.base.attributes.tags.Tag; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev170509.interfaces._interface.sub.interfaces.SubInterface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev170509.sub._interface.base.attributes.Tags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev170509.sub._interface.base.attributes.tags.Tag; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev170509.sub._interface.routing.attributes.Routing; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public final class SubInterfaceUtils { @@ -32,6 +39,22 @@ public final class SubInterfaceUtils { return String.format("%s.%d", superIfName, subIfaceId); } + public static String subInterfaceFullNameConfig(final @Nonnull InstanceIdentifier<Routing> instanceIdentifier) { + final String parentInterfaceName = + checkNotNull(instanceIdentifier.firstKeyOf(Interface.class), "Configuration identifier expected") + .getName(); + final Long subIfId = instanceIdentifier.firstKeyOf(SubInterface.class).getIdentifier(); + return SubInterfaceUtils.getSubInterfaceName(parentInterfaceName, subIfId.intValue()); + } + + public static String subInterfaceFullNameOperational(final @Nonnull InstanceIdentifier<Routing> instanceIdentifier) { + final String parentInterfaceName = checkNotNull(instanceIdentifier.firstKeyOf( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.class), + "Operational identifier expected").getName(); + final Long subIfId = instanceIdentifier.firstKeyOf(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev170509.interfaces.state._interface.sub.interfaces.SubInterface.class).getIdentifier(); + return SubInterfaceUtils.getSubInterfaceName(parentInterfaceName, subIfId.intValue()); + } + /** * Returns number of sub-interface tags. * |