use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.
the class ItmManagerRpcServiceTest method setupMocks.
private void setupMocks() {
deviceVteps = new DeviceVtepsBuilder().setIpAddress(ipAddress1).setKey(new DeviceVtepsKey(ipAddress1, "abc")).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
deviceVtepsList.add(deviceVteps);
stringList.add(sourceDevice);
dpId1List.add(dpId1);
stringList.add("def");
trunkInterfaceName = ItmUtils.getTrunkInterfaceName(tunnelInterfaceName, String.valueOf(ipAddress1.getValue()), String.valueOf(ipAddress1.getValue()), tunnelType1.getName());
interfaceIdentifier = ItmUtils.buildId(trunkInterfaceName);
tunnelEndPointsVxlan = new TunnelEndPointsBuilder().setVLANID(vlanId).setPortname(portName1).setIpAddress(ipAddress1).setGwIpAddress(gtwyIp1).setInterfaceName(tunnelInterfaceName).setTzMembership(ItmUtils.createTransportZoneMembership(transportZone1)).setTunnelType(tunnelType1).setSubnetMask(ipPrefixTest).setKey(new TunnelEndPointsKey(ipAddress1, portName1, tunnelType1, vlanId)).build();
tunnelEndPointsListVxlan.add(tunnelEndPointsVxlan);
dpntePsInfoVxlan = new DPNTEPsInfoBuilder().setDPNID(dpId1).setKey(new DPNTEPsInfoKey(dpId1)).setUp(true).setTunnelEndPoints(tunnelEndPointsListVxlan).build();
cfgdDpnListVxlan.add(dpntePsInfoVxlan);
dpnEndpoints = new DpnEndpointsBuilder().setDPNTEPsInfo(cfgdDpnListVxlan).build();
externalTunnel = new ExternalTunnelBuilder().setSourceDevice(sourceDevice).setDestinationDevice(destinationDevice).setTransportType(tunnelType1).setTunnelInterfaceName(tunnelInterfaceName).setKey(new ExternalTunnelKey(destinationDevice, sourceDevice, tunnelType1)).build();
internalTunnel = new InternalTunnelBuilder().setTunnelInterfaceNames(Collections.singletonList(tunnelInterfaceName)).setDestinationDPN(dpId2).setSourceDPN(dpId1).setTransportType(tunnelType1).setKey(new InternalTunnelKey(dpId2, dpId1, tunnelType1)).build();
getInternalOrExternalInterfaceNameInput = new GetInternalOrExternalInterfaceNameInputBuilder().setDestinationIp(ipAddress1).setSourceDpid(dpId1).setTunnelType(tunnelType2).build();
addExternalTunnelEndpointInput = new AddExternalTunnelEndpointInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).build();
addL2GwDeviceInput = new AddL2GwDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
deleteL2GwDeviceInput = new DeleteL2GwDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
addL2GwMlagDeviceInput = new AddL2GwMlagDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(stringList).setTopologyId(destinationDevice).build();
deleteL2GwMlagDeviceInput = new DeleteL2GwMlagDeviceInputBuilder().setIpAddress(ipAddress1).setNodeId(stringList).setTopologyId(destinationDevice).build();
buildExternalTunnelFromDpnsInput = new BuildExternalTunnelFromDpnsInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).setDpnId(dpId1List).build();
removeExternalTunnelFromDpnsInput = new RemoveExternalTunnelFromDpnsInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).setDpnId(dpId1List).build();
removeExternalTunnelEndpointInput = new RemoveExternalTunnelEndpointInputBuilder().setTunnelType(tunnelType1).setDestinationIp(ipAddress1).build();
removeTerminatingServiceActionsInput = new RemoveTerminatingServiceActionsInputBuilder().setServiceId(vlanId).setDpnId(dpId1).build();
getTunnelInterfaceNameInput = new GetTunnelInterfaceNameInputBuilder().setTunnelType(tunnelType1).setSourceDpid(dpId1).setDestinationDpid(dpId2).build();
getExternalTunnelInterfaceNameInput = new GetExternalTunnelInterfaceNameInputBuilder().setTunnelType(tunnelType1).setDestinationNode(destinationDevice).setSourceNode(sourceDevice).build();
iface = ItmUtils.buildTunnelInterface(dpId1, trunkInterfaceName, String.format("%s %s", ItmUtils.convertTunnelTypetoString(tunnelType1), "Trunk Interface"), true, tunnelType1, tunnelEndPointsVxlan.getIpAddress(), ipAddress1, gtwyIp1, tunnelEndPointsVxlan.getVLANID(), false, false, monitorProtocol, null, false, null);
subnetsTest = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).setKey(new SubnetsKey(ipPrefixTest)).setDeviceVteps(deviceVtepsList).build();
subnetsList.add(subnetsTest);
transportZone = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType1).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
transportZoneList.add(transportZone);
transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
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.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.
the class ItmTepAutoConfigTest method tepAddDeleteFromDefTzViaSouthboundTest.
@Test
public void tepAddDeleteFromDefTzViaSouthboundTest() throws Exception {
String tepIp = ItmTestConstants.DEF_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);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(connInfo, tepIp, ITMConstants.DEFAULT_TRANSPORT_ZONE, dataBroker);
future.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
Thread.sleep(1000);
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ITMConstants.DEFAULT_TRANSPORT_ZONE);
Assert.assertNotNull(tzonePath);
// check TEP is added into default-TZ
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithTep(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
// 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, ITMConstants.DEFAULT_TRANSPORT_ZONE, null, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
Thread.sleep(1000);
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> vtepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(vtepPath);
// check TEP is deleted from default-TZ when TEP-Ip is removed from southbound
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, vtepPath).get());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.
the class ItmTepAutoConfigTest method processDefTzOnItmConfig.
// Common method created for code-reuse
private InstanceIdentifier<TransportZone> processDefTzOnItmConfig(boolean defTzEnabledFlag, String defTzTunnelType) throws Exception {
ItmConfig itmConfigObj = null;
if (defTzTunnelType != null) {
// set def-tz-enabled flag and def-tz-tunnel-type
itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(defTzEnabledFlag).setDefTzTunnelType(defTzTunnelType).build();
} else {
// set def-tz-enabled flag only
itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(defTzEnabledFlag).build();
}
// Create TepCommandHelper object which creates/deletes default-TZ based
// on def-tz-enabled flag
TepCommandHelper tepCmdHelper = new TepCommandHelper(dataBroker, itmConfigObj);
tepCmdHelper.start();
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ITMConstants.DEFAULT_TRANSPORT_ZONE);
return tzonePath;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.
the class ItmTepAutoConfigTest method defTzDeletionTest.
@Test
public void defTzDeletionTest() throws Exception {
// create default-TZ first by setting def-tz-enabled flag to true
ItmConfig itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(true).setDefTzTunnelType(ITMConstants.TUNNEL_TYPE_GRE).build();
TepCommandHelper tepCmdHelper = new TepCommandHelper(dataBroker, itmConfigObj);
tepCmdHelper.start();
// Create TepCommandHelper object which creates/deletes default-TZ based on def-tz-enabled flag
InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ITMConstants.DEFAULT_TRANSPORT_ZONE);
Assert.assertNotNull(tzonePath);
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithGreTunnelType(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
// now delete default-TZ first by setting def-tz-enabled flag to false
itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(false).build();
// Create TepCommandHelper object which creates/deletes default-TZ based on def-tz-enabled flag
tepCmdHelper = new TepCommandHelper(dataBroker, itmConfigObj);
tepCmdHelper.start();
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).get());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone in project genius by opendaylight.
the class ItmTepAutoConfigTest method tepUpdateForTzTest.
@Test
public void tepUpdateForTzTest() throws Exception {
String tepIp = ItmTestConstants.DEF_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);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(connInfo, tepIp, ITMConstants.DEFAULT_TRANSPORT_ZONE, dataBroker);
future.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
Thread.sleep(1000);
// iid for default-TZ
InstanceIdentifier<TransportZone> defTzonePath = ItmTepAutoConfigTestUtil.getTzIid(ITMConstants.DEFAULT_TRANSPORT_ZONE);
Assert.assertNotNull(defTzonePath);
// check TEP is added into default-TZ
assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithTep(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, defTzonePath).checkedGet().get());
IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
InstanceIdentifier<Vteps> oldVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
Assert.assertNotNull(oldVTepPath);
// create Transport-zone TZA
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, tzonesPath, transportZones, dataBroker);
// iid for TZA configured from NB
InstanceIdentifier<TransportZone> tzaTzonePath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzaTzonePath);
// update OVSDB node with tzname=TZA in ExternalIds list
String tzName = ItmTestConstants.TZ_NAME;
OvsdbTestUtil.updateNode(connInfo, tepIp, tzName, null, dataBroker);
future.get();
// wait for OvsdbNodeListener to perform config DS update through transaction
Thread.sleep(1000);
// check old TEP which was in default-TZ is deleted
Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, oldVTepPath).get());
// check TEP is updated and now it is added into TZA transport-zone when tzname is updated
// to TZA from southbound
assertEqualBeans(ExpectedTransportZoneObjects.updatedTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzaTzonePath).checkedGet().get());
}
Aggregations