Search in sources :

Example 46 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project netvirt by opendaylight.

the class NeutronvpnManager method checkAndPublishRouterAssociatedtoVpnNotification.

private void checkAndPublishRouterAssociatedtoVpnNotification(Uuid routerId, Uuid vpnId) throws InterruptedException {
    RouterAssociatedToVpn routerAssociatedToVpn = new RouterAssociatedToVpnBuilder().setRouterId(routerId).setVpnId(vpnId).build();
    LOG.info("publishing notification upon association of router to VPN");
    notificationPublishService.putNotification(routerAssociatedToVpn);
}
Also used : RouterAssociatedToVpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.RouterAssociatedToVpn) RouterAssociatedToVpnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.RouterAssociatedToVpnBuilder)

Example 47 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project netvirt by opendaylight.

the class NeutronvpnManager method removeVpnFromVpnInterface.

protected void removeVpnFromVpnInterface(Uuid vpnId, Port port, WriteTransaction writeConfigTxn, Subnetmap sm) {
    if (vpnId == null || port == null) {
        return;
    }
    String infName = port.getUuid().getValue();
    InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(infName);
    try {
        Optional<VpnInterface> optionalVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
        if (optionalVpnInterface.isPresent()) {
            List<VpnInstanceNames> listVpn = optionalVpnInterface.get().getVpnInstanceNames();
            if (listVpn != null && VpnHelper.doesVpnInterfaceBelongToVpnInstance(vpnId.getValue(), listVpn)) {
                VpnHelper.removeVpnInterfaceVpnInstanceNamesFromList(vpnId.getValue(), listVpn);
            }
            VpnInterfaceBuilder vpnIfBuilder = new VpnInterfaceBuilder(optionalVpnInterface.get()).setVpnInstanceNames(listVpn);
            Adjacencies adjs = vpnIfBuilder.getAugmentation(Adjacencies.class);
            LOG.debug("Updating vpn interface {}", infName);
            List<Adjacency> adjacencyList = adjs != null ? adjs.getAdjacency() : new ArrayList<>();
            Iterator<Adjacency> adjacencyIter = adjacencyList.iterator();
            while (adjacencyIter.hasNext()) {
                Adjacency adjacency = adjacencyIter.next();
                if (adjacency.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
                    continue;
                }
                String mipToQuery = adjacency.getIpAddress().split("/")[0];
                InstanceIdentifier<LearntVpnVipToPort> id = NeutronvpnUtils.buildLearntVpnVipToPortIdentifier(vpnId.getValue(), mipToQuery);
                Optional<LearntVpnVipToPort> optionalVpnVipToPort = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
                if (optionalVpnVipToPort.isPresent()) {
                    LOG.trace("Removing adjacencies from vpninterface {} upon dissociation of router {}", infName, vpnId);
                    if (listVpn == null || listVpn.isEmpty()) {
                        adjacencyIter.remove();
                    }
                    neutronvpnUtils.removeLearntVpnVipToPort(vpnId.getValue(), mipToQuery);
                    LOG.trace("Entry for fixedIP {} for port {} on VPN {} removed from VpnPortFixedIPToPortData", mipToQuery, infName, vpnId.getValue());
                }
            }
            List<FixedIps> ips = port.getFixedIps();
            for (FixedIps ip : ips) {
                String ipValue = String.valueOf(ip.getIpAddress().getValue());
                neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipValue, writeConfigTxn);
            }
            if (listVpn == null || listVpn.isEmpty()) {
                if (sm != null && sm.getRouterId() != null) {
                    removeFromNeutronRouterInterfacesMap(sm.getRouterId(), port.getUuid().getValue());
                }
                deleteVpnInterface(port.getUuid().getValue(), null, /* vpn-id */
                writeConfigTxn);
            } else {
                writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder.build());
            }
        } else {
            LOG.info("removeVpnFromVpnInterface: VPN Interface {} not found", infName);
        }
    } catch (ReadFailedException ex) {
        LOG.error("Update of vpninterface {} failed", infName, ex);
    }
}
Also used : VpnInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceBuilder) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Adjacencies(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.Adjacencies) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps)

Example 48 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project netvirt by opendaylight.

