diff --git a/napalm/base/base.py b/napalm/base/base.py index 1f2b94e93..2eadc331a 100644 --- a/napalm/base/base.py +++ b/napalm/base/base.py @@ -1512,13 +1512,14 @@ def get_optics(self): """ raise NotImplementedError - def get_config(self, retrieve="all"): + def get_config(self, retrieve="all", full=False): """ Return the configuration of a device. Args: retrieve(string): Which configuration type you want to populate, default is all of them. The rest will be set to "". + full(bool): Retrieve all the configuration. For instance, on ios, "sh run all". Returns: The object returned is a dictionary with a key for each configuration store: diff --git a/napalm/eos/eos.py b/napalm/eos/eos.py index 30ee212c8..2d6cb8387 100644 --- a/napalm/eos/eos.py +++ b/napalm/eos/eos.py @@ -1692,7 +1692,7 @@ def get_optics(self): return optics_detail - def get_config(self, retrieve="all"): + def get_config(self, retrieve="all", full=False): """get_config implementation for EOS.""" get_startup = retrieve == "all" or retrieve == "startup" get_running = retrieve == "all" or retrieve == "running" @@ -1700,12 +1700,19 @@ def get_config(self, retrieve="all"): retrieve == "all" or retrieve == "candidate" ) and self.config_session + run_full = " all" if full else "" + if retrieve == "all": - commands = ["show startup-config", "show running-config"] + commands = [ + "show startup-config{}".format(run_full), + "show running-config{}".format(run_full), + ] if self.config_session: commands.append( - "show session-config named {}".format(self.config_session) + "show session-config named {} {}".format( + self.config_session, run_full + ) ) output = self.device.run_commands(commands, encoding="text") @@ -1721,7 +1728,7 @@ def get_config(self, retrieve="all"): else "", } elif get_startup or get_running: - commands = ["show {}-config".format(retrieve)] + commands = ["show {}-config{}".format(retrieve, run_full)] output = self.device.run_commands(commands, encoding="text") return { "startup": py23_compat.text_type(output[0]["output"]) @@ -1733,7 +1740,9 @@ def get_config(self, retrieve="all"): "candidate": "", } elif get_candidate: - commands = ["show session-config named {}".format(self.config_session)] + commands = [ + "show session-config named {}{}".format(self.config_session, run_full) + ] output = self.device.run_commands(commands, encoding="text") return { "startup": "", diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 01479e895..c33617b3f 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -2958,7 +2958,7 @@ def get_network_instances(self, name=""): } return instances if not name else instances[name] - def get_config(self, retrieve="all"): + def get_config(self, retrieve="all", full=False): """Implementation of get_config for IOS. Returns the startup or/and running configuration as dictionary. @@ -2968,14 +2968,15 @@ def get_config(self, retrieve="all"): """ configs = {"startup": "", "running": "", "candidate": ""} + run_full = " all" if full else "" if retrieve in ("startup", "all"): - command = "show startup-config" + command = "show startup-config{}".format(run_full) output = self._send_command(command) configs["startup"] = output if retrieve in ("running", "all"): - command = "show running-config" + command = "show running-config{}".format(run_full) output = self._send_command(command) configs["running"] = output diff --git a/napalm/iosxr/iosxr.py b/napalm/iosxr/iosxr.py index 098a8cd66..2d2945cc4 100644 --- a/napalm/iosxr/iosxr.py +++ b/napalm/iosxr/iosxr.py @@ -2224,17 +2224,22 @@ def get_users(self): return users - def get_config(self, retrieve="all"): + def get_config(self, retrieve="all", full=False): config = {"startup": "", "running": "", "candidate": ""} # default values + run_full = " all" if full else "" if retrieve.lower() in ["running", "all"]: config["running"] = py23_compat.text_type( - self.device._execute_config_show("show running-config") + self.device._execute_config_show( + "show running-config{}".format(run_full) + ) ) if retrieve.lower() in ["candidate", "all"]: config["candidate"] = py23_compat.text_type( - self.device._execute_config_show("show configuration merge") + self.device._execute_config_show( + "show configuration merge{}".format(run_full) + ) ) return config diff --git a/napalm/junos/junos.py b/napalm/junos/junos.py index 003ad116e..3e29f8a36 100644 --- a/napalm/junos/junos.py +++ b/napalm/junos/junos.py @@ -2231,7 +2231,7 @@ def get_optics(self): return optics_detail - def get_config(self, retrieve="all"): + def get_config(self, retrieve="all", full=False): rv = {"startup": "", "running": "", "candidate": ""} options = {"format": "text", "database": "candidate"} diff --git a/napalm/nxos/nxos.py b/napalm/nxos/nxos.py index dee643c24..63cb78f60 100644 --- a/napalm/nxos/nxos.py +++ b/napalm/nxos/nxos.py @@ -524,16 +524,17 @@ def _create_tmp_file(config): def _disable_confirmation(self): self._send_command_list(["terminal dont-ask"]) - def get_config(self, retrieve="all"): + def get_config(self, retrieve="all", full=False): config = {"startup": "", "running": "", "candidate": ""} # default values + run_full = " all" if full else "" if retrieve.lower() in ("running", "all"): - command = "show running-config" + command = "show running-config{}".format(run_full) config["running"] = py23_compat.text_type( self._send_command(command, raw_text=True) ) if retrieve.lower() in ("startup", "all"): - command = "show startup-config" + command = "show startup-config{}".format(run_full) config["startup"] = py23_compat.text_type( self._send_command(command, raw_text=True) )