Trying to create a route-policy that includes a prefix-set match . Getting 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
......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">
.....
</edit-config>
</rpc>
- The Netconf server is a Cisco IOS XRv Series Cisco IOS XR Software, Version 6.1.2[Default].
- Also, if the the prefix-set statement is excluded It works just fine.
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.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')
In LAB also getting same error. First thought 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.
Noticed that when 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 don't have error.
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.
Comments
0 comments
Please sign in to leave a comment.