Search in sources :

Example 1 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces in project netvirt by opendaylight.

the class ElanInterfaceManager method setupLeavesLocalBroadcastGroups.

private void setupLeavesLocalBroadcastGroups(ElanInstance elanInfo, DpnInterfaces newDpnInterface, InterfaceInfo interfaceInfo) {
    EtreeInstance etreeInstance = elanInfo.getAugmentation(EtreeInstance.class);
    if (etreeInstance != null) {
        List<Bucket> listBucket = new ArrayList<>();
        int bucketId = 0;
        List<String> interfaces = new ArrayList<>();
        if (newDpnInterface != null) {
            interfaces = newDpnInterface.getInterfaces();
        }
        for (String ifName : interfaces) {
            // In case if there is a InterfacePort in the cache which is not
            // in
            // operational state, skip processing it
            InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(ifName, interfaceInfo.getInterfaceType());
            if (!isOperational(ifInfo)) {
                continue;
            }
            if (!interfaceManager.isExternalInterface(ifName)) {
                // only add root interfaces
                bucketId = addInterfaceIfRootInterface(bucketId, ifName, listBucket, ifInfo);
            }
        }
        if (listBucket.isEmpty()) {
            // No Buckets
            createDropBucket(listBucket);
        }
        long etreeLeafTag = etreeInstance.getEtreeLeafTagVal().getValue();
        long groupId = ElanUtils.getEtreeLeafLocalBCGId(etreeLeafTag);
        Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
        LOG.trace("installing the localBroadCast Group:{}", group);
        mdsalManager.syncInstallGroup(interfaceInfo.getDpId(), group);
    }
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ArrayList(java.util.ArrayList) EtreeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 2 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces in project netvirt by opendaylight.

the class ElanInterfaceManager method setupStandardLocalBroadcastGroups.

public void setupStandardLocalBroadcastGroups(ElanInstance elanInfo, DpnInterfaces newDpnInterface, InterfaceInfo interfaceInfo) {
    List<Bucket> listBucket = new ArrayList<>();
    int bucketId = 0;
    long groupId = ElanUtils.getElanLocalBCGId(elanInfo.getElanTag());
    List<String> interfaces = new ArrayList<>();
    if (newDpnInterface != null) {
        interfaces = newDpnInterface.getInterfaces();
    }
    for (String ifName : interfaces) {
        // In case if there is a InterfacePort in the cache which is not in
        // operational state, skip processing it
        InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(ifName, interfaceInfo.getInterfaceType());
        if (!isOperational(ifInfo)) {
            continue;
        }
        if (!interfaceManager.isExternalInterface(ifName)) {
            listBucket.add(MDSALUtil.buildBucket(getInterfacePortActions(ifInfo), MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
            bucketId++;
        }
    }
    Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
    LOG.trace("installing the localBroadCast Group:{}", group);
    mdsalManager.syncInstallGroup(interfaceInfo.getDpId(), group);
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ArrayList(java.util.ArrayList) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 3 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces in project netvirt by opendaylight.

the class HwvtepTerminationPointListener method getVlanBindings.

private List<VlanBindings> getVlanBindings(List<L2gatewayConnection> l2GwConns, NodeId hwvtepNodeId, String psName, String newPortId) {
    List<VlanBindings> vlanBindings = new ArrayList<>();
    for (L2gatewayConnection l2GwConn : l2GwConns) {
        L2gateway l2Gateway = L2GatewayConnectionUtils.getNeutronL2gateway(broker, l2GwConn.getL2gatewayId());
        if (l2Gateway == null) {
            LOG.error("L2Gateway with id {} is not present", l2GwConn.getL2gatewayId().getValue());
        } else {
            String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(l2GwConn.getNetworkId().getValue());
            List<Devices> l2Devices = l2Gateway.getDevices();
            for (Devices l2Device : l2Devices) {
                String l2DeviceName = l2Device.getDeviceName();
                if (l2DeviceName != null && l2DeviceName.equals(psName)) {
                    for (Interfaces deviceInterface : l2Device.getInterfaces()) {
                        if (deviceInterface.getInterfaceName().equals(newPortId)) {
                            if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
                                for (Integer vlanId : deviceInterface.getSegmentationIds()) {
                                    vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(hwvtepNodeId, vlanId, logicalSwitchName));
                                }
                            } else {
                                // Use defaultVlanId (specified in L2GatewayConnection) if Vlan
                                // ID not specified at interface level.
                                Integer segmentationId = l2GwConn.getSegmentId();
                                int defaultVlanId = segmentationId != null ? segmentationId : 0;
                                vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(hwvtepNodeId, defaultVlanId, logicalSwitchName));
                            }
                        }
                    }
                }
            }
        }
    }
    return vlanBindings;
}
Also used : Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces) ArrayList(java.util.ArrayList) VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) L2gateway(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) L2gatewayConnection(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection)

Example 4 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces in project netvirt by opendaylight.

the class ElanInterfaceManager method removeElanInterface.

