Search in sources :

Example 66 with ElanInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.

the class NeutronNetworkChangeListener method createElanInstance.

private ElanInstance createElanInstance(Network input) {
    String elanInstanceName = input.getUuid().getValue();
    InstanceIdentifier<ElanInstance> id = createElanInstanceIdentifier(elanInstanceName);
    Optional<ElanInstance> existingElanInstance = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
    if (existingElanInstance.isPresent()) {
        return existingElanInstance.get();
    }
    Class<? extends SegmentTypeBase> segmentType = NeutronvpnUtils.getSegmentTypeFromNeutronNetwork(input);
    String segmentationId = NeutronvpnUtils.getSegmentationIdFromNeutronNetwork(input);
    String physicalNetworkName = NeutronvpnUtils.getPhysicalNetworkName(input);
    long elanTag = elanService.retrieveNewElanTag(elanInstanceName);
    ElanInstance elanInstance = createElanInstanceBuilder(elanInstanceName, segmentType, segmentationId, physicalNetworkName, input).setElanTag(elanTag).build();
    MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, id, elanInstance);
    LOG.debug("ELANInstance {} created with elan tag {} and segmentation ID {}", elanInstanceName, elanTag, segmentationId);
    return elanInstance;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 67 with ElanInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.

the class NeutronNetworkChangeListener method update.

@Override
protected void update(InstanceIdentifier<Network> identifier, Network original, Network update) {
    LOG.trace("Updating Network : key: {}, original value={}, update value={}", identifier, original, update);
    neutronvpnUtils.addToNetworkCache(update);
    String elanInstanceName = original.getUuid().getValue();
    Class<? extends SegmentTypeBase> origSegmentType = NeutronvpnUtils.getSegmentTypeFromNeutronNetwork(original);
    String origSegmentationId = NeutronvpnUtils.getSegmentationIdFromNeutronNetwork(original);
    String origPhysicalNetwork = NeutronvpnUtils.getPhysicalNetworkName(original);
    Class<? extends SegmentTypeBase> updateSegmentType = NeutronvpnUtils.getSegmentTypeFromNeutronNetwork(update);
    String updateSegmentationId = NeutronvpnUtils.getSegmentationIdFromNeutronNetwork(update);
    String updatePhysicalNetwork = NeutronvpnUtils.getPhysicalNetworkName(update);
    Boolean origExternal = NeutronvpnUtils.getIsExternal(original);
    Boolean updateExternal = NeutronvpnUtils.getIsExternal(update);
    Boolean origIsFlatOrVlanNetwork = NeutronvpnUtils.isFlatOrVlanNetwork(original);
    Boolean updateIsFlatOrVlanNetwork = NeutronvpnUtils.isFlatOrVlanNetwork(update);
    if (!Objects.equals(origSegmentType, updateSegmentType) || !Objects.equals(origSegmentationId, updateSegmentationId) || !Objects.equals(origPhysicalNetwork, updatePhysicalNetwork) || !Objects.equals(origExternal, updateExternal)) {
        if (origExternal && origIsFlatOrVlanNetwork && (!updateExternal || !updateIsFlatOrVlanNetwork)) {
            nvpnManager.removeExternalVpnInterfaces(original.getUuid());
            nvpnManager.removeVpn(original.getUuid());
            nvpnNatManager.removeExternalNetwork(original);
        }
        ElanInstance elanInstance = elanService.getElanInstance(elanInstanceName);
        if (elanInstance != null) {
            elanService.deleteExternalElanNetwork(elanInstance);
            elanInstance = updateElanInstance(elanInstanceName, updateSegmentType, updateSegmentationId, updatePhysicalNetwork, update);
            if (updateExternal) {
                elanService.updateExternalElanNetwork(elanInstance);
            }
        }
        if (updateExternal && updateIsFlatOrVlanNetwork && !origExternal) {
            nvpnNatManager.addExternalNetwork(update);
            nvpnManager.createL3InternalVpn(update.getUuid(), null, null, null, null, null, null, null);
            nvpnManager.createExternalVpnInterfaces(update.getUuid());
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 68 with ElanInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.

the class NeutronNetworkChangeListener method buildSegments.

@Nonnull
private List<ElanSegments> buildSegments(Network input) {
    Long numSegments = NeutronUtils.getNumberSegmentsFromNeutronNetwork(input);
    List<ElanSegments> segments = new ArrayList<>();
    for (long index = 0L; index < numSegments; index++) {
        ElanSegmentsBuilder elanSegmentsBuilder = new ElanSegmentsBuilder();
        elanSegmentsBuilder.setSegmentationId(0L);
        if (NeutronUtils.getSegmentationIdFromNeutronNetworkSegment(input, index) != null) {
            try {
                elanSegmentsBuilder.setSegmentationId(Long.valueOf(NeutronUtils.getSegmentationIdFromNeutronNetworkSegment(input, index)));
            } catch (NumberFormatException error) {
                LOG.error("Failed to get the segment id for network {}", input);
            }
        }
        if (NeutronUtils.isNetworkSegmentType(input, index, NetworkTypeVxlan.class)) {
            elanSegmentsBuilder.setSegmentType(SegmentTypeVxlan.class);
        } else if (NeutronUtils.isNetworkSegmentType(input, index, NetworkTypeVlan.class)) {
            elanSegmentsBuilder.setSegmentType(SegmentTypeVlan.class);
        } else if (NeutronUtils.isNetworkSegmentType(input, index, NetworkTypeFlat.class)) {
            elanSegmentsBuilder.setSegmentType(SegmentTypeFlat.class);
        }
        elanSegmentsBuilder.setSegmentationIndex(index);
        segments.add(elanSegmentsBuilder.build());
        LOG.debug("Added segment {} to ELANInstance", segments.get((int) index - 1));
    }
    return segments;
}
Also used : SegmentTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeVlan) ElanSegments(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegments) ElanSegmentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegmentsBuilder) ArrayList(java.util.ArrayList) NetworkTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan) Nonnull(javax.annotation.Nonnull)

