Search in sources :

Example 66 with Router

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router in project netvirt by opendaylight.

the class ArpResponderUtil method getExtInterfaceInstructions.

/**
 * Get instruction list for ARP responder flows originated from ext-net e.g.
 * router-gw/fip.<br>
 * The split-horizon bit should be reset in order to allow traffic from
 * provider network to be routed back to flat/VLAN network and override the
 * egress table drop flow.<br>
 * In order to allow write-metadata in the ARP responder table the resubmit
 * action needs to be replaced with goto instruction.
 */
public static List<Instruction> getExtInterfaceInstructions(IInterfaceManager ifaceMgrRpcService, String extInterfaceName, String ipAddress, String macAddress) {
    AtomicInteger tableId = new AtomicInteger(-1);
    List<Instruction> instructions = new ArrayList<>();
    List<Action> actions = getActions(ifaceMgrRpcService, extInterfaceName, ipAddress, macAddress);
    actions.removeIf(v -> {
        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionClass = v.getAction();
        if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
            tableId.set(((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable());
            return true;
        } else {
            return false;
        }
    });
    instructions.add(MDSALUtil.buildApplyActionsInstruction(actions, 0));
    if (tableId.get() != -1) {
        // write-metadata
        if ((short) tableId.get() > NwConstants.ARP_RESPONDER_TABLE) {
            instructions.add(new InstructionGotoTable((short) tableId.get()).buildInstruction(2));
        } else {
            LOG.warn("Failed to insall responder flow for interface {}. Resubmit to {} can't be replaced with goto", extInterfaceName, tableId);
        }
    }
    return instructions;
}
Also used : NxActionResubmitRpcAddGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.group.input.buckets.bucket.action.action.NxActionResubmitRpcAddGroupCase) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) ArrayList(java.util.ArrayList) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 67 with Router

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router in project netvirt by opendaylight.

the class VPNServiceChainHandler method programVpnToScfPipeline.

/**
 * Programs the necessary flows in LFIB and LPortDispatcher table so that
 * the packets coming from a given VPN are delivered to a given
 * ServiceChain Pipeline.
 *
 * @param vpnName Name of the VPN. Typically the UUID
 * @param tableId Table to which the LPortDispatcher table sends the packet
 *                 to (Uplink or Downlink Subsc table)
 * @param scfTag Scf tag to the SCF to which the Vpn is linked to.
 * @param lportTag VpnPseudo Port lportTag
 * @param addOrRemove States if the VPN2SCF Pipeline must be installed or
 *        removed
 */
public void programVpnToScfPipeline(String vpnName, short tableId, long scfTag, int lportTag, int addOrRemove) {
    // This entries must be created in the DPN where the CGNAT is installed. Since it is not possible
    // to know where CGNAT is located, this entries are installed in all the VPN footprint.
    // LFIB:
    // - Match: cgnatLabel   Instr: lportTag=vpnPseudoPortTag + SI=SCF  +  GOTO 17
    // LportDisp:
    // - Match: vpnPseudoPortTag + SI==SCF   Instr:  scfTag  +  GOTO 70
    LOG.info("programVpnToScfPipeline ({}) : Parameters VpnName:{} tableId:{} scftag:{}  lportTag:{}", addOrRemove == NwConstants.ADD_FLOW ? "Creation" : "Removal", vpnName, tableId, scfTag, lportTag);
    String rd = VpnServiceChainUtils.getVpnRd(dataBroker, vpnName);
    LOG.debug("Router distinguisher (rd):{}", rd);
    if (rd == null || rd.isEmpty()) {
        LOG.warn("programVpnToScfPipeline: Could not find Router-distinguisher for VPN {}. No further actions", vpnName);
        return;
    }
    VpnInstanceOpDataEntry vpnInstance = getVpnInstance(rd);
    if (vpnInstance == null) {
        LOG.warn("Could not find a suitable VpnInstance for Route-Distinguisher={}", rd);
        return;
    }
    // Find out the set of DPNs for the given VPN ID
    Collection<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
    List<VrfEntry> vrfEntries = VpnServiceChainUtils.getAllVrfEntries(dataBroker, rd);
    if (vrfEntries != null) {
        if (addOrRemove == NwConstants.ADD_FLOW) {
            AddVpnPseudoPortDataJob updateVpnToPseudoPortTask = new AddVpnPseudoPortDataJob(dataBroker, rd, lportTag, tableId, (int) scfTag);
            jobCoordinator.enqueueJob(updateVpnToPseudoPortTask.getDsJobCoordinatorKey(), updateVpnToPseudoPortTask);
        } else {
            RemoveVpnPseudoPortDataJob removeVpnPseudoPortDataTask = new RemoveVpnPseudoPortDataJob(dataBroker, rd);
            jobCoordinator.enqueueJob(removeVpnPseudoPortDataTask.getDsJobCoordinatorKey(), removeVpnPseudoPortDataTask);
        }
        for (VpnToDpnList dpnInVpn : vpnToDpnList) {
            BigInteger dpnId = dpnInVpn.getDpnId();
            programVpnToScfPipelineOnDpn(dpnId, vrfEntries, tableId, (int) scfTag, lportTag, addOrRemove);
            if (dpnInVpn.getVpnInterfaces() != null) {
                long vpnId = vpnInstance.getVpnId();
                Flow flow = VpnServiceChainUtils.buildLPortDispFromScfToL3VpnFlow(vpnId, dpnId, lportTag, NwConstants.ADD_FLOW);
                if (addOrRemove == NwConstants.ADD_FLOW) {
                    mdsalManager.installFlow(dpnId, flow);
                } else {
                    mdsalManager.removeFlow(dpnId, flow);
                }
                dpnInVpn.getVpnInterfaces().forEach(vpnIf -> {
                    if (addOrRemove == NwConstants.ADD_FLOW) {
                        bindScfOnVpnInterface(vpnIf.getInterfaceName(), (int) scfTag);
                    } else {
                        unbindScfOnVpnInterface(vpnIf.getInterfaceName());
                    }
                });
            }
        }
    }
}
Also used : VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) BigInteger(java.math.BigInteger) AddVpnPseudoPortDataJob(org.opendaylight.netvirt.cloudservicechain.jobs.AddVpnPseudoPortDataJob) RemoveVpnPseudoPortDataJob(org.opendaylight.netvirt.cloudservicechain.jobs.RemoveVpnPseudoPortDataJob) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 68 with Router

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router in project netvirt by opendaylight.

