Search in sources :

Example 56 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 DhcpInterfaceEventListener method update.

@Override
public void update(InstanceIdentifier<Interface> identifier, Interface original, Interface update) {
    // We're only interested in Vlan and Tunnel ports
    if (!L2vlan.class.equals(update.getType()) && !Tunnel.class.equals(update.getType())) {
        return;
    }
    if ((original.getOperStatus().getIntValue() ^ update.getOperStatus().getIntValue()) == 0) {
        LOG.trace("Interface operstatus is same orig {} updated {}", original, update);
        return;
    }
    List<String> ofportIds = update.getLowerLayerIf();
    if (ofportIds == null || ofportIds.isEmpty()) {
        return;
    }
    NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
    Uint64 dpnId = DhcpServiceUtils.getDpnIdFromNodeConnectorId(nodeConnectorId);
    String interfaceName = update.getName();
    OperStatus updatedOperStatus = update.getOperStatus();
    if (original.getOperStatus().equals(OperStatus.Up) && updatedOperStatus.equals(OperStatus.Unknown)) {
        updatedOperStatus = OperStatus.Down;
    }
    DhcpInterfaceUpdateJob job = new DhcpInterfaceUpdateJob(dhcpExternalTunnelManager, dataBroker, interfaceName, dpnId, updatedOperStatus, interfaceManager);
    jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) OperStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus) DhcpInterfaceUpdateJob(org.opendaylight.netvirt.dhcpservice.jobs.DhcpInterfaceUpdateJob) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 57 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 DhcpSubnetListener method installDirectPortEntries.

