summaryrefslogtreecommitdiffstats
path: root/ansible_collections/cisco/nxos/plugins/action
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/cisco/nxos/plugins/action')
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/__init__.py0
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/aaa_server.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/aaa_server_host.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/acl.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/acl_interface.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/acl_interfaces.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/acls.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/banner.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bfd_global.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bfd_interfaces.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_address_family.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_af.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_global.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_neighbor.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_address_family.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_af.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/command.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/config.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/devicealias.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/evpn_global.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/evpn_vni.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/facts.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/feature.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/file_copy.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/gir.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/gir_profile_management.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/hostname.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/hsrp.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/hsrp_interfaces.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/igmp.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/igmp_interface.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/igmp_snooping.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/install_os.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/interface.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/interface_ospf.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/interfaces.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/l2_interface.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/l2_interfaces.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/l3_interface.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/l3_interfaces.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lacp.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lacp_interfaces.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lag_interfaces.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/linkagg.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lldp.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lldp_global.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lldp_interfaces.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/logging.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/logging_global.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ntp.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ntp_auth.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ntp_global.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ntp_options.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/nxapi.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/nxos.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ospf.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ospf_interfaces.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ospf_vrf.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ospfv2.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ospfv3.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/overlay_global.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/pim.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/pim_interface.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/pim_rp_address.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ping.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/prefix_lists.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/reboot.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/rollback.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/route_maps.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/rpm.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/smu.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snapshot.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_community.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_contact.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_host.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_location.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_server.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_traps.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_user.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/static_route.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/static_routes.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/system.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/telemetry.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/udld.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/udld_interface.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/user.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vlan.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vlans.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vpc.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vpc_interface.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vrf.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vrf_af.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vrf_interface.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vrrp.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vsan.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vtp_domain.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vtp_password.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vtp_version.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vxlan_vtep.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vxlan_vtep_vni.py125
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/zone_zoneset.py125
102 files changed, 12625 insertions, 0 deletions
diff --git a/ansible_collections/cisco/nxos/plugins/action/__init__.py b/ansible_collections/cisco/nxos/plugins/action/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/__init__.py
diff --git a/ansible_collections/cisco/nxos/plugins/action/aaa_server.py b/ansible_collections/cisco/nxos/plugins/action/aaa_server.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/aaa_server.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/aaa_server_host.py b/ansible_collections/cisco/nxos/plugins/action/aaa_server_host.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/aaa_server_host.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/acl.py b/ansible_collections/cisco/nxos/plugins/action/acl.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/acl.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/acl_interface.py b/ansible_collections/cisco/nxos/plugins/action/acl_interface.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/acl_interface.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/acl_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/acl_interfaces.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/acl_interfaces.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/acls.py b/ansible_collections/cisco/nxos/plugins/action/acls.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/acls.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/banner.py b/ansible_collections/cisco/nxos/plugins/action/banner.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/banner.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/bfd_global.py b/ansible_collections/cisco/nxos/plugins/action/bfd_global.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/bfd_global.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/bfd_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/bfd_interfaces.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/bfd_interfaces.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp.py b/ansible_collections/cisco/nxos/plugins/action/bgp.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp_address_family.py b/ansible_collections/cisco/nxos/plugins/action/bgp_address_family.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_address_family.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp_af.py b/ansible_collections/cisco/nxos/plugins/action/bgp_af.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_af.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp_global.py b/ansible_collections/cisco/nxos/plugins/action/bgp_global.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_global.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor.py b/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_address_family.py b/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_address_family.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_address_family.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_af.py b/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_af.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_af.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/command.py b/ansible_collections/cisco/nxos/plugins/action/command.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/command.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/config.py b/ansible_collections/cisco/nxos/plugins/action/config.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/config.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/devicealias.py b/ansible_collections/cisco/nxos/plugins/action/devicealias.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/devicealias.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/evpn_global.py b/ansible_collections/cisco/nxos/plugins/action/evpn_global.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/evpn_global.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/evpn_vni.py b/ansible_collections/cisco/nxos/plugins/action/evpn_vni.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/evpn_vni.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/facts.py b/ansible_collections/cisco/nxos/plugins/action/facts.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/facts.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/feature.py b/ansible_collections/cisco/nxos/plugins/action/feature.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/feature.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/file_copy.py b/ansible_collections/cisco/nxos/plugins/action/file_copy.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/file_copy.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/gir.py b/ansible_collections/cisco/nxos/plugins/action/gir.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/gir.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/gir_profile_management.py b/ansible_collections/cisco/nxos/plugins/action/gir_profile_management.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/gir_profile_management.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/hostname.py b/ansible_collections/cisco/nxos/plugins/action/hostname.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/hostname.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/hsrp.py b/ansible_collections/cisco/nxos/plugins/action/hsrp.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/hsrp.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/hsrp_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/hsrp_interfaces.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/hsrp_interfaces.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/igmp.py b/ansible_collections/cisco/nxos/plugins/action/igmp.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/igmp.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/igmp_interface.py b/ansible_collections/cisco/nxos/plugins/action/igmp_interface.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/igmp_interface.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/igmp_snooping.py b/ansible_collections/cisco/nxos/plugins/action/igmp_snooping.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/igmp_snooping.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/install_os.py b/ansible_collections/cisco/nxos/plugins/action/install_os.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/install_os.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/interface.py b/ansible_collections/cisco/nxos/plugins/action/interface.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/interface.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/interface_ospf.py b/ansible_collections/cisco/nxos/plugins/action/interface_ospf.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/interface_ospf.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/interfaces.py b/ansible_collections/cisco/nxos/plugins/action/interfaces.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/interfaces.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/l2_interface.py b/ansible_collections/cisco/nxos/plugins/action/l2_interface.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/l2_interface.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/l2_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/l2_interfaces.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/l2_interfaces.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/l3_interface.py b/ansible_collections/cisco/nxos/plugins/action/l3_interface.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/l3_interface.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/l3_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/l3_interfaces.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/l3_interfaces.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/lacp.py b/ansible_collections/cisco/nxos/plugins/action/lacp.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/lacp.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/lacp_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/lacp_interfaces.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/lacp_interfaces.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/lag_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/lag_interfaces.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/lag_interfaces.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/linkagg.py b/ansible_collections/cisco/nxos/plugins/action/linkagg.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/linkagg.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/lldp.py b/ansible_collections/cisco/nxos/plugins/action/lldp.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/lldp.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/lldp_global.py b/ansible_collections/cisco/nxos/plugins/action/lldp_global.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/lldp_global.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/lldp_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/lldp_interfaces.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/lldp_interfaces.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/logging.py b/ansible_collections/cisco/nxos/plugins/action/logging.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/logging.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/logging_global.py b/ansible_collections/cisco/nxos/plugins/action/logging_global.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/logging_global.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/ntp.py b/ansible_collections/cisco/nxos/plugins/action/ntp.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/ntp.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/ntp_auth.py b/ansible_collections/cisco/nxos/plugins/action/ntp_auth.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/ntp_auth.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/ntp_global.py b/ansible_collections/cisco/nxos/plugins/action/ntp_global.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/ntp_global.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/ntp_options.py b/ansible_collections/cisco/nxos/plugins/action/ntp_options.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/ntp_options.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/nxapi.py b/ansible_collections/cisco/nxos/plugins/action/nxapi.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/nxapi.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/nxos.py b/ansible_collections/cisco/nxos/plugins/action/nxos.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/nxos.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/ospf.py b/ansible_collections/cisco/nxos/plugins/action/ospf.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/ospf.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/ospf_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/ospf_interfaces.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/ospf_interfaces.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/ospf_vrf.py b/ansible_collections/cisco/nxos/plugins/action/ospf_vrf.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/ospf_vrf.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/ospfv2.py b/ansible_collections/cisco/nxos/plugins/action/ospfv2.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/ospfv2.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/ospfv3.py b/ansible_collections/cisco/nxos/plugins/action/ospfv3.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/ospfv3.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/overlay_global.py b/ansible_collections/cisco/nxos/plugins/action/overlay_global.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/overlay_global.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/pim.py b/ansible_collections/cisco/nxos/plugins/action/pim.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/pim.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/pim_interface.py b/ansible_collections/cisco/nxos/plugins/action/pim_interface.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/pim_interface.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/pim_rp_address.py b/ansible_collections/cisco/nxos/plugins/action/pim_rp_address.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/pim_rp_address.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/ping.py b/ansible_collections/cisco/nxos/plugins/action/ping.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/ping.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/prefix_lists.py b/ansible_collections/cisco/nxos/plugins/action/prefix_lists.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/prefix_lists.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/reboot.py b/ansible_collections/cisco/nxos/plugins/action/reboot.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/reboot.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/rollback.py b/ansible_collections/cisco/nxos/plugins/action/rollback.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/rollback.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/route_maps.py b/ansible_collections/cisco/nxos/plugins/action/route_maps.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/route_maps.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/rpm.py b/ansible_collections/cisco/nxos/plugins/action/rpm.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/rpm.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/smu.py b/ansible_collections/cisco/nxos/plugins/action/smu.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/smu.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/snapshot.py b/ansible_collections/cisco/nxos/plugins/action/snapshot.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/snapshot.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_community.py b/ansible_collections/cisco/nxos/plugins/action/snmp_community.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_community.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_contact.py b/ansible_collections/cisco/nxos/plugins/action/snmp_contact.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_contact.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_host.py b/ansible_collections/cisco/nxos/plugins/action/snmp_host.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_host.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_location.py b/ansible_collections/cisco/nxos/plugins/action/snmp_location.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_location.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_server.py b/ansible_collections/cisco/nxos/plugins/action/snmp_server.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_server.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_traps.py b/ansible_collections/cisco/nxos/plugins/action/snmp_traps.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_traps.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_user.py b/ansible_collections/cisco/nxos/plugins/action/snmp_user.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_user.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/static_route.py b/ansible_collections/cisco/nxos/plugins/action/static_route.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/static_route.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/static_routes.py b/ansible_collections/cisco/nxos/plugins/action/static_routes.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/static_routes.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/system.py b/ansible_collections/cisco/nxos/plugins/action/system.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/system.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/telemetry.py b/ansible_collections/cisco/nxos/plugins/action/telemetry.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/telemetry.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/udld.py b/ansible_collections/cisco/nxos/plugins/action/udld.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/udld.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/udld_interface.py b/ansible_collections/cisco/nxos/plugins/action/udld_interface.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/udld_interface.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/user.py b/ansible_collections/cisco/nxos/plugins/action/user.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/user.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vlan.py b/ansible_collections/cisco/nxos/plugins/action/vlan.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vlan.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vlans.py b/ansible_collections/cisco/nxos/plugins/action/vlans.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vlans.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vpc.py b/ansible_collections/cisco/nxos/plugins/action/vpc.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vpc.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vpc_interface.py b/ansible_collections/cisco/nxos/plugins/action/vpc_interface.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vpc_interface.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vrf.py b/ansible_collections/cisco/nxos/plugins/action/vrf.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vrf.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vrf_af.py b/ansible_collections/cisco/nxos/plugins/action/vrf_af.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vrf_af.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vrf_interface.py b/ansible_collections/cisco/nxos/plugins/action/vrf_interface.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vrf_interface.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vrrp.py b/ansible_collections/cisco/nxos/plugins/action/vrrp.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vrrp.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vsan.py b/ansible_collections/cisco/nxos/plugins/action/vsan.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vsan.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vtp_domain.py b/ansible_collections/cisco/nxos/plugins/action/vtp_domain.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vtp_domain.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vtp_password.py b/ansible_collections/cisco/nxos/plugins/action/vtp_password.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vtp_password.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vtp_version.py b/ansible_collections/cisco/nxos/plugins/action/vtp_version.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vtp_version.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep.py b/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep_vni.py b/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep_vni.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep_vni.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result
diff --git a/ansible_collections/cisco/nxos/plugins/action/zone_zoneset.py b/ansible_collections/cisco/nxos/plugins/action/zone_zoneset.py
new file mode 100644
index 00000000..3602c407
--- /dev/null
+++ b/ansible_collections/cisco/nxos/plugins/action/zone_zoneset.py
@@ -0,0 +1,125 @@
+#
+# (c) 2016 Red Hat Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+from __future__ import absolute_import, division, print_function
+
+
+__metaclass__ = type
+
+from ansible import constants as C
+from ansible.module_utils.connection import Connection
+from ansible.utils.display import Display
+from ansible_collections.ansible.netcommon.plugins.action.network import (
+ ActionModule as ActionNetworkModule,
+)
+
+
+display = Display()
+
+
+class ActionModule(ActionNetworkModule):
+ def run(self, tmp=None, task_vars=None):
+ del tmp # tmp no longer has any effect
+
+ module_name = self._task.action.split(".")[-1]
+ self._config_module = True if module_name in ["nxos_config", "config"] else False
+ persistent_connection = self._play_context.connection.split(".")[-1]
+
+ warnings = []
+
+ if (self._play_context.connection == "httpapi") and module_name in (
+ "nxos_file_copy",
+ "nxos_nxapi",
+ ):
+ return {
+ "failed": True,
+ "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ }
+
+ if module_name == "nxos_file_copy":
+ # when file_pull is enabled, the file_pull_timeout and connect_ssh_port options
+ # will override persistent_command_timeout and port
+ # this has been kept for backwards compatibility till these options are removed
+ if persistent_connection != "network_cli":
+ return {
+ "failed": True,
+ "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ % self._play_context.connection,
+ }
+
+ conn = Connection(self._connection.socket_path)
+ file_pull = self._task.args.get("file_pull", False)
+ file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
+
+ if file_pull:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ conn.set_option("port", connect_ssh_port)
+
+ if module_name == "nxos_install_os":
+ connection = self._connection
+ if connection.transport == "local":
+ persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT
+ persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT
+ else:
+ persistent_command_timeout = connection.get_option("persistent_command_timeout")
+ persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
+
+ display.vvvv(
+ "PERSISTENT_COMMAND_TIMEOUT is %s" % str(persistent_command_timeout),
+ self._play_context.remote_addr,
+ )
+ display.vvvv(
+ "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ self._play_context.remote_addr,
+ )
+ if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
+ msg = "PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
+ msg += " must be set to 600 seconds or higher when using nxos_install_os module."
+ msg += " Current persistent_command_timeout setting:" + str(
+ persistent_command_timeout,
+ )
+ msg += " Current persistent_connect_timeout setting:" + str(
+ persistent_connect_timeout,
+ )
+ return {"failed": True, "msg": msg}
+
+ if persistent_connection in ("network_cli", "httpapi"):
+ if module_name == "nxos_gir":
+ conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
+ gir_timeout = 200
+ if persistent_command_timeout < gir_timeout:
+ conn.set_option("persistent_command_timeout", gir_timeout)
+ msg = "timeout value extended to %ss for nxos_gir" % gir_timeout
+ display.warning(msg)
+
+ else:
+ return {
+ "failed": True,
+ "msg": "Connection type %s is not valid for this module"
+ % self._play_context.connection,
+ }
+
+ result = super(ActionModule, self).run(task_vars=task_vars)
+ if warnings:
+ if "warnings" in result:
+ result["warnings"].extend(warnings)
+ else:
+ result["warnings"] = warnings
+ return result