Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Table/View] Can not pass args into rpc when call get_rpc #1298

Open
linhnt-hub opened this issue Mar 28, 2024 · 1 comment
Open

[Table/View] Can not pass args into rpc when call get_rpc #1298

linhnt-hub opened this issue Mar 28, 2024 · 1 comment
Assignees

Comments

@linhnt-hub
Copy link

I have issue when i try use args info rpc call.

===========================================


 from jnpr.junos import Device
 from jnpr.junos.factory.factory_loader import FactoryLoader
 import yaml
 
 myYAML = """
 ---
 OspfNeighborTable:
     item: ospf-neighbor
     key:
     - interface-name
     - neighbor-id
     rpc: get-ospf-neighbor-information
     view: _OspfNeighborView
 _OspfNeighborView:
     fields:
         activity_timer: activity-timer
         interface_name: interface-name
         neighbor_address: neighbor-address
         neighbor_id: neighbor-id
         neighbor_priority: neighbor-priority
         ospf_neighbor_state: ospf-neighbor-state
 """
 globals().update(FactoryLoader().load(yaml.load(myYAML, Loader=yaml.FullLoader)))
 with Device(host="10.96.10.102", user='xxx', password='xxx', gather_facts=False) as dev:
      ospfs = OspfNeighborTable(dev)
      input_args = {"interfacename" : "xe-1/3/0"}
      result= ospfs.get(input_args)
 print(result)
 for i in result:
     print("Interface is {}\nNeighbor is {}\nState is {}".format(i.interface_name, i.neighbor_id, i.ospf_neighbor_state))
 

Traceoptions in router:

Mar 27 08:59:20 [NETCONF] - [39885] Incoming: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:c7fb0bc8-722c-4902-9d67-a245bbf2b18c"><get-ospf-neighbor-information/></nc:rpc>]]>]]>

Mar 27 08:59:20 [NETCONF] - [39885] Incoming: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:4986e61f-b1b7-41e4-94b4-699ed06e29af"><nc:close-session/></nc:rpc>]]>]]>

Logging for outgoing

2024-03-27 09:23:13,023 DEBUG send(168)     [host 10.96.10.102 session-id 40373] queueing <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:b9ce4fb5-a23e-4241-8f5a-81226750a89a"><get-ospf-neighbor-information/></nc:rpc>

Like below. I saw args when I pass into get(). It couldn's pass into packet sent to router:

      input_args = {"interfacename" : "xe-1/3/0"}
      result= ospfs.get(input_args)

Could you give me info about this issue? Thanks

@dineshbaburam91
Copy link
Collaborator

@linhnt-hub To filter the RPC output for a specific interface name, you need to use the following code snippet in the get API.

     ospfs = OspfNeighborTable(dev)
     result= ospfs.get(interface="ge-0/0/0")

Output:

Interface is ge-0/0/0.0
Neighbor is 128.221.138.217
State is Full

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants