cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
849
Views
0
Helpful
4
Replies

CRUD error: routing-policy prefix set match

FelipeRivera
Level 1
Level 1

Hi experts!

While trying to create a route-policy that includes a prefix-set match I get the following error:

CREATE operation completed

Traceback (most recent call last):

  File "main.py", line 239, in <module>

    rp_cfg = crud_service.create(ne, rp)

  File "/usr/local/lib/python2.7/dist-packages/ydk/services/crud_service.py", line 62, in create

    self._execute_crud_operation_on_provider(provider, entity, 'CREATE', False)

  File "/usr/local/lib/python2.7/dist-packages/ydk/services/crud_service.py", line 168, in _execute_crud_operation_on_provider

    operation

  File "/usr/local/lib/python2.7/dist-packages/ydk/services/service.py", line 36, in execute_payload

    reply = provider.execute(payload, operation)

  File "/usr/local/lib/python2.7/dist-packages/ydk/providers/netconf_provider.py", line 94, in execute

    return self.sp_instance.execute_operation(payload, operation)

  File "/usr/local/lib/python2.7/dist-packages/ydk/providers/_provider_plugin.py", line 224, in execute_operation

    return self._handle_rpc_reply(operation, payload, reply.xml)

  File "/usr/local/lib/python2.7/dist-packages/ydk/providers/_provider_plugin.py", line 246, in _handle_rpc_reply

    self._handle_rpc_error(payload, reply_str, pathlist)

  File "/usr/local/lib/python2.7/dist-packages/ydk/providers/_provider_plugin.py", line 259, in _handle_rpc_error

    raise YPYServiceProviderError(error_code=YPYErrorCode.SERVER_REJ, error_msg=reply_str)

ydk.errors.YPYServiceProviderError: Server rejected request.

        error-type: application

        error-tag: operation-failed

        error-severity: error

        error-message: The requested operation failed.

This is the XML:

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:f88733e8-346f-49eb-a8c2-57926f607cf6">

  <edit-config>

    <target>

      <candidate/>

    </target>

    <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">

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

        <policy-definitions>

          <policy-definition>

            <name>Politicas</name>

            <statements>

              <statement>

                <name>Black Hole</name>

                <actions>

                  <accept-route></accept-route>

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

                    <set-next-hop>192.0.2.1</set-next-hop>

                  </bgp-actions>

                </actions>

                <conditions>

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

                    <match-community-set>

                      <community-set>blackHoleCli</community-set>

                      <match-set-options>ANY</match-set-options>

                    </match-community-set>

                  </bgp-conditions>

                </conditions>

              </statement>

              <statement>

                <name>Prefix Set</name>

                <conditions>

                  <match-prefix-set>

                    <match-set-options>ANY</match-set-options>

                    <prefix-set>int_BH</prefix-set>

                  </match-prefix-set>

                </conditions>

              </statement>

              <statement>

                <name>reject route</name>

                <actions>

                  <reject-route></reject-route>

                </actions>

              </statement>

            </statements>

          </policy-definition>

        </policy-definitions>

      </routing-policy>

    </config>

  </edit-config>

</rpc>

The Netconf server is a Cisco IOS XRv Series Cisco IOS XR Software, Version 6.1.2[Default].

Also, if I exlude the the prefix-set statement It works just fine.

Any ideas?

4 Replies 4

Anton Abik
Level 4
Level 4

Hi,

can you please paste your code?

Thanks

Ofcourse, here you have the relevant section of the code:

from ydk.providers import NetconfServiceProvider

import logging

from ydk.services import CRUDService

from ydk.models.openconfig.openconfig_routing_policy import RoutingPolicy

from ydk.models.openconfig import openconfig_bgp

from ydk.models.openconfig import openconfig_interfaces

from ydk.models.openconfig import openconfig_policy_types

from ydk.types import Empty

host = "10.10.10.1"

port = "22"

username = "user"

password = "pass"

proto = "ssh"

print('Establishing connection with device %s:%s using %s :'%(host, port, proto))

ne = NetconfServiceProvider(address=host,

                            port=port,

                            username=username,

                            password=password,

                            protocol=proto)

crud_service = CRUDService()

