use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones in project genius by opendaylight.
the class TepCommandHelper method configureTunnelType.
public void configureTunnelType(String transportZoneName, String tunnelType) {
LOG.debug("configureTunnelType {} for transportZone {}", tunnelType, transportZoneName);
TransportZone transportZoneFromConfigDS = ItmUtils.getTransportZoneFromConfigDS(transportZoneName, dataBroker);
Class<? extends TunnelTypeBase> tunType;
validateTunnelType(transportZoneName, tunnelType, transportZoneFromConfigDS);
if (transportZoneFromConfigDS != null) {
if (!transportZoneName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
LOG.debug("Transport zone {} with tunnel type {} already exists. No action required.", transportZoneName, tunnelType);
return;
} else {
tunnelType = StringUtils.upperCase(tunnelType);
tunType = ItmUtils.TUNNEL_TYPE_MAP.get(tunnelType);
if (transportZoneFromConfigDS.getTunnelType().equals(tunType)) {
// controller restart, then nothing to do now. Just return.
return;
}
}
}
// get tunnel-type
tunnelType = StringUtils.upperCase(tunnelType);
tunType = ItmUtils.TUNNEL_TYPE_MAP.get(tunnelType);
TransportZones transportZones = null;
List<TransportZone> tzList = null;
InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
Optional<TransportZones> tzones = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
TransportZone tzone = new TransportZoneBuilder().setKey(new TransportZoneKey(transportZoneName)).setTunnelType(tunType).build();
if (tzones.isPresent()) {
tzList = tzones.get().getTransportZone();
if (tzList == null || tzList.isEmpty()) {
tzList = new ArrayList<>();
}
} else {
tzList = new ArrayList<>();
}
tzList.add(tzone);
transportZones = new TransportZonesBuilder().setTransportZone(tzList).build();
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, path, transportZones, dataBroker);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones in project genius by opendaylight.
the class TepDeleteDatastore method doExecute.
@Override
protected Object doExecute() {
final DataBroker dataBroker = itmProvider.getDataBroker();
InstanceIdentifier<TransportZones> itmConfigPath = InstanceIdentifier.builder(TransportZones.class).build();
InstanceIdentifier<Interfaces> interfacesConfigPath = InstanceIdentifier.builder(Interfaces.class).build();
final InstanceIdentifier<InterfacesState> ifStateOpPath = InstanceIdentifier.builder(InterfacesState.class).build();
InstanceIdentifier<Nodes> frmConfigPath = InstanceIdentifier.builder(Nodes.class).build();
List<InstanceIdentifier<T>> allConfigPaths = new ArrayList<>();
allConfigPaths.add((InstanceIdentifier<T>) itmConfigPath);
allConfigPaths.add((InstanceIdentifier<T>) interfacesConfigPath);
allConfigPaths.add((InstanceIdentifier<T>) frmConfigPath);
// allConfigPaths.add((InstanceIdentifier<T>) tunnelsConfigPath);
ItmUtils.asyncBulkRemove(dataBroker, LogicalDatastoreType.CONFIGURATION, allConfigPaths, ItmUtils.DEFAULT_CALLBACK);
List<InstanceIdentifier<T>> allOperationalPaths = new ArrayList<>();
// allOperationalPaths.add((InstanceIdentifier<T>) tnStateOpPath);
allOperationalPaths.add((InstanceIdentifier<T>) ifStateOpPath);
ItmUtils.asyncBulkRemove(dataBroker, LogicalDatastoreType.OPERATIONAL, allOperationalPaths, ItmUtils.DEFAULT_CALLBACK);
return null;
}
Aggregations