File: rpc.py

package info (click to toggle)
python-ncclient 0.6.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,144 kB
  • sloc: python: 9,208; xml: 476; makefile: 83
file content (26 lines) | stat: -rw-r--r-- 902 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from ncclient.xml_ import *

from ncclient.operations.rpc import RPC

def global_operations(node):
    """Instantiate an SR OS global operation action element

    Args:
        node: A string representing the top-level action for a
            given global operation.
    Returns:
        A tuple of 'lxml.etree._Element' values.  The first value
        represents the top-level YANG action element and the second
        represents the caller supplied initial node.
    """
    parent, child = yang_action('global-operations',
            attrs={'xmlns': SROS_GLOBAL_OPS_NS})
    ele = sub_ele(child, node)
    return (parent, ele)

class MdCliRawCommand(RPC):
    def request(self, command=None):
        node, raw_cmd_node = global_operations('md-cli-raw-command')
        sub_ele(raw_cmd_node, 'md-cli-input-line').text = command
        self._huge_tree = True
        return self._request(node)