private void installDirectPortEntries(List<Uuid> directPortList) {
    LOG.trace("DhcpSubnetListener installDirectPortEntries : directPortList: {}", directPortList);
    for (Uuid portIntf : directPortList) {
        Port port = dhcpManager.getNeutronPort(portIntf.getValue());
        String vmMacAddress = port.getMacAddress().getValue();
        Uuid networkId = port.getNetworkId();
        // install the entries on designated dpnId
        List<Uint64> listOfDpns = DhcpServiceUtils.getListOfDpns(dataBroker);
        IpAddress tunnelIp = dhcpExternalTunnelManager.getTunnelIpBasedOnElan(networkId.getValue(), vmMacAddress);
        if (null == tunnelIp) {
            LOG.warn("DhcpSubnetListener installDirectPortEntries tunnelIP is null for  port {}", portIntf);
            continue;
        }
        Uint64 designatedDpnId = dhcpExternalTunnelManager.readDesignatedSwitchesForExternalTunnel(tunnelIp, networkId.getValue());
        LOG.trace("CR-DHCP DhcpSubnetListener update Install DIRECT vmMacAddress: {} tunnelIp: {} " + "designatedDpnId : {} ListOf Dpn: {}", vmMacAddress, tunnelIp, designatedDpnId, listOfDpns);
        dhcpExternalTunnelManager.installDhcpFlowsForVms(tunnelIp, networkId.getValue(), listOfDpns, designatedDpnId, vmMacAddress);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 58 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 DhcpSubnetListener method update.

@Override
public void update(InstanceIdentifier<Subnet> identifier, Subnet original, Subnet update) {
    if (!config.isControllerDhcpEnabled()) {
        return;
    }
    LOG.trace("DhcpSubnetListener Update : Original dhcpstatus: {}, Updated dhcpstatus {}", original.isEnableDhcp(), update.isEnableDhcp());
    if (!Objects.equals(original.isEnableDhcp(), update.isEnableDhcp())) {
        // write api to get port list
        SubnetmapBuilder subnetmapBuilder = getSubnetMapBuilder(dataBroker, update.getUuid());
        List<Uuid> portList = subnetmapBuilder.getPortList();
        List<Uuid> directPortList = subnetmapBuilder.getDirectPortList();
        if (update.isEnableDhcp()) {
            if (null != portList) {
                // Install Entries for neutron ports
                installNeutronPortEntries(portList);
            }
            if (null != directPortList) {
                // install Entries for direct ports
                installDirectPortEntries(directPortList);
            }
        } else {
            if (null != portList) {
                // UnInstall Entries for neutron ports
                uninstallNeutronPortEntries(portList);
            }
            if (null != directPortList) {
                // Uninstall Entries for direct ports
                uninstallDirectPortEntries(directPortList);
            }
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) SubnetmapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.SubnetmapBuilder)

Example 59 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 NatUtil method handleSNATForDPN.

@SuppressWarnings("checkstyle:IllegalCatch")
public static void handleSNATForDPN(DataBroker dataBroker, IMdsalApiManager mdsalManager, IdManagerService idManager, NaptSwitchHA naptSwitchHA, Uint64 dpnId, Routers extRouters, Uint32 routerId, Uint32 routerVpnId, TypedReadWriteTransaction<Configuration> confTx, ProviderTypes extNwProvType, UpgradeState upgradeState) {
    // Check if primary and secondary switch are selected, If not select the role
    // Install select group to NAPT switch
    // Install default miss entry to NAPT switch
    Uint64 naptSwitch;
    String routerName = extRouters.getRouterName();
    Boolean upgradeInProgress = false;
    if (upgradeState != null) {
        upgradeInProgress = upgradeState.isUpgradeInProgress();
    }
    Uint64 naptId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerName);
    if (naptId == null || naptId.equals(Uint64.ZERO) || !NatUtil.getSwitchStatus(dataBroker, naptId) && upgradeInProgress == false) {
        LOG.debug("handleSNATForDPN : NaptSwitch is down or not selected for router {},naptId {}", routerName, naptId);
        naptSwitch = dpnId;
        boolean naptstatus = naptSwitchHA.updateNaptSwitch(routerName, naptSwitch);
        if (!naptstatus) {
            LOG.error("handleSNATForDPN : Failed to update newNaptSwitch {} for routername {}", naptSwitch, routerName);
            return;
        }
        LOG.debug("handleSNATForDPN : Switch {} is elected as NaptSwitch for router {}", dpnId, routerName);
        String externalVpnName = null;
        NatUtil.createRouterIdsConfigDS(dataBroker, routerId, routerName);
        naptSwitchHA.subnetRegisterMapping(extRouters, routerId);
        Uuid extNwUuid = extRouters.getNetworkId();
        externalVpnName = NatUtil.getAssociatedVPN(dataBroker, extNwUuid);
        if (externalVpnName != null) {
            naptSwitchHA.installSnatFlows(routerName, routerId, naptSwitch, routerVpnId, extNwUuid, externalVpnName, confTx);
        }
        // Install miss entry (table 26) pointing to table 46
        FlowEntity flowEntity = naptSwitchHA.buildSnatFlowEntityForNaptSwitch(dpnId, routerName, routerVpnId, NatConstants.ADD_FLOW);
        if (flowEntity == null) {
            LOG.error("handleSNATForDPN : Failed to populate flowentity for router {} with dpnId {}", routerName, dpnId);
            return;
        }
        LOG.debug("handleSNATForDPN : Successfully installed flow for dpnId {} router {}", dpnId, routerName);
        mdsalManager.addFlow(confTx, flowEntity);
        // Removing primary flows from old napt switch
        if (naptId != null && !naptId.equals(Uint64.ZERO)) {
            LOG.debug("handleSNATForDPN : Removing primary flows from old napt switch {} for router {}", naptId, routerName);
            try {
                naptSwitchHA.removeSnatFlowsInOldNaptSwitch(extRouters, routerId, naptId, null, externalVpnName, confTx);
            } catch (Exception e) {
                LOG.error("Exception while removing SnatFlows form OldNaptSwitch {}", naptId, e);
            }
        }
        naptSwitchHA.updateNaptSwitchBucketStatus(routerName, routerId, naptSwitch);
    } else if (naptId.equals(dpnId)) {
        LOG.error("handleSNATForDPN : NaptSwitch {} gone down during cluster reboot came alive", naptId);
    } else {
        naptSwitch = naptId;
        LOG.debug("handleSNATForDPN : Napt switch with Id {} is already elected for router {}", naptId, routerName);
        // installing group
        List<BucketInfo> bucketInfo = naptSwitchHA.handleGroupInNeighborSwitches(dpnId, routerName, routerId, naptSwitch);
        naptSwitchHA.installSnatGroupEntry(dpnId, bucketInfo, routerName);
        // Install miss entry (table 26) pointing to group
        Uint32 groupId = NatUtil.getUniqueId(idManager, NatConstants.SNAT_IDPOOL_NAME, NatUtil.getGroupIdKey(routerName));
        if (groupId != NatConstants.INVALID_ID) {
            FlowEntity flowEntity = naptSwitchHA.buildSnatFlowEntity(dpnId, routerName, groupId.longValue(), routerVpnId, NatConstants.ADD_FLOW);
            if (flowEntity == null) {
                LOG.error("handleSNATForDPN : Failed to populate flowentity for router {} with dpnId {}" + " groupId {}", routerName, dpnId, groupId);
                return;
            }
            LOG.debug("handleSNATForDPN : Successfully installed flow for dpnId {} router {} group {}", dpnId, routerName, groupId);
            mdsalManager.addFlow(confTx, flowEntity);
        } else {
            LOG.error("handleSNATForDPN: Unable to get groupId for router:{}", routerName);
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RoutersList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpn.routers.dpn.routers.list.RoutersList) RouterDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.RouterDpnList) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) DpnVpninterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.DpnVpninterfacesList) ArrayList(java.util.ArrayList) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) Collections.emptyList(java.util.Collections.emptyList) DpnRoutersList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.dpn.routers.DpnRoutersList) List(java.util.List) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) TransactionCommitFailedException(org.opendaylight.mdsal.common.api.TransactionCommitFailedException) ExpectedDataObjectNotFoundException(org.opendaylight.genius.datastoreutils.ExpectedDataObjectNotFoundException) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 60 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 UpgradeStateListener method update.

