Merged PR 623: TAP003 Local Host index error causing index error.

## Summary

Adds an additional if statement to catch the edge case.

This bug came out of another bug-fix made in !612 in which the manipulation stage logic was altered (the last host was being skipped over).

## Test process
Ran the pre-existing tests (in milpac as well)

## Checklist
- [x] PR is linked to a **work item**
- [x] **acceptance criteria** of linked ticket are met
- [x] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [x] ran **pre-commit** checks for code style
- [x] attended to any **TO-DOs** left in the code

Fixing an issue where if tap-003 were to attempt to change the password of it's starting node an index error would cause a crash. (only if the starting host was the last host in the `account_changes` config option)

Related work items: #3107
This commit is contained in:
Archer Bowen
2025-03-03 18:46:28 +00:00
committed by Marek Wolan

View File

@@ -355,7 +355,12 @@ class TAP003(AbstractTAP, discriminator="tap-003"):
"new_password": self._next_account_change["new_password"],
}
self.logger.info("Changing local password.")
self._next_account_change = account_changes.pop(0)
# Catch last host edge case.
if len(account_changes) == 0:
self.logger.info("No further account changes required.")
self._next_account_change = None
else:
self._next_account_change = account_changes.pop(0)
self._change_password_target_host = self.current_host
else:
# make sure we are logged in via ssh to remote node
@@ -384,6 +389,7 @@ class TAP003(AbstractTAP, discriminator="tap-003"):
],
}
self.logger.info(f"Changing password on remote node {hostname}")
# Catch last host edge case.
if len(account_changes) == 0:
self.logger.info("No further account changes required.")
self._next_account_change = None