private float computePrice(MachineType flavor) { // We compute the per-hour price so we can choose the smallest/cheapest instance size float price = 0; int cpus = flavor.getGuestCpus() != null ? flavor.getGuestCpus() : 0; int memoryMb = flavor.getMemoryMb() != null ? flavor.getMemoryMb() : 0; // // RAM is $0.10 / hour / GB // price += (0.10 / 1024.0) * ram; // // Disk is $0.10 / hour / TB // int disk = flavor.getDisk(); // price += (0.10 / 1024.0) * disk; // CPUs are $0.145 / hour / vCPU price += 0.145 * cpus; return price; }