use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.
the class ElanUtils method buildRemoteDmacFlowEntry.
/**
* Builds a Flow to be programmed in a remote DPN's DMAC table. This flow
* consists in: Match: + elanTag in packet's metadata + packet going to a
* MAC known to be located in another DPN Actions: + set_tunnel_id
* + output ITM internal tunnel interface with the other DPN
*
* @param srcDpId
* the src Dpn Id
* @param destDpId
* dest Dp Id
* @param lportTagOrVni
* lportTag or network VNI
* @param elanTag
* elan Tag
* @param macAddress
* macAddress
* @param displayName
* display Name
* @param elanInstance
* elanInstance
* @return the flow remote Dmac
*/
@SuppressWarnings("checkstyle:IllegalCatch")
public Flow buildRemoteDmacFlowEntry(BigInteger srcDpId, BigInteger destDpId, long lportTagOrVni, long elanTag, String macAddress, String displayName, ElanInstance elanInstance) {
List<MatchInfo> mkMatches = new ArrayList<>();
mkMatches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanTag), MetaDataUtil.METADATA_MASK_SERVICE));
mkMatches.add(new MatchEthernetDestination(new MacAddress(macAddress)));
List<Instruction> mkInstructions = new ArrayList<>();
// List of Action for the provided Source and Destination DPIDs
try {
List<Action> actions = null;
if (isVlan(elanInstance) || isFlat(elanInstance)) {
String interfaceName = getExternalElanInterface(elanInstance.getElanInstanceName(), srcDpId);
if (null == interfaceName) {
LOG.info("buildRemoteDmacFlowEntry: Could not find interfaceName for {} {}", srcDpId, elanInstance);
}
actions = getEgressActionsForInterface(interfaceName, null);
} else if (isVxlanNetworkOrVxlanSegment(elanInstance)) {
actions = elanItmUtils.getInternalTunnelItmEgressAction(srcDpId, destDpId, lportTagOrVni);
}
mkInstructions.add(MDSALUtil.buildApplyActionsInstruction(actions));
} catch (Exception e) {
LOG.error("Could not get egress actions to add to flow for srcDpId {}, destDpId {}, lportTag/VNI {}", srcDpId, destDpId, lportTagOrVni, e);
}
Flow flow = MDSALUtil.buildFlowNew(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, srcDpId, destDpId, macAddress, elanTag), 20, /* prio */
displayName, 0, /* idleTimeout */
0, /* hardTimeout */
ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), mkMatches, mkInstructions);
return flow;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.
the class ElanServiceProvider method updateExternalElanNetworks.
@Override
public void updateExternalElanNetworks(Node origNode, Node updatedNode) {
if (!bridgeMgr.isIntegrationBridge(updatedNode)) {
return;
}
List<ElanInstance> elanInstances = getElanInstances();
if (elanInstances == null || elanInstances.isEmpty()) {
LOG.trace("No ELAN instances found");
return;
}
LOG.debug("updateExternalElanNetworks, orig bridge {} . updated bridge {}", origNode, updatedNode);
Map<String, String> origProviderMappping = getMapFromOtherConfig(origNode, ElanBridgeManager.PROVIDER_MAPPINGS_KEY);
Map<String, String> updatedProviderMappping = getMapFromOtherConfig(updatedNode, ElanBridgeManager.PROVIDER_MAPPINGS_KEY);
boolean hasDatapathIdOnOrigNode = bridgeMgr.hasDatapathID(origNode);
boolean hasDatapathIdOnUpdatedNode = bridgeMgr.hasDatapathID(updatedNode);
BigInteger origDpnID = bridgeMgr.getDatapathId(origNode);
for (ElanInstance elanInstance : elanInstances) {
String physicalNetworkName = elanInstance.getPhysicalNetworkName();
boolean createExternalElanNw = true;
if (physicalNetworkName != null) {
String origPortName = origProviderMappping.get(physicalNetworkName);
String updatedPortName = updatedProviderMappping.get(physicalNetworkName);
/**
* for internal vlan network, vlan provider interface creation should be
* triggered only if there is existing vlan provider intf indicating presence
* of VM ports on the DPN
*/
if (hasDatapathIdOnOrigNode && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
String externalIntf = getExternalElanInterface(elanInstance.getElanInstanceName(), origDpnID);
if (externalIntf == null) {
createExternalElanNw = false;
}
}
if (hasPortNameRemoved(origPortName, updatedPortName)) {
deleteExternalElanNetwork(elanInstance, bridgeMgr.getProviderInterfaceName(origNode, physicalNetworkName));
}
if (createExternalElanNw && (hasPortNameUpdated(origPortName, updatedPortName) || hasDatapathIdAdded(hasDatapathIdOnOrigNode, hasDatapathIdOnUpdatedNode))) {
createExternalElanNetwork(elanInstance, bridgeMgr.getProviderInterfaceName(updatedNode, physicalNetworkName));
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.
the class ElanServiceProvider method createIetfInterfaces.
/**
* Create ietf-interfaces based on the ELAN segment type.<br>
* For segment type flat - create transparent interface pointing to the
* patch-port attached to the physnet port.<br>
* For segment type vlan - create trunk interface pointing to the patch-port
* attached to the physnet port + trunk-member interface pointing to the
* trunk interface.
*
* @param elanInstance
* ELAN instance
* @param parentRef
* parent interface name
* @return the name of the interface to be added to the ELAN instance i.e.
* trunk-member name for vlan network and transparent for flat
* network or null otherwise
*/
private String createIetfInterfaces(ElanInstance elanInstance, String parentRef) {
String interfaceName = null;
try {
String trunkName = getTrunkInterfaceName(parentRef);
// trunk interface may have been created by other vlan network
Interface trunkInterface = interfaceManager.getInterfaceInfoFromConfigDataStore(trunkName);
if (trunkInterface == null) {
interfaceManager.createVLANInterface(trunkName, parentRef, null, null, IfL2vlan.L2vlanMode.Trunk, true);
}
if (ElanUtils.isFlat(elanInstance)) {
interfaceName = trunkName;
} else if (ElanUtils.isVlan(elanInstance)) {
Long segmentationId = elanInstance.getSegmentationId();
interfaceName = parentRef + IfmConstants.OF_URI_SEPARATOR + segmentationId;
interfaceManager.createVLANInterface(interfaceName, trunkName, segmentationId.intValue(), null, IfL2vlan.L2vlanMode.TrunkMember, true);
}
} catch (InterfaceAlreadyExistsException e) {
LOG.trace("Interface {} was already created", interfaceName);
}
return interfaceName;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.
the class VpnInterfaceManager method processExternalVpnInterface.
private void processExternalVpnInterface(String interfaceName, String vpnName, long vpnId, BigInteger dpId, int lportTag, WriteTransaction writeInvTxn, int addOrRemove) {
Uuid extNetworkId;
try {
// vpn instance of ext-net interface is the network-id
extNetworkId = new Uuid(vpnName);
} catch (IllegalArgumentException e) {
LOG.error("processExternalVpnInterface: VPN instance {} is not Uuid. Processing external vpn interface {}" + " on dpn {} failed", vpnName, interfaceName, dpId);
return;
}
List<Uuid> routerIds = VpnUtil.getExternalNetworkRouterIds(dataBroker, extNetworkId);
if (routerIds == null || routerIds.isEmpty()) {
LOG.info("processExternalVpnInterface: No router is associated with {}." + " Bailing out of processing external vpn interface {} on dpn {} for vpn {}", extNetworkId.getValue(), interfaceName, dpId, vpnName);
return;
}
LOG.info("processExternalVpnInterface: Router-ids {} associated with exernal vpn-interface {} on dpn {}" + " for vpn {}", routerIds, interfaceName, dpId, vpnName);
for (Uuid routerId : routerIds) {
String routerName = routerId.getValue();
BigInteger primarySwitch = VpnUtil.getPrimarySwitchForRouter(dataBroker, routerName);
if (Objects.equals(primarySwitch, dpId)) {
Routers router = VpnUtil.getExternalRouter(dataBroker, routerName);
if (router != null) {
if (addOrRemove == NwConstants.ADD_FLOW) {
vpnManager.addArpResponderFlowsToExternalNetworkIps(routerName, VpnUtil.getIpsListFromExternalIps(router.getExternalIps()), router.getExtGwMacAddress(), dpId, interfaceName, lportTag, writeInvTxn);
} else {
vpnManager.removeArpResponderFlowsToExternalNetworkIps(routerName, VpnUtil.getIpsListFromExternalIps(router.getExternalIps()), dpId, interfaceName, lportTag);
}
} else {
LOG.error("processExternalVpnInterface: No external-router found for router-id {}. Bailing out of" + " processing external vpn-interface {} on dpn {} for vpn {}", routerName, interfaceName, dpId, vpnName);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.dhcp_allocation_pool.rev161214.dhcp_allocation_pool.Network in project netvirt by opendaylight.
the class VpnManagerImpl method setupRouterGwMacFlow.
private void setupRouterGwMacFlow(String routerName, String routerGwMac, BigInteger dpnId, Uuid extNetworkId, WriteTransaction writeTx, RouterGwMacFlowSetupMethod consumer, String operation) {
if (routerGwMac == null) {
LOG.warn("Failed to handle router GW flow in GW-MAC table. MAC address is missing for router-id {}", routerName);
return;
}
if (dpnId == null || BigInteger.ZERO.equals(dpnId)) {
LOG.info("setupRouterGwMacFlow: DPN id is missing for router-id {}", routerName);
return;
}
Uuid vpnId = VpnUtil.getExternalNetworkVpnId(dataBroker, extNetworkId);
if (vpnId == null) {
LOG.warn("Network {} is not associated with VPN", extNetworkId.getValue());
return;
}
LOG.info("{} router GW MAC flow for router-id {} on switch {}", operation, routerName, dpnId);
if (writeTx == null) {
ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> consumer.process(vpnId.getValue(), tx)), LOG, "Commit transaction");
} else {
consumer.process(vpnId.getValue(), writeTx);
}
}
Aggregations