use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project netvirt by opendaylight.
the class ElanInterfaceManager method removeElanInterface.
public List<ListenableFuture<Void>> removeElanInterface(ElanInstance elanInfo, String interfaceName, InterfaceInfo interfaceInfo) {
String elanName = elanInfo.getElanInstanceName();
boolean isLastElanInterface = false;
boolean isLastInterfaceOnDpn = false;
BigInteger dpId = null;
long elanTag = elanInfo.getElanTag();
// We use two transaction so we don't suffer on multiple shards (interfaces and flows)
WriteTransaction interfaceTx = broker.newWriteOnlyTransaction();
Elan elanState = removeElanStateForInterface(elanInfo, interfaceName, interfaceTx);
if (elanState == null) {
interfaceTx.cancel();
return Collections.emptyList();
}
WriteTransaction flowTx = broker.newWriteOnlyTransaction();
List<String> elanInterfaces = elanState.getElanInterfaces();
if (elanInterfaces.isEmpty()) {
isLastElanInterface = true;
}
if (interfaceInfo != null) {
dpId = interfaceInfo.getDpId();
DpnInterfaces dpnInterfaces = removeElanDpnInterfaceFromOperationalDataStore(elanName, dpId, interfaceName, elanTag, interfaceTx);
/*
* If there are not elan ports, remove the unknown dmac, terminating
* service table flows, remote/local bc group
*/
if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null || dpnInterfaces.getInterfaces().isEmpty()) {
// No more Elan Interfaces in this DPN
LOG.debug("deleting the elan: {} present on dpId: {}", elanInfo.getElanInstanceName(), dpId);
if (!elanUtils.isOpenstackVniSemanticsEnforced()) {
removeDefaultTermFlow(dpId, elanInfo.getElanTag());
}
removeUnknownDmacFlow(dpId, elanInfo, flowTx, elanInfo.getElanTag());
removeEtreeUnknownDmacFlow(dpId, elanInfo, flowTx);
removeElanBroadcastGroup(elanInfo, interfaceInfo, flowTx);
removeLocalBroadcastGroup(elanInfo, interfaceInfo, flowTx);
removeEtreeBroadcastGrups(elanInfo, interfaceInfo, flowTx);
if (isVxlanNetworkOrVxlanSegment(elanInfo)) {
if (elanUtils.isOpenstackVniSemanticsEnforced()) {
elanUtils.removeTerminatingServiceAction(dpId, elanUtils.getVxlanSegmentationId(elanInfo).intValue());
}
unsetExternalTunnelTable(dpId, elanInfo);
}
isLastInterfaceOnDpn = true;
} else {
setupLocalBroadcastGroups(elanInfo, dpnInterfaces, interfaceInfo);
}
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(ElanUtils.waitForTransactionToComplete(interfaceTx));
futures.add(ElanUtils.waitForTransactionToComplete(flowTx));
if (isLastInterfaceOnDpn && dpId != null && isVxlanNetworkOrVxlanSegment(elanInfo)) {
setElanAndEtreeBCGrouponOtherDpns(elanInfo, dpId);
}
InterfaceRemoveWorkerOnElanInterface removeInterfaceWorker = new InterfaceRemoveWorkerOnElanInterface(interfaceName, elanInfo, interfaceInfo, this, isLastElanInterface);
jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(interfaceName), removeInterfaceWorker, ElanConstants.JOB_MAX_RETRIES);
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project netvirt by opendaylight.
the class PortPairGroupTranslator method buildServiceFunctionForwarder.
public static ServiceFunctionForwarder buildServiceFunctionForwarder(PortPairGroup portPairGroup, List<PortPair> portPairs) {
Preconditions.checkNotNull(portPairGroup, "Port pair group must not be null");
Preconditions.checkNotNull(portPairs, "Port pairs must not be null");
Preconditions.checkElementIndex(0, portPairs.size(), "There must be at least one port pair");
// Currently we only support one SF per type. Mean, one port-pair per port-pair-group.
final PortPair portPair = portPairs.get(0);
ServiceFunctionForwarderBuilder sffBuilder = new ServiceFunctionForwarderBuilder();
sffBuilder.setName(new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME));
DataPlaneLocatorBuilder forwardDplBuilder = new DataPlaneLocatorBuilder();
forwardDplBuilder.setTransport(Mac.class);
String forwardPort = portPair.getIngress().getValue();
LogicalInterface forwardInterface = new LogicalInterfaceBuilder().setInterfaceName(forwardPort).build();
forwardDplBuilder.setLocatorType(forwardInterface);
SffDataPlaneLocatorBuilder sffForwardDplBuilder = new SffDataPlaneLocatorBuilder();
sffForwardDplBuilder.setDataPlaneLocator(forwardDplBuilder.build());
String forwardDplName = portPair.getName() + DPL_INGRESS_SUFFIX;
sffForwardDplBuilder.setName(new SffDataPlaneLocatorName(forwardDplName));
DataPlaneLocatorBuilder reverseDplBuilder = new DataPlaneLocatorBuilder();
reverseDplBuilder.setTransport(Mac.class);
String reversePort = portPair.getEgress().getValue();
LogicalInterface reverseInterface = new LogicalInterfaceBuilder().setInterfaceName(reversePort).build();
reverseDplBuilder.setLocatorType(reverseInterface);
SffDataPlaneLocatorBuilder sffReverseDplBuilder = new SffDataPlaneLocatorBuilder();
sffReverseDplBuilder.setDataPlaneLocator(reverseDplBuilder.build());
String reverseDplName = portPair.getName() + DPL_EGRESS_SUFFIX;
sffReverseDplBuilder.setName(new SffDataPlaneLocatorName(reverseDplName));
List<SffDataPlaneLocator> sffDataPlaneLocator = new ArrayList<>();
sffDataPlaneLocator.add(sffForwardDplBuilder.build());
sffDataPlaneLocator.add(sffReverseDplBuilder.build());
sffBuilder.setSffDataPlaneLocator(sffDataPlaneLocator);
SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder = new SffSfDataPlaneLocatorBuilder();
sffSfDataPlaneLocatorBuilder.setSffForwardDplName(new SffDataPlaneLocatorName(forwardDplName));
sffSfDataPlaneLocatorBuilder.setSfForwardDplName(new SfDataPlaneLocatorName(forwardDplName));
sffSfDataPlaneLocatorBuilder.setSffReverseDplName(new SffDataPlaneLocatorName(reverseDplName));
sffSfDataPlaneLocatorBuilder.setSfReverseDplName(new SfDataPlaneLocatorName(reverseDplName));
ServiceFunctionDictionaryBuilder sfdBuilder = new ServiceFunctionDictionaryBuilder();
sfdBuilder.setName(new SfName(portPair.getName()));
sfdBuilder.setSffSfDataPlaneLocator(sffSfDataPlaneLocatorBuilder.build());
List<ServiceFunctionDictionary> sfdList = new ArrayList<>();
sfdList.add(sfdBuilder.build());
sffBuilder.setServiceFunctionDictionary(sfdList);
return sffBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project netvirt by opendaylight.
the class AclServiceOFFlowBuilder method programIcmpFlow.
/**
*Converts icmp matches to flows.
* @param acl the access control list
* @return the map containing the flows and the respective flow id
*/
public static Map<String, List<MatchInfoBase>> programIcmpFlow(AceIp acl) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
flowMatches.addAll(addSrcIpMatches(acl));
flowMatches.addAll(addDstIpMatches(acl));
// For ICMP port range indicates type and code
SourcePortRange sourcePortRange = acl.getSourcePortRange();
String flowId = "ICMP_";
if (sourcePortRange != null) {
if (acl.getAceIpVersion() instanceof AceIpv4) {
flowMatches.add(new MatchIcmpv4(sourcePortRange.getLowerPort().getValue().shortValue(), sourcePortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V4_SOURCE_" + sourcePortRange.getLowerPort().getValue() + sourcePortRange.getUpperPort().getValue();
} else if (acl.getAceIpVersion() instanceof AceIpv6) {
flowMatches.add(new MatchIcmpv6(sourcePortRange.getLowerPort().getValue().shortValue(), sourcePortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V6_SOURCE_" + sourcePortRange.getLowerPort().getValue() + "_" + sourcePortRange.getUpperPort().getValue() + "_";
}
}
DestinationPortRange destinationPortRange = acl.getDestinationPortRange();
if (destinationPortRange != null) {
if (acl.getAceIpVersion() instanceof AceIpv4) {
flowMatches.add(new MatchIcmpv4(destinationPortRange.getLowerPort().getValue().shortValue(), destinationPortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V4_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_";
} else if (acl.getAceIpVersion() instanceof AceIpv6) {
flowMatches.add(new MatchIcmpv6(destinationPortRange.getLowerPort().getValue().shortValue(), destinationPortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V6_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_";
}
}
if (acl.getAceIpVersion() instanceof AceIpv6 && acl.getProtocol() == NwConstants.IP_PROT_ICMP) {
// We are aligning our implementation similar to Neutron Firewall driver where a Security
// Group rule with "Ethertype as IPv6 and Protocol as icmp" is treated as ICMPV6 SG Rule.
flowMatches.add(new MatchIpProtocol(AclConstants.IP_PROT_ICMPV6));
} else {
flowMatches.add(new MatchIpProtocol(acl.getProtocol()));
}
Map<String, List<MatchInfoBase>> flowMatchesMap = new HashMap<>();
flowMatchesMap.put(flowId, flowMatches);
return flowMatchesMap;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project netvirt by opendaylight.
the class ExternalNetworkGroupInstaller method buildExtNetGroupEntity.
private GroupEntity buildExtNetGroupEntity(String macAddress, String subnetName, long groupId, String extInterface, BigInteger dpnId) {
List<ActionInfo> actionList = new ArrayList<>();
final int setFieldEthDestActionPos = 0;
List<ActionInfo> egressActionList = new ArrayList<>();
if (extInterface != null) {
egressActionList = NatUtil.getEgressActionsForInterface(interfaceManager, extInterface, null, setFieldEthDestActionPos + 1);
}
if (Strings.isNullOrEmpty(macAddress) || egressActionList.isEmpty()) {
if (Strings.isNullOrEmpty(macAddress)) {
LOG.trace("buildExtNetGroupEntity : Building ext-net group {} entry with drop action since " + "GW mac has not been resolved for subnet {} extInterface {}", groupId, subnetName, extInterface);
} else {
LOG.warn("buildExtNetGroupEntity : Building ext-net group {} entry with drop action since " + "no egress actions were found for subnet {} extInterface {}", groupId, subnetName, extInterface);
}
actionList.add(new ActionDrop());
} else {
LOG.trace("Building ext-net group {} entry for subnet {} extInterface {} macAddress {}", groupId, subnetName, extInterface, macAddress);
actionList.add(new ActionSetFieldEthernetDestination(setFieldEthDestActionPos, new MacAddress(macAddress)));
actionList.addAll(egressActionList);
}
List<BucketInfo> listBucketInfo = new ArrayList<>();
listBucketInfo.add(new BucketInfo(actionList));
return MDSALUtil.buildGroupEntity(dpnId, groupId, subnetName, GroupTypes.GroupAll, listBucketInfo);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project netvirt by opendaylight.
the class ExternalRoutersListener method createGroupId.
protected long createGroupId(String groupIdKey) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(NatConstants.SNAT_IDPOOL_NAME).setIdKey(groupIdKey).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
return rpcResult.getResult().getIdValue();
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.error("Exception While allocating id for group: {}", groupIdKey, e);
}
return 0;
}
Aggregations