use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.
the class ItmManagerRpcService method addExternalTunnelEndpoint.
@Override
public Future<RpcResult<Void>> addExternalTunnelEndpoint(AddExternalTunnelEndpointInput input) {
// TODO Auto-generated method stub
// Ignore the Futures for now
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
externalTunnelAddWorker.buildTunnelsToExternalEndPoint(meshedDpnList, input.getDestinationIp(), input.getTunnelType());
InstanceIdentifier<DcGatewayIp> extPath = InstanceIdentifier.builder(DcGatewayIpList.class).child(DcGatewayIp.class, new DcGatewayIpKey(input.getDestinationIp())).build();
DcGatewayIp dcGatewayIp = new DcGatewayIpBuilder().setIpAddress(input.getDestinationIp()).setTunnnelType(input.getTunnelType()).build();
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(LogicalDatastoreType.CONFIGURATION, extPath, dcGatewayIp, true);
ListenableFuture<Void> futureCheck = writeTransaction.submit();
Futures.addCallback(futureCheck, new FutureCallback<Void>() {
@Override
public void onSuccess(Void voidInstance) {
result.set(RpcResultBuilder.<Void>success().build());
}
@Override
public void onFailure(Throwable error) {
String msg = "Unable to create DcGatewayIp {} in datastore for ip " + input.getDestinationIp() + "and " + "tunnel type " + input.getTunnelType();
LOG.error("Unable to create DcGatewayIp in datastore for ip {} and tunnel type {}", input.getDestinationIp(), input.getTunnelType());
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
});
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.
the class InterfaceStateListener method update.
@Override
public void update(@Nonnull Interface originalInterface, @Nonnull Interface updatedInterface) {
/*
* update contains only delta, may not include iftype Note: This assumes
* type can't be edited on the fly
*/
if (ItmUtils.isItmIfType(originalInterface.getType())) {
LOG.trace("Interface updated. Old: {} New: {}", originalInterface, updatedInterface);
OperStatus operStatus = updatedInterface.getOperStatus();
if (!Objects.equals(originalInterface.getOperStatus(), updatedInterface.getOperStatus())) {
LOG.debug("Tunnel Interface {} changed state to {}", originalInterface.getName(), operStatus);
jobCoordinator.enqueueJob(ITMConstants.ITM_PREFIX + originalInterface.getName(), () -> updateTunnel(updatedInterface));
}
if (tunnelAggregationHelper.isTunnelAggregationEnabled()) {
tunnelAggregationHelper.updateLogicalTunnelState(originalInterface, updatedInterface, ItmTunnelAggregationHelper.MOD_TUNNEL, dataBroker);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.
the class OvsdbNodeListener method processBridgeUpdate.
private void processBridgeUpdate(OvsdbBridgeAugmentation ovsdbNewBridgeAugmentation) {
String bridgeName = null;
String strDpnId = null;
OvsdbNodeAugmentation ovsdbNewNodeAugmentation = null;
if (ovsdbNewBridgeAugmentation != null) {
bridgeName = ovsdbNewBridgeAugmentation.getBridgeName().getValue();
// Read DPID from OVSDBBridgeAugmentation
strDpnId = ItmUtils.getStrDatapathId(ovsdbNewBridgeAugmentation);
if (strDpnId == null || strDpnId.isEmpty()) {
LOG.info("OvsdbBridgeAugmentation processBridgeUpdate: DPID for bridge {} is NULL.", bridgeName);
return;
}
// TBD: Move this time taking operations into DataStoreJobCoordinator
Node ovsdbNodeFromBridge = ItmUtils.getOvsdbNode(ovsdbNewBridgeAugmentation, dataBroker);
// check for OVSDB node
if (ovsdbNodeFromBridge != null) {
ovsdbNewNodeAugmentation = ovsdbNodeFromBridge.getAugmentation(OvsdbNodeAugmentation.class);
} else {
LOG.error("processBridgeUpdate: Ovsdb Node could not be fetched from Oper DS for bridge {}.", bridgeName);
return;
}
}
if (ovsdbNewNodeAugmentation != null) {
OvsdbTepInfo ovsdbTepInfo = getOvsdbTepInfo(ovsdbNewNodeAugmentation);
if (ovsdbTepInfo == null) {
LOG.trace("processBridgeUpdate: No Tep Info");
return;
}
// store TEP info required parameters
String newLocalIp = ovsdbTepInfo.getLocalIp();
String tzName = ovsdbTepInfo.getTzName();
String newBridgeName = ovsdbTepInfo.getBrName();
boolean ofTunnel = ovsdbTepInfo.getOfTunnel();
// check if Local IP is configured or not
if (newLocalIp != null && !newLocalIp.isEmpty()) {
// if it is br-int, then add TEP into Config DS
if (newBridgeName.equals(bridgeName)) {
LOG.trace("Ovs Node with bridge {} is configured with Local IP.", bridgeName);
// if flag is OFF, then no need to add TEP into ITM config DS.
if (tzName == null || tzName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
boolean defTzEnabled = itmConfig.isDefTzEnabled();
if (!defTzEnabled) {
LOG.info("TEP ({}) cannot be added into {} when def-tz-enabled flag is false.", newLocalIp, ITMConstants.DEFAULT_TRANSPORT_ZONE);
return;
}
}
LOG.trace("Local-IP: {}, TZ name: {}, Bridge Name: {}, Bridge DPID: {}," + "of-tunnel flag: {}", newLocalIp, tzName, newBridgeName, strDpnId, ofTunnel);
// Enqueue 'add TEP into new TZ' operation into DataStoreJobCoordinator
jobCoordinator.enqueueJob(newLocalIp, new OvsdbTepAddWorker(newLocalIp, strDpnId, tzName, ofTunnel, dataBroker));
} else {
LOG.trace("TEP ({}) would be added later when bridge {} gets added into Ovs Node.", newLocalIp, newBridgeName);
}
} else {
LOG.trace("Ovs Node with bridge {} is not configured with Local IP. Nothing to do.", bridgeName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel in project genius by opendaylight.
the class TransportZoneListener method remove.
@Override
public void remove(@Nonnull TransportZone transportZone) {
LOG.debug("Received Transport Zone Remove Event: {}", transportZone);
boolean allowTunnelDeletion;
// due to change in def-tz-tunnel-type, then allow def-tz tunnels deletion
if (transportZone.getZoneName().equalsIgnoreCase(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
// Get TunnelTypeBase object for tunnel-type configured in config file
Class<? extends TunnelTypeBase> tunType = ItmUtils.getTunnelType(itmConfig.getDefTzTunnelType());
if (!itmConfig.isDefTzEnabled() || !transportZone.getTunnelType().equals(tunType)) {
allowTunnelDeletion = true;
} else {
// this is case when def-tz removal request is from Northbound.
allowTunnelDeletion = false;
LOG.error("Deletion of {} is an incorrect usage", ITMConstants.DEFAULT_TRANSPORT_ZONE);
}
} else {
allowTunnelDeletion = true;
}
if (allowTunnelDeletion) {
// TODO : DPList code can be refactor with new specific class
// which implement TransportZoneValidator
List<DPNTEPsInfo> opDpnList = createDPNTepInfo(transportZone);
List<HwVtep> hwVtepList = createhWVteps(transportZone);
LOG.trace("Delete: Invoking deleteTunnels in ItmManager with DpnList {}", opDpnList);
if (!opDpnList.isEmpty() || !hwVtepList.isEmpty()) {
LOG.trace("Delete: Invoking ItmManager with hwVtep List {} ", hwVtepList);
jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmTepRemoveWorker(opDpnList, hwVtepList, transportZone, dataBroker, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache));
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel 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);
}
Aggregations