diff --git a/plugins/modules/panos_ipsec_ipv4_proxyid.py b/plugins/modules/panos_ipsec_ipv4_proxyid.py index b196539d0..e13585286 100644 --- a/plugins/modules/panos_ipsec_ipv4_proxyid.py +++ b/plugins/modules/panos_ipsec_ipv4_proxyid.py @@ -35,7 +35,7 @@ - Check mode is supported. extends_documentation_fragment: - paloaltonetworks.panos.fragments.transitional_provider - - paloaltonetworks.panos.fragments.state + - paloaltonetworks.panos.fragments.network_resource_module_state - paloaltonetworks.panos.fragments.full_template_support - paloaltonetworks.panos.fragments.deprecated_commit options: @@ -106,11 +106,9 @@ ) try: - from panos.errors import PanDeviceError from panos.network import IpsecTunnel, IpsecTunnelIpv4ProxyId except ImportError: try: - from pandevice.errors import PanDeviceError from pandevice.network import IpsecTunnel, IpsecTunnelIpv4ProxyId except ImportError: pass @@ -121,10 +119,12 @@ def main(): template=True, template_stack=True, with_classic_provider_spec=True, - with_state=True, - argument_spec=dict( + with_network_resource_module_state=True, + with_commit=True, + parents=((IpsecTunnel, "tunnel_name"),), + sdk_cls=IpsecTunnelIpv4ProxyId, + sdk_params=dict( name=dict(type="str", required=True), - tunnel_name=dict(default="default"), local=dict(default="192.168.2.0/24"), remote=dict(default="192.168.1.0/24"), any_protocol=dict(type="bool", default=True), @@ -133,7 +133,6 @@ def main(): tcp_remote_port=dict(type="int"), udp_local_port=dict(type="int"), udp_remote_port=dict(type="int"), - commit=dict(type="bool", default=False), ), ) @@ -143,48 +142,7 @@ def main(): required_one_of=helper.required_one_of, ) - # Object specifications - spec = { - "name": module.params["name"], - "local": module.params["local"], - "remote": module.params["remote"], - "any_protocol": module.params["any_protocol"], - "number_protocol": module.params["number_proto"], - "tcp_local_port": module.params["tcp_local_port"], - "tcp_remote_port": module.params["tcp_remote_port"], - "udp_local_port": module.params["udp_local_port"], - "udp_remote_port": module.params["udp_remote_port"], - } - - # Additional infos - commit = module.params["commit"] - - # Verify libs are present, get parent object. - parent = helper.get_pandevice_parent(module) - tunnel_name = module.params["tunnel_name"] - - # get the tunnel object - tunnel = IpsecTunnel(tunnel_name) - parent.add(tunnel) - try: - tunnel.refresh() - except PanDeviceError as e: - module.fail_json(msg="Failed refresh: {0}".format(e)) - - # get the listing - listing = tunnel.findall(IpsecTunnelIpv4ProxyId) - obj = IpsecTunnelIpv4ProxyId(**spec) - tunnel.add(obj) - - # Apply the state. - changed, diff = helper.apply_state(obj, listing, module) - - # Commit. - if commit and changed: - helper.commit(module) - - # Done. - module.exit_json(changed=changed, diff=diff) + helper.process(module) if __name__ == "__main__":