diff --git a/plugins/module_utils/network/iosxr/iosxr.py b/plugins/module_utils/network/iosxr/iosxr.py index 2ad50f1b..3b9c5479 100644 --- a/plugins/module_utils/network/iosxr/iosxr.py +++ b/plugins/module_utils/network/iosxr/iosxr.py @@ -116,16 +116,6 @@ "answer": dict(default=None), } -iosxr_top_spec = { - "host": dict(removed_in_version=2.9), - "port": dict(removed_in_version=2.9, type="int"), - "username": dict(removed_in_version=2.9), - "password": dict(removed_in_version=2.9, no_log=True), - "ssh_keyfile": dict(removed_in_version=2.9, type="path"), - "timeout": dict(removed_in_version=2.9, type="int"), -} -iosxr_argument_spec.update(iosxr_top_spec) - CONFIG_MISPLACED_CHILDREN = [re.compile(r"^end-\s*(.+)$")] # Objects defined in Route-policy Language guide of IOS_XR. diff --git a/plugins/modules/iosxr_user.py b/plugins/modules/iosxr_user.py index 34a05c9d..107219d0 100644 --- a/plugins/modules/iosxr_user.py +++ b/plugins/modules/iosxr_user.py @@ -264,18 +264,18 @@ def convert_key_to_base64(self): def copy_key_to_node(self, base64keyfile): """ Copy key to IOS-XR node. We use SFTP because older IOS-XR versions don't handle SCP very well. """ - if ( - self._module.params["host"] is None - or self._module.params["provider"]["host"] is None - ): + provider = self._module.params.get("provider") or {} + node = provider.get("host") + if node is None: return False - if ( - self._module.params["username"] is None - or self._module.params["provider"]["username"] is None - ): + user = provider.get("username") + if user is None: return False + password = provider.get("password") + ssh_keyfile = provider.get("ssh_keyfile") + if self._module.params["aggregate"]: name = "aggregate" else: @@ -284,23 +284,6 @@ def copy_key_to_node(self, base64keyfile): src = base64keyfile dst = "/harddisk:/publickey_%s.b64" % (name) - user = ( - self._module.params["username"] - or self._module.params["provider"]["username"] - ) - node = ( - self._module.params["host"] - or self._module.params["provider"]["host"] - ) - password = ( - self._module.params["password"] - or self._module.params["provider"]["password"] - ) - ssh_keyfile = ( - self._module.params["ssh_keyfile"] - or self._module.params["provider"]["ssh_keyfile"] - ) - ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) if not ssh_keyfile: @@ -315,34 +298,17 @@ def copy_key_to_node(self, base64keyfile): def addremovekey(self, command): """ Add or remove key based on command """ - if ( - self._module.params["host"] is None - or self._module.params["provider"]["host"] is None - ): + provider = self._module.params.get("provider") or {} + node = provider.get("host") + if node is None: return False - if ( - self._module.params["username"] is None - or self._module.params["provider"]["username"] is None - ): + user = provider.get("username") + if user is None: return False - user = ( - self._module.params["username"] - or self._module.params["provider"]["username"] - ) - node = ( - self._module.params["host"] - or self._module.params["provider"]["host"] - ) - password = ( - self._module.params["password"] - or self._module.params["provider"]["password"] - ) - ssh_keyfile = ( - self._module.params["ssh_keyfile"] - or self._module.params["provider"]["ssh_keyfile"] - ) + password = provider.get("password") + ssh_keyfile = provider.get("ssh_keyfile") ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) @@ -905,11 +871,6 @@ def main(): ) result = {"changed": False, "warnings": []} - if module.params["password"] and not module.params["configured_password"]: - result["warnings"].append( - 'The "password" argument is used to authenticate the current connection. ' - + 'To set a user password use "configured_password" instead.' - ) config_object = None if is_cliconf(module):