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");
}
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());
}
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();
}
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();
}
Aggregations