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..3f5babb3c 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,8 +1700,11 @@ def get_config(self, retrieve="all"): retrieve == "all" or retrieve == "candidate" ) and self.config_session + # EOS only supports "all" on "show run" + run_full = " all" if full else "" + if retrieve == "all": - commands = ["show startup-config", "show running-config"] + commands = ["show startup-config", "show running-config{}".format(run_full)] if self.config_session: commands.append( @@ -1721,7 +1724,10 @@ def get_config(self, retrieve="all"): else "", } elif get_startup or get_running: - commands = ["show {}-config".format(retrieve)] + if retrieve == "running": + commands = ["show {}-config{}".format(retrieve, run_full)] + elif retrieve == "startup": + commands = ["show {}-config".format(retrieve)] output = self.device.run_commands(commands, encoding="text") return { "startup": py23_compat.text_type(output[0]["output"]) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 01479e895..62b9d0d2c 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,6 +2968,8 @@ def get_config(self, retrieve="all"): """ configs = {"startup": "", "running": "", "candidate": ""} + # IOS only supports "all" on "show run" + run_full = " all" if full else "" if retrieve in ("startup", "all"): command = "show startup-config" @@ -2975,7 +2977,7 @@ def get_config(self, retrieve="all"): 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..82e1a1bf7 100644 --- a/napalm/iosxr/iosxr.py +++ b/napalm/iosxr/iosxr.py @@ -2224,13 +2224,17 @@ 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 + # IOS-XR only supports "all" on "show run" + 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( 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..d4ceebfec 100644 --- a/napalm/nxos/nxos.py +++ b/napalm/nxos/nxos.py @@ -524,11 +524,13 @@ 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 + # NX-OS only supports "all" on "show run" + 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) )