@Override
public void update(@NonNull UpgradeConfig original, UpgradeConfig updated) {
    if (natMode == NatserviceConfig.NatMode.Controller) {
        if (original.isUpgradeInProgress() && !updated.isUpgradeInProgress()) {
            Optional<NaptSwitches> npatSwitches = NatUtil.getAllPrimaryNaptSwitches(dataBroker);
            if (npatSwitches.isPresent()) {
                for (RouterToNaptSwitch routerToNaptSwitch : npatSwitches.get().nonnullRouterToNaptSwitch().values()) {
                    Uint64 primaryNaptDpnId = routerToNaptSwitch.getPrimarySwitchId();
                    if (!NatUtil.getSwitchStatus(dataBroker, routerToNaptSwitch.getPrimarySwitchId())) {
                        String routerUuid = routerToNaptSwitch.getRouterName();
                        coordinator.enqueueJob(NatConstants.NAT_DJC_PREFIX + routerUuid, () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, confTx -> reElectNewNaptSwitch(routerUuid, primaryNaptDpnId, confTx))), NatConstants.NAT_DJC_MAX_RETRIES);
                    }
                }
            }
        }
        return;
    }
    LOG.info("UpgradeStateListener update from {} to {}", original, updated);
    if (!(original.isUpgradeInProgress() && !updated.isUpgradeInProgress())) {
        return;
    }
    SingleTransactionDataBroker reader = new SingleTransactionDataBroker(dataBroker);
    ExtRouters routers;
    try {
        routers = reader.syncRead(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(ExtRouters.class));
    } catch (ReadFailedException e) {
        LOG.error("Error reading external routers", e);
        return;
    }
    for (Routers router : routers.nonnullRouters().values()) {
        Map<ExternalIpsKey, ExternalIps> keyExternalIpsMap = router.nonnullExternalIps();
        if (router.isEnableSnat() && keyExternalIpsMap != null && !keyExternalIpsMap.isEmpty()) {
            centralizedSwitchScheduler.scheduleCentralizedSwitch(router);
        }
    }
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) ExternalIpsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIpsKey) RouterToNaptSwitch(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.napt.switches.RouterToNaptSwitch) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) ExtRouters(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExtRouters) NaptSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.NaptSwitches) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) ExtRouters(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExtRouters) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ExternalIps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps)

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