rp = RoutingPolicy()

p_d = rp.PolicyDefinitions.PolicyDefinition()

p_d.name = "Politicas"

st = p_d.Statements.Statement()

st.name = "Black Hole"

bgp_conditions = st.conditions.bgp_conditions

match_community_set = bgp_conditions.MatchCommunitySet()

match_community_set.community_set = "blackHoleCli"

match_set_options = openconfig_policy_types.MatchSetOptionsTypeEnum.ANY

match_community_set.match_set_options = match_set_options

bgp_conditions.match_community_set = match_community_set

st.actions.bgp_actions.set_next_hop = "192.0.2.1"

st.actions.accept_route = Empty()

p_d.statements.statement.append(st)

st2 = p_d.Statements.Statement()

st2.name = "Prefix Set"

match_prefix_set = st2.conditions.MatchPrefixSet()

match_prefix_set.prefix_set = "int_BH"

match_set_options = openconfig_policy_types.MatchSetOptionsRestrictedTypeEnum.ANY

match_prefix_set.match_set_options = match_set_options

st2.conditions.match_prefix_set = match_prefix_set

p_d.statements.statement.append(st2)

st1 = p_d.Statements.Statement()

st1.name = "reject route"

st1.actions.reject_route = Empty()

p_d.statements.statement.append(st1)

rp.policy_definitions.policy_definition.append(p_d)

rp_cfg = crud_service.create(ne, rp)

ne.close()

exit()

Also, in the router's syslog you can see this message:

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: adding http://openconfig.net/yang/bgp-policy to namespace hashmap

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Tag <set-next-hop> data len: 9

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <set-next-hop> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <bgp-actions> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <actions> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Updating prefix of http://openconfig.net/yang/bgp-policy namespace in the hashmap

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Tag <community-set> data len: 12

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <community-set> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Tag <match-set-options> data len: 3

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <match-set-options> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <match-community-set> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <bgp-conditions> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <conditions> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <statement> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Tag <name> data len: 10

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <name> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Tag <match-set-options> data len: 3

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <match-set-options> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Tag <prefix-set> data len: 14

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <prefix-set> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <match-prefix-set> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <conditions> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <statement> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Tag <name> data len: 12

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <name> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <reject-route> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <actions> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.606 : netconf[1111]: TRC: NC: Element <statement> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.616 : netconf[1111]: TRC: NC: Element <statements> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.616 : netconf[1111]: TRC: NC: Element <policy-definition> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.616 : netconf[1111]: TRC: NC: Element <policy-definitions> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.616 : netconf[1111]: TRC: NC: Element <routing-policy> is not outer-most element under <filter>, state is unchanged.

RP/0/0/CPU0:Mar  1 19:36:48.616 : netconf[1111]: TRC: NC: Parsed the incoming message

RP/0/0/CPU0:Mar  1 19:36:48.616 : netconf[1111]: TRC: NC: No NC SM YFW request in progress right now, calling nc_sm_request_process to process this request.

RP/0/0/CPU0:Mar  1 19:36:48.616 : netconf[1111]: ERR: YFW: ctx=1200a8bc,Failed to map open config model ('YANG framework' detected the 'fatal' condition 'Invalid argument')

This is interesting. I tried it in my LAB and getting same error. First I though you missed action.accept_rotue on prefix-set definition or you didnt create the prefix-set itself under RoutingPolicy.DefinedSets or you dont have the prefix set at all but that is not the issue.

I noticed that when I request get-configuration from the device via ncclient, the xml output doesnt contain the action specification RoutingPolicy.PolicyDefinitions.PolicyDefinition.Statements.Statement.Actions at all, even though we have it configured on the box and CLI displays it. Also the script is pushing it to device (that can verified from your xml output above)

It shows though the bgp_actions ->next_hop action and that works OK because as you verified, when we remove the prefix-set match we dont have error.

I dont have any other ideas, hopefully someone else can help.

EDIT: Added attachments

I'm not sure why you are seeing this error. The router is rejecting this request for some reason and unfortunately, the error message is not too helpful. There are some samples using openconfig-routing-policy here in the ydk-py-sample repository. Hope some of these may be of use to you.