protected Instance getInstanceForPrimaryIp(IpAddress ipAddress) { if (IpAddressConstants.ROLE_PRIMARY.equals(ipAddress.getRole())) { for (Nic nic : getObjectManager().mappedChildren(ipAddress, Nic.class)) { if (nic.getDeviceNumber() != null && nic.getDeviceNumber() == 0) { Instance instance = getObjectManager().loadResource(Instance.class, nic.getInstanceId()); if (instance != null) { return instance; } } } } return null; }
protected String getIpAddress( ServiceInstanceData serviceInstanceData, boolean isSource, Map<Long, IpAddress> instanceIdToHostIpMap) { Nic nic = serviceInstanceData.getNic(); ServiceExposeMap exposeMap = serviceInstanceData.getExposeMap(); IpAddress ipAddr = serviceInstanceData.getIpAddress(); String ip = null; if (isSource && serviceInstanceData .getService() .getKind() .equalsIgnoreCase(ServiceDiscoveryConstants.KIND.SERVICE.name())) { if (ipAddr != null) { ip = ipAddr.getAddress(); } } else { if (ipAddr != null) { ip = ipAddr.getAddress(); } else { ip = exposeMap.getIpAddress(); } } if (nic == null || nic.getDeviceNumber().equals(0)) { return ip; } else { IpAddress hostIp = instanceIdToHostIpMap.get(nic.getInstanceId()); if (hostIp != null) { if (isSource) { return "default"; } return hostIp.getAddress(); } } return null; }