protected IpAddress getIpAddress(Host host) { IpAddress choice = null; for (IpAddress ip : objectManager.mappedChildren(host, IpAddress.class)) { if (ip.getAddress() == null || !CommonStatesConstants.ACTIVE.equals(ip.getState())) { continue; } if (IpAddressConstants.ROLE_PRIMARY.equals(ip.getRole())) { choice = ip; break; } else if (choice == null || choice.getCreated() == null) { choice = ip; } else if (ip.getCreated() != null && ip.getCreated().before(choice.getCreated())) { choice = ip; } } return choice; }
/** * {@inheritDoc} */ @Override public void from(io.cattle.platform.core.model.IpAddress from) { setId(from.getId()); setName(from.getName()); setAccountId(from.getAccountId()); setKind(from.getKind()); setUuid(from.getUuid()); setDescription(from.getDescription()); setState(from.getState()); setCreated(from.getCreated()); setRemoved(from.getRemoved()); setRemoveTime(from.getRemoveTime()); setData(from.getData()); setAddress(from.getAddress()); setSubnetId(from.getSubnetId()); setNetworkId(from.getNetworkId()); setIsPublic(from.getIsPublic()); setRole(from.getRole()); setHostname(from.getHostname()); }