Skip to content

Commit

Permalink
feat(panos_userid): Add timeout to login
Browse files Browse the repository at this point in the history
resolves #283
  • Loading branch information
shinmog committed Jul 27, 2022
1 parent f42650c commit d407938
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions plugins/modules/panos_userid.py
Expand Up @@ -48,6 +48,11 @@
- IP of the user's machine that needs to be registered with userid.
type: str
required: true
timeout:
description:
- The timeout in minutes to remove this mapping.
- This is used only for I(state=present).
type: int
"""

EXAMPLES = """
Expand Down Expand Up @@ -84,6 +89,7 @@ def main():
argument_spec=dict(
userid=dict(required=True),
register_ip=dict(required=True),
timeout=dict(type="int"),
),
)

Expand All @@ -97,26 +103,29 @@ def main():

func = None
prefix = ""
extras = {}
if module.params["state"] == "present":
func = "login"
extras["timeout"] = module.params["timeout"]
else:
func = "logout"
prefix = "un"

# Apply the state.
try:
getattr(parent.userid, func)(
module.params["userid"], module.params["register_ip"]
module.params["userid"], module.params["register_ip"], **extras,
)
except PanDeviceError as e:
module.fail_json(
msg="Failed to {0} {1}: {2}".format(func, module.params["userid"], e)
)

module.exit_json(
changed=True,
msg="User '{0}' successfully {1}registered".format(
module.params["userid"], prefix
)
),
)


Expand Down

0 comments on commit d407938

Please sign in to comment.