Search in sources :

Example 1 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 ElanInterfaceManager method addElanInterface.

List<ListenableFuture<Void>> addElanInterface(ElanInterface elanInterface, InterfaceInfo interfaceInfo, ElanInstance elanInstance) throws ElanException {
    Preconditions.checkNotNull(elanInstance, "elanInstance cannot be null");
    Preconditions.checkNotNull(interfaceInfo, "interfaceInfo cannot be null");
    Preconditions.checkNotNull(elanInterface, "elanInterface cannot be null");
    String interfaceName = elanInterface.getName();
    String elanInstanceName = elanInterface.getElanInstanceName();
    Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    if (elanInfo == null) {
        List<String> elanInterfaces = new ArrayList<>();
        elanInterfaces.add(interfaceName);
        ElanUtils.updateOperationalDataStore(idManager, elanInstance, elanInterfaces, tx);
    } else {
        createElanStateList(elanInstanceName, interfaceName, tx);
    }
    boolean isFirstInterfaceInDpn = false;
    // Specific actions to the DPN where the ElanInterface has been added,
    // for example, programming the
    // External tunnel table if needed or adding the ElanInterface to the
    // DpnInterfaces in the operational DS.
    BigInteger dpId = interfaceInfo.getDpId();
    DpnInterfaces dpnInterfaces = null;
    if (dpId != null && !dpId.equals(ElanConstants.INVALID_DPN)) {
        InstanceIdentifier<DpnInterfaces> elanDpnInterfaces = ElanUtils.getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId);
        Optional<DpnInterfaces> existingElanDpnInterfaces = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaces);
        if (!existingElanDpnInterfaces.isPresent()) {
            isFirstInterfaceInDpn = true;
            // ELAN's 1st ElanInterface added to this DPN
            dpnInterfaces = createElanInterfacesList(elanInstanceName, interfaceName, dpId, tx);
            // table, but only if Elan has VNI
            if (isVxlanNetworkOrVxlanSegment(elanInstance)) {
                setExternalTunnelTable(dpId, elanInstance);
            }
            elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
        } else {
            List<String> elanInterfaces = existingElanDpnInterfaces.get().getInterfaces();
            elanInterfaces.add(interfaceName);
            if (elanInterfaces.size() == 1) {
                // 1st dpn interface
                elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
            }
            dpnInterfaces = updateElanDpnInterfacesList(elanInstanceName, dpId, elanInterfaces, tx);
        }
    }
    // add code to install Local/Remote BC group, unknow DMAC entry,
    // terminating service table flow entry
    // call bindservice of interfacemanager to create ingress table flow
    // enty.
    // Add interface to the ElanInterfaceForwardingEntires Container
    createElanInterfaceTablesList(interfaceName, tx);
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    futures.add(ElanUtils.waitForTransactionToComplete(tx));
    installEntriesForFirstInterfaceonDpn(elanInstance, interfaceInfo, dpnInterfaces, isFirstInterfaceInDpn);
    // for internal vlan networks
    if (ElanUtils.isVlan(elanInstance) && !elanInstance.isExternal()) {
        if (interfaceManager.isExternalInterface(interfaceName)) {
            LOG.debug("adding vlan prv intf {} to elan {} BC group", interfaceName, elanInstanceName);
            handleExternalInterfaceEvent(elanInstance, dpnInterfaces, dpId);
        }
    }
    if (isFirstInterfaceInDpn && isVxlanNetworkOrVxlanSegment(elanInstance)) {
        // update the remote-DPNs remoteBC group entry with Tunnels
        LOG.trace("update remote bc group for elan {} on other DPNs for newly added dpn {}", elanInstance, dpId);
        setElanAndEtreeBCGrouponOtherDpns(elanInstance, dpId);
    }
    String jobKey = ElanUtils.getElanInterfaceJobKey(interfaceName);
    InterfaceAddWorkerOnElanInterface addWorker = new InterfaceAddWorkerOnElanInterface(jobKey, elanInterface, interfaceInfo, elanInstance, isFirstInterfaceInDpn, this);
    jobCoordinator.enqueueJob(jobKey, addWorker, ElanConstants.JOB_MAX_RETRIES);
    return futures;
}
Also used : ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ArrayList(java.util.ArrayList) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 2 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 ElanBridgeManager method generateRandomMac.

private String generateRandomMac() {
    byte[] macBytes = new byte[6];
    random.nextBytes(macBytes);
    // the two low bits of the first byte need to be zero
    macBytes[0] &= 0xfc;
    StringBuilder stringBuilder = new StringBuilder();
    int index = 0;
    while (true) {
        stringBuilder.append(String.format("%02x", macBytes[index++]));
        if (index >= 6) {
            break;
        }
        stringBuilder.append(':');
    }
    return stringBuilder.toString();
}
Also used : TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 3 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 NodeConnectedHandler method copyHANodeConfigToChild.

