use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.
the class ItmUtils method constructVtepConfigSchema.
public static VtepConfigSchema constructVtepConfigSchema(String schemaName, String portName, Integer vlanId, String subnetMask, String gatewayIp, String transportZone, String tunnelType, List<BigInteger> dpnIds, String excludeIpFilter) {
IpAddress gatewayIpObj = StringUtils.isBlank(gatewayIp) ? null : IpAddressBuilder.getDefaultInstance(gatewayIp);
IpPrefix subnet = StringUtils.isBlank(subnetMask) ? null : IpPrefixBuilder.getDefaultInstance(subnetMask);
Class<? extends TunnelTypeBase> tunType;
if (tunnelType.equals(ITMConstants.TUNNEL_TYPE_VXLAN)) {
tunType = TunnelTypeVxlan.class;
} else {
tunType = TunnelTypeGre.class;
}
VtepConfigSchemaBuilder schemaBuilder = new VtepConfigSchemaBuilder().setSchemaName(schemaName).setPortName(portName).setVlanId(vlanId).setSubnet(subnet).setGatewayIp(gatewayIpObj).setTransportZoneName(transportZone).setTunnelType(tunType).setDpnIds(getDpnIdsListFromBigInt(dpnIds)).setExcludeIpFilter(excludeIpFilter);
return schemaBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.
the class ItmUtils method getInternalTunnelsofTzone.
public static List<String> getInternalTunnelsofTzone(String tzone, DataBroker dataBroker) {
List<String> tunnels = new ArrayList<>();
LOG.trace("Getting internal tunnels of {}", tzone);
InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzone)).build();
Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
if (transportZoneOptional.isPresent()) {
TransportZone transportZone = transportZoneOptional.get();
if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
for (Subnets sub : transportZone.getSubnets()) {
if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
for (Vteps vtepLocal : sub.getVteps()) {
for (Vteps vtepRemote : sub.getVteps()) {
if (!vtepLocal.equals(vtepRemote)) {
InternalTunnelKey key = new InternalTunnelKey(vtepRemote.getDpnId(), vtepLocal.getDpnId(), transportZone.getTunnelType());
InstanceIdentifier<InternalTunnel> intIID = InstanceIdentifier.builder(TunnelList.class).child(InternalTunnel.class, key).build();
Optional<InternalTunnel> tunnelsOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, intIID, dataBroker);
if (tunnelsOptional.isPresent()) {
List<String> tunnelInterfaceNames = tunnelsOptional.get().getTunnelInterfaceNames();
if (tunnelInterfaceNames != null && !tunnelInterfaceNames.isEmpty()) {
String tunnelInterfaceName = tunnelInterfaceNames.get(0);
LOG.trace("Internal Tunnel added {}", tunnelInterfaceName);
tunnels.add(tunnelInterfaceName);
}
}
}
}
}
}
}
}
}
return tunnels;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.
the class VtepSchemaAdd method doExecute.
/*
* (non-Javadoc)
*
* @see org.apache.karaf.shell.console.AbstractAction#doExecute()
*/
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected Object doExecute() {
try {
if (this.schemaName == null || this.portName == null || this.vlanId == null || this.subnetCIDR == null || this.transportZone == null) {
usage();
return null;
}
LOG.debug("Executing vtep:schema-add command\t {} \t {} \t {} \t {} \t {} \t {} \t {} \t {} \t {}", schemaName, portName, vlanId, subnetCIDR, gatewayIp, transportZone, tunnelType, dpnIds, excludeIpFilter);
if (null == tunnelType) {
tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
}
VtepConfigSchema schema = ItmUtils.constructVtepConfigSchema(schemaName, portName, vlanId, subnetCIDR, gatewayIp, transportZone, tunnelType, ItmCliUtils.constructDpnIdList(dpnIds), excludeIpFilter);
this.itmProvider.addVtepConfigSchema(schema);
} catch (Exception e) {
LOG.error("Exception occurred during execution of command \"vtep:schema-add\": ", e);
throw e;
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.
the class ItmExternalTunnelAddWorker method createTunnelsFromOVSinTransportZone.
private void createTunnelsFromOVSinTransportZone(String zoneName, DPNTEPsInfo dpn, TunnelEndPoints tep, WriteTransaction transaction, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol) {
InstanceIdentifier<TransportZone> tzonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(zoneName)).build();
Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tzonePath, dataBroker);
if (transportZoneOptional.isPresent()) {
TransportZone transportZone = transportZoneOptional.get();
// do we need to check tunnel type?
if (transportZone.getSubnets() != null && !transportZone.getSubnets().isEmpty()) {
for (Subnets sub : transportZone.getSubnets()) {
if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
// dont mesh if hwVteps and OVS-tep have same ip-address
if (hwVtepDS.getIpAddress().equals(tep.getIpAddress())) {
continue;
}
final String cssID = dpn.getDPNID().toString();
String nodeId = hwVtepDS.getNodeId();
boolean useOfTunnel = ItmUtils.falseIfNull(tep.isOptionOfTunnel());
LOG.trace("wire up {} and {}", tep, hwVtepDS);
if (!wireUp(dpn.getDPNID(), tep.getPortname(), sub.getVlanId(), tep.getIpAddress(), useOfTunnel, nodeId, hwVtepDS.getIpAddress(), tep.getSubnetMask(), sub.getGatewayIp(), sub.getPrefix(), transportZone.getTunnelType(), false, monitorInterval, monitorProtocol, transaction)) {
LOG.error("Unable to build tunnel {} -- {}", tep.getIpAddress(), hwVtepDS.getIpAddress());
}
// TOR-OVS
LOG.trace("wire up {} and {}", hwVtepDS, tep);
if (!wireUp(hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), cssID, tep.getIpAddress(), sub.getPrefix(), sub.getGatewayIp(), tep.getSubnetMask(), transportZone.getTunnelType(), false, monitorInterval, monitorProtocol, transaction)) {
LOG.error("Unable to build tunnel {} -- {}", hwVtepDS.getIpAddress(), tep.getIpAddress());
}
}
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.
the class ItmExternalTunnelDeleteWorker method tunnelsDeletion.
private static void tunnelsDeletion(List<DPNTEPsInfo> cfgdDpnList, List<HwVtep> cfgdhwVteps, TransportZone originalTZone, WriteTransaction writeTransaction, DataBroker dataBroker) {
if (cfgdDpnList != null) {
for (DPNTEPsInfo dpn : cfgdDpnList) {
if (dpn.getTunnelEndPoints() != null) {
for (TunnelEndPoints srcTep : dpn.getTunnelEndPoints()) {
for (TzMembership zone : srcTep.getTzMembership()) {
deleteTunnelsInTransportZone(zone.getZoneName(), dpn, srcTep, cfgdhwVteps, dataBroker, writeTransaction);
}
}
}
}
}
if (cfgdhwVteps != null && !cfgdhwVteps.isEmpty()) {
for (HwVtep hwTep : cfgdhwVteps) {
LOG.trace("processing hwTep from list {}", hwTep);
for (HwVtep hwTepRemote : cfgdhwVteps) {
if (!hwTep.getHwIp().equals(hwTepRemote.getHwIp())) {
deleteTrunksTorTor(dataBroker, hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), hwTepRemote.getTopoId(), hwTepRemote.getNodeId(), hwTepRemote.getHwIp(), TunnelTypeVxlan.class, writeTransaction);
}
}
// do we need to check tunnel type?
LOG.trace("subnets under tz {} are {}", originalTZone.getZoneName(), originalTZone.getSubnets());
if (originalTZone.getSubnets() != null && !originalTZone.getSubnets().isEmpty()) {
for (Subnets sub : originalTZone.getSubnets()) {
if (sub.getDeviceVteps() != null && !sub.getDeviceVteps().isEmpty()) {
for (DeviceVteps hwVtepDS : sub.getDeviceVteps()) {
LOG.trace("hwtepDS exists {}", hwVtepDS);
// for mlag case and non-m-lag case, isnt it enough to just check ipaddress?
if (hwVtepDS.getIpAddress().equals(hwTep.getHwIp())) {
// dont delete tunnels with self
continue;
}
// TOR-TOR
LOG.trace("deleting tor-tor {} and {}", hwTep, hwVtepDS);
deleteTrunksTorTor(dataBroker, hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), hwVtepDS.getTopologyId(), hwVtepDS.getNodeId(), hwVtepDS.getIpAddress(), originalTZone.getTunnelType(), writeTransaction);
}
}
if (sub.getVteps() != null && !sub.getVteps().isEmpty()) {
for (Vteps vtep : sub.getVteps()) {
// TOR-OVS
LOG.trace("deleting tor-css-tor {} and {}", hwTep, vtep);
String parentIf = ItmUtils.getInterfaceName(vtep.getDpnId(), vtep.getPortname(), sub.getVlanId());
deleteTrunksOvsTor(dataBroker, vtep.getDpnId(), parentIf, vtep.getIpAddress(), hwTep.getTopoId(), hwTep.getNodeId(), hwTep.getHwIp(), originalTZone.getTunnelType(), writeTransaction);
}
}
}
}
}
}
}
Aggregations