diff --git a/napalm_device_types/local_accounts.py b/napalm_device_types/local_accounts.py index a5eae0c..bf20abf 100644 --- a/napalm_device_types/local_accounts.py +++ b/napalm_device_types/local_accounts.py @@ -520,21 +520,27 @@ class LocalAccountsMixin: check_public_key(public_key) old = [key for key in _checked_keys(replaces) if _key_blob(key) != _key_blob(public_key)] login, existing = self._accounts_service_target(name, uid) + first = self._accounts_service_account_step(name, login, existing, uid) + parts = [first] + if first["success"]: + parts += self._accounts_service_keys(name, public_key, old) + return self._accounts_result(name, parts) + + def _accounts_service_account_step( + self, name: str, login: str, existing: list[str] | None, uid: int | None + ) -> FixResultDict: + """The ``account`` step of netOrk's own account; nothing to do when the driver + logs in as *name* already.""" if name == login: step: FixStepDict = { "step": "account", "ok": True, "output": f"this driver logs in as {name} already", } - first: FixResultDict = _joined([step]) - else: - first = run_fix_steps( - [("account", lambda: self._accounts_service_account(name, existing, uid))] - ) - parts = [first] - if first["success"]: - parts += self._accounts_service_keys(name, public_key, old) - return self._accounts_result(name, parts) + return _joined([step]) + return run_fix_steps( + [("account", lambda: self._accounts_service_account(name, existing, uid))] + ) def _accounts_service_keys( self, name: str, public_key: str, old: list[str]