Search in sources :

Example 1 with ManagerOtherConfigs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs in project netvirt by opendaylight.

the class HwvtepHAUtil method getChildNodeIdsFromManagerOtherConfig.

/**
 * Returns ha child node path from ha node of config data tree.
 *
 * @param haGlobalConfigNodeOptional HA global node
 * @return ha Child ids
 */
public static List<NodeId> getChildNodeIdsFromManagerOtherConfig(Optional<Node> haGlobalConfigNodeOptional) {
    List<NodeId> childNodeIds = new ArrayList<>();
    if (!haGlobalConfigNodeOptional.isPresent()) {
        return childNodeIds;
    }
    HwvtepGlobalAugmentation augmentation = haGlobalConfigNodeOptional.get().getAugmentation(HwvtepGlobalAugmentation.class);
    if (augmentation != null && augmentation.getManagers() != null && augmentation.getManagers().size() > 0) {
        Managers managers = augmentation.getManagers().get(0);
        if (null == managers.getManagerOtherConfigs()) {
            return childNodeIds;
        }
        for (ManagerOtherConfigs otherConfigs : managers.getManagerOtherConfigs()) {
            if (otherConfigs.getOtherConfigKey().equals(HA_CHILDREN)) {
                String nodeIdsVal = otherConfigs.getOtherConfigValue();
                if (nodeIdsVal != null) {
                    String[] parts = nodeIdsVal.split(",");
                    for (String part : parts) {
                        childNodeIds.add(new NodeId(part));
                    }
                }
            }
        }
    }
    return childNodeIds;
}
Also used : Managers(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ArrayList(java.util.ArrayList) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) ManagerOtherConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs)

Example 2 with ManagerOtherConfigs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs in project netvirt by opendaylight.

the class HwvtepHAUtil method buildManagersForHANode.

/**
 * Transform child managers (Source) to HA managers using HA node path.
 *
 * @param childNode Child Node
 * @param haGlobalCfg HA global config node
 * @return Transformed managers
 */
public static List<Managers> buildManagersForHANode(Node childNode, Optional<Node> haGlobalCfg) {
    Set<NodeId> nodeIds = new HashSet<>();
    nodeIds.add(childNode.getNodeId());
    List<NodeId> childNodeIds = getChildNodeIdsFromManagerOtherConfig(haGlobalCfg);
    nodeIds.addAll(childNodeIds);
    ManagersBuilder builder1 = new ManagersBuilder();
    builder1.setKey(new ManagersKey(new Uri(MANAGER_KEY)));
    List<ManagerOtherConfigs> otherConfigses = new ArrayList<>();
    StringBuffer stringBuffer = new StringBuffer();
    for (NodeId nodeId : nodeIds) {
        stringBuffer.append(nodeId.getValue());
        stringBuffer.append(",");
    }
    String children = stringBuffer.substring(0, stringBuffer.toString().length() - 1);
    otherConfigses.add(getOtherConfigBuilder(HA_CHILDREN, children).build());
    builder1.setManagerOtherConfigs(otherConfigses);
    List<Managers> managers = new ArrayList<>();
    managers.add(builder1.build());
    return managers;
}
Also used : ArrayList(java.util.ArrayList) ManagersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersBuilder) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) ManagerOtherConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs) Managers(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers) ManagersKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersKey) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) HashSet(java.util.HashSet)

Example 3 with ManagerOtherConfigs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs in project netvirt by opendaylight.

the class TestBuilders method buildOtherConfig.

public static ManagerOtherConfigs buildOtherConfig(String key, String val) {
    ManagerOtherConfigsBuilder otherConfigsBuilder = new ManagerOtherConfigsBuilder();
    ManagerOtherConfigsKey managerOtherConfigsKey = new ManagerOtherConfigsKey(key);
    otherConfigsBuilder.setKey(managerOtherConfigsKey);
    otherConfigsBuilder.setOtherConfigKey(key);
    otherConfigsBuilder.setOtherConfigValue(val);
    return otherConfigsBuilder.build();
}
Also used : ManagerOtherConfigsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigsBuilder) ManagerOtherConfigsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigsKey)

Example 4 with ManagerOtherConfigs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs in project netvirt by opendaylight.

the class TestBuilders method buildManagers.

public static List<Managers> buildManagers() {
    ManagersBuilder builder1 = new ManagersBuilder();
    builder1.setKey(new ManagersKey(new Uri("test")));
    List<ManagerOtherConfigs> otherConfigses = new ArrayList<>();
    otherConfigses.add(buildOtherConfig("ha_enabled", "true"));
    otherConfigses.add(buildOtherConfig("ha_id", "switchxyz"));
    builder1.setManagerOtherConfigs(otherConfigses);
    List<Managers> managers = new ArrayList<>();
    managers.add(builder1.build());
    return managers;
}
Also used : Managers(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers) ManagersKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersKey) ArrayList(java.util.ArrayList) ManagersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersBuilder) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) ManagerOtherConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs)

Aggregations

ArrayList (java.util.ArrayList)3 Managers (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers)3 ManagerOtherConfigs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs)3 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)2 ManagersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersBuilder)2 ManagersKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ManagersKey)2 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)2 HashSet (java.util.HashSet)1 HwvtepGlobalAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)1 ManagerOtherConfigsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigsBuilder)1 ManagerOtherConfigsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigsKey)1