Search in sources :

Example 81 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.

the class QosNeutronNetworkChangeListener method update.

@Override
public void update(InstanceIdentifier<Network> instanceIdentifier, Network original, Network update) {
    qosNeutronUtils.addToNetworkCache(update);
    QosNetworkExtension updateQos = update.augmentation(QosNetworkExtension.class);
    QosNetworkExtension originalQos = original.augmentation(QosNetworkExtension.class);
    if (originalQos == null && updateQos != null) {
        // qosservice policy add
        qosNeutronUtils.addToQosNetworksCache(updateQos.getQosPolicyId(), update);
        qosNeutronUtils.handleNeutronNetworkQosUpdate(update, updateQos.getQosPolicyId());
    } else if (originalQos != null && updateQos != null && !Objects.equals(originalQos.getQosPolicyId(), updateQos.getQosPolicyId())) {
        // qosservice policy update
        qosNeutronUtils.removeFromQosNetworksCache(originalQos.getQosPolicyId(), original);
        qosNeutronUtils.addToQosNetworksCache(updateQos.getQosPolicyId(), update);
        qosNeutronUtils.handleNeutronNetworkQosUpdate(update, updateQos.getQosPolicyId());
    } else if (originalQos != null && updateQos == null) {
        // qosservice policy delete
        qosNeutronUtils.handleNeutronNetworkQosRemove(original, originalQos.getQosPolicyId());
        qosNeutronUtils.removeFromQosNetworksCache(originalQos.getQosPolicyId(), original);
    }
}
Also used : QosNetworkExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.ext.rev160613.QosNetworkExtension)

Example 82 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.

the class AbstractAclServiceImpl method handleRemoteAclUpdate.

protected void handleRemoteAclUpdate(Acl aclBefore, Acl aclAfter, Collection<AclInterface> portsBefore) {
    String aclName = aclAfter.getAclName();
    Collection<AclInterface> interfaceList = aclDataUtil.getInterfaceList(new Uuid(aclName));
    if (interfaceList.isEmpty()) {
        LOG.trace("handleRemoteAclUpdate: No interfaces found with ACL={}", aclName);
        return;
    }
    Set<Uuid> remoteAclsBefore = AclServiceUtils.getRemoteAclIdsByDirection(aclBefore, this.direction);
    Set<Uuid> remoteAclsAfter = AclServiceUtils.getRemoteAclIdsByDirection(aclAfter, this.direction);
    Set<Uuid> remoteAclsAdded = new HashSet<>(remoteAclsAfter);
    remoteAclsAdded.removeAll(remoteAclsBefore);
    Set<Uuid> remoteAclsDeleted = new HashSet<>(remoteAclsBefore);
    remoteAclsDeleted.removeAll(remoteAclsAfter);
    List<FlowEntity> addFlowEntries = new ArrayList<>();
    List<FlowEntity> deleteFlowEntries = new ArrayList<>();
    if (!remoteAclsAdded.isEmpty() || !remoteAclsDeleted.isEmpty()) {
        // delete and add flows in ACL dispatcher table for all applicable ports
        for (AclInterface portBefore : portsBefore) {
            if (portBefore.getDpId() != null) {
                programAclDispatcherTable(deleteFlowEntries, portBefore, NwConstants.DEL_FLOW);
            } else {
                LOG.debug("Skip ACL dispatcher table update as DP ID for interface {} is not present.", portBefore.getInterfaceId());
            }
        }
        for (AclInterface port : interfaceList) {
            programAclDispatcherTable(addFlowEntries, port, NwConstants.ADD_FLOW);
        }
    }
    Set<BigInteger> dpns = interfaceList.stream().filter(port -> {
        if (port.getDpId() == null) {
            LOG.debug("Skip remote ACL table update as DP ID for interface {} is not present.", port.getInterfaceId());
            return false;
        }
        return true;
    }).map(AclInterface::getDpId).collect(Collectors.toSet());
    programRemoteAclTable(deleteFlowEntries, aclName, remoteAclsDeleted, dpns, NwConstants.DEL_FLOW);
    programRemoteAclTable(addFlowEntries, aclName, remoteAclsAdded, dpns, NwConstants.ADD_FLOW);
    programFlows(AclConstants.ACL_JOB_KEY_PREFIX + aclName, deleteFlowEntries, NwConstants.DEL_FLOW);
    programFlows(AclConstants.ACL_JOB_KEY_PREFIX + aclName, addFlowEntries, NwConstants.ADD_FLOW);
}
Also used : AclInterface(org.opendaylight.netvirt.aclservice.api.utils.AclInterface) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) HashSet(java.util.HashSet) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 83 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.

the class NexthopManager method createLocalNextHop.

