From ff1dac648908acc3e868ad3e0dabcac1398e8f14 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesinger Date: Fri, 7 Feb 2014 13:25:27 +0100 Subject: [PATCH] Allow lists and tuples as RPC command values There are a few commands in JunOS that require multiple tags to be sent, for example the call when using a set of update packages for a Virtual-Chassis: jinstall-ex-4200-... jinstall-ex-4500-... This was not possible as a command value could only be a string. Now it can also be a tuple or list and a tag will be generated for every value of the list. --- lib/jnpr/junos/rpcmeta.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/jnpr/junos/rpcmeta.py b/lib/jnpr/junos/rpcmeta.py index 871906613..7e5b1674d 100644 --- a/lib/jnpr/junos/rpcmeta.py +++ b/lib/jnpr/junos/rpcmeta.py @@ -106,8 +106,13 @@ def _exec_rpc(*vargs, **kvargs): if kvargs: for arg_name, arg_value in kvargs.items(): arg_name = re.sub('_','-',arg_name) - arg = etree.SubElement( rpc, arg_name ) - if arg_value != True: arg.text = arg_value + if isinstance(arg_value, (tuple, list)): + for a in arg_value: + arg = etree.SubElement( rpc, arg_name ) + if a != True: arg.text = a + else: + arg = etree.SubElement( rpc, arg_name ) + if arg_value != True: arg.text = arg_value # vargs[0] is a dict, command options like format='text' if vargs: