use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports 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.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project netvirt by opendaylight.
the class NetvirtProviderTest method getLogicalInterfacesFromNeutronNetwork.
@Test
public void getLogicalInterfacesFromNeutronNetwork() {
// Network doesnt exist
NeutronNetworkBuilder nwBuilder = new NeutronNetworkBuilder();
nwBuilder.setNetworkUuid(NW_UUID_NOEXIST_STR);
List<String> interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
assertTrue(interfaces.isEmpty());
// Network exists, subnet list empty
createNetworkMap(NW_UUID_STR);
nwBuilder = new NeutronNetworkBuilder();
nwBuilder.setNetworkUuid(NW_UUID_STR);
interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
assertTrue(interfaces.isEmpty());
// Network exists, subnet does not exist
createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, false, EMPTY_STR);
nwBuilder = new NeutronNetworkBuilder();
nwBuilder.setNetworkUuid(NW_UUID_STR);
interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
assertTrue(interfaces.isEmpty());
// Network exists, subnet exists, no ports
createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, true, EMPTY_STR);
nwBuilder = new NeutronNetworkBuilder();
nwBuilder.setNetworkUuid(NW_UUID_STR);
interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
assertTrue(interfaces.isEmpty());
// Network exists, subnet exists, port exists
createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, true, PORT_UUID_STR);
nwBuilder = new NeutronNetworkBuilder();
nwBuilder.setNetworkUuid(NW_UUID_STR);
interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
assertFalse(interfaces.isEmpty());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project netvirt by opendaylight.
the class AclServiceUtils method skipDeleteInCaseOfOverlappingIP.
/**
* Skip delete in case of overlapping IP.
*
* <p>
* When there are multiple ports (e.g., p1, p2, p3) having same AAP (e.g.,
* 224.0.0.5) configured which are part of single SG, there would be single
* flow in remote ACL table. When one of these ports (say p1) is deleted,
* the single flow which is configured in remote ACL table shouldn't be
* deleted. It should be deleted only when there are no more references to
* it.
*
* @param portId the port id
* @param remoteAclId the remote Acl Id
* @param ipPrefix the ip prefix
* @param addOrRemove the add or remove
* @return true, if successful
*/
public boolean skipDeleteInCaseOfOverlappingIP(String portId, Uuid remoteAclId, IpPrefixOrAddress ipPrefix, int addOrRemove) {
boolean skipDelete = false;
if (addOrRemove != NwConstants.DEL_FLOW) {
return skipDelete;
}
AclIpPrefixes aclIpPrefixes = getAclIpPrefixesFromOperDs(remoteAclId.getValue(), ipPrefix);
if (aclIpPrefixes != null && aclIpPrefixes.getPortIds() != null) {
List<String> ignorePorts = Lists.newArrayList(portId);
List<PortIds> portIds = new ArrayList<>(aclIpPrefixes.getPortIds());
// Checking if there are any other ports excluding ignorePorts
long noOfRemotePorts = portIds.stream().map(x -> x.getPortId()).filter(y -> !ignorePorts.contains(y)).count();
if (noOfRemotePorts > 0) {
skipDelete = true;
}
}
return skipDelete;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project netvirt by opendaylight.
the class AclLiveStatisticsRpcServiceTest method getStatsTwoPortBothDirection.
/**
* Test stats for two ports and both direction. <br>
* port1 is valid <br>
* port2 is invalid <br>
* Expectation: Error expected for port2
*
* @throws Exception the exception
*/
@Test
public void getStatsTwoPortBothDirection() throws Exception {
List<String> lstInterfaces = Arrays.asList(PORT_1, PORT_2);
Direction direction = Direction.Both;
GetAclPortStatisticsInput input = new GetAclPortStatisticsInputBuilder().setDirection(direction).setInterfaceNames(lstInterfaces).build();
Future<RpcResult<GetAclPortStatisticsOutput>> rpcResultFuture = aclStatsService.getAclPortStatistics(input);
RpcResult<GetAclPortStatisticsOutput> output = rpcResultFuture.get();
LOG.info("getStatsTwoPortBothDirection output = {}", output);
assertStatsOutput(output, direction);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project netvirt by opendaylight.
the class ExternalNetworksChangeListener method disassociateExternalNetworkFromVPN.
private void disassociateExternalNetworkFromVPN(Networks network, String vpnName) {
List<Uuid> routerIds = network.getRouterIds();
for (Uuid routerId : routerIds) {
InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerId.getValue());
Optional<RouterPorts> optRouterPorts = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
if (!optRouterPorts.isPresent()) {
LOG.debug("disassociateExternalNetworkFromVPN : Could not read Router Ports data object with id: {} " + "to handle disassociate ext nw {}", routerId, network.getId());
continue;
}
RouterPorts routerPorts = optRouterPorts.get();
List<Ports> interfaces = routerPorts.getPorts();
WriteTransaction removeFlowInvTx = dataBroker.newWriteOnlyTransaction();
for (Ports port : interfaces) {
String portName = port.getPortName();
BigInteger dpnId = NatUtil.getDpnForInterface(interfaceManager, portName);
if (dpnId.equals(BigInteger.ZERO)) {
LOG.debug("disassociateExternalNetworkFromVPN : DPN not found for {}," + "skip handling of ext nw {} disassociation", portName, network.getId());
continue;
}
List<InternalToExternalPortMap> intExtPortMapList = port.getInternalToExternalPortMap();
for (InternalToExternalPortMap intExtPortMap : intExtPortMapList) {
floatingIpListener.removeNATFlowEntries(dpnId, portName, vpnName, routerId.getValue(), intExtPortMap, removeFlowInvTx);
}
}
NatUtil.waitForTransactionToComplete(removeFlowInvTx);
}
}
Aggregations