use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.
the class HwvtepHAUtil method convertLogicalSwitchRef.
/**
* Trnaform logical switch to nodepath passed .
*
* @param src {@link HwvtepLogicalSwitchRef} Logical Switch Ref which needs to be transformed
* @param nodePath {@link InstanceIdentifier} src needs to be transformed to this path
* @return ref {@link HwvtepLogicalSwitchRef} the transforrmed result
*/
public static HwvtepLogicalSwitchRef convertLogicalSwitchRef(HwvtepLogicalSwitchRef src, InstanceIdentifier<Node> nodePath) {
InstanceIdentifier<LogicalSwitches> srcId = (InstanceIdentifier<LogicalSwitches>) src.getValue();
HwvtepNodeName switchName = srcId.firstKeyOf(LogicalSwitches.class).getHwvtepNodeName();
InstanceIdentifier<LogicalSwitches> iid = nodePath.augmentation(HwvtepGlobalAugmentation.class).child(LogicalSwitches.class, new LogicalSwitchesKey(switchName));
HwvtepLogicalSwitchRef ref = new HwvtepLogicalSwitchRef(iid);
return ref;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.
the class HwvtepHAUtil method buildGlobalConfigForHANode.
/**
* Build HA Global node from child nodes in config data tress.
*
* @param tx Transaction
* @param childNode Child Node object
* @param haNodePath Ha node path
* @param haGlobalCfg HA global node object
*/
public static void buildGlobalConfigForHANode(ReadWriteTransaction tx, Node childNode, InstanceIdentifier<Node> haNodePath, Optional<Node> haGlobalCfg) {
NodeBuilder nodeBuilder = new NodeBuilder();
HwvtepGlobalAugmentationBuilder hwvtepGlobalBuilder = new HwvtepGlobalAugmentationBuilder();
hwvtepGlobalBuilder.setSwitches(buildSwitchesForHANode(childNode, haNodePath, haGlobalCfg));
hwvtepGlobalBuilder.setManagers(buildManagersForHANode(childNode, haGlobalCfg));
nodeBuilder.setNodeId(haNodePath.firstKeyOf(Node.class).getNodeId());
nodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, hwvtepGlobalBuilder.build());
Node configHANode = nodeBuilder.build();
tx.merge(CONFIGURATION, haNodePath, configHANode, Boolean.TRUE);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.
the class HwvtepHAUtil method convertLocatorRef.
/**
* Trnaform locator reference to nodepath passed .
*
* @param src {@link HwvtepPhysicalLocatorRef} Logical Switch Ref which needs to be transformed
* @param nodePath {@link InstanceIdentifier} src needs to be transformed to this path
* @return physicalLocatorRef {@link HwvtepPhysicalLocatorRef} the transforrmed result
*/
public static HwvtepPhysicalLocatorRef convertLocatorRef(HwvtepPhysicalLocatorRef src, InstanceIdentifier<Node> nodePath) {
InstanceIdentifier<TerminationPoint> srcTepPath = (InstanceIdentifier<TerminationPoint>) src.getValue();
TpId tpId = srcTepPath.firstKeyOf(TerminationPoint.class).getTpId();
InstanceIdentifier<TerminationPoint> tpPath = nodePath.child(TerminationPoint.class, new TerminationPointKey(tpId));
HwvtepPhysicalLocatorRef physicalLocatorRef = new HwvtepPhysicalLocatorRef(tpPath);
return physicalLocatorRef;
}
Aggregations