cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
713
Views
1
Helpful
6
Replies
Highlighted
SA2 Beginner
Beginner

python policy map update trouble.

Hi i'm having some issues with the update_policy_map method. as well as with the policy_map.remove_all_entry()

I'm currently working on an application that needs to dynamically set and change the service-policy of an interface on the router,

according to data input from another source. I've been able to create the service policy with the class maps and the actions needed (priority classes, bw guarantees and marking actions).


However I've been unable to change the service policy after it's creation.

from qosPolicy.py:

def create_policy_map(self, name=None):

        self.policy_map[name] = bulkService.create_policy(self.QOS_EGRESS, self.network_element, name)

def change_policy_map(self, class_actions, name=None):

        self.policy_entries[name] = []

        for class_action in class_actions:

            logger.info("Creating action entry for: " + str(class_action[0]) + " with action: " + str(class_action[1]))

            self.policy_entries[name].append( self.policy_map[name].create_entry(self.class_map[ class_action[0] ]) )

            self.policy_entries[name][-1].add_action(self.action[ class_action[1] ])

           self.policy_map[name].remove_all_entry()

          #^ this is just to try out the remove_all_entry method

def submit_policy_map(self, name=None):

        bulkService.submit_policy_map(self.policy_map[name])

def update_policy_map(self, name=None):

        bulkService.update_policy_map(self.policy_map[name])

Creating the policy works:

pmap_name = 'TEST-QOS'

qosPolicy.create_policy_map(pmap_name)

qosPolicy.change_policy_map(policy_map, name=pmap_name)

qosPolicy.submit_policy_map(pmap_name)

This successfully creates the policy map on the network element with a number of classes and actions, not shown in the code above.

However since I'm doing self.policy_map[name].remove_all_entry(), shouldn't the the resulting policy map be empty?

Here is the output from onepk bulk service:

INFO:onep.policyservice.bulk:submit_policy_map: pmap_idl_list:[PmapIDL(pmap_name='TEST-QOS', entryList=[EntryIDL(matchList=[], sequence=0, actionList=[ActionIDL(actionHandle=0, pqAction=ActionPriorityQueueIDL(burst=160, level=1, bandwidth=128, bandwidthUnits=1, queueSize=64, queueSizeUnits=1), opCode=0, opId=0, markAction=None, shapeAction=None, outputAction=None, parameterMapName=None, wredProfile=None, mplsAction=None, outIfAction=None, policeAction=None, protocolAction=None, nhAction=None, mplsExpAction=None, queueLimitAction=None, pktCopyAction=None, wredParam=None, vlanAction=None, pktDivertAction=None, macAction=None, tcpPortAction=None, cqAction=None, fqAction=None, ttlAction=None, fwdClassIdAction=None, ipAddressAction=None, actionType=12, gotoTableAction=None, dsid=0)], entryOper=1, priority=0, opCode=2, entryHandle=0, opId=0, cmapHandle=2305843009213694428, dsid=0, order=0, policy_op_index=0), EntryIDL(matchList=[], sequence=0, actionList=[ActionIDL(actionHandle=0, pqAction=None, opCode=0, opId=0, markAction=None, shapeAction=None, outputAction=None, parameterMapName=None, wredProfile=None, mplsAction=None, outIfAction=None, policeAction=None, protocolAction=None, nhAction=None, mplsExpAction=None, queueLimitAction=None, pktCopyAction=None, wredParam=None, vlanAction=None, pktDivertAction=None, macAction=None, tcpPortAction=None, cqAction=ActionClassQueueIDL(bandwidth=207, queueSize=64, queueSizeUnits=1, bandwidthUnits=1), fqAction=None, ttlAction=None, fwdClassIdAction=None, ipAddressAction=None, actionType=13, gotoTableAction=None, dsid=0)], entryOper=1, priority=0, opCode=2, entryHandle=0, opId=0, cmapHandle=2305843009213694430, dsid=0, order=0, policy_op_index=0), EntryIDL(matchList=[], sequence=0, actionList=[ActionIDL(actionHandle=0, pqAction=None, opCode=0, opId=0, markAction=None, shapeAction=None, outputAction=None, parameterMapName=None, wredProfile=None, mplsAction=None, outIfAction=None, policeAction=None, protocolAction=None, nhAction=None, mplsExpAction=None, queueLimitAction=None, pktCopyAction=None, wredParam=None, vlanAction=None, pktDivertAction=None, macAction=None, tcpPortAction=None, cqAction=ActionClassQueueIDL(bandwidth=101, queueSize=64, queueSizeUnits=1, bandwidthUnits=1), fqAction=None, ttlAction=None, fwdClassIdAction=None, ipAddressAction=None, actionType=13, gotoTableAction=None, dsid=0)], entryOper=1, priority=0, opCode=2, entryHandle=0, opId=0, cmapHandle=2305843009213694431, dsid=0, order=0, policy_op_index=0), EntryIDL(matchList=[], sequence=0, actionList=[ActionIDL(actionHandle=0, pqAction=None, opCode=0, opId=0, markAction=ActionMarkIDL(type=0, value=0), shapeAction=None, outputAction=None, parameterMapName=None, wredProfile=None, mplsAction=None, outIfAction=None, policeAction=None, protocolAction=None, nhAction=None, mplsExpAction=None, queueLimitAction=None, pktCopyAction=None, wredParam=None, vlanAction=None, pktDivertAction=None, macAction=None, tcpPortAction=None, cqAction=None, fqAction=None, ttlAction=None, fwdClassIdAction=None, ipAddressAction=None, actionType=8, gotoTableAction=None, dsid=0), ActionIDL(actionHandle=0, pqAction=None, opCode=0, opId=0, markAction=ActionMarkIDL(type=0, value=0), shapeAction=None, outputAction=None, parameterMapName=None, wredProfile=None, mplsAction=None, outIfAction=None, policeAction=None, protocolAction=None, nhAction=None, mplsExpAction=None, queueLimitAction=None, pktCopyAction=None, wredParam=None, vlanAction=None, pktDivertAction=None, macAction=None, tcpPortAction=None, cqAction=None, fqAction=None, ttlAction=None, fwdClassIdAction=None, ipAddressAction=None, actionType=8, gotoTableAction=None, dsid=0)], entryOper=1, priority=0, opCode=2, entryHandle=0, opId=0, cmapHandle=2305843009213694432, dsid=0, order=0, policy_op_index=0)], filter=None, opCode=0, table_handle=None, pmapHandle=0, dsid=0, opId=0)]

DEBUG:onep.core.event.KeepaliveMonitor:done checking socket keepalive, socket is alive.

DEBUG:onep.core.event.KeepaliveMonitor:checking socket keepalive ...

DEBUG:onep.core.event.KeepaliveMonitor:seconds since last heartbeat: 5.00668120384, try #1

INFO:onep.policyservice.bulk:submit_policy_map: idl results:[PmapResultIDL(entryResult=[EntryResultIDL(cmapResult=None, matchResultList=[], opCode=0, entryHandle=2305843009213694428, actionResultList=[ResultIDL(handle=0, resultString='', opcode=0, result=0, opId=0, dsid=0)], resultCode=0, dsid=0, opId=0, policy_op_index=0), EntryResultIDL(cmapResult=None, matchResultList=[], opCode=0, entryHandle=2305843009213694430, actionResultList=[ResultIDL(handle=0, resultString='', opcode=0, result=0, opId=0, dsid=0)], resultCode=0, dsid=0, opId=0, policy_op_index=0), EntryResultIDL(cmapResult=None, matchResultList=[], opCode=0, entryHandle=2305843009213694431, actionResultList=[ResultIDL(handle=0, resultString='', opcode=0, result=0, opId=0, dsid=0)], resultCode=0, dsid=0, opId=0, policy_op_index=0), EntryResultIDL(cmapResult=None, matchResultList=[], opCode=0, entryHandle=2305843009213694432, actionResultList=[ResultIDL(handle=0, resultString='', opcode=0, result=0, opId=0, dsid=0), ResultIDL(handle=0, resultString='', opcode=0, result=0, opId=0, dsid=0)], resultCode=0, dsid=0, opId=0, policy_op_index=0)], statsResult=None, statsResultEventHandle=None, getResult=None, opCode=0, resultCode=0, pmapHandle=2305843009213694072, dsid=0, opId=0)]

