}
protected AugeasNode getExistingChildNodeForListMemberPropertyMap(AugeasNode parentNode,
PropertyDefinitionList propDefList, PropertyMap propMap) {
// First find all child nodes with the same 'canonical' value as the PropertyMap.
Augeas augeas = getAugeas();
String canonicalFilter = parentNode.getPath() + "/*/canonical";
String canonical = propMap.getSimple("canonical").getStringValue();
List<String> canonicalPaths = AugeasUtility.matchFilter(augeas, canonicalFilter, canonical);
if (canonicalPaths.isEmpty()) {
return null;
}
// Now see if there's at least one node in this list with an 'ipaddr' value with the same IP address version as
// the PropertyMap.
String ipaddr = propMap.getSimple("ipaddr").getStringValue();
int ipAddressVersion = (ipaddr.indexOf(':') == -1) ? 4 : 6;
for (String canonicalPath : canonicalPaths) {
AugeasNode canonicalNode = new AugeasNode(canonicalPath);
AugeasNode childNode = canonicalNode.getParent();
AugeasNode ipaddrNode = new AugeasNode(childNode, "ipaddr");
String existingIpaddr = augeas.get(ipaddrNode.getPath());
int existingIpAddressVersion = (existingIpaddr.indexOf(':') == -1) ? 4 : 6;
if (existingIpAddressVersion == ipAddressVersion) {
return childNode;
}
}