Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes#27314 - Handled issue in parsing "exit" in dellos6 running config #28060

Merged
merged 1 commit into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/ansible/module_utils/dellos6.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def os6_parse(lines, indent=None, comment_tokens=None):
re.compile(r'support-assist.*$'),
re.compile(r'template.*$'),
re.compile(r'address-family.*$'),
re.compile(r'spanning-tree mst.*$'),
re.compile(r'spanning-tree mst configuration.*$'),
re.compile(r'logging.*$'),
re.compile(r'(radius-server|tacacs-server) host.*$')]

Expand Down Expand Up @@ -208,7 +208,7 @@ def os6_parse(lines, indent=None, comment_tokens=None):
if parent:
cfg._parents.extend(parent)
parent = list()
config.append(cfg)
config.append(cfg)
# handle sublevel children
elif parent_match is False and len(parent) > 0:
if not children:
Expand All @@ -234,7 +234,11 @@ def _diff_line(self, other, path=None):
for item in self.items:
if str(item) == "exit":
for diff_item in diff:
if item._parents == diff_item._parents:
if diff_item._parents:
if item._parents == diff_item._parents:
diff.append(item)
break
else:
diff.append(item)
break
elif item not in other:
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/plugins/terminal/dellos6.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def on_authorize(self, passwd=None):

cmd = {u'command': u'enable'}
if passwd:
cmd[u'prompt'] = to_text(r"[\r\n]?password: $", errors='surrogate_or_strict')
cmd[u'prompt'] = to_text(r"[\r\n]?password:$", errors='surrogate_or_strict')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prexisting but note that you're still operating on a string literal here so you can write it like this:

cmd[u'promt'] = ur"[\r\n]?password:$"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string literals are quicker than calling to_text() so that's why I mention it.

cmd[u'answer'] = passwd
try:
self._exec_cli_command(to_bytes(json.dumps(cmd), errors='surrogate_or_strict'))
Expand Down