Search in sources :

Example 1 with OpenvswitchOtherConfigsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigsBuilder 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();
}
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) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) OpenvswitchOtherConfigsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigsBuilder)

Example 2 with OpenvswitchOtherConfigsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigsBuilder 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

ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 OvsdbNodeAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentationBuilder)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 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)2 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)2 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)1