Search in sources :

Example 1 with SegmentTypeBase

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

the class CoeUtils method createElanInstanceForTheFirstPodInTheNetwork.

public static ElanInstance createElanInstanceForTheFirstPodInTheNetwork(String networkNS, String nodeIp, org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod.rev170611.pod_attributes.Interface podInterface, ReadWriteTransaction wrtConfigTxn) throws ReadFailedException {
    String elanInstanceName = buildElanInstanceName(nodeIp, networkNS);
    InstanceIdentifier<ElanInstance> id = createElanInstanceIdentifier(elanInstanceName);
    ElanInstance existingElanInstance = wrtConfigTxn.read(LogicalDatastoreType.CONFIGURATION, id).checkedGet().orNull();
    if (existingElanInstance != null) {
        return existingElanInstance;
    }
    Class<? extends SegmentTypeBase> segmentType = getSegmentTypeFromNetwork(podInterface);
    String segmentationId = String.valueOf(podInterface.getSegmentationId());
    // FIXME String physicalNetworkName = ??
    // TODO external network support not added currently
    Boolean isExternal = false;
    ElanInstance elanInstance = CoeUtils.buildElanInstance(elanInstanceName, segmentType, segmentationId, isExternal);
    wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, id, elanInstance);
    LOG.info("ELAN instance created for the first pod in the network {}", podInterface.getUid());
    return elanInstance;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 2 with SegmentTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeBase 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 3 with SegmentTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.SegmentTypeBase 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 4 with SegmentTypeBase

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

the class CoeUtils method buildElanInstance.

static ElanInstance buildElanInstance(String elanInstanceName, Class<? extends SegmentTypeBase> segmentType, String segmentationId, Boolean isExternal) {
    ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName);
    if (segmentType != null) {
        elanInstanceBuilder.setSegmentType(segmentType);
        if (segmentationId != null) {
            elanInstanceBuilder.setSegmentationId(Long.valueOf(segmentationId));
        }
    }
    elanInstanceBuilder.setExternal(isExternal);
    elanInstanceBuilder.setKey(new ElanInstanceKey(elanInstanceName));
    return elanInstanceBuilder.build();
}
Also used : ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)

Example 5 with SegmentTypeBase

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

the class NeutronNetworkChangeListener method createElanInstanceBuilder.

private ElanInstanceBuilder createElanInstanceBuilder(String elanInstanceName, Class<? extends SegmentTypeBase> segmentType, String segmentationId, String physicalNetworkName, Network network) {
    Boolean isExternal = NeutronvpnUtils.getIsExternal(network);
    List<ElanSegments> segments = buildSegments(network);
    ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName);
    if (segmentType != null) {
        elanInstanceBuilder.setSegmentType(segmentType);
        if (segmentationId != null) {
            elanInstanceBuilder.setSegmentationId(Long.valueOf(segmentationId));
        }
        if (physicalNetworkName != null) {
            elanInstanceBuilder.setPhysicalNetworkName(physicalNetworkName);
        }
    }
    elanInstanceBuilder.setElanSegments(segments);
    elanInstanceBuilder.setExternal(isExternal);
    elanInstanceBuilder.setKey(new ElanInstanceKey(elanInstanceName));
    return elanInstanceBuilder;
}
Also used : ElanSegments(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegments) ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)

Aggregations

ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)4 ElanInstanceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)2 ElanInstanceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey)2 ElanSegments (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.elan.instance.ElanSegments)1