Add user_data field to Node

This will allow users to record information about their use of the
node.  Nodepool will ignore this.

This is similar to the comment field, except that it won't show up
in the node listing output.  It's opaque data to nodepool.

This is also similar to requestor_data for the node request.

We can use this in Zuul to record the tenant/project information,
then just use the existing nodepool node records to calculate
resource usage by tenant.  Without this, we would need to create
a nearly parallel data structure for that purpose alone.  Bonus;
it will let Zuul include autohold node resource usage in its
stats (if desired).

Change-Id: If382ca1c554ddd2ef9be8ad87049b133c8b3873c
This commit is contained in:
James E. Blair 2021-09-03 09:26:24 -07:00
parent 4edaeba702
commit d1c14beafb
1 changed files with 4 additions and 0 deletions

View File

@ -585,6 +585,7 @@ class Node(BaseModel):
self.external_id = None
self.hostname = None
self.comment = None
self.user_data = None
self.hold_job = None
self.username = None
self.host_keys = []
@ -623,6 +624,7 @@ class Node(BaseModel):
self.external_id == other.external_id and
self.hostname == other.hostname and
self.comment == other.comment and
self.user_data == other.user_data and
self.hold_job == other.hold_job and
self.username == other.username and
self.connection_type == other.connection_type and
@ -674,6 +676,7 @@ class Node(BaseModel):
d['external_id'] = self.external_id
d['hostname'] = self.hostname
d['comment'] = self.comment
d['user_data'] = self.user_data
d['hold_job'] = self.hold_job
d['host_keys'] = self.host_keys
d['username'] = self.username
@ -729,6 +732,7 @@ class Node(BaseModel):
self.external_id = d.get('external_id')
self.hostname = d.get('hostname')
self.comment = d.get('comment')
self.user_data = d.get('user_data')
self.hold_job = d.get('hold_job')
self.username = d.get('username', 'zuul')
self.connection_type = d.get('connection_type')