INFO:onep.policyservice.bulk:submit_policy_map executed with success.

Trying to use the update to change the policy does not work:

pmap_name = 'TEST-QOS'

qosPolicy.create_policy_map(pmap_name)

qosPolicyOnePk.submit_policy_map(pmap_name)

qosPolicy.change_policy_map(policy_map, name=pmap_name)

qosPolicyOnePk.update_policy_map(pmap_name)

Here is the output from onepk bulk service:

INFO:QoSPolicyOnePk:Submitting policy map TEST-QOS...
INFO:onep.policyservice.bulk:submit_policy_map: pmap_idl_list:[PmapIDL(pmap_name='TEST-QOS', entryList=[], filter=None, opCode=0, table_handle=None, pmapHandle=0, dsid=0, opId=0)]
INFO:onep.policyservice.bulk:submit_policy_map: idl results:[PmapResultIDL(entryResult=[], statsResult=None, statsResultEventHandle=None, getResult=None, opCode=0, resultCode=0, pmapHandle=2305843009213694074, dsid=0, opId=0)]
INFO:onep.policyservice.bulk:submit_policy_map executed with success.
INFO:QoSPolicyOnePk:Updating policy map TEST-QOS...
INFO:onep.policyservice.bulk:update_policy_map: pmap_idl_list:[PmapIDL(pmap_name='TEST-QOS', entryList=[EntryIDL(matchList=[], sequence=0, actionList=[ActionIDL(actionHandle=0, pqAction=ActionPriorityQueueIDL(burst=160, level=1, bandwidth=128, bandwidthUnits=1, queueSize=64, queueSizeUnits=1), opCode=0, opId=0, markAction=None, shapeAction=None, outputAction=None, parameterMapName=None, wredProfile=None, mplsAction=None, outIfAction=None, policeAction=None, protocolAction=None, nhAction=None, mplsExpAction=None, queueLimitAction=None, pktCopyAction=None, wredParam=None, vlanAction=None, pktDivertAction=None, macAction=None, tcpPortAction=None, cqAction=None, fqAction=None, ttlAction=None, fwdClassIdAction=None, ipAddressAction=None, actionType=12, gotoTableAction=None, dsid=0)], entryOper=1, priority=0, opCode=2, entryHandle=0, opId=0, cmapHandle=2305843009213694445, dsid=0, order=0, policy_op_index=0), EntryIDL(matchList=[], sequence=0, actionList=[ActionIDL(actionHandle=0, pqAction=None, opCode=0, opId=0, markAction=None, shapeAction=None, outputAction=None, parameterMapName=None, wredProfile=None, mplsAction=None, outIfAction=None, policeAction=None, protocolAction=None, nhAction=None, mplsExpAction=None, queueLimitAction=None, pktCopyAction=None, wredParam=None, vlanAction=None, pktDivertAction=None, macAction=None, tcpPortAction=None, cqAction=ActionClassQueueIDL(bandwidth=140, queueSize=64, queueSizeUnits=1, bandwidthUnits=1), fqAction=None, ttlAction=None, fwdClassIdAction=None, ipAddressAction=None, actionType=13, gotoTableAction=None, dsid=0)], entryOper=1, priority=0, opCode=2, entryHandle=0, opId=0, cmapHandle=2305843009213694447, dsid=0, order=0, policy_op_index=0), EntryIDL(matchList=[], sequence=0, actionList=[ActionIDL(actionHandle=0, pqAction=None, opCode=0, opId=0, markAction=None, shapeAction=None, outputAction=None, parameterMapName=None, wredProfile=None, mplsAction=None, outIfAction=None, policeAction=None, protocolAction=None, nhAction=None, mplsExpAction=None, queueLimitAction=None, pktCopyAction=None, wredParam=None, vlanAction=None, pktDivertAction=None, macAction=None, tcpPortAction=None, cqAction=ActionClassQueueIDL(bandwidth=69, queueSize=64, queueSizeUnits=1, bandwidthUnits=1), fqAction=None, ttlAction=None, fwdClassIdAction=None, ipAddressAction=None, actionType=13, gotoTableAction=None, dsid=0)], entryOper=1, priority=0, opCode=2, entryHandle=0, opId=0, cmapHandle=2305843009213694448, dsid=0, order=0, policy_op_index=0), EntryIDL(matchList=[], sequence=0, actionList=[ActionIDL(actionHandle=0, pqAction=None, opCode=0, opId=0, markAction=ActionMarkIDL(type=0, value=0), shapeAction=None, outputAction=None, parameterMapName=None, wredProfile=None, mplsAction=None, outIfAction=None, policeAction=None, protocolAction=None, nhAction=None, mplsExpAction=None, queueLimitAction=None, pktCopyAction=None, wredParam=None, vlanAction=None, pktDivertAction=None, macAction=None, tcpPortAction=None, cqAction=None, fqAction=None, ttlAction=None, fwdClassIdAction=None, ipAddressAction=None, actionType=8, gotoTableAction=None, dsid=0), ActionIDL(actionHandle=0, pqAction=None, opCode=0, opId=0, markAction=ActionMarkIDL(type=0, value=0), shapeAction=None, outputAction=None, parameterMapName=None, wredProfile=None, mplsAction=None, outIfAction=None, policeAction=None, protocolAction=None, nhAction=None, mplsExpAction=None, queueLimitAction=None, pktCopyAction=None, wredParam=None, vlanAction=None, pktDivertAction=None, macAction=None, tcpPortAction=None, cqAction=None, fqAction=None, ttlAction=None, fwdClassIdAction=None, ipAddressAction=None, actionType=8, gotoTableAction=None, dsid=0)], entryOper=1, priority=0, opCode=2, entryHandle=0, opId=0, cmapHandle=2305843009213694449, dsid=0, order=0, policy_op_index=0)], filter=None, opCode=1, table_handle=None, pmapHandle=2305843009213694074, dsid=0, opId=0)]
DEBUG:onep.core.event.KeepaliveMonitor:done checking socket keepalive, socket is alive.
DEBUG:onep.core.event.KeepaliveMonitor:checking socket keepalive ...
DEBUG:onep.core.event.KeepaliveMonitor:seconds since last heartbeat: 5.00672507286, try #1
Traceback (most recent call last):
  File "batsSatelliteQos.py", line 343, in <module>
    qosPolicyOnePk.update_policy_map(pmap_name)
  File "/home/cisco/workspace-python/BATS OnePK Satellite QoS/QoSPolicyOnePk.py", line 73, in update_policy_map
    bulkService.update_policy_map(self.policy_map[name])
  File "onep/policyservice/bulk.py", line 644, in update_policy_map
