use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder in project genius by opendaylight.
the class OvsdbTepAddConfigHelper method addVtepInITMConfigDS.
/**
* Adds the TEP into Vtep list in the subnet list in the transport zone list
* from ITM configuration Datastore by merge operation with write transaction.
*
* @param subnetList subnets list object
* @param subnetMaskObj subnet mask in IpPrefix object
* @param updatedVtepList updated Vteps list object which will have new TEP for addition
* @param tepIpAddress TEP IP address in IpAddress object
* @param tzName transport zone name in string
* @param dpid bridge datapath ID in BigInteger
* @param portName port name as a part of VtepsKey
* @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
* @param wrTx WriteTransaction object
*/
public static void addVtepInITMConfigDS(List<Subnets> subnetList, IpPrefix subnetMaskObj, List<Vteps> updatedVtepList, IpAddress tepIpAddress, String tzName, BigInteger dpid, String portName, boolean ofTunnel, WriteTransaction wrTx) {
// Create TZ node path
InstanceIdentifier<TransportZone> tranzportZonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzName)).build();
// when VTEP is moved from TepsNotHosted list to TZ configured from Northbound.
if (dpid.compareTo(BigInteger.ZERO) > 0) {
// create vtep
VtepsKey vtepkey = new VtepsKey(dpid, portName);
Vteps vtepObj = new VtepsBuilder().setDpnId(dpid).setIpAddress(tepIpAddress).setKey(vtepkey).setPortname(portName).setOptionOfTunnel(ofTunnel).build();
// Add vtep obtained from bridge into list
updatedVtepList.add(vtepObj);
LOG.trace("Adding TEP (TZ: {} Subnet: {} TEP IP: {} DPID: {}, of-tunnel: {}) in ITM Config DS.", tzName, subnetMaskObj, tepIpAddress, dpid, ofTunnel);
} else {
// corresponding TZ is configured from northbound.
for (Vteps vtep : updatedVtepList) {
LOG.trace("Moving TEP (TEP IP: {} DPID: {}, of-tunnel: {})" + "from not-hosted-transport-zone {} into ITM Config DS.", vtep.getIpAddress(), vtep.getDpnId(), ofTunnel, tzName);
}
}
// Create subnet object
SubnetsKey subKey = new SubnetsKey(subnetMaskObj);
IpAddress gatewayIP = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP);
int vlanID = ITMConstants.DUMMY_VLANID;
Subnets subnet = new SubnetsBuilder().setGatewayIp(gatewayIP).setKey(subKey).setPrefix(subnetMaskObj).setVlanId(vlanID).setVteps(updatedVtepList).build();
// add subnet into subnet list
subnetList.add(subnet);
// create TZ node with updated subnet having new vtep
TransportZone updatedTzone = new TransportZoneBuilder().setKey(new TransportZoneKey(tzName)).setSubnets(subnetList).setZoneName(tzName).build();
// Update TZ in Config DS to add vtep in TZ
wrTx.merge(LogicalDatastoreType.CONFIGURATION, tranzportZonePath, updatedTzone, true);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder 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);
}
Aggregations