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

Error when handling leaf-list of identityref type #186

Closed
ghost opened this issue Jul 20, 2016 · 2 comments
Closed

Error when handling leaf-list of identityref type #186

ghost opened this issue Jul 20, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Jul 20, 2016

Below YDK script using leaf-list of identityref type from openconfig routing-policy model produces the below error:

from ydk.providers import NetconfServiceProvider
from ydk.services import CRUDService

from ydk.models.routing.routing_policy import RoutingPolicy
from ydk.models.bgp.bgp_types import BgpOriginAttrTypeEnum
from ydk.models.bgp.bgp_types import Ipv4UnicastIdentity

ncc = NativeNetconfServiceProvider(address='127.0.0.1' , username='admin', password='admin', port=12022)
crud = CRUDService()

bgp_conditions = RoutingPolicy.PolicyDefinitions.PolicyDefinition.Statements.Statement.Conditions.BgpConditions()
bgp_conditions.med_eq = 100
bgp_conditions.origin_eq = BgpOriginAttrTypeEnum.IGP
bgp_conditions.next_hop_in.append('1.2.3.4')
bgp_conditions.afi_safi_in = Ipv4UnicastIdentity()
bgp_conditions.local_pref_eq = 100
bgp_conditions.route_type = RoutingPolicy.PolicyDefinitions.PolicyDefinition.Statements.Statement.Conditions.BgpConditions.RouteTypeEnum.INTERNAL
conditions = RoutingPolicy.PolicyDefinitions.PolicyDefinition.Statements.Statement.Conditions()
statement = RoutingPolicy.PolicyDefinitions.PolicyDefinition.Statements.Statement()
statement.name = 'Hello'
statements = RoutingPolicy.PolicyDefinitions.PolicyDefinition.Statements()
statements.statement.append(statement)
statements = RoutingPolicy.PolicyDefinitions.PolicyDefinition.Statements()
policy_definition = RoutingPolicy.PolicyDefinitions.PolicyDefinition()
policy_definition.name = 'Hello'
policy_definitions = RoutingPolicy.PolicyDefinitions()
policy_definitions.policy_definition.append(policy_definition)
policy_definitions = RoutingPolicy.PolicyDefinitions()
routing_policy = RoutingPolicy()
policy_definitions.parent = routing_policy
policy_definition.parent = policy_definitions
statements.parent = policy_definition
statement.parent = statements
conditions.parent = statement
bgp_conditions.parent = conditions
crud.create(ncc, bgp_conditions)

ncc.close()
Traceback (most recent call last):
...

    self.crud.create(self.ncc, bgp_conditions)
  File "/ydk-gen/gen-api/python/ydk/services/crud_service.py", line 60, in create
    MetaService.normalize_meta(provider._get_capabilities(), entity)
  File "/ydk-gen/gen-api/python/ydk/services/meta_service.py", line 52, in normalize_meta
    MetaService.inject_imeta(entity, deviation_tables)
  File "/ydk-gen/gen-api/python/ydk/services/meta_service.py", line 96, in inject_imeta
    inject_imeta_helper(entity, deviation_tables)
  File "/ydk-gen/gen-api/python/ydk/services/meta_service.py", line 223, in inject_imeta_helper
    for v in value:
TypeError: 'Ipv4UnicastIdentity' object is not iterable
@ghost ghost added the bug label Jul 20, 2016
@ghost ghost added this to the 0.5.0 milestone Jul 20, 2016
@psykokwak4 psykokwak4 self-assigned this Jul 20, 2016
@ghost
Copy link
Author

ghost commented Jul 20, 2016

Another issue is the encoding is not done correctly for leaf-list of identity-ref type. Below is current encoding.

Python code:

bgp_conditions = RoutingPolicy.PolicyDefinitions.PolicyDefinition.Statements.Statement.Conditions.BgpConditions()
bgp_conditions.afi_safi_in.append(Ipv4UnicastIdentity())

Encoding:

              <bgp-conditions xmlns="http://openconfig.net/yang/bgp-policy">

<ipv4-unicast xmlns="http://openconfig.net/yang/bgp-types"/>


                  </bgp-conditions>

This should be like the below:
<afi-safi-in xmlns:idx="http://openconfig.net/yang/bgp-types">idx:ipv4-unicast</afi-safi-in>

@psykokwak4
Copy link
Contributor

psykokwak4 commented Jul 21, 2016

psykokwak4 added a commit that referenced this issue Jul 21, 2016
@ghost ghost added the in progress label Jul 22, 2016
ghost pushed a commit that referenced this issue Jul 23, 2016
* Issue #184, #186

* Added/Reenabled sanity tests for Issue #184, #186, cleaned up decoder little bit.
@ghost ghost removed the in progress label Jul 25, 2016
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