the class NeutronvpnManager method removeExternalVpnInterfaces.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void removeExternalVpnInterfaces(Uuid extNetId) {
    Collection<String> extElanInterfaces = elanService.getExternalElanInterfaces(extNetId.getValue());
    if (extElanInterfaces == null || extElanInterfaces.isEmpty()) {
        LOG.error("No external ports attached for external network {}", extNetId.getValue());
        return;
    }
    try {
        WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
        for (String elanInterface : extElanInterfaces) {
            InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(elanInterface);
            LOG.info("Removing vpn interface {}", elanInterface);
            wrtConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
        }
        wrtConfigTxn.submit();
    } catch (Exception ex) {
        LOG.error("Removal of vpninterfaces {} failed", extElanInterfaces, ex);
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)

Example 49 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project netvirt by opendaylight.

the class NeutronvpnManager method deleteVpnInterface.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected boolean deleteVpnInterface(String infName, @Nullable String vpnId, WriteTransaction wrtConfigTxn) {
    InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(infName);
    Optional<VpnInterface> optionalVpnInterface = null;
    try {
        optionalVpnInterface = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
    } catch (ReadFailedException ex) {
        LOG.error("Error during deletion of vpninterface {}", infName, ex);
        return false;
    }
    if (!optionalVpnInterface.isPresent()) {
        LOG.warn("Deletion of vpninterface {}, optionalVpnInterface is not present()", infName);
        return false;
    }
    boolean wrtConfigTxnPresent = true;
    if (wrtConfigTxn == null) {
        wrtConfigTxnPresent = false;
        wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
    }
    if (vpnId != null) {
        VpnInterface vpnInterface = optionalVpnInterface.get();
        List<VpnInstanceNames> vpnList = vpnInterface.getVpnInstanceNames();
        if (vpnList != null && VpnHelper.doesVpnInterfaceBelongToVpnInstance(vpnId, vpnList)) {
            VpnHelper.removeVpnInterfaceVpnInstanceNamesFromList(vpnId, vpnList);
            if (!vpnList.isEmpty()) {
                if (!wrtConfigTxnPresent) {
                    wrtConfigTxn.submit();
                }
                LOG.debug("Deleting vpn interface {} not immediately since vpnInstanceName " + "List not empty", infName);
                return false;
            }
            VpnInterfaceBuilder vpnIfBuilder = new VpnInterfaceBuilder(optionalVpnInterface.get()).setVpnInstanceNames(vpnList);
            wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder.build());
        }
    }
    LOG.debug("Deleting vpn interface {}", infName);
    wrtConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
    if (!wrtConfigTxnPresent) {
        wrtConfigTxn.submit();
    }
    return true;
}
Also used : VpnInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceBuilder) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames)

Example 50 with Of

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of in project netvirt by opendaylight.

the class OpenFlow13Provider method createIngressClassifierFilterChainEgressFlow.

/*
     * Classifier chain termination flow:
     *     Handle packets at the end of the chain
     *     Match C1 on local IP, NSP and ending NSI, restore metadata and
     *     resubmit to egress dispatcher
     */
public Flow createIngressClassifierFilterChainEgressFlow(NodeId nodeId, long nsp, short egressNsi) {
    MatchBuilder match = new MatchBuilder();
    OpenFlow13Utils.addMatchNsp(match, nsp);
    OpenFlow13Utils.addMatchNsi(match, egressNsi);
    List<Action> actionList = new ArrayList<>();
    actionList.add(OpenFlow13Utils.createActionNxMoveNsc4ToReg6Register(actionList.size()));
    actionList.add(OpenFlow13Utils.createActionNxPopNsh(actionList.size()));
    actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.EGRESS_LPORT_DISPATCHER_TABLE, actionList.size()));
    InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
    String flowIdStr = INGRESS_CLASSIFIER_FILTER_NSH_CHAIN_EGRESS_FLOW_NAME + nodeId.getValue() + "_" + nsp;
    return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_FILTER_TABLE, INGRESS_CLASSIFIER_FILTER_CHAIN_EGRESS_PRIORITY, INGRESS_CLASSIFIER_FILTER_COOKIE, INGRESS_CLASSIFIER_FILTER_NSH_CHAIN_EGRESS_FLOW_NAME, flowIdStr, match, isb).build();
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ArrayList(java.util.ArrayList) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)

Aggregations

ArrayList (java.util.ArrayList)376 Test (org.junit.Test)275 ByteBuf (io.netty.buffer.ByteBuf)262 ExecutionException (java.util.concurrent.ExecutionException)130 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)123 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)121 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)114 InstructionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)100 InstructionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder)99 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)98 ApplyActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder)93 ApplyActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder)91 SetVlanIdActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder)85 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)83 BigInteger (java.math.BigInteger)82 List (java.util.List)82 DropActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder)82 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)82 ControllerActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder)81 DropAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction)81