Search in sources :

Example 16 with Switches

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches in project netvirt by opendaylight.

the class ExternalRoutersListener method handleEnableSnat.

public void handleEnableSnat(Routers routers, long routerId, BigInteger primarySwitchId, long bgpVpnId, WriteTransaction writeFlowInvTx) {
    String routerName = routers.getRouterName();
    LOG.info("handleEnableSnat : Handling SNAT for router {}", routerName);
    naptManager.initialiseExternalCounter(routers, routerId);
    subnetRegisterMapping(routers, routerId);
    LOG.debug("handleEnableSnat:About to create and install outbound miss entry in Primary Switch {} for router {}", primarySwitchId, routerName);
    ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, routers.getNetworkId());
    if (extNwProvType == null) {
        LOG.error("handleEnableSnat : External Network Provider Type missing");
        return;
    }
    if (bgpVpnId != NatConstants.INVALID_ID) {
        installFlowsWithUpdatedVpnId(primarySwitchId, routerName, bgpVpnId, routerId, false, writeFlowInvTx, extNwProvType);
    } else {
        // write metadata and punt
        installOutboundMissEntry(routerName, routerId, primarySwitchId, writeFlowInvTx);
        // Now install entries in SNAT tables to point to Primary for each router
        List<BigInteger> switches = naptSwitchSelector.getDpnsForVpn(routerName);
        for (BigInteger dpnId : switches) {
            // Handle switches and NAPT switches separately
            if (!dpnId.equals(primarySwitchId)) {
                LOG.debug("handleEnableSnat : Handle Ordinary switch");
                handleSwitches(dpnId, routerName, routerId, primarySwitchId);
            } else {
                LOG.debug("handleEnableSnat : Handle NAPT switch");
                handlePrimaryNaptSwitch(dpnId, routerName, routerId, writeFlowInvTx);
            }
        }
    }
    Collection<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerId);
    if (externalIps.isEmpty()) {
        LOG.error("handleEnableSnat : Internal External mapping not found for router {}", routerName);
        return;
    } else {
        for (String externalIpAddrPrefix : externalIps) {
            LOG.debug("handleEnableSnat : Calling handleSnatReverseTraffic for primarySwitchId {}, " + "routerName {} and externalIpAddPrefix {}", primarySwitchId, routerName, externalIpAddrPrefix);
            handleSnatReverseTraffic(primarySwitchId, routers, routerId, routerName, externalIpAddrPrefix, writeFlowInvTx);
        }
    }
    LOG.debug("handleEnableSnat : Exit");
}
Also used : ProviderTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes) BigInteger(java.math.BigInteger)

Example 17 with Switches

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches in project netvirt by opendaylight.

the class TestComparators method compareLogicalSwitches.

public static void compareLogicalSwitches(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
    LogicalSwitchesCmd cmd = new LogicalSwitchesCmd();
    HwvtepGlobalAugmentation d1Aug = d1.getAugmentation(HwvtepGlobalAugmentation.class);
    HwvtepGlobalAugmentation d2Aug = d2.getAugmentation(HwvtepGlobalAugmentation.class);
    HwvtepGlobalAugmentation haAug = ha.getAugmentation(HwvtepGlobalAugmentation.class);
    List<LogicalSwitches> d1Values = d1Aug.getLogicalSwitches() != null ? d1Aug.getLogicalSwitches() : new ArrayList<>();
    List<LogicalSwitches> result1 = cmd.transform(nodePath, d1Values);
    List<LogicalSwitches> d2Values = d2Aug.getLogicalSwitches() != null ? d2Aug.getLogicalSwitches() : new ArrayList<>();
    List<LogicalSwitches> result2 = cmd.transform(nodePath, d2Values);
    // Merge data of both d1 and d2 logical switch info should be same as ha
    Set<LogicalSwitches> set1 = new HashSet<>();
    set1.addAll(result1);
    set1.addAll(result2);
    List<LogicalSwitches> result = cmd.transform(nodePath, haAug.getLogicalSwitches());
    Set<LogicalSwitches> set2 = Sets.newHashSet(result);
    assertEquals("should have equal logical switches", 0, Sets.symmetricDifference(set1, set2).size());
}
Also used : LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) LogicalSwitchesCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.LogicalSwitchesCmd) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) HashSet(java.util.HashSet)

Example 18 with Switches

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches in project genius by opendaylight.

the class HwvtepSouthboundUtils method createLogicalSwitch.

/**
 * Create logical switch.
 *
 * @param name
 *            the name
 * @param desc
 *            the desc
 * @param tunnelKey
 *            the tunnel key
 * @return the logical switches
 */
public static LogicalSwitches createLogicalSwitch(String name, String desc, String tunnelKey, String replicationMode) {
    HwvtepNodeName hwvtepName = new HwvtepNodeName(name);
    LogicalSwitchesBuilder lsBuilder = new LogicalSwitchesBuilder().setHwvtepNodeDescription(desc).setHwvtepNodeName(hwvtepName).setKey(new LogicalSwitchesKey(hwvtepName)).setTunnelKey(tunnelKey);
    if (replicationMode != null && !replicationMode.isEmpty()) {
        lsBuilder.setReplicationMode(replicationMode);
    }
    return lsBuilder.build();
}
Also used : LogicalSwitchesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitchesBuilder) HwvtepNodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName) LogicalSwitchesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitchesKey)

Example 19 with Switches

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches in project genius by opendaylight.

the class HwvtepUtils method getLogicalSwitches.

/**
 * Get LogicalSwitches for a given hwVtepNodeId.
 *
 * @param broker
 *            the broker
 * @param hwVtepNodeId
 *            Hardware VTEP Node Id
 * @param vni
 *            virtual network id
 * @return the logical switches
 */
public static LogicalSwitches getLogicalSwitches(DataBroker broker, String hwVtepNodeId, String vni) {
    NodeId nodeId = new NodeId(hwVtepNodeId);
    InstanceIdentifier<LogicalSwitches> logicalSwitchesIdentifier = HwvtepSouthboundUtils.createLogicalSwitchesInstanceIdentifier(nodeId, new HwvtepNodeName(vni));
    return MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, logicalSwitchesIdentifier).orNull();
}
Also used : LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) HwvtepNodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName)

Aggregations

HwvtepGlobalAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)8 LogicalSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)7 Switches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches)7 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)6 BigInteger (java.math.BigInteger)4 ArrayList (java.util.ArrayList)4 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)2 RouterToNaptSwitch (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch)2 HwvtepNodeName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName)2 HwvtepPhysicalSwitchRef (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalSwitchRef)2 Optional (com.google.common.base.Optional)1 Strings (com.google.common.base.Strings)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 ExecutionException (java.util.concurrent.ExecutionException)1