def hasRemainingQuota(self, ntype): needed_quota = self.manager.quotaNeededByNodeType(ntype, self.pool) if not self.pool.ignore_provider_quota: # Calculate remaining quota which is calculated as: # quota = <total nodepool quota> - <used quota> - <quota for node> cloud_quota = self.manager.estimatedNodepoolQuota() cloud_quota.subtract( self.manager.estimatedNodepoolQuotaUsed()) cloud_quota.subtract(needed_quota) self.log.debug("Predicted remaining provider quota: %s", cloud_quota) if not cloud_quota.non_negative(): return False # Now calculate pool specific quota. Values indicating no quota default # to math.inf representing infinity that can be calculated with. pool_quota = QuotaInformation(cores=self.pool.max_cores, instances=self.pool.max_servers, ram=self.pool.max_ram, default=math.inf) pool_quota.subtract( self.manager.estimatedNodepoolQuotaUsed(self.pool)) self.log.debug("Current pool quota: %s" % pool_quota) pool_quota.subtract(needed_quota) self.log.debug("Predicted remaining pool quota: %s", pool_quota) return pool_quota.non_negative()
def hasRemainingQuota(self, ntype): needed_quota = self.manager.quotaNeededByNodeType(ntype, self.pool) # Calculate remaining quota which is calculated as: # quota = <total nodepool quota> - <used quota> - <quota for node> cloud_quota = self.manager.estimatedNodepoolQuota() cloud_quota.subtract(self.manager.estimatedNodepoolQuotaUsed(self.zk)) cloud_quota.subtract(needed_quota) self.log.debug("Predicted remaining tenant quota: %s", cloud_quota) if not cloud_quota.non_negative(): return False # Now calculate pool specific quota. Values indicating no quota default # to math.inf representing infinity that can be calculated with. pool_quota = QuotaInformation(cores=self.pool.max_cores, instances=self.pool.max_servers, ram=self.pool.max_ram, default=math.inf) pool_quota.subtract( self.manager.estimatedNodepoolQuotaUsed(self.zk, self.pool)) pool_quota.subtract(needed_quota) self.log.debug("Predicted remaining pool quota: %s", pool_quota) return pool_quota.non_negative()
def hasRemainingQuota(self, ntype): ''' Apply max_servers check, ignoring other quotas. :returns: True if we have room, False otherwise. ''' needed_quota = QuotaInformation(cores=1, instances=1, ram=1, default=1) n_running = self.manager.countNodes(self.pool.name) pool_quota = QuotaInformation(cores=math.inf, instances=self.pool.max_servers - n_running, ram=math.inf, default=math.inf) pool_quota.subtract(needed_quota) self.log.debug("hasRemainingQuota({},{}) = {}".format( self.pool, ntype, pool_quota)) return pool_quota.non_negative()
def hasRemainingQuota(self, ntype): ''' Apply max_servers check, ignoring other quotas. :returns: True if we have room, False otherwise. ''' needed_quota = QuotaInformation(cores=1, instances=1, ram=1, default=1) n_running = self.manager.countNodes(self.pool.name) pool_quota = QuotaInformation( cores=math.inf, instances=self.pool.max_servers - n_running, ram=math.inf, default=math.inf) pool_quota.subtract(needed_quota) self.log.debug("hasRemainingQuota({},{}) = {}".format( self.pool, ntype, pool_quota)) return pool_quota.non_negative()
def hasProviderQuota(self, node_types): ''' Apply max_servers check to a whole request :returns: True if we have room, False otherwise. ''' needed_quota = QuotaInformation(cores=1, instances=len(node_types), ram=1, default=1) pool_quota = QuotaInformation(cores=math.inf, instances=self.pool.max_servers, ram=math.inf, default=math.inf) pool_quota.subtract(needed_quota) self.log.debug("hasProviderQuota({},{}) = {}".format( self.pool, node_types, pool_quota)) return pool_quota.non_negative()
def hasProviderQuota(self, node_types): ''' Apply max_servers check to a whole request :returns: True if we have room, False otherwise. ''' needed_quota = QuotaInformation( cores=1, instances=len(node_types), ram=1, default=1) pool_quota = QuotaInformation( cores=math.inf, instances=self.pool.max_servers, ram=math.inf, default=math.inf) pool_quota.subtract(needed_quota) self.log.debug("hasProviderQuota({},{}) = {}".format( self.pool, node_types, pool_quota)) return pool_quota.non_negative()
def hasProviderQuota(self, node_types): needed_quota = QuotaInformation() for ntype in node_types: needed_quota.add( self.manager.quotaNeededByNodeType(ntype, self.pool)) cloud_quota = self.manager.estimatedNodepoolQuota() cloud_quota.subtract(needed_quota) if not cloud_quota.non_negative(): return False # Now calculate pool specific quota. Values indicating no quota default # to math.inf representing infinity that can be calculated with. pool_quota = QuotaInformation(cores=self.pool.max_cores, instances=self.pool.max_servers, ram=self.pool.max_ram, default=math.inf) pool_quota.subtract(needed_quota) return pool_quota.non_negative()
def hasProviderQuota(self, node_types): needed_quota = QuotaInformation() for ntype in node_types: needed_quota.add( self.manager.quotaNeededByNodeType(ntype, self.pool)) if not self.pool.ignore_provider_quota: cloud_quota = self.manager.estimatedNodepoolQuota() cloud_quota.subtract(needed_quota) if not cloud_quota.non_negative(): return False # Now calculate pool specific quota. Values indicating no quota default # to math.inf representing infinity that can be calculated with. pool_quota = QuotaInformation(cores=self.pool.max_cores, instances=self.pool.max_servers, ram=self.pool.max_ram, default=math.inf) pool_quota.subtract(needed_quota) return pool_quota.non_negative()