Search in sources :

Example 26 with TransportZones

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);
}
Also used : TransportZonesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Example 27 with TransportZones

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;
}
Also used : ArrayList(java.util.ArrayList) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Interfaces(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) InterfacesState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState)

Aggregations

TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)20 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)18 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)11 TransportZonesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder)9 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)8 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)8 TransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder)7 DeviceVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey)7 DeviceVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)5 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)5 SubnetsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder)5 DeviceVtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4