the class NeutronvpnNatManager method removeRouterFromExternalSubnets.

private void removeRouterFromExternalSubnets(Uuid routerId, Uuid externalNetworkId, List<ExternalFixedIps> externalFixedIps) {
    LOG.debug("Removing routerID {} from external subnets of external network{}", routerId, externalNetworkId);
    List<Subnets> fixedIpsSubnets = getSubnets(getExternalSubnetsUuidsSetForFixedIps(externalFixedIps));
    for (Subnets subnets : fixedIpsSubnets) {
        Uuid subnetId = subnets.getId();
        List<Uuid> routerIds = subnets.getRouterIds();
        if (routerIds != null) {
            if (subnets.getExternalNetworkId() != null && subnets.getExternalNetworkId().equals(externalNetworkId) && routerIds.contains(routerId)) {
                routerIds.remove(routerId);
                LOG.debug("Will remove routerIDs {} from external subnet {} router ID {}", routerIds, subnetId, routerId);
                addExternalSubnet(externalNetworkId, subnetId, routerIds);
            }
        }
    }
}
Also used : ExternalSubnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalSubnets) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.subnets.Subnets) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 69 with Router

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router in project netvirt by opendaylight.

the class NeutronvpnNatManager method handleExternalFixedIpsForRouter.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleExternalFixedIpsForRouter(Router update) {
    Uuid routerId = update.getUuid();
    InstanceIdentifier<Routers> routersIdentifier = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
    try {
        Optional<Routers> optionalRouters = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier);
        LOG.trace("Updating External Fixed IPs Routers node {}", routerId.getValue());
        if (optionalRouters.isPresent()) {
            RoutersBuilder builder = new RoutersBuilder(optionalRouters.get());
            List<ExternalIps> externalIps = new ArrayList<>();
            for (ExternalFixedIps fixedIps : update.getExternalGatewayInfo().getExternalFixedIps()) {
                addExternalFixedIpToExternalIpsList(externalIps, fixedIps);
            }
            builder.setExternalIps(externalIps);
            updateExternalSubnetsForRouter(routerId, update.getExternalGatewayInfo().getExternalNetworkId(), update.getExternalGatewayInfo().getExternalFixedIps());
            Routers routerss = builder.build();
            LOG.trace("Updating external fixed ips for router {} with value {}", routerId.getValue(), routerss);
            SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier, routerss);
            LOG.trace("Added External Fixed IPs successfully for Routers to CONFIG Datastore");
        }
    } catch (TransactionCommitFailedException | ReadFailedException ex) {
        LOG.error("Updating extfixedips for {} in extrouters failed", routerId.getValue(), ex);
    }
}
Also used : ExternalFixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RoutersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.RoutersBuilder) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers) ArrayList(java.util.ArrayList) ExternalIps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps)

Example 70 with Router

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router in project netvirt by opendaylight.

the class NeutronvpnNatManager method removeExternalRouter.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void removeExternalRouter(Router update) {
    Uuid routerId = update.getUuid();
    InstanceIdentifier<Routers> routersIdentifier = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
    try {
        Optional<Routers> optionalRouters = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier);
        LOG.trace(" Removing Routers node {}", routerId.getValue());
        if (optionalRouters.isPresent()) {
            RoutersBuilder builder = new RoutersBuilder(optionalRouters.get());
            builder.setExternalIps(null);
            builder.setSubnetIds(null);
            SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier);
            LOG.trace("Removed router {} from extrouters", routerId.getValue());
        }
    } catch (TransactionCommitFailedException | ReadFailedException ex) {
        LOG.error("Removing extrouter {} from extrouters failed", routerId.getValue(), ex);
    }
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) RoutersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.RoutersBuilder) Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)93 BigInteger (java.math.BigInteger)60 ArrayList (java.util.ArrayList)46 ExecutionException (java.util.concurrent.ExecutionException)27 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)24 Routers (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers)24 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)23 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)21 ProviderTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes)20 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)20 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)19 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)15 ExternalIps (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps)14 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)13 UnknownHostException (java.net.UnknownHostException)12 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)12 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)11 RouterPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)11 List (java.util.List)10 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)10