Pass agent token to get command results

Change-Id: Iad0d8086e1e79b59da3f9940b83128a3b34d4787
This commit is contained in:
cid 2025-02-13 21:28:32 +01:00
parent 472744f390
commit 279392966b
3 changed files with 14 additions and 3 deletions

View File

@ -316,9 +316,15 @@ class AgentClient(object):
url = self._get_command_url(node)
LOG.debug('Fetching status of agent commands for node %s', node.uuid)
request_params = {}
agent_token = node.driver_internal_info.get('agent_secret_token')
if agent_token:
request_params['agent_token'] = agent_token
def _get():
try:
return self.session.get(url,
params=request_params,
verify=self._get_verify(node),
timeout=CONF.agent.command_timeout)
except (requests.ConnectionError, requests.Timeout) as e:

View File

@ -552,7 +552,7 @@ class TestAgentClient(base.TestCase):
params={'wait': 'false'},
timeout=60,
verify=True)
self.client.session.get.assert_called_with(url, timeout=60,
self.client.session.get.assert_called_with(url, params={}, timeout=60,
verify=True)
mock_sleep.assert_called_with(CONF.agent.command_wait_interval)
@ -571,7 +571,7 @@ class TestAgentClient(base.TestCase):
'%(agent_url)s/%(api_version)s/commands/' % {
'agent_url': agent_url,
'api_version': CONF.agent.agent_api_version},
verify=True, timeout=CONF.agent.command_timeout)
params={}, verify=True, timeout=CONF.agent.command_timeout)
def test_get_commands_status_retries(self):
res = mock.MagicMock(spec_set=['json'])
@ -608,7 +608,7 @@ class TestAgentClient(base.TestCase):
'%(agent_url)s/%(api_version)s/commands/' % {
'agent_url': agent_url,
'api_version': CONF.agent.agent_api_version},
verify='/path/to/agent.crt',
params={}, verify='/path/to/agent.crt',
timeout=CONF.agent.command_timeout)
def _test_install_bootloader(self, root_uuid, efi_system_part_uuid=None,

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Includes the agent token parameter in get command status requests as
the endpoint now requires authentication.