onep.core.exception.OnepRemoteProcedureException.OnepRemoteProcedureException: invalid entry_handle in modify request, ONEP_ERR_BAD_ARGUMENT

I assume it's some basic detail I'm missing here.

Grateful for any helpful pointers!

-Anders

Everyone's tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: python policy map update trouble.

What you are attempting needs to be done using the Datapath service set.  That is currently not supported in the Java or Python SDK.  You will have to use the C SDK.  You can make a request to onep-dev to have that service set added to Python.

6 REPLIES 6
Hall of Fame Cisco Employee

Re: python policy map update trouble.

Hey, Anders.  For the first issues, make sure you call:

bulkService.update_policy_map(self.policy_map[name])


After you remove_all_entry.


For the second issue, it would help to see the code that shows the specific modifications to the pmap to see if there is a bad argument in there.



SA2 Beginner
Beginner

Re: python policy map update trouble.

Hi, and thank you for answering.

should the update_policy_map be needed even though the policy hasn't been submitted yet?

The policy gets submitted after the change_policy method is called.

and indeed trying to do an update_policy_map before it is submitted results in the following error:

onep.core.exception.OnepRemoteProcedureException.OnepRemoteProcedureException: invalid pmap handle, ONEP_ERR_BAD_ARGUMENT

Which to me suggests that it needs to be submitted before it can be changed.

