Skip to content

Commit

Permalink
chore: auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Oct 21, 2024
1 parent dd65799 commit 6f8657c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions plugins/modules/nxos_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,19 @@ def update_objects(want, have):
updates.append((entry, item))
return updates


def get_configured_usernames(module):
config_output = run_commands(module, [{"command": "show running-config | section ^username", "output": "text"}])
config_output = run_commands(
module, [{"command": "show running-config | section ^username", "output": "text"}]
)
usernames = set()
for line in config_output[0].splitlines():
if line.startswith("username "):
username = line.split()[1]
usernames.add(username)
return usernames


def main():
"""main entry point for module execution"""
element_spec = dict(
Expand Down Expand Up @@ -467,11 +471,11 @@ def main():
if module.params["purge"]:
want_users = set([x["name"] for x in want])
have_users = set([x["name"] for x in have])

configured_usernames = get_configured_usernames(module)
non_local_users=have_users.difference(want_users).difference(configured_usernames)

non_local_users = have_users.difference(want_users).difference(configured_usernames)

for item in configured_usernames.difference(non_local_users):
if item != "admin":
item = item.replace("\\", "\\\\")
Expand Down

0 comments on commit 6f8657c

Please sign in to comment.