Skip to content

yang_to_legacy fails on gnpy-eqpt-config:equipment when converting the full API payload #564

@RenatoParker

Description

@RenatoParker

I’m reporting a bug in gnpy related to the YANG conversion functions.

I’m using yang_to_legacy to develop the gnpy APIs.

I’m doing:

legacy_data = yang_to_legacy(json.loads(request.json))

and then I expect to be able to read:

service = legacy_data['gnpy-path-computation:services']
topology = legacy_data['gnpy-network-topology:topology']
equipment = legacy_data['gnpy-eqpt-config:equipment']

but I get this error:

cr = raman_coefficient.pop('cr')
TypeError: 'str' object cannot be interpreted as an integer

The issue seems to come from a conversion problem, because it works if I convert only the equipment part of the API payload:

equipment = yang_to_legacy(json.loads(request.json)["gnpy-api:api"]['gnpy-eqpt-config:equipment'])

So the result of yang_to_legacy seems to be different depending on whether I pass the full payload or only the gnpy-eqpt-config:equipment section.

I added some debug prints for dict/list conversion here:
https://pastebin.com/GxRzQht5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions