@Override public Long getIdPublicAddressOfVM(VirtualMachine vm) { if (vm.publicIpAddress() != null) { return vm.publicIpAddress().get().getId(); } return null; }
@Override public RemoteConnection apply(VirtualMachine virtualMachine) { checkArgument(virtualMachine.publicIpAddress().isPresent()); checkArgument(virtualMachine.loginName().isPresent()); checkArgument(virtualMachine.loginPassword().isPresent()); int remotePort = virtualMachine.remotePort(); OSFamily osFamily = virtualMachine.osFamily(); return connectionService.getRemoteConnection( HostAndPort.fromParts(virtualMachine.publicIpAddress().get().getIp(), remotePort), osFamily, LoginCredentialBuilder.newBuilder() .password(virtualMachine.loginPassword().get()) .username(virtualMachine.loginName().get()) .build()); }