QuotaInformation : abstract resource recording
Change I670d4bfd7d35ce1109b3ee9b3342fb45ee283a79 added the quota['compute'] property to ZK nodes for Zuul to keep track of. Instead of accessing the property directly, this adds a get_resources() function to QuotaInformation which returns it, and makes a point to note that the property is used so that we don't modify it in incompatible ways in future. This is a no-op refactor, but helpful in a follow-on change that also adds this field to leaked nodes. Change-Id: Id78b059cf2121e01e4cd444f6ad3834373cf7fb6
This commit is contained in:
parent
9c83e8a95e
commit
bf40e145e4
|
@ -156,7 +156,7 @@ class OpenStackNodeLauncher(NodeLauncher):
|
|||
pool = self.handler.provider.pools.get(self.node.pool)
|
||||
resources = self.handler.manager.quotaNeededByLabel(
|
||||
self.node.type[0], pool)
|
||||
self.node.resources = resources.quota['compute']
|
||||
self.node.resources = resources.get_resources()
|
||||
if username:
|
||||
self.node.username = username
|
||||
|
||||
|
|
|
@ -122,6 +122,10 @@ class QuotaInformation:
|
|||
:param ram:
|
||||
:param default:
|
||||
'''
|
||||
# Note that the self.quota['compute'] map is inserted into ZK as
|
||||
# a node property (via get_resources) and is consumed by Zuul to
|
||||
# calculate resource usage. Thus care should be taken if
|
||||
# modifying fields below.
|
||||
self.quota = {
|
||||
'compute': {
|
||||
'cores': self._get_default(cores, default),
|
||||
|
@ -173,6 +177,10 @@ class QuotaInformation:
|
|||
return False
|
||||
return True
|
||||
|
||||
def get_resources(self):
|
||||
'''Return resources value to register in ZK node'''
|
||||
return self.quota['compute']
|
||||
|
||||
def __str__(self):
|
||||
return str(self.quota)
|
||||
|
||||
|
|
Loading…
Reference in New Issue