from lxml import etree

from ncclient.xml_ import *
from ncclient.operations.rpc import RPC

class ExecCommand(RPC):
    def request(self, cmd):
        parent_node = etree.Element(qualify('exec-command', NXOS_1_0))
        child_node = etree.SubElement(parent_node, qualify('cmd', NXOS_1_0))
        child_node.text = cmd
        return self._request(parent_node)

from lxml import etree

from ncclient.xml_ import *
from ncclient.operations.rpc import RPC

class ExecCommand(RPC):
    def request(self, cmds):
        node = etree.Element(qualify('exec-command', NXOS_1_0))

        for cmd in cmds:
            etree.SubElement(node, qualify('cmd', NXOS_1_0)).text = cmd

        return self._request(node)

Allow specifying multiple cmd elements
Allow specifying multiple cmd elements

  from lxml import etree
  
  from ncclient.xml_ import *
  from ncclient.operations.rpc import RPC
  
  class ExecCommand(RPC):
-     def request(self, cmd):
+     def request(self, cmds):
-         parent_node = etree.Element(qualify('exec-command', NXOS_1_0))
+         node = etree.Element(qualify('exec-command', NXOS_1_0))
-         child_node = etree.SubElement(parent_node, qualify('cmd', NXOS_1_0))
-         child_node.text = cmd
-         return self._request(parent_node)
  
+         for cmd in cmds:
+             etree.SubElement(node, qualify('cmd', NXOS_1_0)).text = cmd
+ 
+         return self._request(node)
+ 
Allow specifying multiple cmd elements
## Code Before:
from lxml import etree

from ncclient.xml_ import *
from ncclient.operations.rpc import RPC

class ExecCommand(RPC):
    def request(self, cmd):
        parent_node = etree.Element(qualify('exec-command', NXOS_1_0))
        child_node = etree.SubElement(parent_node, qualify('cmd', NXOS_1_0))
        child_node.text = cmd
        return self._request(parent_node)

## Instruction:
Allow specifying multiple cmd elements
## Code After:
from lxml import etree

from ncclient.xml_ import *
from ncclient.operations.rpc import RPC

class ExecCommand(RPC):
    def request(self, cmds):
        node = etree.Element(qualify('exec-command', NXOS_1_0))

        for cmd in cmds:
            etree.SubElement(node, qualify('cmd', NXOS_1_0)).text = cmd

        return self._request(node)
