Skip to content

Commit

Permalink
feat(panos_snmp_profile): Add network resource module states
Browse files Browse the repository at this point in the history
  • Loading branch information
shinmog committed Jul 26, 2022
1 parent 5fffeee commit e1e799a
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions plugins/modules/panos_snmp_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
- paloaltonetworks.panos.fragments.transitional_provider
- paloaltonetworks.panos.fragments.vsys_shared
- paloaltonetworks.panos.fragments.device_group
- paloaltonetworks.panos.fragments.state
- paloaltonetworks.panos.fragments.network_resource_module_state
options:
name:
description:
Expand Down Expand Up @@ -73,11 +73,9 @@

try:
from panos.device import SnmpServerProfile
from panos.errors import PanDeviceError
except ImportError:
try:
from pandevice.device import SnmpServerProfile
from pandevice.errors import PanDeviceError
except ImportError:
pass

Expand All @@ -86,38 +84,24 @@ def main():
helper = get_connection(
vsys_shared=True,
device_group=True,
with_state=True,
with_network_resource_module_state=True,
with_classic_provider_spec=True,
min_pandevice_version=(0, 11, 1),
min_panos_version=(7, 1, 0),
argument_spec=dict(
sdk_cls=SnmpServerProfile,
sdk_params=dict(
name=dict(required=True),
version=dict(default="v2c", choices=["v2c", "v3"]),
),
)

module = AnsibleModule(
argument_spec=helper.argument_spec,
supports_check_mode=True,
required_one_of=helper.required_one_of,
)

# Verify imports, build pandevice object tree.
parent = helper.get_pandevice_parent(module)

try:
listing = SnmpServerProfile.refreshall(parent)
except PanDeviceError as e:
module.fail_json(msg="Failed refresh: {0}".format(e))

spec = {
"name": module.params["name"],
"version": module.params["version"],
}
obj = SnmpServerProfile(**spec)
parent.add(obj)

changed, diff = helper.apply_state(obj, listing, module)
module.exit_json(changed=changed, diff=diff, msg="Done")
helper.process(module)


if __name__ == "__main__":
Expand Down

0 comments on commit e1e799a

Please sign in to comment.