Skip to content

Commit

Permalink
Updated from network content collector
Browse files Browse the repository at this point in the history
Signed-off-by: CaptTrews <capttrews@gmail.com>
  • Loading branch information
CaptTrews committed Oct 28, 2019
1 parent b730792 commit 64d60a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 64 deletions.
10 changes: 0 additions & 10 deletions plugins/module_utils/network/iosxr/iosxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
69 changes: 15 additions & 54 deletions plugins/modules/iosxr_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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())
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 64d60a6

Please sign in to comment.