--- /dev/null
+/*
+ * Copyright (c) 2017 Cisco Systems. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.groupbasedpolicy.renderer.vpp.lisp;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+
+/**
+ * Created by Shakib Ahmed on 6/23/17.
+ */
+public class InterfaceInfo {
+ private String interfaceName;
+ private IpAddress interfaceIp;
+
+ public InterfaceInfo(String interfaceName, IpAddress interfaceIp) {
+ this.interfaceName = interfaceName;
+ this.interfaceIp = interfaceIp;
+ }
+
+ public String getInterfaceName() {
+ return interfaceName;
+ }
+
+ public IpAddress getInterfaceIp() {
+ return interfaceIp;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Cisco Systems. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.mappers;
+
+import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.InterfaceInfo;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+
+import java.util.HashMap;
+
+/**
+ * Created by Shakib Ahmed on 6/23/17.
+ */
+public class HostIdToInterfaceInfoMapper {
+
+ public enum InterfaceType {
+ PUBLIC
+ }
+
+ HashMap<String, HashMap<InterfaceType, InterfaceInfo>> hostIdToInterfaceInfoMapper;
+
+ private HostIdToInterfaceInfoMapper() {
+ hostIdToInterfaceInfoMapper = new HashMap<>();
+ }
+
+ private static final HostIdToInterfaceInfoMapper INSTANCE = new HostIdToInterfaceInfoMapper();
+
+ public static HostIdToInterfaceInfoMapper getInstance() {
+ return INSTANCE;
+ }
+
+ public void addInterfaceInfo(String hostId,
+ InterfaceType interfaceType,
+ String interfaceName,
+ IpAddress interfaceIp) {
+ HashMap<InterfaceType, InterfaceInfo> typeToInterfaceInfoMapper =
+ hostIdToInterfaceInfoMapper.computeIfAbsent(hostId, id -> new HashMap<>());
+
+ typeToInterfaceInfoMapper.put(interfaceType, new InterfaceInfo(interfaceName, interfaceIp));
+ }
+
+ public InterfaceInfo getInterfaceInfo(String hostId, InterfaceType interfaceType) {
+
+ if (!hostIdToInterfaceInfoMapper.containsKey(hostId)) {
+ return null;
+ }
+
+ return hostIdToInterfaceInfoMapper.get(hostId).get(interfaceType);
+ }
+}
import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.LispState;
import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.LispStateManager;
import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.exception.LispNotFoundException;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.mappers.HostIdToInterfaceInfoMapper;
import org.opendaylight.groupbasedpolicy.renderer.vpp.util.GbpNetconfTransaction;
import org.opendaylight.groupbasedpolicy.renderer.vpp.util.LispUtil;
import org.opendaylight.groupbasedpolicy.renderer.vpp.util.MountedDataBrokerProvider;
public ListenableFuture<String> readRlocInterface(@Nonnull String hostName, @Nonnull DataBroker vppDataBroker) {
Preconditions.checkNotNull(hostName, "Hostname is null!");
Preconditions.checkNotNull(vppDataBroker, "Vpp DataBroker is null!");
+
+ String publicInterfaceName = HostIdToInterfaceInfoMapper.getInstance()
+ .getInterfaceInfo(hostName, HostIdToInterfaceInfoMapper.InterfaceType.PUBLIC).getInterfaceName();
+
final Optional<InterfacesState> opInterfaceState = GbpNetconfTransaction.read(vppDataBroker,
LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(InterfacesState.class),
GbpNetconfTransaction.RETRY_COUNT);
if (opInterfaces.isPresent()) {
+
+ List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.
+ interfaces.Interface> hostInterfaceFromOpDS = opInterfaces.get().getInterface();
+
for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.
- interfaces.Interface intf : opInterfaces.get().getInterface()) {
+ interfaces.Interface intf : hostInterfaceFromOpDS) {
if (TENANT_INTERFACE.equals(intf.getDescription())
&& ipAddressPresent(intf)
&& intf.getType().equals(EthernetCsmacd.class)) {
return Futures.immediateFuture(intf.getName());
}
}
+
+ for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.
+ interfaces.Interface intf : hostInterfaceFromOpDS) {
+ if (ipAddressPresent(intf)
+ && intf.getType().equals(EthernetCsmacd.class)
+ && !intf.getName().equalsIgnoreCase(publicInterfaceName)) {
+ return Futures.immediateFuture(intf.getName());
+ }
+ }
}
if (interfaceName == null) {
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.mappers.HostIdToInterfaceInfoMapper;
import org.opendaylight.groupbasedpolicy.renderer.vpp.nat.NatUtil;
import org.opendaylight.groupbasedpolicy.renderer.vpp.util.VppIidFactory;
import org.opendaylight.groupbasedpolicy.renderer.vpp.util.VppRendererProcessingException;
phIface.setInterfaceName(iface.getName());
phIface.setType(iface.getType());
phIface.setAddress(resolveIpAddress(iface.getAugmentation(Interface1.class)));
+
if (extInterfaces.get(nodeId) != null
&& extInterfaces.get(nodeId).getInterfaceName().equals(phIface.getInterfaceName())) {
phIface.setExternal(true);
extInterfaces.put(nodeId, new PhysicalInterfaceKey(iface.getName()));
+ HostIdToInterfaceInfoMapper.getInstance()
+ .addInterfaceInfo(nodeId.getValue(), HostIdToInterfaceInfoMapper.InterfaceType.PUBLIC,
+ phIface.getInterfaceName(), phIface.getAddress().get(0));
LOG.info("Interface {} is marked as public interface based on bundle configuration.",
iface.getName());
}
if (PUBLIC_INTERFACE.equals(iface.getDescription())) {
phIface.setExternal(true);
extInterfaces.put(nodeId, new PhysicalInterfaceKey(iface.getName()));
+ HostIdToInterfaceInfoMapper.getInstance()
+ .addInterfaceInfo(nodeId.getValue(), HostIdToInterfaceInfoMapper.InterfaceType.PUBLIC,
+ phIface.getInterfaceName(), phIface.getAddress().get(0));
LOG.info("Interface {} is marked as public interface based on HC configuration.",
iface.getName());
}