Esempio n. 1
0
        public double calculate(HostData host) {
          ArrayList<VmAllocation> vms =
              new ArrayList<VmAllocation>(host.getHost().getVMAllocations());
          vms.add(host.getHost().getPrivDomainAllocation());

          int cpu = 0;
          int mem = 0;
          double bw = 0;
          for (VmAllocation vm : vms) {
            // If the VMAllocation has an associated VM, record its resource allocation.
            if (vm.getVm() != null) cpu += vm.getCpu();
            mem += vm.getMemory();
            bw += vm.getBandwidth();
          }

          Resources res = host.getHostDescription().getResourceCapacity();
          return (cpu * mem * bw) / (res.getCpu() * res.getMemory() * res.getBandwidth());
        }