I'll include the code that sets the actions below. Although it is the same code that does this for both the submit and update action, it works for submit, I would think it worked for update as well. From the documentation all I could find both the submit and update needed the same policy_map class passed to it.

Some logging and error checking left out for brevity...

from qosPolicy.py:

    def create_class_map(self, matchAll, dscpMatches, name=None):

        self.class_map[name] = bulkService.create_class(self.QOS_EGRESS, self.network_element, name)

        self.class_map[name].match_all = matchAll

        for dscpMatch in dscpMatches:

            self.class_map[name].add_match(match.DSCP(dscpMatch))

        bulkService.submit_class_map(self.class_map[name])

   def create_action(self, function, name=None, interval=10, rate=None, queue=64, DSCP=None, pri_level=1):

        if function == 'pri':

            self.action[name] = action.PriorityQueue(\

                                                     rate,\

                                                     action.BandwidthUnits.BW_UNITS_KBPS,\

                                                     pri_level,\

                                                     rate*interval/8,\

                                                     queue,\

                                                     action.QueueSizeUnits.QUEUE_UNITS_PKTS\

                                                     )

        elif function == 'mark':

            self.action[name] = action.Mark(action.ActionType.SET_DSCP, DSCP)

        elif function == 'bw':

            self.action[name] = action.ClassQueue(\

                                                  rate,\

                                                  action.BandwidthUnits.BW_UNITS_KBPS,\

                                                  queue,\

                                                  action.QueueSizeUnits.QUEUE_UNITS_PKTS\

                                                  )

From the main script:

class TrafficClass:

    def __init__(self, name, tc_type, match, pri_level=1, rate=0, interval=10, queue=64, mark=None):

        self.name=name
        self.type=tc_type
        self.match=match
        self.pri_level=pri_level
        self.rate=rate
        self.interval=interval
        self.queue=queue
        self.mark=mark

#Defining the traffic classes

    trafficClasses = []

    trafficClasses.append(TrafficClass('Voice', 'pri', [46], rate=128))

    trafficClasses.append(TrafficClass('Video', 'pri', [34], rate=512, pri_level=2))

    trafficClasses.append(TrafficClass('Business', 'bw', [26,28,30], rate=1024))

    trafficClasses.append(TrafficClass('Other', 'bw', [18,20,22], rate=512))

    trafficClasses.append(TrafficClass('Mark', 'mark', [8,10,12,14,16], mark=0))

#Create class maps

        for trafficClass in trafficClasses:

            if qosPolicy.create_class_map(True, trafficClass.match, str(trafficClass.name)):

                logger.info("Creation of class-map %s OK", trafficClass.name)

            else:

                logger.warning("Creation of class-map %s Failed!", trafficClass.name)

#Creating the actions

        for trafficClass in trafficClasses_local:

            rate = trafficClass.rate      

            if trafficClass.type != 'pri':

                rate = int(bwLeft/100 * trafficClass.percentage)

            if qosPolicy.create_action(\

                                        trafficClass.type,\

                                        name = str(trafficClass.name),\

                                        rate = rate,\

                                        pri_level = trafficClass.pri_level,\

                                        DSCP = trafficClass.mark,\

                                        queue = trafficClass.queue,\

                                        interval = trafficClass.interval\

                                        ):

                logger.info("Creation of action %s OK", trafficClass.name)

            else:

                logger.warning("Creation of action %s Failed!", trafficClass.name)




---------


It seems to me that the entry handle is automatically generated during submit but not during the update action.

