

def call_rpc(cmd=None, *args, **kwargs):
    "\n    This function executes the rpc provided as arguments on the junos device.\n    The returned data can be stored in a file whose destination can be\n    specified with 'dest' keyword in the arguments.\n\n    Usage:\n\n    .. code-block:: bash\n\n        salt 'device' junos.call_rpc 'get_config' '<configuration><system/></configuration>' terse=True\n\n        salt 'device' junos.call_rpc 'get-chassis-inventory' dest=/home/user/rpc_information.txt\n\n\n    Options:\n      * cmd: the rpc to be executed\n      * args: other arguments as taken by rpc call of PyEZ\n      * kwargs: keyworded arguments taken by rpc call of PyEZ\n    "
    conn = __proxy__['junos.conn']()
    ret = dict()
    ret['out'] = True
    op = dict()
    if (('__pub_arg' in kwargs) and isinstance(kwargs['__pub_arg'][(- 1)], dict)):
        op.update(kwargs['__pub_arg'][(- 1)])
    else:
        op.update(kwargs)
    for (k, v) in op.iteritems():
        op[k] = str(v)
    op['format'] = 'json'
    try:
        if (cmd in ['get-config', 'get_config']):
            filter_reply = None
            if (len(args) > 0):
                filter_reply = etree.XML(args[0])
            ret['message'] = getattr(conn.rpc, cmd.replace('-', '_'))(filter_reply, options=op)
        else:
            ret['message'] = getattr(cmd.rpc, cmd.replace('-', '_'))(op)
    except Exception as exception:
        ret['message'] = 'Execution failed due to "{0}"'.format(exception)
        ret['out'] = False
    if ('dest' in op):
        f = open(op['dest'], 'w')
        f.write(ret['message'])
        f.close()
    return ret

dataset/ETHPy150Open saltstack/salt/salt/modules/junos.py call_rpc/VarMisuse@223/523 `conn`->`cmd`