use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project genius by opendaylight.
the class VtepConfigSchemaListener method deAllocateIpAddresses.
/**
* De-allocate ip addresses.
*
* @param freeIps
* the free ips
* @param subnetCidr
* the subnet cidr
*/
private void deAllocateIpAddresses(List<IpAddress> freeIps, String subnetCidr) {
VtepIpPool vtepIpPool = getVtepIpPool(subnetCidr);
if (freeIps != null && !freeIps.isEmpty() && vtepIpPool != null) {
// Remove from the allocated IP address list and add to available IP
// address list.
VtepIpPoolBuilder builder = new VtepIpPoolBuilder(vtepIpPool);
if (builder.getAllocatedIpaddress() != null) {
builder.getAllocatedIpaddress().removeAll(freeIps);
}
if (builder.getAvailableIpaddress() == null) {
builder.setAvailableIpaddress(freeIps);
} else {
builder.getAvailableIpaddress().addAll(freeIps);
}
MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION, ItmUtils.getVtepIpPoolIdentifier(subnetCidr), builder.build());
LOG.debug("Vtep IP Pool with key:{} updated to config DS", subnetCidr);
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project genius by opendaylight.
the class VtepConfigSchemaListener method handleNewlyAddedDpnsToSchema.
/**
* Handle newly added dpns to schema.
*
* @param original
* the original
* @param originalDpnIds
* the original dpn ids
* @param updatedDpnIds
* the updated dpn ids
*/
private void handleNewlyAddedDpnsToSchema(VtepConfigSchema original, List<DpnIds> originalDpnIds, List<DpnIds> updatedDpnIds) {
LOG.trace("Handle Addition of DPNs from VTEP Original Dpn: {}. Updated Dpn: {}", originalDpnIds, updatedDpnIds);
ArrayList<DpnIds> newlyAddedDpns = new ArrayList<>(updatedDpnIds);
newlyAddedDpns.removeAll(originalDpnIds);
LOG.debug("Newly added DPNs {} to VTEP config schema [{}].", newlyAddedDpns, original.getSchemaName());
if (!newlyAddedDpns.isEmpty()) {
VtepConfigSchema diffSchema = new VtepConfigSchemaBuilder(original).setDpnIds(newlyAddedDpns).build();
String subnetCidr = ItmUtils.getSubnetCidrAsString(original.getSubnet());
VtepIpPool vtepIpPool = getVtepIpPool(subnetCidr);
LOG.debug("Adding of DPNs in Diff Schema: {}", diffSchema);
addVteps(diffSchema, vtepIpPool);
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project genius by opendaylight.
the class VtepConfigSchemaListener method addVteps.
/**
* Adds the vteps.
*
* @param schema
* the schema
* @param vtepIpPool
* the vtep ip pool
*/
private void addVteps(VtepConfigSchema schema, VtepIpPool vtepIpPool) {
if (schema.getDpnIds() == null || schema.getDpnIds().isEmpty()) {
LOG.debug("DPN list is empty, skipping addVteps for schema: {}", schema);
return;
}
String subnetCidr = ItmUtils.getSubnetCidrAsString(schema.getSubnet());
if (vtepIpPool == null) {
LOG.error("VTEP config pool not found for subnetCidr {}. Failed to add VTEPs for schema {}", subnetCidr, schema);
return;
}
TepCommandHelper tepCommandHelper = new TepCommandHelper(this.dataBroker, itmConfig);
// Check this later
String tunType;
Class<? extends TunnelTypeBase> tunnelType = schema.getTunnelType();
if (tunnelType.equals(TunnelTypeVxlan.class)) {
tunType = ITMConstants.TUNNEL_TYPE_VXLAN;
} else {
tunType = ITMConstants.TUNNEL_TYPE_GRE;
}
tepCommandHelper.configureTunnelType(schema.getTransportZoneName(), StringUtils.upperCase(tunType));
List<IpAddress> availableIps = vtepIpPool.getAvailableIpaddress();
List<IpAddress> newlyAllocatedIps = new ArrayList<>();
List<BigInteger> skippedDpnIds = new ArrayList<>();
String gatewayIp = handleGatewayIp(schema.getGatewayIp());
for (BigInteger dpnId : ItmUtils.getDpnIdList(schema.getDpnIds())) {
IpAddress ipAddress = getAnAvailableIP(availableIps);
if (ipAddress == null) {
skippedDpnIds.add(dpnId);
continue;
}
try {
tepCommandHelper.createLocalCache(dpnId, schema.getPortName(), schema.getVlanId(), String.valueOf(ipAddress.getValue()), subnetCidr, gatewayIp, schema.getTransportZoneName(), null);
} catch (TepException e) {
LOG.error("create local cache Failed", e);
}
newlyAllocatedIps.add(ipAddress);
}
if (!skippedDpnIds.isEmpty()) {
LOG.error("No available IP addresses in the VTEP config pool {}, skipping VTEP configurations for DPN's {}", subnetCidr, skippedDpnIds);
}
if (!newlyAllocatedIps.isEmpty()) {
LOG.debug("Delete OnCommit and buildTeps in NewlyAddedDpns");
tepCommandHelper.deleteOnCommit();
tepCommandHelper.buildTeps();
allocateIpAddresses(newlyAllocatedIps, vtepIpPool, subnetCidr);
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project genius by opendaylight.
the class ItmManagerRpcServiceTest method setUp.
@Before
public void setUp() throws Exception {
deviceVteps = new DeviceVtepsBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setKey(new DeviceVtepsKey(ItmTestConstants.IP_ADDRESS_3, ItmTestConstants.SOURCE_DEVICE)).setNodeId(ItmTestConstants.SOURCE_DEVICE).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
deviceVtepsList.add(deviceVteps);
stringList.add(ItmTestConstants.SOURCE_DEVICE);
dpId1List.add(ItmTestConstants.DP_ID_1);
stringList.add(ItmTestConstants.SOURCE_DEVICE_2);
trunkInterfaceName = ItmUtils.getTrunkInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME, String.valueOf(ItmTestConstants.IP_ADDRESS_3.getValue()), String.valueOf(ItmTestConstants.IP_ADDRESS_3.getValue()), ItmTestConstants.TUNNEL_TYPE_VXLAN.getName());
interfaceIdentifier = ItmUtils.buildId(trunkInterfaceName);
tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(ItmTestConstants.VLAN_ID).setPortname(ItmTestConstants.PORT_NAME_1).setIpAddress(ItmTestConstants.IP_ADDRESS_3).setGwIpAddress(ItmTestConstants.GTWY_IP_1).setInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).setTzMembership(ItmUtils.createTransportZoneMembership(ItmTestConstants.TZ_NAME)).setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setSubnetMask(ItmTestConstants.IP_PREFIX_TEST).setKey(new TunnelEndPointsKey(ItmTestConstants.IP_ADDRESS_3, ItmTestConstants.PORT_NAME_1, ItmTestConstants.TUNNEL_TYPE_VXLAN, ItmTestConstants.VLAN_ID)).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(ItmTestConstants.DP_ID_1).setKey(new DPNTEPsInfoKey(ItmTestConstants.DP_ID_1)).setUp(true).setTunnelEndPoints(tunnelEndPointsListVxlan).build();
cfgdDpnListVxlan.add(dpntePsInfoVxlan);
dpnEndpoints = new DpnEndpointsBuilder().setDPNTEPsInfo(cfgdDpnListVxlan).build();
internalTunnel = new InternalTunnelBuilder().setTunnelInterfaceNames(Collections.singletonList(ItmTestConstants.PARENT_INTERFACE_NAME)).setDestinationDPN(ItmTestConstants.DP_ID_2).setSourceDPN(ItmTestConstants.DP_ID_1).setTransportType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setKey(new InternalTunnelKey(ItmTestConstants.DP_ID_2, ItmTestConstants.DP_ID_1, ItmTestConstants.TUNNEL_TYPE_VXLAN)).build();
getExternalInterfaceNameInput = new GetInternalOrExternalInterfaceNameInputBuilder().setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setSourceDpid(ItmTestConstants.DP_ID_1).setTunnelType(ItmTestConstants.TUNNEL_TYPE_MPLS_OVER_GRE).build();
getInternalInterfaceNameInput = new GetInternalOrExternalInterfaceNameInputBuilder().setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setSourceDpid(ItmTestConstants.DP_ID_1).setTunnelType(ItmTestConstants.TUNNEL_TYPE_MPLS_OVER_GRE).build();
addExternalTunnelEndpointInput = new AddExternalTunnelEndpointInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).build();
addL2GwDeviceInput = new AddL2GwDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(ItmTestConstants.SOURCE_DEVICE).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
deleteL2GwDeviceInput = new DeleteL2GwDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(ItmTestConstants.SOURCE_DEVICE).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
addL2GwMlagDeviceInput = new AddL2GwMlagDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(stringList).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
deleteL2GwMlagDeviceInput = new DeleteL2GwMlagDeviceInputBuilder().setIpAddress(ItmTestConstants.IP_ADDRESS_3).setNodeId(stringList).setTopologyId(ItmTestConstants.DESTINATION_DEVICE).build();
buildExternalTunnelFromDpnsInput = new BuildExternalTunnelFromDpnsInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setDpnId(dpId1List).build();
removeExternalTunnelFromDpnsInput = new RemoveExternalTunnelFromDpnsInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).setDpnId(dpId1List).build();
removeExternalTunnelEndpointInput = new RemoveExternalTunnelEndpointInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationIp(ItmTestConstants.IP_ADDRESS_3).build();
getTunnelInterfaceNameInput = new GetTunnelInterfaceNameInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setSourceDpid(ItmTestConstants.DP_ID_1).setDestinationDpid(ItmTestConstants.DP_ID_2).build();
getExternalTunnelInterfaceNameInput = new GetExternalTunnelInterfaceNameInputBuilder().setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setDestinationNode(ItmTestConstants.DESTINATION_DEVICE).setSourceNode(ItmTestConstants.SOURCE_DEVICE).build();
iface = ItmUtils.buildTunnelInterface(ItmTestConstants.DP_ID_1, trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(ItmTestConstants.TUNNEL_TYPE_VXLAN), "Trunk Interface"), true, ItmTestConstants.TUNNEL_TYPE_VXLAN, tunnelEndPointsVxlan.getIpAddress(), ItmTestConstants.IP_ADDRESS_3, ItmTestConstants.GTWY_IP_1, tunnelEndPointsVxlan.getVLANID(), false, false, ItmTestConstants.MONITOR_PROTOCOL, null, false, null);
subnetsTest = new SubnetsBuilder().setGatewayIp(ItmTestConstants.GTWY_IP_1).setVlanId(ItmTestConstants.VLAN_ID).setKey(new SubnetsKey(ItmTestConstants.IP_PREFIX_TEST)).setDeviceVteps(deviceVtepsList).build();
subnetsList.add(subnetsTest);
transportZone = new TransportZoneBuilder().setZoneName(ItmTestConstants.TZ_NAME).setTunnelType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setKey(new TransportZoneKey(ItmTestConstants.TZ_NAME)).setSubnets(subnetsList).build();
transportZoneList.add(transportZone);
transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
// build external tunnel objects
externalTunnel = new ExternalTunnelBuilder().setSourceDevice(ItmTestConstants.DP_ID_1.toString()).setDestinationDevice(String.valueOf(ItmTestConstants.IP_ADDRESS_3.getValue())).setTransportType(TunnelTypeMplsOverGre.class).setTunnelInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).build();
externalTunnel2 = new ExternalTunnelBuilder().setSourceDevice(ItmTestConstants.SOURCE_DEVICE).setDestinationDevice(ItmTestConstants.DESTINATION_DEVICE).setTransportType(ItmTestConstants.TUNNEL_TYPE_VXLAN).setTunnelInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).build();
getInternalOrExternalInterfaceNameOutput = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(ItmTestConstants.PARENT_INTERFACE_NAME).build();
// commit external tunnel into config DS
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier, externalTunnel, dataBroker);
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, externalTunnelIdentifier2, externalTunnel2, dataBroker);
// commit internal tunnel into config DS
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, internalTunnelIdentifier, internalTunnel, dataBroker);
// commit dpnEndpoints into config DS
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, dpnEndpointsIdentifier, dpnEndpoints, dataBroker);
// commit TZ into config DS
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, transportZonesIdentifier, transportZones, dataBroker);
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project genius by opendaylight.
the class ItmTepAutoConfigTest method defTzEnabledTrueConfigTest.
@Test
public void defTzEnabledTrueConfigTest() throws Exception {
InstanceIdentifier<ItmConfig> iid = InstanceIdentifier.create(ItmConfig.class);
// set def-tz-enabled flag to true
ItmConfig itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(true).build();
// write into config DS
CheckedFuture<Void, TransactionCommitFailedException> futures = ItmTepAutoConfigTestUtil.writeItmConfig(iid, itmConfigObj, dataBroker);
futures.get();
// read from config DS
boolean defTzEnabled = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, iid).get().isDefTzEnabled();
Assert.assertEquals(defTzEnabled, true);
}
Aggregations