/**
 * Copy HA global node data to Child HA node of config data tree .
 *
 * @param srcNode Node which to be transformed
 * @param childPath Path to which source node will be transformed
 * @param tx Transaction
 */
private void copyHANodeConfigToChild(Node srcNode, InstanceIdentifier<Node> childPath, ReadWriteTransaction tx) {
    if (srcNode == null) {
        return;
    }
    HwvtepGlobalAugmentation src = srcNode.getAugmentation(HwvtepGlobalAugmentation.class);
    if (src == null) {
        return;
    }
    NodeBuilder nodeBuilder = HwvtepHAUtil.getNodeBuilderForPath(childPath);
    HwvtepGlobalAugmentationBuilder dstBuilder = new HwvtepGlobalAugmentationBuilder();
    globalAugmentationMerger.mergeConfigData(dstBuilder, src, childPath);
    globalNodeMerger.mergeConfigData(nodeBuilder, srcNode, childPath);
    nodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, dstBuilder.build());
    Node dstNode = nodeBuilder.build();
    tx.put(CONFIGURATION, childPath, dstNode, WriteTransaction.CREATE_MISSING_PARENTS);
}
Also used : HwvtepGlobalAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)

Example 4 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 NodeConnectedHandler method copyChildOpToHA.

/**
 * Copy HA child node to HA node of Operational data tree.
 *
 * @param childNode HA Child Node
 * @param haNodePath HA node path
 * @param tx Transaction
 * @throws ReadFailedException  Exception thrown if read fails
 */
private void copyChildOpToHA(Node childNode, InstanceIdentifier<Node> haNodePath, ReadWriteTransaction tx) throws ReadFailedException {
    if (childNode == null) {
        return;
    }
    HwvtepGlobalAugmentation childData = childNode.getAugmentation(HwvtepGlobalAugmentation.class);
    if (childData == null) {
        return;
    }
    NodeBuilder haNodeBuilder = HwvtepHAUtil.getNodeBuilderForPath(haNodePath);
    HwvtepGlobalAugmentationBuilder haBuilder = new HwvtepGlobalAugmentationBuilder();
    Optional<Node> existingHANodeOptional = tx.read(OPERATIONAL, haNodePath).checkedGet();
    Node existingHANode = existingHANodeOptional.isPresent() ? existingHANodeOptional.get() : null;
    HwvtepGlobalAugmentation existingHAData = HwvtepHAUtil.getGlobalAugmentationOfNode(existingHANode);
    globalAugmentationMerger.mergeOperationalData(haBuilder, existingHAData, childData, haNodePath);
    globalNodeMerger.mergeOperationalData(haNodeBuilder, existingHANode, childNode, haNodePath);
    haBuilder.setManagers(HwvtepHAUtil.buildManagersForHANode(childNode, existingHANodeOptional));
    haBuilder.setSwitches(HwvtepHAUtil.buildSwitchesForHANode(childNode, haNodePath, existingHANodeOptional));
    haBuilder.setDbVersion(childData.getDbVersion());
    haNodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, haBuilder.build());
    Node haNode = haNodeBuilder.build();
    tx.merge(OPERATIONAL, haNodePath, haNode, true);
}
Also used : HwvtepGlobalAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)

Example 5 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 NodeConnectedHandler method copyHAPSConfigToChildPS.

/**
 * Copy HA physical switch data to Child Physical switch node of config data tree.
 *
 * @param haPsNode HA physical Switch Node
 * @param childPath HA Child Node path
 * @param tx Transaction
 */
public void copyHAPSConfigToChildPS(Node haPsNode, InstanceIdentifier<Node> childPath, ReadWriteTransaction tx) {
    InstanceIdentifier<Node> childPsPath = HwvtepHAUtil.convertPsPath(haPsNode, childPath);
    NodeBuilder childPsBuilder = HwvtepHAUtil.getNodeBuilderForPath(childPsPath);
    PhysicalSwitchAugmentationBuilder dstBuilder = new PhysicalSwitchAugmentationBuilder();
    PhysicalSwitchAugmentation src = haPsNode.getAugmentation(PhysicalSwitchAugmentation.class);
    psAugmentationMerger.mergeConfigData(dstBuilder, src, childPath);
    psNodeMerger.mergeConfigData(childPsBuilder, haPsNode, childPath);
    childPsBuilder.addAugmentation(PhysicalSwitchAugmentation.class, dstBuilder.build());
    Node childPSNode = childPsBuilder.build();
    tx.put(CONFIGURATION, childPsPath, childPSNode, WriteTransaction.CREATE_MISSING_PARENTS);
}
Also used : PhysicalSwitchAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentationBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)

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