Example 69 with ElanInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.

the class ElanL2GatewayMulticastUtils method getRemoteBCGroupBucketsOfElanExternalTeps.

public List<Bucket> getRemoteBCGroupBucketsOfElanExternalTeps(ElanInstance elanInfo, BigInteger dpnId, int bucketId) {
    ElanInstance operElanInstance = null;
    try {
        operElanInstance = new SingleTransactionDataBroker(broker).syncReadOptional(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, elanInfo.getKey()).build()).orNull();
    } catch (ReadFailedException e) {
        LOG.error("Failed to read elan instance operational path {}", elanInfo, e);
        return emptyList();
    }
    if (operElanInstance == null) {
        return emptyList();
    }
    List<ExternalTeps> teps = operElanInstance.getExternalTeps();
    if (teps == null || teps.isEmpty()) {
        return emptyList();
    }
    List<Bucket> listBucketInfo = new ArrayList<>();
    for (ExternalTeps tep : teps) {
        String externalTep = tep.getNodeid() != null ? tep.getNodeid() : tep.getTepIp().toString();
        String interfaceName = elanItmUtils.getExternalTunnelInterfaceName(String.valueOf(dpnId), externalTep);
        if (interfaceName == null) {
            LOG.error("Could not get interface name to ext tunnel {} {}", dpnId, tep.getTepIp());
            continue;
        }
        List<Action> listActionInfo = elanItmUtils.buildTunnelItmEgressActions(interfaceName, elanUtils.getVxlanSegmentationId(elanInfo));
        listBucketInfo.add(MDSALUtil.buildBucket(listActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
        bucketId++;
    }
    return listBucketInfo;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ExternalTeps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ExternalTeps) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ArrayList(java.util.ArrayList) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances)

Example 70 with ElanInstance

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.

the class ElanL2GatewayUtils method deleteElanL2GwDevicesUcastLocalMacsFromDpn.

/**
 * Delete elan l2 gateway devices ucast local macs from dpn.
 *
 * @param elanName
 *            the elan name
 * @param dpnId
 *            the dpn id
 */
public void deleteElanL2GwDevicesUcastLocalMacsFromDpn(final String elanName, final BigInteger dpnId) {
    ConcurrentMap<String, L2GatewayDevice> elanL2GwDevices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
    if (elanL2GwDevices == null || elanL2GwDevices.isEmpty()) {
        LOG.trace("No L2 gateway devices in Elan [{}] cache.", elanName);
        return;
    }
    final ElanInstance elan = elanInstanceCache.get(elanName).orNull();
    if (elan == null) {
        LOG.error("Could not find Elan by name: {}", elanName);
        return;
    }
    LOG.info("Deleting Elan [{}] L2GatewayDevices UcastLocalMacs from Dpn [{}]", elanName, dpnId);
    final Long elanTag = elan.getElanTag();
    for (final L2GatewayDevice l2GwDevice : elanL2GwDevices.values()) {
        getL2GwDeviceLocalMacsAndRunCallback(elan.getElanInstanceName(), l2GwDevice, (localMacs) -> {
            for (MacAddress mac : localMacs) {
                String jobKey = elanName + ":" + mac.getValue();
                elanClusterUtils.runOnlyInOwnerNode(jobKey, () -> elanDmacUtils.deleteDmacFlowsToExternalMac(elanTag, dpnId, l2GwDevice.getHwvtepNodeId(), mac.getValue()));
            }
            return null;
        });
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Aggregations

ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)75 BigInteger (java.math.BigInteger)36 ArrayList (java.util.ArrayList)33 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)18 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)16 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)14 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)14 ElanInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)13 ElanDpnInterfacesList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 EtreeInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance)11 ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)11 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)10 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)10 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)10 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)10 ElanInstanceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)10 ElanInstanceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey)10 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)9 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)9