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/aaa_server.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/aaa_server_host.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/acl.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/acl_interface.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/acl_interfaces.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/acls.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/banner.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bfd_global.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bfd_interfaces.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_address_family.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_af.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_global.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_neighbor.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_address_family.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_af.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/command.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/config.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/devicealias.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/evpn_global.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/evpn_vni.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/facts.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/feature.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/file_copy.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/gir.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/gir_profile_management.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/hostname.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/hsrp.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/hsrp_interfaces.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/igmp.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/igmp_interface.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/igmp_snooping.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/install_os.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/interface.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/interface_ospf.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/interfaces.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/l2_interface.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/l2_interfaces.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/l3_interface.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/l3_interfaces.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lacp.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lacp_interfaces.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lag_interfaces.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/linkagg.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lldp.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lldp_global.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/lldp_interfaces.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/logging.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/logging_global.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ntp.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ntp_auth.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ntp_global.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ntp_options.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/nxapi.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/nxos.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ospf.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ospf_interfaces.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ospf_vrf.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ospfv2.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ospfv3.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/overlay_global.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/pim.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/pim_interface.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/pim_rp_address.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/ping.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/prefix_lists.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/reboot.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/rollback.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/route_maps.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/rpm.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/smu.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snapshot.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_community.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_contact.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_host.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_location.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_server.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_traps.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/snmp_user.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/static_route.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/static_routes.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/system.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/telemetry.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/udld.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/udld_interface.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/user.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vlan.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vlans.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vpc.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vpc_interface.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vrf.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vrf_af.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vrf_interface.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vrrp.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vsan.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vtp_domain.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vtp_password.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vtp_version.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vxlan_vtep.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/vxlan_vtep_vni.py43
-rw-r--r--ansible_collections/cisco/nxos/plugins/action/zone_zoneset.py43
101 files changed, 2626 insertions, 1717 deletions
diff --git a/ansible_collections/cisco/nxos/plugins/action/aaa_server.py b/ansible_collections/cisco/nxos/plugins/action/aaa_server.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/aaa_server.py
+++ b/ansible_collections/cisco/nxos/plugins/action/aaa_server.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/aaa_server_host.py b/ansible_collections/cisco/nxos/plugins/action/aaa_server_host.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/aaa_server_host.py
+++ b/ansible_collections/cisco/nxos/plugins/action/aaa_server_host.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/acl.py b/ansible_collections/cisco/nxos/plugins/action/acl.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/acl.py
+++ b/ansible_collections/cisco/nxos/plugins/action/acl.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/acl_interface.py b/ansible_collections/cisco/nxos/plugins/action/acl_interface.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/acl_interface.py
+++ b/ansible_collections/cisco/nxos/plugins/action/acl_interface.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/acl_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/acl_interfaces.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/acl_interfaces.py
+++ b/ansible_collections/cisco/nxos/plugins/action/acl_interfaces.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/acls.py b/ansible_collections/cisco/nxos/plugins/action/acls.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/acls.py
+++ b/ansible_collections/cisco/nxos/plugins/action/acls.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/banner.py b/ansible_collections/cisco/nxos/plugins/action/banner.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/banner.py
+++ b/ansible_collections/cisco/nxos/plugins/action/banner.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/bfd_global.py b/ansible_collections/cisco/nxos/plugins/action/bfd_global.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/bfd_global.py
+++ b/ansible_collections/cisco/nxos/plugins/action/bfd_global.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/bfd_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/bfd_interfaces.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/bfd_interfaces.py
+++ b/ansible_collections/cisco/nxos/plugins/action/bfd_interfaces.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp.py b/ansible_collections/cisco/nxos/plugins/action/bgp.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/bgp.py
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp_address_family.py b/ansible_collections/cisco/nxos/plugins/action/bgp_address_family.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/bgp_address_family.py
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_address_family.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp_af.py b/ansible_collections/cisco/nxos/plugins/action/bgp_af.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/bgp_af.py
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_af.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp_global.py b/ansible_collections/cisco/nxos/plugins/action/bgp_global.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/bgp_global.py
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_global.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor.py b/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor.py
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
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
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_address_family.py
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_address_family.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_af.py b/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_af.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_af.py
+++ b/ansible_collections/cisco/nxos/plugins/action/bgp_neighbor_af.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/command.py b/ansible_collections/cisco/nxos/plugins/action/command.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/command.py
+++ b/ansible_collections/cisco/nxos/plugins/action/command.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/config.py b/ansible_collections/cisco/nxos/plugins/action/config.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/config.py
+++ b/ansible_collections/cisco/nxos/plugins/action/config.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/devicealias.py b/ansible_collections/cisco/nxos/plugins/action/devicealias.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/devicealias.py
+++ b/ansible_collections/cisco/nxos/plugins/action/devicealias.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/evpn_global.py b/ansible_collections/cisco/nxos/plugins/action/evpn_global.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/evpn_global.py
+++ b/ansible_collections/cisco/nxos/plugins/action/evpn_global.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/evpn_vni.py b/ansible_collections/cisco/nxos/plugins/action/evpn_vni.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/evpn_vni.py
+++ b/ansible_collections/cisco/nxos/plugins/action/evpn_vni.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/facts.py b/ansible_collections/cisco/nxos/plugins/action/facts.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/facts.py
+++ b/ansible_collections/cisco/nxos/plugins/action/facts.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/feature.py b/ansible_collections/cisco/nxos/plugins/action/feature.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/feature.py
+++ b/ansible_collections/cisco/nxos/plugins/action/feature.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/file_copy.py b/ansible_collections/cisco/nxos/plugins/action/file_copy.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/file_copy.py
+++ b/ansible_collections/cisco/nxos/plugins/action/file_copy.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/gir.py b/ansible_collections/cisco/nxos/plugins/action/gir.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/gir.py
+++ b/ansible_collections/cisco/nxos/plugins/action/gir.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/gir_profile_management.py b/ansible_collections/cisco/nxos/plugins/action/gir_profile_management.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/gir_profile_management.py
+++ b/ansible_collections/cisco/nxos/plugins/action/gir_profile_management.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/hostname.py b/ansible_collections/cisco/nxos/plugins/action/hostname.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/hostname.py
+++ b/ansible_collections/cisco/nxos/plugins/action/hostname.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/hsrp.py b/ansible_collections/cisco/nxos/plugins/action/hsrp.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/hsrp.py
+++ b/ansible_collections/cisco/nxos/plugins/action/hsrp.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/hsrp_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/hsrp_interfaces.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/hsrp_interfaces.py
+++ b/ansible_collections/cisco/nxos/plugins/action/hsrp_interfaces.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/igmp.py b/ansible_collections/cisco/nxos/plugins/action/igmp.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/igmp.py
+++ b/ansible_collections/cisco/nxos/plugins/action/igmp.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/igmp_interface.py b/ansible_collections/cisco/nxos/plugins/action/igmp_interface.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/igmp_interface.py
+++ b/ansible_collections/cisco/nxos/plugins/action/igmp_interface.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/igmp_snooping.py b/ansible_collections/cisco/nxos/plugins/action/igmp_snooping.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/igmp_snooping.py
+++ b/ansible_collections/cisco/nxos/plugins/action/igmp_snooping.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/install_os.py b/ansible_collections/cisco/nxos/plugins/action/install_os.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/install_os.py
+++ b/ansible_collections/cisco/nxos/plugins/action/install_os.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/interface.py b/ansible_collections/cisco/nxos/plugins/action/interface.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/interface.py
+++ b/ansible_collections/cisco/nxos/plugins/action/interface.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/interface_ospf.py b/ansible_collections/cisco/nxos/plugins/action/interface_ospf.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/interface_ospf.py
+++ b/ansible_collections/cisco/nxos/plugins/action/interface_ospf.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/interfaces.py b/ansible_collections/cisco/nxos/plugins/action/interfaces.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/interfaces.py
+++ b/ansible_collections/cisco/nxos/plugins/action/interfaces.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/l2_interface.py b/ansible_collections/cisco/nxos/plugins/action/l2_interface.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/l2_interface.py
+++ b/ansible_collections/cisco/nxos/plugins/action/l2_interface.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/l2_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/l2_interfaces.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/l2_interfaces.py
+++ b/ansible_collections/cisco/nxos/plugins/action/l2_interfaces.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/l3_interface.py b/ansible_collections/cisco/nxos/plugins/action/l3_interface.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/l3_interface.py
+++ b/ansible_collections/cisco/nxos/plugins/action/l3_interface.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/l3_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/l3_interfaces.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/l3_interfaces.py
+++ b/ansible_collections/cisco/nxos/plugins/action/l3_interfaces.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/lacp.py b/ansible_collections/cisco/nxos/plugins/action/lacp.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/lacp.py
+++ b/ansible_collections/cisco/nxos/plugins/action/lacp.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/lacp_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/lacp_interfaces.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/lacp_interfaces.py
+++ b/ansible_collections/cisco/nxos/plugins/action/lacp_interfaces.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/lag_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/lag_interfaces.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/lag_interfaces.py
+++ b/ansible_collections/cisco/nxos/plugins/action/lag_interfaces.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/linkagg.py b/ansible_collections/cisco/nxos/plugins/action/linkagg.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/linkagg.py
+++ b/ansible_collections/cisco/nxos/plugins/action/linkagg.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/lldp.py b/ansible_collections/cisco/nxos/plugins/action/lldp.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/lldp.py
+++ b/ansible_collections/cisco/nxos/plugins/action/lldp.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/lldp_global.py b/ansible_collections/cisco/nxos/plugins/action/lldp_global.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/lldp_global.py
+++ b/ansible_collections/cisco/nxos/plugins/action/lldp_global.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/lldp_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/lldp_interfaces.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/lldp_interfaces.py
+++ b/ansible_collections/cisco/nxos/plugins/action/lldp_interfaces.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/logging.py b/ansible_collections/cisco/nxos/plugins/action/logging.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/logging.py
+++ b/ansible_collections/cisco/nxos/plugins/action/logging.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/logging_global.py b/ansible_collections/cisco/nxos/plugins/action/logging_global.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/logging_global.py
+++ b/ansible_collections/cisco/nxos/plugins/action/logging_global.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/ntp.py b/ansible_collections/cisco/nxos/plugins/action/ntp.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/ntp.py
+++ b/ansible_collections/cisco/nxos/plugins/action/ntp.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/ntp_auth.py b/ansible_collections/cisco/nxos/plugins/action/ntp_auth.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/ntp_auth.py
+++ b/ansible_collections/cisco/nxos/plugins/action/ntp_auth.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/ntp_global.py b/ansible_collections/cisco/nxos/plugins/action/ntp_global.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/ntp_global.py
+++ b/ansible_collections/cisco/nxos/plugins/action/ntp_global.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/ntp_options.py b/ansible_collections/cisco/nxos/plugins/action/ntp_options.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/ntp_options.py
+++ b/ansible_collections/cisco/nxos/plugins/action/ntp_options.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/nxapi.py b/ansible_collections/cisco/nxos/plugins/action/nxapi.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/nxapi.py
+++ b/ansible_collections/cisco/nxos/plugins/action/nxapi.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/nxos.py b/ansible_collections/cisco/nxos/plugins/action/nxos.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/nxos.py
+++ b/ansible_collections/cisco/nxos/plugins/action/nxos.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/ospf.py b/ansible_collections/cisco/nxos/plugins/action/ospf.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/ospf.py
+++ b/ansible_collections/cisco/nxos/plugins/action/ospf.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/ospf_interfaces.py b/ansible_collections/cisco/nxos/plugins/action/ospf_interfaces.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/ospf_interfaces.py
+++ b/ansible_collections/cisco/nxos/plugins/action/ospf_interfaces.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/ospf_vrf.py b/ansible_collections/cisco/nxos/plugins/action/ospf_vrf.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/ospf_vrf.py
+++ b/ansible_collections/cisco/nxos/plugins/action/ospf_vrf.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/ospfv2.py b/ansible_collections/cisco/nxos/plugins/action/ospfv2.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/ospfv2.py
+++ b/ansible_collections/cisco/nxos/plugins/action/ospfv2.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/ospfv3.py b/ansible_collections/cisco/nxos/plugins/action/ospfv3.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/ospfv3.py
+++ b/ansible_collections/cisco/nxos/plugins/action/ospfv3.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/overlay_global.py b/ansible_collections/cisco/nxos/plugins/action/overlay_global.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/overlay_global.py
+++ b/ansible_collections/cisco/nxos/plugins/action/overlay_global.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/pim.py b/ansible_collections/cisco/nxos/plugins/action/pim.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/pim.py
+++ b/ansible_collections/cisco/nxos/plugins/action/pim.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/pim_interface.py b/ansible_collections/cisco/nxos/plugins/action/pim_interface.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/pim_interface.py
+++ b/ansible_collections/cisco/nxos/plugins/action/pim_interface.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/pim_rp_address.py b/ansible_collections/cisco/nxos/plugins/action/pim_rp_address.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/pim_rp_address.py
+++ b/ansible_collections/cisco/nxos/plugins/action/pim_rp_address.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/ping.py b/ansible_collections/cisco/nxos/plugins/action/ping.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/ping.py
+++ b/ansible_collections/cisco/nxos/plugins/action/ping.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/prefix_lists.py b/ansible_collections/cisco/nxos/plugins/action/prefix_lists.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/prefix_lists.py
+++ b/ansible_collections/cisco/nxos/plugins/action/prefix_lists.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/reboot.py b/ansible_collections/cisco/nxos/plugins/action/reboot.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/reboot.py
+++ b/ansible_collections/cisco/nxos/plugins/action/reboot.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/rollback.py b/ansible_collections/cisco/nxos/plugins/action/rollback.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/rollback.py
+++ b/ansible_collections/cisco/nxos/plugins/action/rollback.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/route_maps.py b/ansible_collections/cisco/nxos/plugins/action/route_maps.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/route_maps.py
+++ b/ansible_collections/cisco/nxos/plugins/action/route_maps.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/rpm.py b/ansible_collections/cisco/nxos/plugins/action/rpm.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/rpm.py
+++ b/ansible_collections/cisco/nxos/plugins/action/rpm.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/smu.py b/ansible_collections/cisco/nxos/plugins/action/smu.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/smu.py
+++ b/ansible_collections/cisco/nxos/plugins/action/smu.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/snapshot.py b/ansible_collections/cisco/nxos/plugins/action/snapshot.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/snapshot.py
+++ b/ansible_collections/cisco/nxos/plugins/action/snapshot.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_community.py b/ansible_collections/cisco/nxos/plugins/action/snmp_community.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/snmp_community.py
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_community.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_contact.py b/ansible_collections/cisco/nxos/plugins/action/snmp_contact.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/snmp_contact.py
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_contact.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_host.py b/ansible_collections/cisco/nxos/plugins/action/snmp_host.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/snmp_host.py
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_host.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_location.py b/ansible_collections/cisco/nxos/plugins/action/snmp_location.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/snmp_location.py
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_location.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_server.py b/ansible_collections/cisco/nxos/plugins/action/snmp_server.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/snmp_server.py
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_server.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_traps.py b/ansible_collections/cisco/nxos/plugins/action/snmp_traps.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/snmp_traps.py
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_traps.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/snmp_user.py b/ansible_collections/cisco/nxos/plugins/action/snmp_user.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/snmp_user.py
+++ b/ansible_collections/cisco/nxos/plugins/action/snmp_user.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/static_route.py b/ansible_collections/cisco/nxos/plugins/action/static_route.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/static_route.py
+++ b/ansible_collections/cisco/nxos/plugins/action/static_route.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/static_routes.py b/ansible_collections/cisco/nxos/plugins/action/static_routes.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/static_routes.py
+++ b/ansible_collections/cisco/nxos/plugins/action/static_routes.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/system.py b/ansible_collections/cisco/nxos/plugins/action/system.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/system.py
+++ b/ansible_collections/cisco/nxos/plugins/action/system.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/telemetry.py b/ansible_collections/cisco/nxos/plugins/action/telemetry.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/telemetry.py
+++ b/ansible_collections/cisco/nxos/plugins/action/telemetry.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/udld.py b/ansible_collections/cisco/nxos/plugins/action/udld.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/udld.py
+++ b/ansible_collections/cisco/nxos/plugins/action/udld.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/udld_interface.py b/ansible_collections/cisco/nxos/plugins/action/udld_interface.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/udld_interface.py
+++ b/ansible_collections/cisco/nxos/plugins/action/udld_interface.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/user.py b/ansible_collections/cisco/nxos/plugins/action/user.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/user.py
+++ b/ansible_collections/cisco/nxos/plugins/action/user.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vlan.py b/ansible_collections/cisco/nxos/plugins/action/vlan.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vlan.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vlan.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vlans.py b/ansible_collections/cisco/nxos/plugins/action/vlans.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vlans.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vlans.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vpc.py b/ansible_collections/cisco/nxos/plugins/action/vpc.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vpc.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vpc.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vpc_interface.py b/ansible_collections/cisco/nxos/plugins/action/vpc_interface.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vpc_interface.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vpc_interface.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vrf.py b/ansible_collections/cisco/nxos/plugins/action/vrf.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vrf.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vrf.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vrf_af.py b/ansible_collections/cisco/nxos/plugins/action/vrf_af.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vrf_af.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vrf_af.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vrf_interface.py b/ansible_collections/cisco/nxos/plugins/action/vrf_interface.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vrf_interface.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vrf_interface.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vrrp.py b/ansible_collections/cisco/nxos/plugins/action/vrrp.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vrrp.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vrrp.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vsan.py b/ansible_collections/cisco/nxos/plugins/action/vsan.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vsan.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vsan.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vtp_domain.py b/ansible_collections/cisco/nxos/plugins/action/vtp_domain.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vtp_domain.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vtp_domain.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vtp_password.py b/ansible_collections/cisco/nxos/plugins/action/vtp_password.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vtp_password.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vtp_password.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vtp_version.py b/ansible_collections/cisco/nxos/plugins/action/vtp_version.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vtp_version.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vtp_version.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep.py b/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep_vni.py b/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep_vni.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep_vni.py
+++ b/ansible_collections/cisco/nxos/plugins/action/vxlan_vtep_vni.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)
diff --git a/ansible_collections/cisco/nxos/plugins/action/zone_zoneset.py b/ansible_collections/cisco/nxos/plugins/action/zone_zoneset.py
index 3602c4074..e57c08aeb 100644
--- a/ansible_collections/cisco/nxos/plugins/action/zone_zoneset.py
+++ b/ansible_collections/cisco/nxos/plugins/action/zone_zoneset.py
@@ -21,7 +21,6 @@ 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 (
@@ -48,7 +47,7 @@ class ActionModule(ActionNetworkModule):
):
return {
"failed": True,
- "msg": "Connection httpapi is not valid for '%s' module." % (module_name),
+ "msg": f"Connection httpapi is not valid for {module_name} module.",
}
if module_name == "nxos_file_copy":
@@ -58,34 +57,43 @@ class ActionModule(ActionNetworkModule):
if persistent_connection != "network_cli":
return {
"failed": True,
- "msg": "Connection type must be fully qualified name for network_cli connection type, got %s"
+ "msg": (
+ f"Connection type must be fully qualified name for "
+ f"network_cli connection type, got {self._play_context.connection}"
+ )
% self._play_context.connection,
}
conn = Connection(self._connection.socket_path)
+ persistent_command_timeout = conn.get_option("persistent_command_timeout")
file_pull = self._task.args.get("file_pull", False)
- file_pull_timeout = self._task.args.get("file_pull_timeout", 300)
+ file_pull_timeout = self._task.args.get("file_pull_timeout")
connect_ssh_port = self._task.args.get("connect_ssh_port", 22)
if file_pull:
- conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is explicitly set, use that
+ if file_pull_timeout:
+ conn.set_option("persistent_command_timeout", file_pull_timeout)
+ # if file_pull_timeout is not set and command_timeout < 300s, bump to 300s.
+ elif persistent_command_timeout < 300:
+ conn.set_option("persistent_command_timeout", 300)
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")
+ 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),
+ f"PERSISTENT_COMMAND_TIMEOUT is {persistent_command_timeout}",
self._play_context.remote_addr,
)
display.vvvv(
- "PERSISTENT_CONNECT_TIMEOUT is %s" % str(persistent_connect_timeout),
+ f"PERSISTENT_CONNECT_TIMEOUT is %s {persistent_connect_timeout}",
self._play_context.remote_addr,
)
if persistent_command_timeout < 600 or persistent_connect_timeout < 600:
@@ -102,18 +110,19 @@ class ActionModule(ActionNetworkModule):
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")
+ 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
+ msg = f"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,
+ "msg": f"Connection type {self._play_context.connection} is not valid for this module",
}
result = super(ActionModule, self).run(task_vars=task_vars)