Loading cloudcontrol/server/allocator.py +7 −2 Original line number Diff line number Diff line Loading @@ -137,14 +137,19 @@ class HaveEnoughCPU(Filter): """ DEFAULT_ALLOWED_RATIO = 1 DEFAULT_RESERVED_CPU = 0 def tql_filter(self, query): return '(%s)$cpualloc$cpu$cpuallowedratio$cpuremaining$cpuallocratio' % query return '(%s)$cpualloc$cpu$cpuallowedratio$cpuremaining$cpuallocratio$cpureserved' % query def filter(self, candidates): cpu = int(self.vmspec['cpu']) for candidate in candidates: ratio = (float(candidate.get('cpualloc')) + cpu) / float(candidate.get('cpu')) try: reserved = int(candidate.get('cpureserved', self.DEFAULT_RESERVED_CPU)) except ValueError: reserved = self.DEFAULT_RESERVED_CPU ratio = (float(candidate.get('cpualloc')) + cpu) / (float(candidate.get('cpu')) + reserved) if ratio <= float(candidate.get('cpuallowedratio', self.DEFAULT_ALLOWED_RATIO)): yield candidate Loading Loading
cloudcontrol/server/allocator.py +7 −2 Original line number Diff line number Diff line Loading @@ -137,14 +137,19 @@ class HaveEnoughCPU(Filter): """ DEFAULT_ALLOWED_RATIO = 1 DEFAULT_RESERVED_CPU = 0 def tql_filter(self, query): return '(%s)$cpualloc$cpu$cpuallowedratio$cpuremaining$cpuallocratio' % query return '(%s)$cpualloc$cpu$cpuallowedratio$cpuremaining$cpuallocratio$cpureserved' % query def filter(self, candidates): cpu = int(self.vmspec['cpu']) for candidate in candidates: ratio = (float(candidate.get('cpualloc')) + cpu) / float(candidate.get('cpu')) try: reserved = int(candidate.get('cpureserved', self.DEFAULT_RESERVED_CPU)) except ValueError: reserved = self.DEFAULT_RESERVED_CPU ratio = (float(candidate.get('cpualloc')) + cpu) / (float(candidate.get('cpu')) + reserved) if ratio <= float(candidate.get('cpuallowedratio', self.DEFAULT_ALLOWED_RATIO)): yield candidate Loading