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

yaml output starts off as a list instead of dict #120

Open
bassman-junk opened this issue Feb 8, 2024 · 2 comments
Open

yaml output starts off as a list instead of dict #120

bassman-junk opened this issue Feb 8, 2024 · 2 comments

Comments

@bassman-junk
Copy link

Is there a way to remove the '-' or list from the parent dict structure of the yaml output?

ex:

  • r_cfg: <<<<<<<<<--------- Is there an option to not have the '-'?
    protocols:
    bgp:
    groups:
    IBGP:
    R_ASN: '65201'
    local_address: Loopback0
    nbrs:
    - nbr: 10.100.0.1
    - nbr: 10.100.0.2
    - nbr: 10.100.0.3
    L_ASN: '65201'

I would like for it to be as so:
r_cfg:
interfaces:
intf: Loopback0
ip: !!python/object/apply:ipaddress.IPv4Interface
- 10.1.1.1/32
is_loop: true
mask: 255.255.255.255
protocols:
bgp:
groups:
IBGP:
R_ASN: '65201'
local_address: Loopback0
nbrs:
- nbr: 10.100.0.1
- nbr: 10.100.0.2
- nbr: 10.100.0.3
L_ASN: '65201'

@bassman-junk
Copy link
Author

Sorry, the format came out wrong. Here is a screenshot.
Screenshot 2024-02-08 at 8 50 55 AM

@dmulyalin
Copy link
Owner

yeah, have a look at these:
https://ttp.readthedocs.io/en/latest/Forming%20Results%20Structure/index.html#results-structure
https://ttp.readthedocs.io/en/latest/Template%20Tag/Template%20Tag.html#results

Need to use <template name="r_cfg" results="per_template"> ...template goes here... </template> plus when calling ttp parser object result need to add structure keyword e.g. parser.result(structure="dictionary"), that combined should give you all dictionary output with no top list.

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

No branches or pull requests

2 participants