Manually setting the entry handle before doing an update changes the error message from

invalid entry_handle to:


onep.core.exception.OnepRemoteProcedureException.OnepRemoteProcedureException: Pmap_olist result failure, ONEP_FAIL


However this does not seem like it should be the way to do it.



If it is of any help at all here is the debug output from the router when the update fails (with the entry_handle set manually):

*Apr 29 01:51:53.415: [116] [ONEP][Message]: Server Done tos 1 [cthrift_recv_main__:2644]

*Apr 29 01:51:53.415: [116] [ONEP][Message]: Received 845(bytes) equal to or grater than parsed 845(bytes) [cthrift_recv_main__:2654]

*Apr 29 01:51:53.416: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Received Policy_submitPmapBulk=3077 [Policy_submitPmapBulkIDL_AL:10450]

*Apr 29 01:51:53.416: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] validate_input_parameter_pmap_list: 0 [validate_input_parameter_pmap_olist:2688]

*Apr 29 01:51:53.416: [116] [ONEP][Session]: BATS-Satellite-QoS-10.10.10.120-3077: [0x14271510][C05] found [network_element_find_app_by_handle:562]

*Apr 29 01:51:53.416: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Not an ACL op list [Policy_submitPmapBulkIDL_AL:10510]

*Apr 29 01:51:53.417: [116] [ONEP][Session]: BATS-Satellite-QoS-10.10.10.120-3077: [0x14271510][C05] found [network_element_find_app_by_handle:562]

*Apr 29 01:51:53.417: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] num_pmap = 1, async = 0 table_type = 4 [policy_bulk_create_pmap_olist:8854]

*Apr 29 01:51:53.417: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] opId=0, persistent=0, table_type=0 [onep_al_policy_set_op_ctx:333]

*Apr 29 01:51:53.417: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] num_entry = 4, pmap op_id = 0 [policy_bulk_modify_policy_pmap:6871]

*Apr 29 01:51:53.417: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Rx num_action = 1 [policy_bulk_action_append:5979]

*Apr 29 01:51:53.417: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Append action=12 [policy_bulk_action_append:5983]

*Apr 29 01:51:53.417: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Rx num_action = 1 [policy_bulk_action_append:5979]

*Apr 29 01:51:53.417: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Append action=13 [policy_bulk_action_append:5983]

*Apr 29 01:51:53.419: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Rx num_action = 1 [policy_bulk_action_append:5979]

*Apr 29 01:51:53.419: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Append action=13 [policy_bulk_action_append:5983]

*Apr 29 01:51:53.419: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Rx num_action = 2 [policy_bulk_action_append:5979]

*Apr 29 01:51:53.419: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Append action=8 [policy_bulk_action_append:5983]

*Apr 29 01:51:53.420: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Append action=8 [policy_bulk_action_append:5983]

*Apr 29 01:51:53.420: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Get client handle: 35 [policy_bulk_get_client_handle:140]

*Apr 29 01:51:53.421: [debug][tid: 215][ONEP][Policy]: [FLOW] Pmap h=20000000000000B6 [shim_pmap_policy_common:2249]

*Apr 29 01:51:53.421: [debug][tid: 215][ONEP][Policy]: [FLOW] Pmap h=20000000000000B6 [shim_pmap_policy_common:2251]

*Apr 29 01:51:53.421: [debug][tid: 215][ONEP][Policy]: [FLOW] Modify pmap op bind-ctx=14237570 [shim_pmap_policy_common:2267]

*Apr 29 01:51:53.421: [debug][tid: 215][ONEP][Policy]: [FLOW] Activate Target loop [shim_pmap_policy_common:2270]

*Apr 29 01:51:53.421: [debug][tid: 215][ONEP][Policy]: [FLOW] Deactivate Target loop [shim_pmap_policy_common:2286]

*Apr 29 01:51:53.421: [debug][tid: 215][ONEP][Policy]: [FLOW] CMAP loop [shim_pmap_policy_common:2300]

