private static VmInstance maybeFindVm( final String instanceId, final String publicIp, final String privateIp) { VmInstance vm = null; if (instanceId != null) { try { vm = VmInstances.lookup(instanceId); } catch (NoSuchElementException ex) { Logs.extreme().error(ex); } } if (vm == null && privateIp != null) { try { vm = VmInstances.lookupByPrivateIp(privateIp); } catch (NoSuchElementException ex) { Logs.extreme().error(ex); } } if (vm == null && publicIp != null) { try { vm = VmInstances.lookupByPublicIp(publicIp); } catch (NoSuchElementException ex) { Logs.extreme().error(ex); } } if (vm != null && VmState.RUNNING.equals(vm.getState()) && publicIp.equals(vm.getPublicAddress())) { Logs.extreme() .debug( "Candidate vm which claims this address: " + vm.getInstanceId() + " " + vm.getState() + " " + publicIp); if (publicIp.equals(vm.getPublicAddress())) { Logs.extreme() .debug( "Found vm which claims this address: " + vm.getInstanceId() + " " + vm.getState() + " " + publicIp); } return vm; } else { return null; } }
private static void markAsAllocated( final Cluster cluster, final ClusterAddressInfo addrInfo, final Address address) { try { if (!address.isPending()) { for (final VmInstance vm : VmInstances.list(VmState.RUNNING)) { if (addrInfo.getInstanceIp().equals(vm.getPrivateAddress()) && VmState.RUNNING.equals(vm.getState())) { LOG.warn( "Out of band address state change: " + LogUtil.dumpObject(addrInfo) + " address=" + address + " vm=" + vm); // if ( !address.isAllocated( ) ) { // address.pendingAssignment( ).assign( vm ).clearPending( ); // } else { // address.assign( vm ).clearPending( ); // } // clearOrphan( addrInfo ); return; } } } } catch (final IllegalStateException e) { LOG.error(e); } }