public long createLocalNextHop(Uint32 vpnId, Uint64 dpnId, String ifName, String primaryIpAddress, String currDestIpPrefix, String gwMacAddress, Uint32 parentVpnId) {
    // For VPN Imported routes, getting VPN Instance name using parentVpnId
    String vpnName = parentVpnId != null ? fibUtil.getVpnNameFromId(parentVpnId) : fibUtil.getVpnNameFromId(vpnId);
    if (vpnName == null) {
        return 0;
    }
    String macAddress = fibUtil.getMacAddressFromPrefix(ifName, vpnName, primaryIpAddress);
    long groupId = createNextHopPointer(getNextHopKey(vpnId, primaryIpAddress));
    if (groupId == 0) {
        LOG.error("Unable to allocate groupId for vpnId {} , IntfName {}, primaryIpAddress {} curIpPrefix {}", vpnId, ifName, primaryIpAddress, currDestIpPrefix);
        return groupId;
    }
    String nextHopLockStr = vpnId + primaryIpAddress;
    String jobKey = FibUtil.getCreateLocalNextHopJobKey(vpnId, dpnId, currDestIpPrefix);
    jobCoordinator.enqueueJob(jobKey, () -> {
        try {
            if (FibUtil.lockCluster(lockManager, nextHopLockStr, WAIT_TIME_TO_ACQUIRE_LOCK)) {
                VpnNexthop nexthop = getVpnNexthop(vpnId, primaryIpAddress);
                LOG.trace("nexthop: {} retrieved for vpnId {}, prefix {}, ifName {} on dpn {}", nexthop, vpnId, primaryIpAddress, ifName, dpnId);
                if (nexthop == null) {
                    String encMacAddress = macAddress == null ? fibUtil.getMacAddressFromPrefix(ifName, vpnName, primaryIpAddress) : macAddress;
                    List<ActionInfo> listActionInfo = new ArrayList<>();
                    int actionKey = 0;
                    // MAC re-write
                    if (encMacAddress != null) {
                        if (gwMacAddress != null) {
                            LOG.trace("The Local NextHop Group Source Mac {} for VpnInterface {} on VPN {}", gwMacAddress, ifName, vpnId);
                            listActionInfo.add(new ActionSetFieldEthernetSource(actionKey++, new MacAddress(gwMacAddress)));
                        }
                        listActionInfo.add(new ActionSetFieldEthernetDestination(actionKey++, new MacAddress(encMacAddress)));
                    // listActionInfo.add(0, new ActionPopMpls());
                    } else {
                        LOG.error("mac address for new local nexthop group {} is null for vpnId {}, prefix {}, " + "ifName {} on dpn {}", groupId, vpnId, primaryIpAddress, ifName, dpnId);
                    }
                    List<ActionInfo> nhActionInfoList = getEgressActionsForInterface(ifName, actionKey, false, vpnId, currDestIpPrefix);
                    if (nhActionInfoList.isEmpty()) {
                        LOG.error("createLocalNextHop: Skipping, Empty list of egress actions received for " + "interface {} on dpn {} for vpn {} prefix {}", ifName, dpnId, vpnId, currDestIpPrefix);
                    }
                    listActionInfo.addAll(nhActionInfoList);
                    BucketInfo bucket = new BucketInfo(listActionInfo);
                    List<BucketInfo> listBucketInfo = new ArrayList<>();
                    listBucketInfo.add(bucket);
                    GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, primaryIpAddress, GroupTypes.GroupAll, listBucketInfo);
                    LOG.trace("Install LNH Group: id {}, mac address {}, interface {} for prefix {}", groupId, encMacAddress, ifName, primaryIpAddress);
                    // Try to install group directly on the DPN bypassing the FRM, in order to avoid waiting for the
                    // group to get installed before programming the flows
                    installGroupOnDpn(groupId, dpnId, primaryIpAddress, listBucketInfo, getNextHopKey(vpnId, primaryIpAddress), GroupTypes.GroupAll);
                    // install Group
                    mdsalApiManager.syncInstallGroup(groupEntity);
                    // update MD-SAL DS
                    addVpnNexthopToDS(dpnId, vpnId, primaryIpAddress, currDestIpPrefix, groupId);
                } else {
                    // Ignore adding new prefix , if it already exists
                    Map<IpAdjacenciesKey, IpAdjacencies> keyIpAdjacenciesMap = nexthop.getIpAdjacencies();
                    IpAdjacencies prefix = new IpAdjacenciesBuilder().setIpAdjacency(currDestIpPrefix).build();
                    if (keyIpAdjacenciesMap != null && keyIpAdjacenciesMap.values().contains(prefix)) {
                        LOG.trace("Prefix {} is already present in l3nextHop {} ", currDestIpPrefix, nexthop);
                    } else {
                        IpAdjacenciesBuilder ipPrefixesBuilder = new IpAdjacenciesBuilder().withKey(new IpAdjacenciesKey(currDestIpPrefix));
                        LOG.trace("Updating prefix {} to vpnNextHop {} Operational DS", currDestIpPrefix, nexthop);
                        MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, getVpnNextHopIpPrefixIdentifier(vpnId, primaryIpAddress, currDestIpPrefix), ipPrefixesBuilder.build());
                    }
                }
            }
        } finally {
            FibUtil.unlockCluster(lockManager, nextHopLockStr);
        }
        return Collections.emptyList();
    });
    return groupId;
}
Also used : IpAdjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.vpnnexthop.IpAdjacencies) IpAdjacenciesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.vpnnexthop.IpAdjacenciesBuilder) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) VpnNexthop(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthop) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) IpAdjacenciesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.vpnnexthop.IpAdjacenciesKey) ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) ActionSetFieldEthernetSource(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource) GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo)

