py-junos-eznc icon indicating copy to clipboard operation
py-junos-eznc copied to clipboard

cli_to_rpc_string() generating incorrect rpc string if <app> tag text contains a hyphen char

Open ipmonk opened this issue 10 months ago • 1 comments

// the following generates output that results in an exception

>>> d.cli_to_rpc_string("show platform app-controller app l2ald-agent complete")
"rpc.app_controller_show(app='l2ald-agent', complete=True)"

>>> d.rpc.app_controller_show(app='l2ald-agent', complete=True)
/usr/lib64/python3.7/site-packages/jnpr/junos/device.py:858: RuntimeWarning: An unknown exception occurred - please report.
  "An unknown exception occurred - please report.", RuntimeWarning

// this is due to the hyphen inside the <app> tag. substitute for an underscore and the rpc works:

>>> d.rpc.app_controller_show(app='l2ald_agent', complete=True)
<Element app-object-info at 0x7f9c4008c3c0>

// problem originates from the | display xml rpc output.

foo@bar> show platform app-controller app l2ald-agent complete | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/23.3R1-202308210311.0-EVO/junos">
    <rpc>
        <app-controller-show>
                <app>l2ald-agent</app>   <<<<<
                <complete/>
        </app-controller-show>
    </rpc>

ipmonk avatar Aug 31 '23 06:08 ipmonk