summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-12-14 06:43:26 +0100
committerMarek Gradzki <mgradzki@cisco.com>2016-12-14 12:29:58 +0100
commit01619036de54215d1d6d03dd033abfc1f9bdfdf5 (patch)
tree2fae299e09d86303c60523c2876eb17a5fb8aa67 /v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java
parentbbdedfea03d7977165c662fdbb9c4df645df3708 (diff)
HONEYCOMB-314: expose tag for tap and vlan interfaces
It is possible that interface creation for will succeed in VPP, but Honeycomb crashes or request timeouts. In such situations, interface name stored in Honeycomb's cache will not be updated. After restarting Honeycomb, interface name will be generated. In such cases Honeycomb user can use tag to identify interface. Change-Id: I673c52e49dc788c761af471399d2ac839f62be04 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java
index 6a918e842..623c7dbfa 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java
@@ -24,6 +24,7 @@ import io.fd.honeycomb.translate.util.RWUtils;
import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails;
import io.fd.vpp.jvpp.core.dto.SwInterfaceVhostUserDetails;
import io.fd.vpp.jvpp.core.dto.SwInterfaceVhostUserDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.SwInterfaceVhostUserDump;
@@ -120,6 +121,9 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
LOG.trace("Vhost user interface: {} attributes returned from VPP: {}", key.getName(),
swInterfaceVhostUserDetails);
+ final SwInterfaceDetails ifcDetails = getVppInterfaceDetails(getFutureJVpp(), id, key.getName(),
+ interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache(), LOG);
+
builder.setRole(swInterfaceVhostUserDetails.isServer == 1
? VhostUserRole.Server
: VhostUserRole.Client);
@@ -129,6 +133,9 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
builder.setVirtioNetHdrSize((long) swInterfaceVhostUserDetails.virtioNetHdrSz);
// TODO: map error code to meaningful message after VPP-436 is done
builder.setConnectError(Integer.toString(swInterfaceVhostUserDetails.sockErrno));
+ if (ifcDetails.tag[0] != 0) { // tag supplied
+ builder.setTag(toString(ifcDetails.tag));
+ }
LOG.debug("Vhost user interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
}
@@ -138,10 +145,16 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
@Nonnull final InstanceIdentifier<VhostUser> id,
@Nonnull final VhostUser readValue,
@Nonnull final ReadContext ctx) {
+ // The tag is set from interface details, those details are retrieved from cache
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ final SwInterfaceDetails ifcDetails =
+ InterfaceCustomizer.getCachedInterfaceDump(ctx.getModificationCache()).get(index);
return Initialized.create(getCfgId(id),
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.VhostUserBuilder()
.setRole(readValue.getRole())
.setSocket(readValue.getSocket())
+ .setTag(ifcDetails.tag[0] == 0 ? null : toString(ifcDetails.tag))
.build());
}