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

YDK only returns single LDP remote label binding from list of remote label bindings (xr_mpls_ldp_oper) #664

Closed
djsmith20171 opened this issue Jan 11, 2018 · 0 comments
Labels

Comments

@djsmith20171
Copy link

Issue tracker is ONLY used for reporting bugs. Please use the YDK Community for any support issues.

Expected Behavior

List of LDP remote label bindings should be iterable.

Current Behavior

YDK is only returning / processing / iterating on the first item within the list.

Steps to Reproduce

See logs and script below.

Your Script

def process_mpls_ldp(mpls_ldp):
"""Process data in mpls_ldp object."""
# format string for prefixes
prefix_row = "{prefix}, rev {rev}\n"
local_binding_row = " Local binding: label: {label}\n"
peers_row = " Remote bindings: ({num_peers} peers)\n"
# format string for peer header
peer_header = (" Peer Label\n"
" ----------------- ---------\n")
# format string for remote bindings
remote_binding_row = " {peer:19} {label}\n"

label = {0: "ExpNull", 3: "ImpNull"}

show_mpls_ldp_bindings = str()

# iterate over all LDP bindings
for binding in mpls_ldp.global_.active.default_vrf.afs.af[0].bindings.binding:
    if binding.local_label in label:
        local_label = label[int(binding.local_label)]
    else:
        local_label = str(binding.local_label)
    show_mpls_ldp_bindings += prefix_row.format(prefix=binding.prefix,
                                                rev=binding.le_local_binding_revision)
    show_mpls_ldp_bindings += local_binding_row.format(label=local_label)

    # the len(binding.remote_binding) statement directly below returns 1 and should return >1.
    show_mpls_ldp_bindings += peers_row.format(num_peers=len(binding.remote_binding))
    show_mpls_ldp_bindings += peer_header

    # iterate over all remote bindings for a given prefix
    for remote_binding in binding.remote_binding:
        if remote_binding.remote_label in label:
            remote_label = label[remote_binding.remote_label]
        else:
            remote_label = str(remote_binding.remote_label)
        peer_ident = remote_binding.assigning_peer_ldp_ident
        peer_label_space_id = "{}:{}".format(peer_ident.lsr_id, str(peer_ident.label_space_id))
        show_mpls_ldp_bindings += remote_binding_row.format(peer=peer_label_space_id,
                                                            label=remote_label)

# return formatted string
return show_mpls_ldp_bindings.strip()

Logs

2018-01-11 09:47:27,708 - ydk - INFO - Path where models are to be downloaded: /home/admin/.ydk/198.18.1.11:830
2018-01-11 09:47:27,718 - ydk - INFO - Connected to 198.18.1.11 on port 830 using ssh with timeout of -1
2018-01-11 09:47:27,754 - ydk - INFO - Executing CRUD read operation
2018-01-11 09:47:27,802 - ydk - INFO - =============Generating payload to send to device=============
2018-01-11 09:47:27,802 - ydk - INFO -






ipv4













2018-01-11 09:47:27,803 - ydk - INFO -

2018-01-11 09:47:28,052 - ydk - INFO - =============Reply payload received from device=============
2018-01-11 09:47:28,053 - ydk - INFO -








ipv4


10.16.0.0/16

24005

172.16.255.101
0
172.16.255.101:0

false
false


24005

172.16.255.102
0
172.16.255.102:0

false
false



10.64.0.0/16

24006

172.16.255.101
0
172.16.255.101:0

false
false


24006

172.16.255.102
0
172.16.255.102:0

false
false



172.16.1.0/31

3

172.16.255.101
0
172.16.255.101:0

false
false


24003

172.16.255.102
0
172.16.255.102:0

false
false



172.16.1.2/31

24003

172.16.255.101
0
172.16.255.101:0

false
false


3

172.16.255.102
0
172.16.255.102:0

false
false



172.16.2.0/31

24002

172.16.255.101
0
172.16.255.101:0

false
false


3

172.16.255.102
0
172.16.255.102:0

false
false



172.16.2.2/31

3

172.16.255.101
0
172.16.255.101:0

false
false


24002

172.16.255.102
0
172.16.255.102:0

false
false



172.16.2.4/31

3

172.16.255.101
0
172.16.255.101:0

false
false


3

172.16.255.102
0
172.16.255.102:0

false
false



172.16.255.1/32

24007

172.16.255.101
0
172.16.255.101:0

false
false


24007

172.16.255.102
0
172.16.255.102:0

false
false



172.16.255.2/32

24000

172.16.255.101
0
172.16.255.101:0

false
false


24000

172.16.255.102
0
172.16.255.102:0

false
false



172.16.255.101/32

3

172.16.255.101
0
172.16.255.101:0

false
false


24001

172.16.255.102
0
172.16.255.102:0

false
false



172.16.255.102/32

24001

172.16.255.101
0
172.16.255.101:0

false
false


3

172.16.255.102
0
172.16.255.102:0

false
false



198.18.0.0/16

24004

172.16.255.101
0
172.16.255.101:0

false
false


24004

172.16.255.102
0
172.16.255.102:0

false
false



198.18.1.0/24

3

172.16.255.101
0
172.16.255.101:0

false
false


3

172.16.255.102
0
172.16.255.102:0

false
false










2018-01-11 09:47:28,053 - ydk - INFO -

10.16.0.0/16, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 24005
10.64.0.0/16, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 24006
172.16.1.0/31, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 24003
172.16.1.2/31, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 3
172.16.2.0/31, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 3
172.16.2.2/31, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 24002
172.16.2.4/31, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 3
172.16.255.1/32, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 24007
172.16.255.2/32, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 24000
172.16.255.101/32, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 24001
172.16.255.102/32, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 3
198.18.0.0/16, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 24004
198.18.1.0/24, rev
Local binding: label:
Remote bindings: (1 peers)
Peer Label
----------------- ---------
172.16.255.102:0 3
2018-01-11 09:47:28,119 - ydk - INFO - Disconnected from device

System Information

• ydk (0.6.2)
• ydk-models-cisco-ios-xr (6.3.1)
• ydk-models-ietf (0.1.4)
• Python 3.5.2
• IOS XRv release 6.3.2.22I

@ghost ghost added the bug label Jan 17, 2018
@ghost ghost closed this as completed in #667 Jan 24, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant