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

rpc get-subscribers returns no data using Tables/View #1275

Open
ChrisHills463 opened this issue Oct 19, 2023 · 0 comments
Open

rpc get-subscribers returns no data using Tables/View #1275

ChrisHills463 opened this issue Oct 19, 2023 · 0 comments

Comments

@ChrisHills463
Copy link
Contributor

ChrisHills463 commented Oct 19, 2023

When trying to query subscribers using tables and view, no data is returned.

The script below gives the following output:-

There are 4 subscribers using dev.rpc.get_subscribers()
There are 0 subscribers using SubscriberTable()

Script:-

#!/usr/bin/python3

import yaml

from jnpr.junos import Device
from jnpr.junos.factory.factory_loader import FactoryLoader

subscriber_table = """
---
SubscriberTable:
    rpc: get-subscribers
    item: subscriber
    view: SubscriberView

SubscriberView:
    fields:
        interface: interface
        user_name: user-name
        logical_system: logical-system
        routing_instance: routing-instance
        stacked_vlan_id: stacked-vlan-id
        vlan_id: vlan-id
        ipv6_address: ipv6-address
"""

globals().update(
    FactoryLoader().load(yaml.load(subscriber_table, Loader=yaml.FullLoader))
)

HOST = "mx204-bng.lab"
dev = Device(host=HOST, port=22)
dev.open()

res = dev.rpc.get_subscribers()
subscribers = res.xpath('//subscriber')
print(f"There are {len(subscribers)} subscribers using dev.rpc.get_subscribers()")

res = SubscriberTable(dev)
res.get()
print(f"There are {len(res)} subscribers using SubscriberTable()")

dev.close()

This is the result of ssh mx204-bng.lab 'show subscribers | display xml':-

<rpc-reply xmlns:junos="http://xml.juniper.net/junos/21.2R0/junos">
    <subscribers-information xmlns="http://xml.juniper.net/junos/21.2R0/junos-subscribers">
        <subscriber junos:style="terse">
            <interface>ae2.3732871645</interface>
            <user-name></user-name>
            <logical-system>default</logical-system>
            <routing-instance>default</routing-instance>
            <stacked-vlan-id>0x8100.1000</stacked-vlan-id>
            <vlan-id>0x8100.7</vlan-id>
        </subscriber>
        <subscriber junos:style="terse">
            <interface>demux0.3298857643</interface>
            <user-name>XXXXXXXXXXXX/1/1000/0001</user-name>
            <logical-system>default</logical-system>
            <routing-instance>default</routing-instance>
            <ip-address>10.10.10.10</ip-address>
        </subscriber>
        <subscriber junos:style="terse">
            <interface>*</interface>
            <ipv6-address>2001:db8::/56</ipv6-address>
        </subscriber>
        <subscriber junos:style="terse">
            <interface>*</interface>
            <ipv6-address>2001:db8:1::/64</ipv6-address>
        </subscriber>
    </subscribers-information>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>
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

3 participants