use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.
the class TransportZoneListener method createDPNTepInfo.
private List<DPNTEPsInfo> createDPNTepInfo(TransportZone transportZone) {
Map<BigInteger, List<TunnelEndPoints>> mapDPNToTunnelEndpt = new ConcurrentHashMap<>();
List<DPNTEPsInfo> dpnTepInfo = new ArrayList<>();
List<TzMembership> zones = ItmUtils.createTransportZoneMembership(transportZone.getZoneName());
Class<? extends TunnelTypeBase> tunnelType = transportZone.getTunnelType();
LOG.trace("Transport Zone_name: {}", transportZone.getZoneName());
List<Subnets> subnetsList = transportZone.getSubnets();
if (subnetsList != null) {
for (Subnets subnet : subnetsList) {
IpPrefix ipPrefix = subnet.getPrefix();
IpAddress gatewayIP = subnet.getGatewayIp();
int vlanID = subnet.getVlanId();
LOG.trace("IpPrefix: {}, gatewayIP: {}, vlanID: {} ", ipPrefix, gatewayIP, vlanID);
List<Vteps> vtepsList = subnet.getVteps();
if (vtepsList != null && !vtepsList.isEmpty()) {
for (Vteps vteps : vtepsList) {
BigInteger dpnID = vteps.getDpnId();
String port = vteps.getPortname();
IpAddress ipAddress = vteps.getIpAddress();
boolean useOfTunnel = ItmUtils.falseIfNull(vteps.isOptionOfTunnel());
String tos = vteps.getOptionTunnelTos();
if (tos == null) {
tos = itmConfig.getDefaultTunnelTos();
}
LOG.trace("DpnID: {}, port: {}, ipAddress: {}", dpnID, port, ipAddress);
TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, useOfTunnel, vlanID, ipPrefix, gatewayIP, zones, tunnelType, tos);
List<TunnelEndPoints> tunnelEndPointsList = mapDPNToTunnelEndpt.get(dpnID);
if (tunnelEndPointsList != null) {
LOG.trace("Existing DPN info list in the Map: {} ", dpnID);
tunnelEndPointsList.add(tunnelEndPoints);
} else {
LOG.trace("Adding new DPN info list to the Map: {} ", dpnID);
tunnelEndPointsList = new ArrayList<>();
tunnelEndPointsList.add(tunnelEndPoints);
mapDPNToTunnelEndpt.put(dpnID, tunnelEndPointsList);
}
}
}
}
}
if (!mapDPNToTunnelEndpt.isEmpty()) {
LOG.trace("List of dpns in the Map: {} ", mapDPNToTunnelEndpt.keySet());
for (Entry<BigInteger, List<TunnelEndPoints>> entry : mapDPNToTunnelEndpt.entrySet()) {
DPNTEPsInfo newDpnTepsInfo = ItmUtils.createDPNTepInfo(entry.getKey(), entry.getValue());
dpnTepInfo.add(newDpnTepsInfo);
}
}
return dpnTepInfo;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.
the class ItmExternalTunnelDeleteTest method setupMocks.
private void setupMocks() {
ipAddress1 = IpAddressBuilder.getDefaultInstance(tepIp1);
ipAddress2 = IpAddressBuilder.getDefaultInstance(tepIp2);
ipAddress3 = IpAddressBuilder.getDefaultInstance(tepIp3);
ipPrefixTest = IpPrefixBuilder.getDefaultInstance(subnetIp + "/24");
gtwyIp1 = IpAddressBuilder.getDefaultInstance(gwyIp1);
gtwyIp2 = IpAddressBuilder.getDefaultInstance(gwyIp2);
deviceVteps1 = new DeviceVtepsBuilder().setIpAddress(ipAddress1).setKey(new DeviceVtepsKey(ipAddress1, "hwvtep:1")).setNodeId("hwvtep://192.168.101.30:6640/physicalswitch/s3").setTopologyId("hwvtep:1").build();
deviceVteps2 = new DeviceVtepsBuilder().setIpAddress(ipAddress2).setKey(new DeviceVtepsKey(ipAddress2, "hwvtep:1")).setNodeId("hwvtep://192.168.101.30:6640/physicalswitch/s3").setTopologyId("hwvtep:1").build();
deviceVtepsList.add(deviceVteps1);
deviceVtepsList.add(deviceVteps2);
hwVtep1 = new HwVtep();
hwVtep1.setTransportZone(transportZone1);
hwVtep1.setGatewayIP(gtwyIp1);
hwVtep1.setHwIp(ipAddress2);
hwVtep1.setTunnelType(tunnelType1);
hwVtep1.setVlanID(vlanId);
hwVtep1.setTopoId("hwvtep:1");
hwVtep1.setNodeId("hwvtep://192.168.101.30:6640/physicalswitch/s3");
hwVtep1.setIpPrefix(ipPrefixTest);
vteps = new VtepsBuilder().setDpnId(dpId2).setIpAddress(ipAddress1).setPortname(portName1).setKey(new VtepsKey(dpId2, portName1)).build();
vtepsList.add(vteps);
idOutputOptional1 = RpcResultBuilder.success(expectedId1).buildFuture();
getIdInput1 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.30:VXLAN").build();
doReturn(idOutputOptional1).when(idManagerService).allocateId(getIdInput1);
idOutputOptional2 = RpcResultBuilder.success(expectedId2).buildFuture();
getIdInput2 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep:1:192.168.56.30:192.168.56.101:VXLAN").build();
doReturn(idOutputOptional2).when(idManagerService).allocateId(getIdInput2);
idOutputOptional3 = RpcResultBuilder.success(expectedId3).buildFuture();
getIdInput3 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.101:192.168.56.40:VXLAN").build();
doReturn(idOutputOptional3).when(idManagerService).allocateId(getIdInput3);
idOutputOptional4 = RpcResultBuilder.success(expectedId4).buildFuture();
getIdInput4 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep:1:192.168.56.40:192.168.56.101:VXLAN").build();
doReturn(idOutputOptional4).when(idManagerService).allocateId(getIdInput4);
idOutputOptional5 = RpcResultBuilder.success(expectedId5).buildFuture();
getIdInput5 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep://192.168.101.30:6640/physicalswitch/" + "s3:192.168.56.40:192.168.56.101:VXLAN").build();
doReturn(idOutputOptional5).when(idManagerService).allocateId(getIdInput5);
idOutputOptional6 = RpcResultBuilder.success(expectedId6).buildFuture();
getIdInput6 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep://192.168.101.30:6640/physicalswitch/" + "s3:192.168.56.40:192.168.56.30:VXLAN").build();
doReturn(idOutputOptional6).when(idManagerService).allocateId(getIdInput6);
idOutputOptional7 = RpcResultBuilder.success(expectedId7).buildFuture();
getIdInput7 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("hwvtep:1:hwvtep:1:192.168.56.30:192.168.56.40:VXLAN").build();
doReturn(idOutputOptional7).when(idManagerService).allocateId(getIdInput7);
idOutputOptional8 = RpcResultBuilder.success(expectedId8).buildFuture();
getIdInput8 = new AllocateIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey("1:phy0:100:192.168.56.30:192.168.56.40:VXLAN").build();
doReturn(idOutputOptional8).when(idManagerService).allocateId(getIdInput8);
tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1).setIpAddress(ipAddress3).setGwIpAddress(gtwyIp1).setInterfaceName(parentInterfaceName).setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1).setSubnetMask(ipPrefixTest).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(dpId2).setUp(true).setKey(new DPNTEPsInfoKey(dpId2)).setTunnelEndPoints(tunnelEndPointsListVxlan).build();
dpnTepsList.add(dpntePsInfoVxlan);
cfgdHwVtepsList.add(hwVtep1);
subnets = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).setKey(new SubnetsKey(ipPrefixTest)).setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
subnetsList.add(subnets);
transportZone = new TransportZoneBuilder().setTunnelType(tunnelType1).setZoneName(transportZone1).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
externalTunnel = new ExternalTunnelBuilder().setTunnelInterfaceName(parentInterfaceName).setTransportType(tunnelType1).setDestinationDevice("hwvtep:1").setSourceDevice(dpId2.toString()).setKey(new ExternalTunnelKey(dpId2.toString(), hwVtep1.getNodeId(), tunnelType1)).build();
trunkInterfaceName = ItmUtils.getTrunkInterfaceName(parentInterfaceName, String.valueOf(tunnelEndPointsVxlan.getIpAddress().getValue()), String.valueOf(ipAddress1.getValue()), tunnelType1.getName());
trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, ItmUtils.getExternalTunnelKey(String.valueOf(ipAddress1.getValue()), dpId2.toString(), tunnelType1));
doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId 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.model.match.types.rev131026.vlan.match.fields.VlanId 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.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.
the class ItmExternalTunnelAddWorker method wireUp.
// for tunnels from OVS
private boolean wireUp(BigInteger dpnId, String portname, Integer vlanId, IpAddress srcIp, Boolean remoteIpFlow, String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, IpAddress gwIp, IpPrefix dstSubnet, Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Integer monitorInterval, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, WriteTransaction transaction) {
IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
IpAddress gwyIpAddress = srcSubnet.equals(dstSubnet) ? gatewayIpObj : gwIp;
String parentIf = ItmUtils.getInterfaceName(dpnId, portname, vlanId);
String tunTypeStr = tunType.getName();
String tunnelIfName = ItmUtils.getTrunkInterfaceName(parentIf, new String(srcIp.getValue()), new String(dstIp.getValue()), tunTypeStr);
LOG.debug(" Creating ExternalTrunk Interface with parameters Name - {}, parent I/f name - {}, " + "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp, dstIp, gwyIpAddress);
Interface extTunnelIf = ItmUtils.buildTunnelInterface(dpnId, tunnelIfName, String.format("%s %s", tunType.getName(), "Trunk Interface"), true, tunType, srcIp, dstIp, gwyIpAddress, vlanId, false, monitorEnabled, monitorProtocol, monitorInterval, remoteIpFlow, null);
InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, new InterfaceKey(tunnelIfName)).build();
LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, extTunnelIf);
transaction.merge(LogicalDatastoreType.CONFIGURATION, ifIID, extTunnelIf, true);
ItmUtils.ITM_CACHE.addInterface(extTunnelIf);
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), dpnId.toString(), tunType));
ExternalTunnel tnl = ItmUtils.buildExternalTunnel(dpnId.toString(), getExternalTunnelKey(dstNodeId), tunType, tunnelIfName);
transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true);
ItmUtils.ITM_CACHE.addExternalTunnel(tnl);
return true;
}
Aggregations