public List<ListenableFuture<Void>> removeElanInterface(ElanInstance elanInfo, String interfaceName, InterfaceInfo interfaceInfo) {
    String elanName = elanInfo.getElanInstanceName();
    boolean isLastElanInterface = false;
    boolean isLastInterfaceOnDpn = false;
    BigInteger dpId = null;
    long elanTag = elanInfo.getElanTag();
    // We use two transaction so we don't suffer on multiple shards (interfaces and flows)
    WriteTransaction interfaceTx = broker.newWriteOnlyTransaction();
    Elan elanState = removeElanStateForInterface(elanInfo, interfaceName, interfaceTx);
    if (elanState == null) {
        interfaceTx.cancel();
        return Collections.emptyList();
    }
    WriteTransaction flowTx = broker.newWriteOnlyTransaction();
    List<String> elanInterfaces = elanState.getElanInterfaces();
    if (elanInterfaces.isEmpty()) {
        isLastElanInterface = true;
    }
    if (interfaceInfo != null) {
        dpId = interfaceInfo.getDpId();
        DpnInterfaces dpnInterfaces = removeElanDpnInterfaceFromOperationalDataStore(elanName, dpId, interfaceName, elanTag, interfaceTx);
        /*
             * If there are not elan ports, remove the unknown dmac, terminating
             * service table flows, remote/local bc group
             */
        if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null || dpnInterfaces.getInterfaces().isEmpty()) {
            // No more Elan Interfaces in this DPN
            LOG.debug("deleting the elan: {} present on dpId: {}", elanInfo.getElanInstanceName(), dpId);
            if (!elanUtils.isOpenstackVniSemanticsEnforced()) {
                removeDefaultTermFlow(dpId, elanInfo.getElanTag());
            }
            removeUnknownDmacFlow(dpId, elanInfo, flowTx, elanInfo.getElanTag());
            removeEtreeUnknownDmacFlow(dpId, elanInfo, flowTx);
            removeElanBroadcastGroup(elanInfo, interfaceInfo, flowTx);
            removeLocalBroadcastGroup(elanInfo, interfaceInfo, flowTx);
            removeEtreeBroadcastGrups(elanInfo, interfaceInfo, flowTx);
            if (isVxlanNetworkOrVxlanSegment(elanInfo)) {
                if (elanUtils.isOpenstackVniSemanticsEnforced()) {
                    elanUtils.removeTerminatingServiceAction(dpId, elanUtils.getVxlanSegmentationId(elanInfo).intValue());
                }
                unsetExternalTunnelTable(dpId, elanInfo);
            }
            isLastInterfaceOnDpn = true;
        } else {
            setupLocalBroadcastGroups(elanInfo, dpnInterfaces, interfaceInfo);
        }
    }
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    futures.add(ElanUtils.waitForTransactionToComplete(interfaceTx));
    futures.add(ElanUtils.waitForTransactionToComplete(flowTx));
    if (isLastInterfaceOnDpn && dpId != null && isVxlanNetworkOrVxlanSegment(elanInfo)) {
        setElanAndEtreeBCGrouponOtherDpns(elanInfo, dpId);
    }
    InterfaceRemoveWorkerOnElanInterface removeInterfaceWorker = new InterfaceRemoveWorkerOnElanInterface(interfaceName, elanInfo, interfaceInfo, this, isLastElanInterface);
    jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(interfaceName), removeInterfaceWorker, 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) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) 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) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 5 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces in project netvirt by opendaylight.

the class NetvirtProviderTest method getLogicalInterfacesFromNeutronNetwork.

@Test
public void getLogicalInterfacesFromNeutronNetwork() {
    // Network doesnt exist
    NeutronNetworkBuilder nwBuilder = new NeutronNetworkBuilder();
    nwBuilder.setNetworkUuid(NW_UUID_NOEXIST_STR);
    List<String> interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
    assertTrue(interfaces.isEmpty());
    // Network exists, subnet list empty
    createNetworkMap(NW_UUID_STR);
    nwBuilder = new NeutronNetworkBuilder();
    nwBuilder.setNetworkUuid(NW_UUID_STR);
    interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
    assertTrue(interfaces.isEmpty());
    // Network exists, subnet does not exist
    createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, false, EMPTY_STR);
    nwBuilder = new NeutronNetworkBuilder();
    nwBuilder.setNetworkUuid(NW_UUID_STR);
    interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
    assertTrue(interfaces.isEmpty());
    // Network exists, subnet exists, no ports
    createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, true, EMPTY_STR);
    nwBuilder = new NeutronNetworkBuilder();
    nwBuilder.setNetworkUuid(NW_UUID_STR);
    interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
    assertTrue(interfaces.isEmpty());
    // Network exists, subnet exists, port exists
    createNetworkMap(NW_UUID_STR, SUBNET_UUID_STR, true, PORT_UUID_STR);
    nwBuilder = new NeutronNetworkBuilder();
    nwBuilder.setNetworkUuid(NW_UUID_STR);
    interfaces = netvirtProvider.getLogicalInterfacesFromNeutronNetwork(nwBuilder.build());
    assertFalse(interfaces.isEmpty());
}
Also used : NeutronNetworkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetworkBuilder) Test(org.junit.Test) ConstantSchemaAbstractDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.ConstantSchemaAbstractDataBrokerTest)

Aggregations

ArrayList (java.util.ArrayList)26 BigInteger (java.math.BigInteger)24 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)14 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)10 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 HashSet (java.util.HashSet)7 ExecutionException (java.util.concurrent.ExecutionException)7 HashMap (java.util.HashMap)4 List (java.util.List)4 Test (org.junit.Test)4 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)4 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)4 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)4 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)4 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)4 RouterPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)4 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports)4 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)4