use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport 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 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
* @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
* @param tx TypedWriteTransaction object
*/
public static void addVtepInITMConfigDS(List<Vteps> updatedVtepList, IpAddress tepIpAddress, String tzName, Uint64 dpid, boolean ofTunnel, TypedWriteTransaction<Datastore.Configuration> tx) {
// 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(Uint64.ZERO) > 0) {
// create vtep
VtepsKey vtepkey = new VtepsKey(dpid);
Vteps vtepObj = new VtepsBuilder().setDpnId(dpid).setIpAddress(tepIpAddress).withKey(vtepkey).setOptionOfTunnel(ofTunnel).build();
// Add vtep obtained from bridge into list
updatedVtepList.add(vtepObj);
LOG.trace("Adding TEP (TZ: {} TEP IP: {} DPID: {}, of-tunnel: {}) in ITM Config DS.", tzName, 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 TZ node with updated subnet having new vtep
TransportZone updatedTzone = new TransportZoneBuilder().withKey(new TransportZoneKey(tzName)).setVteps(updatedVtepList).setZoneName(tzName).build();
// Update TZ in Config DS to add vtep in TZ
tx.mergeParentStructureMerge(tranzportZonePath, updatedTzone);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class ItmManagerRpcService method addL2GwDevice.
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public ListenableFuture<RpcResult<AddL2GwDeviceOutput>> addL2GwDevice(AddL2GwDeviceInput input) {
final SettableFuture<RpcResult<AddL2GwDeviceOutput>> result = SettableFuture.create();
boolean foundVxlanTzone = false;
try {
final IpAddress hwIp = input.getIpAddress();
final String nodeId = input.getNodeId();
// iterate through all transport zones and put TORs under vxlan
// if no vxlan tzone is cnfigured, return an error.
InstanceIdentifier<TransportZones> containerPath = InstanceIdentifier.create(TransportZones.class);
Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, containerPath, dataBroker);
if (transportZonesOptional.isPresent()) {
TransportZones transportZones = transportZonesOptional.get();
if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
LOG.error("No transportZone configured");
result.set(RpcResultBuilder.<AddL2GwDeviceOutput>failed().withError(RpcError.ErrorType.APPLICATION, "No transportZone Configured").build());
return result;
}
for (TransportZone tzone : transportZones.getTransportZone()) {
if (!TunnelTypeVxlan.class.equals(tzone.getTunnelType())) {
continue;
}
String transportZone = tzone.getZoneName();
foundVxlanTzone = true;
DeviceVtepsKey deviceVtepKey = new DeviceVtepsKey(hwIp, nodeId);
InstanceIdentifier<DeviceVteps> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone)).child(DeviceVteps.class, deviceVtepKey).build();
DeviceVteps deviceVtep = new DeviceVtepsBuilder().withKey(deviceVtepKey).setIpAddress(hwIp).setNodeId(nodeId).setTopologyId(input.getTopologyId()).build();
// TO DO: add retry if it fails
FluentFuture<?> future = retryingTxRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructurePut(path, deviceVtep));
future.addCallback(new FutureCallback<Object>() {
@Override
public void onSuccess(Object voidInstance) {
result.set(RpcResultBuilder.<AddL2GwDeviceOutput>success().build());
}
@Override
public void onFailure(Throwable error) {
String msg = String.format("Unable to write HwVtep %s to datastore", nodeId);
LOG.error("Unable to write HwVtep {}, {} to datastore", nodeId, hwIp);
result.set(RpcResultBuilder.<AddL2GwDeviceOutput>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
}, MoreExecutors.directExecutor());
}
} else {
result.set(RpcResultBuilder.<AddL2GwDeviceOutput>failed().withError(RpcError.ErrorType.APPLICATION, "No TransportZones configured").build());
return result;
}
if (!foundVxlanTzone) {
result.set(RpcResultBuilder.<AddL2GwDeviceOutput>failed().withError(RpcError.ErrorType.APPLICATION, "No VxLan TransportZones configured").build());
}
return result;
} catch (Exception e) {
RpcResultBuilder<AddL2GwDeviceOutput> resultBuilder = RpcResultBuilder.<AddL2GwDeviceOutput>failed().withError(RpcError.ErrorType.APPLICATION, "Adding l2 Gateway to DS Failed", e);
return Futures.immediateFuture(resultBuilder.build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class ItmTepAutoConfigTest method tepUpdateForBrNameTest.
@Test
public void tepUpdateForBrNameTest() throws Exception {
String tepIp = ItmTestConstants.NB_TZ_TEP_IP;
// prepare OVSDB node with tep-ip set into ExternalIds list
// OvsdbNodeListener would be automatically listen on Node to add TEP
ConnectionInfo connInfo = OvsdbTestUtil.getConnectionInfo(ItmTestConstants.OVSDB_CONN_PORT, ItmTestConstants.LOCALHOST_IP);
FluentFuture<? extends @NonNull CommitInfo> future = OvsdbTestUtil.createNode(connInfo, tepIp, ItmTestConstants.TZ_NAME, dataBroker);
future.get();
// create Transport-zone in advance
InstanceIdentifier<TransportZone> tzPath = ItmUtils.getTZInstanceIdentifier(ItmTestConstants.TZ_NAME);
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructureMerge(tzPath, transportZone)).get();
// add bridge into node
future = OvsdbTestUtil.addBridgeIntoNode(connInfo, ItmTestConstants.DEF_BR_NAME, ItmTestConstants.DEF_BR_DPID, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzonePath);
/*if (dataBroker != null)
{
String errMsg = "present db :" + dataBroker.newReadOnlyTransaction().
read(LogicalDatastoreType.CONFIGURATION, tzonePath);
throw new NullPointerException(errMsg);
}*/
// check TEP is added into TZ
assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get().get());
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> oldVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ItmTestConstants.TZ_NAME, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(oldVTepPath);
// add new bridge br2
future = OvsdbTestUtil.addBridgeIntoNode(connInfo, ItmTestConstants.BR2_NAME, ItmTestConstants.BR2_DPID, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
// update OVSDB node with br-name=br2 in ExternalIds column
String brName = ItmTestConstants.BR2_NAME;
future = OvsdbTestUtil.updateNode(connInfo, ItmTestConstants.NB_TZ_TEP_IP, ItmTestConstants.TZ_NAME, brName, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<Vteps> newVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ItmTestConstants.TZ_NAME, ItmTestConstants.INT_BR2_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(newVTepPath);
// check old TEP having default-bridge-DPID is deleted
Assert.assertEquals(Optional.empty(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, oldVTepPath).get());
// check TEP is updated with dpnId of br2 when br-name is updated to br2 from southbound
Assert.assertEquals(ItmTestConstants.INT_BR2_DPID, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, newVTepPath).get().get().getDpnId());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class ItmTepAutoConfigTest method tzDeletedAndReaddedTest.
@Test
public void tzDeletedAndReaddedTest() throws Exception {
// create TZ
InstanceIdentifier<TransportZone> tzPath = ItmUtils.getTZInstanceIdentifier(ItmTestConstants.TZ_NAME);
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructureMerge(tzPath, transportZone)).get();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzonePath);
// check TZ is created
Assert.assertEquals(ItmTestConstants.TZ_NAME, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get().get().getZoneName());
// add tep
ListenableFuture<?> futures = ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.NB_TZ_TEP_IP, ItmTestConstants.DEF_BR_DPID, ItmTestConstants.TZ_NAME, false, dataBroker, txRunner);
futures.get();
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> vtepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ItmTestConstants.TZ_NAME, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(vtepPath);
// check TEP is added into TZ that is already created.
assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get().get());
// remove Transport Zone
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.delete(tzPath));
// wait for TransportZoneListener to perform config DS update
// for TEP movement through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
// verify delete
Assert.assertEquals(Optional.empty(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get());
// check deleted tz moved to notHosted
InstanceIdentifier<TepsInNotHostedTransportZone> notHostedPath = ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(notHostedPath);
Assert.assertEquals(ItmTestConstants.TZ_NAME, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get().get().getZoneName());
// readd the same tz
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructureMerge(tzPath, transportZone)).get();
// wait for TransportZoneListener to perform config DS update
// for TEP movement through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
Assert.assertEquals(Optional.empty(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedPath).get());
assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get().get());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.
the class ItmTepAutoConfigTest method tepAddDeleteFromNbTzViaSouthboundTest.
@Test
public void tepAddDeleteFromNbTzViaSouthboundTest() throws Exception {
String tepIp = ItmTestConstants.NB_TZ_TEP_IP;
// create Network topology node with tep-ip set into ExternalIds list
// OvsdbNodeListener would be automatically listen on Node to add TEP
ConnectionInfo connInfo = OvsdbTestUtil.getConnectionInfo(ItmTestConstants.OVSDB_CONN_PORT, ItmTestConstants.LOCALHOST_IP);
FluentFuture<? extends @NonNull CommitInfo> future = OvsdbTestUtil.createNode(connInfo, tepIp, ItmTestConstants.TZ_NAME, dataBroker);
future.get();
// create Transport-zone in advance
InstanceIdentifier<TransportZone> tzPath = ItmUtils.getTZInstanceIdentifier(ItmTestConstants.TZ_NAME);
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructureMerge(tzPath, transportZone)).get();
// add bridge into node
future = OvsdbTestUtil.addBridgeIntoNode(connInfo, ItmTestConstants.DEF_BR_NAME, ItmTestConstants.DEF_BR_DPID, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzonePath);
// check TEP is added into NB configured TZ
assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get().get());
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> vtepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ItmTestConstants.TZ_NAME, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(vtepPath);
// test TEP delete now,
// pass tep-ip with NULL value, tep-ip paramtere in external_ids will not be set.
tepIp = null;
future = OvsdbTestUtil.updateNode(connInfo, tepIp, ItmTestConstants.TZ_NAME, null, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
coordinatorEventsWaiter.awaitEventsConsumption();
// check TEP is deleted from default-TZ when TEP-Ip is removed from southbound
Assert.assertEquals(Optional.empty(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, vtepPath).get());
}
Aggregations