From 63bbbedbe267a5fb4ca126a75b2c8fd2a9b38305 Mon Sep 17 00:00:00 2001 From: Holger Schulz Date: Tue, 16 Feb 2021 17:34:49 +0100 Subject: [PATCH] Added support for element to copy-config. (#12) --- netconf_client/ncclient.py | 3 ++- netconf_client/rpc.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/netconf_client/ncclient.py b/netconf_client/ncclient.py index 2452a1f..d693617 100644 --- a/netconf_client/ncclient.py +++ b/netconf_client/ncclient.py @@ -312,7 +312,8 @@ def get_config(self, source="running", filter=None, with_defaults=None): def copy_config(self, target, source, with_defaults=None): """Send a ```` request - :param str source: The source datastore + :param str source: The source datastore or the element + containing the complete configuration to copy. :param str target: The destination datastore diff --git a/netconf_client/rpc.py b/netconf_client/rpc.py index 1c362d4..8758b69 100644 --- a/netconf_client/rpc.py +++ b/netconf_client/rpc.py @@ -65,7 +65,10 @@ def copy_config(target, source, filter=None, with_defaults=None, msg_id=None): pieces = [] pieces.append("") pieces.append("<{}/>".format(target)) - pieces.append("<{}/>".format(source)) + if source.startswith("{}".format(source)) + else: + pieces.append("<{}/>".format(source)) if with_defaults: pieces.append(make_with_defaults(with_defaults)) pieces.append("")