Backport/2.8/60075 ce_rollback: set mmi-mode enable to run commands and unset after running. (#60075) (#60084)

* set mmi-mode enable to run commands nad unset after running. (#60075)


(cherry picked from commit 16e237e095)

* add a changelog fragment.
This commit is contained in:
Xu Yuandong 2019-08-10 02:44:52 +08:00 committed by Toshio Kuratomi
parent 56639d0f68
commit d497d5865b
2 changed files with 5 additions and 5 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- ce_rollback - set mmi-mode enable to run commands and unset after running(https://github.com/ansible/ansible/pull/60075).

View file

@ -170,6 +170,7 @@ class RollBack(object):
def cli_add_command(self, command, undo=False): def cli_add_command(self, command, undo=False):
"""add command to self.update_cmd and self.commands""" """add command to self.update_cmd and self.commands"""
self.commands.append("return") self.commands.append("return")
self.commands.append("mmi-mode enable")
if self.action == "commit": if self.action == "commit":
self.commands.append("sys") self.commands.append("sys")
@ -246,19 +247,15 @@ class RollBack(object):
if self.action == "rollback": if self.action == "rollback":
if self.commit_id: if self.commit_id:
cmd = "rollback configuration to commit-id %s" % self.commit_id cmd = "rollback configuration to commit-id %s" % self.commit_id
cmd = {"command": cmd, "prompt": r"[Y/N]", "answer": "Y"}
self.cli_add_command(cmd) self.cli_add_command(cmd)
if self.label: if self.label:
cmd = "rollback configuration to label %s" % self.label cmd = "rollback configuration to label %s" % self.label
cmd = {"command": cmd, "prompt": r"[Y/N]", "answer": "Y"}
self.cli_add_command(cmd) self.cli_add_command(cmd)
if self.filename: if self.filename:
cmd = "rollback configuration to file %s" % self.filename cmd = "rollback configuration to file %s" % self.filename
cmd = {"command": cmd, "prompt": r"[Y/N]", "answer": "Y"}
self.cli_add_command(cmd) self.cli_add_command(cmd)
if self.last: if self.last:
cmd = "rollback configuration last %s" % self.last cmd = "rollback configuration last %s" % self.last
cmd = {"command": cmd, "prompt": r"[Y/N]", "answer": "Y"}
self.cli_add_command(cmd) self.cli_add_command(cmd)
elif self.action == "set": elif self.action == "set":
if self.commit_id and self.label: if self.commit_id and self.label:
@ -270,7 +267,6 @@ class RollBack(object):
self.cli_add_command(cmd) self.cli_add_command(cmd)
if self.oldest: if self.oldest:
cmd = "clear configuration commit oldest %s" % self.oldest cmd = "clear configuration commit oldest %s" % self.oldest
cmd = {"command": cmd, "prompt": r"[Y/N]", "answer": "Y"}
self.cli_add_command(cmd) self.cli_add_command(cmd)
elif self.action == "commit": elif self.action == "commit":
if self.label: if self.label:
@ -280,6 +276,8 @@ class RollBack(object):
elif self.action == "display": elif self.action == "display":
self.rollback_info = self.get_rollback_dict() self.rollback_info = self.get_rollback_dict()
if self.commands: if self.commands:
self.commands.append('return')
self.commands.append('undo mmi-mode enable')
self.cli_load_config(self.commands) self.cli_load_config(self.commands)
self.changed = True self.changed = True