Example 84 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.

the class IfMgr method addHostIntf.

public void addHostIntf(Uuid portId, Uuid snetId, Uuid networkId, IpAddress fixedIp, String macAddress, String deviceOwner) {
    LOG.debug("addHostIntf portId {}, snetId {}, networkId {}, ip {}, mac {}", portId, snetId, networkId, fixedIp, macAddress);
    // Save the interface ipv6 address in its fully expanded format
    Ipv6Address addr = new Ipv6Address(InetAddresses.forString(fixedIp.getIpv6Address().getValue()).getHostAddress());
    fixedIp = new IpAddress(addr);
    VirtualPort intf = VirtualPort.builder().intfUUID(portId).networkID(networkId).macAddress(macAddress).routerIntfFlag(false).deviceOwner(deviceOwner).build();
    intf.setSubnetInfo(snetId, fixedIp);
    VirtualPort prevIntf = vintfs.putIfAbsent(portId, intf);
    if (prevIntf == null) {
        Long elanTag = getNetworkElanTag(networkId);
        final VirtualPort virtIntf = intf;
        String jobKey = Ipv6ServiceUtils.buildIpv6MonitorJobKey(portId.getValue());
        coordinator.enqueueJob(jobKey, () -> {
            // Do service binding for the port and set the serviceBindingStatus to true.
            ipv6ServiceUtils.bindIpv6Service(portId.getValue(), elanTag, NwConstants.IPV6_TABLE);
            virtIntf.setServiceBindingStatus(true);
            /* Update the intf dpnId/ofPort from the Operational Store */
            updateInterfaceDpidOfPortInfo(portId);
            if (Objects.equals(ipV6NAConfigHelper.getNaResponderMode(), Ipv6serviceConfig.NaResponderMode.Switch)) {
                checkIcmpv6NsMatchAndResponderFlow(Uint64.ZERO, 0, virtIntf, Ipv6ServiceConstants.ADD_FLOW);
            }
            return Collections.emptyList();
        });
    } else {
        intf = prevIntf;
        intf.setSubnetInfo(snetId, fixedIp);
    }
    VirtualSubnet snet = getSubnet(snetId);
    if (snet != null) {
        intf.setSubnet(snetId, snet);
    } else {
        addUnprocessed(unprocessedSubnetIntfs, snetId, intf);
    }
}
Also used : IVirtualPort(org.opendaylight.netvirt.ipv6service.api.IVirtualPort) IVirtualSubnet(org.opendaylight.netvirt.ipv6service.api.IVirtualSubnet) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)

Example 85 with Update

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.

the class VpnUtil method updateVpnInstanceOpDataWithVpnType.

public void updateVpnInstanceOpDataWithVpnType(String vpnName, VpnInstance.BgpvpnType bgpvpnType, WriteTransaction writeOperTxn) {
    VpnInstanceOpDataEntry vpnInstanceOpDataEntry = getVpnInstanceOpDataEntryFromVpnName(vpnName);
    if (vpnInstanceOpDataEntry == null) {
        LOG.error("updateVpnInstanceOpDataWithVpnType: VpnInstance {} with BGPVPN Type {} update Failed." + "Since vpnInstanceOpData is not yet ready.", vpnName, bgpvpnType);
        return;
    }
    if (vpnInstanceOpDataEntry.getType() == VpnInstanceOpDataEntry.Type.L2) {
        LOG.error("updateVpnInstanceOpDataWithVpnType: Unable to update the VpnInstance {} with BGPVPN Type {}." + "Since VPN type is L2 flavour. Do Nothing.", vpnName, bgpvpnType);
        return;
    }
    synchronized (vpnName.intern()) {
        VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder().setVrfId(vpnInstanceOpDataEntry.getVrfId());
        builder.setBgpvpnType(VpnInstanceOpDataEntry.BgpvpnType.forValue(bgpvpnType.getIntValue()));
        InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.builder(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(vpnInstanceOpDataEntry.getVrfId())).build();
        writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build());
        LOG.info("updateVpnInstanceOpDataWithVpnType: Successfully updated vpn-instance-op-data with BGPVPN type " + "{} for the Vpn {}", bgpvpnType, vpnName);
    }
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInstanceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryBuilder) VpnInstanceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey)

Aggregations

ArrayList (java.util.ArrayList)119 Test (org.junit.Test)85 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)71 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)64 ExecutionException (java.util.concurrent.ExecutionException)56 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)47 List (java.util.List)45 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)38 Logger (org.slf4j.Logger)38 LoggerFactory (org.slf4j.LoggerFactory)38 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)37 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)35 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)35 Collections (java.util.Collections)34 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)34 Map (java.util.Map)32 Inject (javax.inject.Inject)32 Singleton (javax.inject.Singleton)32 BigInteger (java.math.BigInteger)31 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)29