Skip to content

Commit

Permalink
Merge pull request #183 from canonical/provision-type-in-agent-data
Browse files Browse the repository at this point in the history
Add provision_type field to agent data
  • Loading branch information
plars committed Jan 10, 2024
2 parents 17c83c7 + 4f9d356 commit 83ebced
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions agent/testflinger_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ def __init__(self, client):
def _post_initial_agent_data(self):
"""Post the initial agent data to the server once on agent startup"""

location = self.client.config.get("location", "")
self._post_advertised_queues()
self._post_advertised_images()

queues = self.client.config.get("job_queues", [])
identifier = self.client.config.get("identifier")
agent_data = {"queues": queues, "location": location}
location = self.client.config.get("location", "")
provision_type = self.client.config.get("provision_type", "")
queues = self.client.config.get("job_queues", [])

agent_data = {
"location": location,
"queues": queues,
"provision_type": provision_type,
}
if identifier:
agent_data["identifier"] = identifier

Expand Down
2 changes: 2 additions & 0 deletions agent/testflinger_agent/tests/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def agent(self, requests_mock):
"server_address": "127.0.0.1:8000",
"job_queues": ["test"],
"location": "nowhere",
"provision_type": "noprovision",
"execution_basedir": self.tmpdir,
"logging_basedir": self.tmpdir,
"results_basedir": os.path.join(self.tmpdir, "results"),
Expand Down Expand Up @@ -219,5 +220,6 @@ def test_post_agent_data(self, agent):
"identifier": self.config["identifier"],
"queues": self.config["job_queues"],
"location": self.config["location"],
"provision_type": self.config["provision_type"],
}
)
2 changes: 2 additions & 0 deletions server/src/api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class AgentIn(Schema):
state = fields.String(required=False)
queues = fields.List(fields.String(), required=False)
location = fields.String(required=False)
provision_type = fields.String(required=False)
job_id = fields.String(required=False)
log = fields.List(fields.String(), required=False)

Expand All @@ -37,6 +38,7 @@ class AgentOut(Schema):
state = fields.String(required=False)
queues = fields.List(fields.String(), required=False)
location = fields.String(required=False)
provision_type = fields.String(required=False)
job_id = fields.String(required=False)


Expand Down
1 change: 1 addition & 0 deletions server/src/templates/agent_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Agent Name: {{ agent.name }}<br>
State: {{ agent.state }}<br>
Location: {{ agent.location }}<br>
Provision Type: {{ agent.provision_type }}<br>
Last Updated: {{ agent.updated_at.strftime('%Y-%m-%d %H:%M:%S') }}<br>
</p>
<p>
Expand Down

0 comments on commit 83ebced

Please sign in to comment.