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;
}
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());
}
}
}
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;
}
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;
}
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;
});
}
}
Aggregations