use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo in project genius by opendaylight.
the class ItmTepAutoConfigTest method tepAddDeleteFromNbTzViaSouthboundTest.
@Test
public void tepAddDeleteFromNbTzViaSouthboundTest() throws Exception {
// create Transport-zone in advance
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, tzonesPath, transportZones, dataBroker);
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);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(connInfo, tepIp, ItmTestConstants.TZ_NAME, 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(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzonePath);
// check TEP is added into NB configured TZ
assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().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
Thread.sleep(1000);
// 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.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo in project genius by opendaylight.
the class ItmTepAutoConfigTest method tepUpdateForBrNameTest.
@Test
public void tepUpdateForBrNameTest() throws Exception {
// create Transport-zone in advance
ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, tzonesPath, transportZones, dataBroker);
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);
CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(connInfo, tepIp, ItmTestConstants.TZ_NAME, 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(ItmTestConstants.TZ_NAME);
Assert.assertNotNull(tzonePath);
// check TEP is added into TZ
assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().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
Thread.sleep(1000);
// 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
Thread.sleep(1000);
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.absent(), 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).checkedGet().get().getDpnId());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo in project genius by opendaylight.
the class OvsdbTestUtil method createNode.
public static CheckedFuture<Void, TransactionCommitFailedException> createNode(ConnectionInfo connectionInfo, String tepIp, String tzName, DataBroker dataBroker) throws Exception {
final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
// build Node using its builder class
NodeBuilder nodeBuilder = new NodeBuilder();
NodeId ovsdbNodeId = SouthboundUtils.createNodeId(connectionInfo.getRemoteIp(), connectionInfo.getRemotePort());
nodeBuilder.setNodeId(ovsdbNodeId);
// build OvsdbNodeAugmentation for Node
OvsdbNodeAugmentationBuilder ovsdbNodeAugBuilder = new OvsdbNodeAugmentationBuilder();
ovsdbNodeAugBuilder.setConnectionInfo(connectionInfo);
// create map of key-val pairs
Map<String, String> externalIds = new HashMap<>();
Map<String, String> otherConfigs = new HashMap<>();
if (tepIp != null && !tepIp.isEmpty()) {
otherConfigs.put(ItmTestConstants.OTHER_CFG_TEP_IP_KEY, tepIp);
}
if (tzName != null) {
externalIds.put(ItmTestConstants.EXTERNAL_ID_TZNAME_KEY, tzName);
}
// get map-keys into set.
Set<String> externalIdKeys = externalIds.keySet();
Set<String> otherConfigKeys = otherConfigs.keySet();
List<OpenvswitchExternalIds> externalIdsList = new ArrayList<>();
String externalIdValue = null;
for (String externalIdKey : externalIdKeys) {
externalIdValue = externalIds.get(externalIdKey);
if (externalIdKey != null && externalIdValue != null) {
externalIdsList.add(new OpenvswitchExternalIdsBuilder().setExternalIdKey(externalIdKey).setExternalIdValue(externalIdValue).build());
}
}
List<OpenvswitchOtherConfigs> otherConfigsList = new ArrayList<>();
String otherConfigValue = null;
for (String otherConfigKey : otherConfigKeys) {
otherConfigValue = otherConfigs.get(otherConfigKey);
if (otherConfigKey != null && otherConfigValue != null) {
otherConfigsList.add(new OpenvswitchOtherConfigsBuilder().setOtherConfigKey(otherConfigKey).setOtherConfigValue(otherConfigValue).build());
}
}
// set ExternalIds list into Node
ovsdbNodeAugBuilder.setOpenvswitchExternalIds(externalIdsList);
// set OtherConfig list into Node
ovsdbNodeAugBuilder.setOpenvswitchOtherConfigs(otherConfigsList);
// add OvsdbNodeAugmentation into Node
nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, ovsdbNodeAugBuilder.build());
Node ovsdbNode = nodeBuilder.build();
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
transaction.put(LogicalDatastoreType.OPERATIONAL, iid, ovsdbNode, true);
return transaction.submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo in project genius by opendaylight.
the class OvsdbTestUtil method getConnectionInfo.
/* methods */
public static ConnectionInfo getConnectionInfo(int port, String strIpAddress) {
IpAddress ipAddress = IpAddressBuilder.getDefaultInstance(strIpAddress);
PortNumber portNumber = new PortNumber(port);
ConnectionInfo connectionInfo = new ConnectionInfoBuilder().setRemoteIp(ipAddress).setRemotePort(portNumber).build();
return connectionInfo;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo in project genius by opendaylight.
the class OvsdbTestUtil method addBridgeIntoNode.
public static CheckedFuture<Void, TransactionCommitFailedException> addBridgeIntoNode(ConnectionInfo connectionInfo, String bridgeName, String dpid, DataBroker dataBroker) throws Exception {
NodeId ovsdbNodeId = SouthboundUtils.createNodeId(connectionInfo.getRemoteIp(), connectionInfo.getRemotePort());
NodeKey nodeKey = new NodeKey(ovsdbNodeId);
NodeBuilder bridgeNodeBuilder = new NodeBuilder();
InstanceIdentifier<Node> bridgeIid = SouthboundUtils.createInstanceIdentifier(nodeKey, bridgeName);
NodeId bridgeNodeId = SouthboundUtils.createManagedNodeId(bridgeIid);
bridgeNodeBuilder.setNodeId(bridgeNodeId);
OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
ovsdbBridgeAugmentationBuilder.setBridgeName(new OvsdbBridgeName(bridgeName)).setDatapathId(new DatapathId(dpid));
ovsdbBridgeAugmentationBuilder.setManagedBy(new OvsdbNodeRef(SouthboundUtils.createInstanceIdentifier(nodeKey.getNodeId())));
bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, ovsdbBridgeAugmentationBuilder.build());
Node bridgeNode = bridgeNodeBuilder.build();
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.merge(LogicalDatastoreType.OPERATIONAL, bridgeIid, bridgeNode, true);
return tx.submit();
}
Aggregations