*Apr 29 01:51:53.421: [debug][tid: 215][ONEP][Policy]: [FLOW] Cmap h=0 [shim_pmap_policy_common:2317]

*Apr 29 01:51:53.422: [error][tid: 215][ONEP][Policy]: [FLOW] Invalid class op_type: 1 [shim_pmap_policy_common:2321]

*Apr 29 01:51:53.423: [error][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Pmap_olist result failure [policy_bulk_olist_pmap_set_result:7205]

*Apr 29 01:51:53.423: [error][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Failed to create pmap [Policy_submitPmapBulkIDL_AL:10526]

*Apr 29 01:51:53.423: [116] [ONEP][Message]: Write cthrift buffer to socket 0: bytes 87 [cthrift_write_entire_buffer__:318]

*Apr 29 01:51:53.426: [116] [ONEP][Message]: cthrift wrote 87 bytes, 0 remaining to send, took 0 usec [cthrift_write_entire_buffer__:386]

*Apr 29 01:51:53.427: [debug][tid: 116] [session id: 3077] [ONEP][Policy]: [FLOW] Enter [Policy_submitPmapBulkIDL_cleanup:10648]

*Apr 29 01:51:53.428: [116] [ONEP][Session]: BATS-Satellite-QoS-10.10.10.120-3077: API served - done [network_app_process_cthrift_msg:1450]


Hall of Fame Cisco Employee

Re: python policy map update trouble.

The code flow should be:

CREATE_PMAP

submit_policy_map

remove_all_entry

update_policy_map


Our test module was written in this manner,and presumably this test worked.  However, it looks like from a high-level code flow perspective, you may be doing the same thing.  This is a snippet from that test module:


def remove_class_map_from_policy_map(self):

  service = BulkService(self.ele) 

  

  cmap1 = self.create_class_map1()

  cmap2 = self.create_class_map2()

  service.submit_class_map(cmap1, cmap2)

  

  pmap1 = self.create_policy_map1(cmap1, cmap2)

  service.submit_policy_map(pmap1)

  

  sleep(SLEEP_TIME)

  

  service.submit_policy_map(pmap1)

  

  entry1= pmap1.get_entry_list()[0]

  pmap1.remove_entry(entry1)

  service.update_policy_map(pmap1)

  

  sleep(SLEEP_TIME)

  

  pmap2 = self.create_policy_map1(cmap1, cmap2)

  service.submit_policy_map(pmap2)

  pmap2.remove_all_entry()

  service.update_policy_map(pmap2)

  

  service.delete_policy_map(pmap1, pmap2)

  service.delete_class_map(cmap1, cmap2)

This may be a platform issue.  The tutorial skips the removal_all_entry step, and goes right to deleting the policy map then the class map(s).  Does that work for you?


As for the second issue, you can only create or delete classes.  The error you see in the debug indicates an invalid operation for the class.  Given that you kind of hacked things for this attempt, that makes sense.

Cisco Employee

Re: python policy map update trouble.

This platform is rejecting the update operation for a class map.

Most operations you perform on a class map or policy map must be *reported to the platform.

create class

*submit class

create policy

create entry with class

add action to entry

*submit policy

remove all entries

*update policy

change class

*update class

create entry with class

*update policy

If you are trying to remove all entries before the policy was submitted you will have problems. The remove_all_... methods in the class or policy map classes are intended for reporting to the platform.  The items are not actually removed from those lists until the platform is notified.  That said, this is Python so you can pretty much access everything in the policy map class before it is submitted.  If you want remove items from a list you can use standard Python commands but be careful.

SA2 Beginner
Beginner

Re: python policy map update trouble.

That makes sense, and yes I didn't expect that hack to work.

To simplify the problem i've written a small test:

#!/usr/bin/env python

import logging

logger = logging.getLogger('testPolicy')

logging.basicConfig(level=logging.DEBUG)

import sys

from BaseTutorial import BaseTutorial

from onep.policyservice import bulk

from onep.policyservice import match

from onep.policyservice import caps

from onep.policyservice.target import Target

from onep.policyservice import action

from onep.core.util import OnepConstants

if __name__ == '__main__':

  

    #Use the Basetutorial for transport...

    tutorial = BaseTutorial(sys.argv)

    tutorial.parse_command_line()

    tutorial.connect("testPolicy")

    bulkService = bulk.BulkService(tutorial.network_element)  

  

    #Create class maps

    class_map1 = bulkService.create_class(4, tutorial.network_element, 'PriorityQueue')

    class_map1.add_match(match.DSCP(46))

    class_map2 = bulkService.create_class(4, tutorial.network_element, 'ClassQueue')

    class_map2.add_match(match.DSCP(24))

    class_map3 = bulkService.create_class(4, tutorial.network_element, 'Mark')

    class_map3.add_match(match.DSCP(16))

  

    bulkService.submit_class_map(class_map1, class_map2, class_map3)

    #Set the actions

    action1 = action.PriorityQueue(128, action.BandwidthUnits.BW_UNITS_KBPS, 1, 160, 64, action.QueueSizeUnits.QUEUE_UNITS_PKTS)

    action2 = action.ClassQueue(512, action.BandwidthUnits.BW_UNITS_KBPS, 64, action.QueueSizeUnits.QUEUE_UNITS_PKTS)

    action3 = action.Mark(action.ActionType.SET_DSCP, 8)

    #Create policy map

    pmap_name = 'TEST-POLICY'

    policy_map = bulkService.create_policy(4, tutorial.network_element, pmap_name)

  

    #Add the entries

    entry1 = policy_map.create_entry(class_map1)

    entry1.add_action(action1)

    entry2 = policy_map.create_entry(class_map2)

    entry2.add_action(action2)

  

    #Submit the policy

    bulkService.submit_policy_map(policy_map)

  

    pause=raw_input()

  

    #Remove all entries from the policy

    policy_map.remove_all_entry()

    bulkService.update_policy_map(policy_map)

  

    pause=raw_input()

  

    entry3 = policy_map.create_entry(class_map3)

    entry3.add_action(action3)

    try:
        bulkService.update_policy_map(policy_map)
    except Exception, e:
        logger.error(e)
        tutorial.disconnect()
        sys.exit(1)
           

    pause=raw_input()

  

    tutorial.disconnect()

The first step (before the pause) completes successfully and leaves the router with a policy map with the 2 classes and actions.:

Router2>sh policy-map

  Policy Map __ONEP_5233_0

    Class __ONEP_5233_0

      priority level 1 128 (kbps) 160

      queue-limit 64 packets

    Class __ONEP_5233_1

      bandwidth 512 (kbps)

      queue-limit 64 packets

The second step removes the entries and updates the policy, leaving the router with an empty policy:

Router2>sh policy-map

  Policy Map __ONEP_5233_0

The third step however crashes with this error:

Traceback (most recent call last):

  File "testPolicy.py", line 78, in <module>

    bulkService.update_policy_map(policy_map)

  File "onep/policyservice/bulk.py", line 644, in update_policy_map

onep.core.exception.OnepRemoteProcedureException.OnepRemoteProcedureException: invalid entry_handle in modify request, ONEP_ERR_BAD_ARGUMENT

-----

This is off course the same issue as described earlier, just simplified a bit.

What I'm trying to do is update the policy map while it is applied to the interface.

As the test above shows I'm able to remove entries but not add them.

Submitting another policy map with the changes needed works, but then I have to first disable the old policy from the interface before I apply the new one. I worry that this would empty the packets buffered in the different classes before the new policy takes effect.

The goal is for the QoS policy to adapt to rapidly changing bandwidths upstream.

Cisco Employee

Re: python policy map update trouble.

What you are attempting needs to be done using the Datapath service set.  That is currently not supported in the Java or Python SDK.  You will have to use the C SDK.  You can make a request to onep-dev to have that service set added to Python.

Content for Community-Ad
August's Community Spotlight Awards
This widget could not be displayed.