Search in sources :

Example 6 with 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 OvsdbSouthboundTestUtil method getConnectionInfo.

public ConnectionInfo getConnectionInfo(Node ovsdbNode) {
    ConnectionInfo connectionInfo = null;
    OvsdbNodeAugmentation ovsdbNodeAugmentation = extractOvsdbNode(ovsdbNode);
    if (ovsdbNodeAugmentation != null) {
        connectionInfo = ovsdbNodeAugmentation.getConnectionInfo();
    }
    return connectionInfo;
}
Also used : OvsdbNodeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation) ConnectionInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo)

Example 7 with 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 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());
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) ConnectionInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) Test(org.junit.Test)

Example 8 with 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 ItmTepAutoConfigTest method tzAddDeleteToNotHostedViaSouthboundTest.

@Test
public void tzAddDeleteToNotHostedViaSouthboundTest() throws Exception {
    // create Network topology node
    ConnectionInfo connInfo = OvsdbTestUtil.getConnectionInfo(ItmTestConstants.OVSDB_CONN_PORT, ItmTestConstants.LOCALHOST_IP);
    CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(connInfo, ItmTestConstants.NOT_HOSTED_TZ_TEP_IP, ItmTestConstants.NOT_HOSTED_TZ_NAME, dataBroker);
    future.get();
    // add bridge into node
    future = OvsdbTestUtil.addBridgeIntoNode(connInfo, ItmTestConstants.DEF_BR_NAME, ItmTestConstants.NOT_HOSTED_DEF_BR_DPID, dataBroker);
    future.get();
    // wait for OvsdbNodeListener to perform config DS update through transaction
    Thread.sleep(1000);
    InstanceIdentifier<TepsInNotHostedTransportZone> notHostedtzPath = ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.NOT_HOSTED_TZ_NAME);
    Assert.assertNotNull(notHostedtzPath);
    // check not hosted
    assertEqualBeans(ExpectedTepNotHostedTransportZoneObjects.newTepNotHostedTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedtzPath).checkedGet().get());
    future = OvsdbTestUtil.updateNode(connInfo, ItmTestConstants.NOT_HOSTED_TZ_TEP_IP, null, ItmTestConstants.DEF_BR_NAME, dataBroker);
    future.get();
    // wait for OvsdbNodeListener to perform config DS update through transaction
    Thread.sleep(1000);
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, notHostedtzPath).get());
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) ConnectionInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo) Test(org.junit.Test)

Example 9 with 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 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());
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) ConnectionInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) Test(org.junit.Test)

Example 10 with 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 updateNode.

public static CheckedFuture<Void, TransactionCommitFailedException> updateNode(ConnectionInfo connectionInfo, String tepIp, String tzName, String brName, DataBroker dataBroker) throws Exception {
    final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
    Node oldOvsdbNode = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, iid).checkedGet().get();
    // build Node using its builder class
    NodeBuilder nodeBuilder = new NodeBuilder();
    nodeBuilder.setNodeId(oldOvsdbNode.getNodeId());
    // 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);
    }
    if (brName != null && !brName.isEmpty()) {
        externalIds.put(ItmTestConstants.EXTERNAL_ID_BR_NAME_KEY, brName);
    }
    // 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 otherConfigsValue = null;
    for (String otherConfigKey : otherConfigKeys) {
        otherConfigsValue = otherConfigs.get(otherConfigKey);
        if (otherConfigKey != null && otherConfigsValue != null) {
            otherConfigsList.add(new OpenvswitchOtherConfigsBuilder().setOtherConfigKey(otherConfigKey).setOtherConfigValue(otherConfigsValue).build());
        }
    }
    // set ExternalIds list into Node
    ovsdbNodeAugBuilder.setOpenvswitchExternalIds(externalIdsList);
    // set OtherConfigs list into Node
    ovsdbNodeAugBuilder.setOpenvswitchOtherConfigs(otherConfigsList);
    // add OvsdbNodeAugmentation into Node
    nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, ovsdbNodeAugBuilder.build());
    Node ovsdbNode = nodeBuilder.build();
    // ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
    WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
    transaction.put(LogicalDatastoreType.OPERATIONAL, iid, ovsdbNode, true);
    return transaction.submit();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) HashMap(java.util.HashMap) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) OvsdbNodeAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentationBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) OpenvswitchExternalIds(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIds) OpenvswitchOtherConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigs) OpenvswitchExternalIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIdsBuilder) OpenvswitchOtherConfigsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigsBuilder)

Aggregations

ConnectionInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo)7 Test (org.junit.Test)5 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)5 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)5 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)4 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)4 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)4 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)2 OvsdbNodeAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentationBuilder)2 ConnectionInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfoBuilder)2 OpenvswitchExternalIds (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIds)2 OpenvswitchExternalIdsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIdsBuilder)2 OpenvswitchOtherConfigs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigs)2 OpenvswitchOtherConfigsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigsBuilder)2