onePK and CSR1000v

Document created by cdnadmin on Jan 25, 2014
Version 1Show Document
  • View in full screen mode
This document was generated from CDN thread

Created by: Tiago Primini on 03-10-2013 07:36:20 AM
We are trying to use onePK with csr1000v and we have some problems over it. 

Basically our csr1000v is configured with onePK running over tcp transport, because we are not able to set tls on it. An user with privilege level 15 was created in router and it is being used by client application to log in csr1000v. 

We are following all tips described in java sdk tutorials in order to work with QosPolicy but none of them are working perfectly.

The code from the first one example (QosPolicy): 

[font='courier new', courier, monospace]    QosPolicy qosPolicy = new QosPolicy(element31.getNetworkElement());
    ClassMap classMap = new ClassMap(element31.getNetworkElement(), ClassMap.ClassOper.CLASS_OPER_AND);
    qosPolicy.addClass(classMap, 10);
    ActionShape actionShape = new ActionShape(20000, 20000, ActionShape.ShapeType.ONEP_SHAPE_AVG,  ActionShape.RateUnits.ONEP_RATE_UNITS_BPS, ActionShape.BurstUnits.ONEP_BURST_UNITS_BITS);
    qosPolicy.addAction(classMap, actionShape);
    Target target = new Target(element31.getNetworkElement().getInterfaceByName("GigabitEthernet2"),    Target.Location.ONEP_TARGET_LOCATION_HARDWARE_DEFINED_OUTPUT);       
    qosPolicy.applyToTarget(target);
[font='courier new', courier, monospace] 

But in the router the action is not being applied.
  There is some compatibility problem with onePK and csr1000v or we are forgetting some initial configuration?

Tks, T. Primini


Subject: RE: onePK and CSR1000v
Replied by: Joseph Clarke on 03-10-2013 10:18:47 AM
Likely compatibility.  The CSR is not officially supported with onePK yet.  We are currently in a controlled availability phase with the ASR1K/CSR and the onePK (assuming you have XE 3.10).  Those images will support the 1.0.0 onePK API (as seen in show onep status).  If you are in that CA cycle, it should work assuming you're using the 1.0.0 SDK.

Subject: RE: onePK and CSR1000v
Replied by: Joseph Clarke on 03-10-2013 01:06:39 PM
How are you adding this data?  It's very hard to read...I can tell you have 1.0.0, though.  Can you post your code as an attachment?

Testing code paste:
1    if (!strcmp(cdstAddr, "ANY")) {
2        TRY(rc, onep_acl_set_l3_ace_dst_prefix(ace, NULL, 0), env, jobj, errFid,
3            "onep_acl_set_l3_ace_dst_prefix");


Subject: RE: onePK and CSR1000v
Replied by: Tiago Primini on 03-10-2013 01:03:17 PM
[font='courier new', courier, monospace]
csr1000v_031#show onep status
Status: enabled
Version: 1.0.0
Transport: tcp;
Status: running; Port: 15001
Transport: tls; Status: running; Port: 15002; localcert: default; remotecert: default; 
Transport: tipc; Status: running; Port: 15003
Service Set: Base         State: Enabled     Version 1.0.0
Service Set: Lisp         State: Disabled    Version 0.1.0
Service Set: Vty          State: Disabled    Version 0.1.0
Service Set: OneFW        State: Disabled    Version 0.1.0
Service Set: Pathtrace    State: Disabled    Version 0.1.0


And element configuration retrived using sdk 1.0.0:

[2013-10-03 14:57:13,985] [INFO ]  [QoS_TP] Successful connection to NetworkElement - NetworkElement [ 10.10.20.32 ]
Product ID   : CSR1000V
Processor    : VXE
Serial No    : 9C595J0NY6Q
Version ID   : V00
sysName      : csr1000v_032
sysUpTime    : Wed Dec 31 21:10:06 BRT 1969
sysDescr     : Cisco IOS Software, CSR1000V Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 15.3(3)S, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2013 by Cisco Systems, Inc.
Compiled Thu 25-Jul-13 18:03 by mcpre


Subject: RE: onePK and CSR1000v
Replied by: Tiago Primini on 03-10-2013 01:24:48 PM
Sorry Joseph...

csr1000v_031#show onep status
Status: enabled
Version: 1.0.0
Transport: tcp; Status: running; Port: 15001
Transport: tls; Status: running; Port: 15002; localcert: default; remotecert: default;
Transport: tipc; Status: running; Port: 15003

Service Set: Base         State: Enabled     Version 1.0.0
Service Set: Lisp         State: Disabled    Version 0.1.0
Service Set: Vty          State: Disabled    Version 0.1.0
Service Set: OneFW        State: Disabled    Version 0.1.0
Service Set: Pathtrace    State: Disabled    Version 0.1.0



And element configuration retrived using sdk 1.0.0

[2013-10-03 14:57:13,985] [INFO ]  [QoS_TP] Successful connection to NetworkElement -
NetworkElement [ 10.10.20.32 ]
Product ID   : CSR1000V
Processor    : VXE
Serial No    : 9C595J0NY6Q
Version ID   : V00
sysName      : csr1000v_032
sysUpTime    : Wed Dec 31 21:10:06 BRT 1969
sysDescr     : Cisco IOS Software, CSR1000V Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 15.3(3)S, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2013 by Cisco Systems, Inc.
Compiled Thu 25-Jul-13 18:03 by mcpre

Subject: RE: onePK and CSR1000v
Replied by: Joseph Clarke on 03-10-2013 01:28:27 PM
Thanks.  Can you also repost your code as an attachment?  What errors are you seeing when you try and apply the policy?

Subject: RE: onePK and CSR1000v
Replied by: Tiago Primini on 03-10-2013 04:45:27 PM
public class ElementCisco {
protected String ip;
protected String username;
protected String password;
public enum TransportType {
  TRANSPORT_TYPE_TCP,
  TRANSPORT_TYPE_TLS
}
protected TransportType transportType;
private NetworkElement networkElement = null;
private SessionConfig config = null;
private SessionHandle sessionHandle = null;
private static final LogSimpleClient logger = LogSimpleClient.getLogger(ElementCisco.class, Definitions.QoS_TP);

public String getIp() {
  return this.ip;
}

public void setIp(String ip) {
  this.ip = ip;
}

public void setUsername(String username) {
  this.username = username;
}

public void setPassword(String password) {
  this.password = password;
}

public void setTransportType(TransportType transportType) {
  this.transportType = transportType;
}

public NetworkElement getNetworkElement() {
  return this.networkElement;
}

public boolean connect(String applicationName) {
  NetworkApplication networkApplication = NetworkApplication.getInstance();

  try {
   InetAddress ipAddress = InetAddress.getByName(ip);
   networkElement = networkApplication.getNetworkElement(ipAddress);
  } catch (UnknownHostException e) {
   logger.error(e.getLocalizedMessage());
   return false;
  } catch (OnepException e) {
   logger.error(e.getLocalizedMessage());
   return false;
  }
 
  if (networkElement == null) {
   logger.error("Failed to get network element");
   return false;
  }
 
  logger.info("We have a NetworkElement - " + networkElement);

  if (transportType == TransportType.TRANSPORT_TYPE_TCP) {
   config = new SessionConfig(SessionTransportMode.SOCKET);
   config.setPort(OnepConstants.ONEP_PORT);
  } else if (transportType == TransportType.TRANSPORT_TYPE_TLS) {
   config = new SessionConfig(SessionTransportMode.TLS);
   config.setPort(OnepConstants.ONEP_TLS_PORT);
  } else {
   logger.error("Invalid transport type: " + transportType);
   return false;
  }

  try {
   sessionHandle = networkElement.connect(username, password, config);
  } catch (OnepConnectionException e) {
   logger.error(e.getMessage());
   return false;
  } catch (OnepException e) {
   logger.error(e.getLocalizedMessage());
   return false;
  }
 
  if (sessionHandle == null) {
   logger.error("Failed to connect to NetworkElement - " + networkElement);
   return false;
  }
 
  logger.info("Successful connection to NetworkElement - " + networkElement);
 
  return true;
}

public boolean disconnect() {
        try {
            networkElement.disconnect();
        } catch (Exception e) {
            logger.error("Failed to disconnect from Network Element");
            return false;
        }
       
        return true;
}

}





public class QoS_TP
{
    public static void main(String[] args) throws ExceptionIDL, TException {
     ElementCisco element31 = new ElementCisco();

        element31.setIp("10.10.20.31");
     element31.setUsername("cisco");
     element31.setPassword("cisco");
     element31.setTransportType(TransportType.TRANSPORT_TYPE_TCP);

        element31.connect("test");

        QosPolicy qosPolicy = new QosPolicy(element31.getNetworkElement());
        ClassMap classMap = new ClassMap(element31.getNetworkElement(), ClassMap.ClassOper.CLASS_OPER_AND);
        
        qosPolicy.addClass(classMap, 10);
        ActionShape actionShape = new ActionShape(20000, 20000,
           1000, ActionShape.ShapeType.ONEP_SHAPE_AVG,
           ActionShape.RateUnits.ONEP_RATE_UNITS_BPS,
           ActionShape.BurstUnits.ONEP_BURST_UNITS_BITS);
 
      qosPolicy.addAction(classMap, actionShape);

        Target target = new Target(element31.getNetworkElement().getInterfaceByName("GigabitEthernet2"),
                    Target.Location.ONEP_TARGET_LOCATION_HARDWARE_DEFINED_OUTPUT);      

        qosPolicy.applyToTarget(target);




csr1000v_031>show policy-map
  Policy Map __ONEP_7283_0
      sequence-interval 1
     10 Class __ONEP_7283_0
      Average Rate Traffic Shaping
      cir 20000 (bps) bc 20000 (bits) be 1000 (bits)

  Policy Map SHAPE_2048
    Class TP
      Average Rate Traffic Shaping
      cir 2048000 (bps)

  Policy Map MARK
    Class TP
      set ip dscp ef

  Policy Map SHAPE_128
    Class TP
      Average Rate Traffic Shaping
      cir 131072 (bps)


But this configuration is not being applied in network interface.

show running-config

interface GigabitEthernet1
ip address 192.168.1.1 255.255.255.0
ip policy route-map TESTE
negotiation auto
!
interface GigabitEthernet2
ip address 192.168.10.1 255.255.255.0
negotiation auto
!
interface GigabitEthernet3
ip address 192.168.20.1 255.255.255.0
negotiation auto
service-policy output SHAPE_128
!
interface GigabitEthernet0
vrf forwarding Mgmt-intf
ip address 10.10.20.31 255.255.255.0
negotiation auto

Subject: RE: onePK and CSR1000v
Replied by: Tiago Primini on 03-10-2013 05:07:11 PM
Here is the show onep trace with debug level activated when my program is running:

10/03/13 21:58:45.392 AA45] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:45.392 AA46] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:45.392 AA47] [333] : Received addActionShapeToClass pH=53 cH=94 [addActionShapeToClass_IDL:3162]
[10/03/13 21:58:45.392 AA48] [333] : Shape Action handle=51 [addActionShapeToClass_IDL:3212]
[10/03/13 21:58:45.392 AA49] [333] : Shape action typ=1 ru=1 bu=1 cir=20000 cbs=20000 ebs=1000 [addActionShapeToClass_IDL:3221]
[10/03/13 21:58:45.392 AA4A] [333] : ru=1 bu=1 type=1 cir=20000 cbs=20000 ebs=1000 [onep_al_policy_shape_action:1767]
[10/03/13 21:58:45.392 AA4B] [333] : PAM class=190589173760 [onep_al_policy_shape_action:1779]
[10/03/13 21:58:45.392 AA4C] [333] : Policy name=__ONEP_710_0 Class name=__ONEP_710_0 [onep_al_policy_shape_action:1782]
[10/03/13 21:58:45.392 AA4D] [333] : Write cthrift buffer to socket 0: bytes 45 [cthrift_write_entire_buffer__:296]
[10/03/13 21:58:45.926 AA4E] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:45.928 AA4F] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:45.929 AA50] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:45.929 AA51] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:45.931 AA52] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:45.931 AA53] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:45.932 AA54] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:45.933 AA55] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:45.933 AA56] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:45.933 AA57] [333] : Write cthrift buffer to socket 0: bytes 94 [cthrift_write_entire_buffer__:296]
[10/03/13 21:58:46.481 AA58] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:46.481 AA59] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:46.481 AA5A] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:46.482 AA5B] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:46.482 AA5C] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:46.482 AA5D] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:46.483 AA5E] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:46.483 AA5F] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:46.483 AA60] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 21:58:46.483 AA61] [333] : Received applyPolicyToTarget pH=53 iH=7 loc=1 [applyPolicyToTarget_IDL:4752]
[10/03/13 21:58:46.483 AA62] [333] : hwidb=10A2EF68 [onep_al_policy_apply_policy_to_target:252]
[10/03/13 21:58:46.488 AA63] [333] : Write cthrift buffer to socket 0: bytes 43 [cthrift_write_entire_buffer__:296]





And here is what happens when my program is finished:

[10/03/13 22:02:02.331 AA84] [333] : teste-rcp3902-710: Session event [0x1] occured [network_app_session_handler:1401]
[10/03/13 22:02:02.331 AA85] [333] : cthrift read returning due to error. errno = 254 [cthrift_recv_check_rb__:512]
[10/03/13 22:02:02.331 AA86] [333] : teste-rcp3902-710: cthrift error: 4294901757 'system error' [na_do_cthrift_read:1105]
[10/03/13 22:02:02.331 AA87] [333] : teste-rcp3902-710: NA_STATE_READ error (1) - generating NA_STATE_CLEANUP [network_app_process_cthrift_msg:1281]
[10/03/13 22:02:02.331 AA88] [333] : teste-rcp3902-710: NA_STATE_CLEANUP - generating NETWORK_APP_STATE_DISCONNECTED [network_app_process_cthrift_msg:1333]
[10/03/13 22:02:02.331 AA89] [333] : teste-rcp3902-710: FSM:  ==>  [network_app_fsm_disconnected:3051]
[10/03/13 22:02:02.331 AA8A] [333] : teste-rcp3902-710: Disconnected with handle [2C6] at Thu Oct 03 22:02:02.330 [network_app_fsm_disconnected:3156]
[10/03/13 22:02:02.331 AA8B] [333] : caller pc 0x0x34F1C75 [network_application_final_cleanup:2371]
[10/03/13 22:02:02.331 AA8C] [333] : teste-rcp3902-710: session_exit [onep_session_manager_session_exit:335]
[10/03/13 22:02:02.331 AA8D] [333] : Session exit for handle 710 [onep_async_session_exit:852]
[10/03/13 22:02:02.331 AA8E] [333] : delete async tbl elem session handle= 710 successfully [onep_event_async_session_remove:1290]
[10/03/13 22:02:02.331 AA8F] [333] : teste-rcp3902-710: Async session_exit done [onep_session_manager_session_exit:345]
[10/03/13 22:02:02.331 AA90] [333] : SESSION_EXIT: session handle 710 [onep_event_session_exit:1053]
[10/03/13 22:02:02.331 AA91] [333] : get by session_handle looking for: 710 [fh_get_ctx_block_by_session_handle:280]
[10/03/13 22:02:02.331 AA92] [333] : get by session_handle found: 9035 [fh_get_ctx_block_by_session_handle:283]
[10/03/13 22:02:02.331 AA93] [333] : get by session_handle found: 710 [fh_get_ctx_block_by_session_handle:283]
[10/03/13 22:02:02.331 AA94] [333] : teste-rcp3902-710: Event session_exit done [onep_session_manager_session_exit:345]
[10/03/13 22:02:02.331 AA95] [333] : Session exit 710 [onep_policy_session_exit:449]
[10/03/13 22:02:02.331 AA96] [333] : Deleting Classes [onep_al_policy_delete_all_classes:375]
[10/03/13 22:02:02.331 AA97] [333] : Deleting Class=93 [onep_al_policy_delete_all_classes:380]
[10/03/13 22:02:02.331 AA98] [333] : Deleting Class=94 [onep_al_policy_delete_all_classes:380]
[10/03/13 22:02:02.331 AA99] [333] : Delete Class onep-class-94 [onep_al_policy_delete_all_classes:402]
[10/03/13 22:02:02.331 AA9A] [333] : Removing action=8 [remove_action:2445]
[10/03/13 22:02:02.331 AA9B] [333] : Remove Shape action typ=1 ru=1 bu=1 cir=20000 cbs=20000 ebs=1000 [remove_action:2458]
[10/03/13 22:02:02.331 AA9C] [333] : ru=1 bu=1 type=1 cir=20000 cbs=20000 ebs=1000 [onep_al_policy_shape_action:1767]
[10/03/13 22:02:02.331 AA9D] [333] : PAM class=190589173760 [onep_al_policy_shape_action:1779]
[10/03/13 22:02:02.332 AA9E] [333] : Policy name=__ONEP_710_0 Class name=__ONEP_710_0 [onep_al_policy_shape_action:1782]
[10/03/13 22:02:02.332 AA9F] [333] : Delete class=__ONEP_710_0 190589173760 [onep_al_policy_delete_class:393]
[10/03/13 22:02:02.332 AAA0] [333] : Deleted Class onep-class-94 [onep_al_policy_delete_all_classes:414]
[10/03/13 22:02:02.332 AAA1] [333] : Deleting Policy=53 [onep_policy_session_exit:463]
[10/03/13 22:02:02.332 AAA2] [333] : Deleting ACLs [onep_al_acl_delete_all_acls:181]
[10/03/13 22:02:02.332 AAA3] [333] : Deleting ACEs [onep_al_acl_delete_all_acls:253]
[10/03/13 22:02:02.332 AAA4] [333] : teste-rcp3902-710: Policy session_exit done [onep_session_manager_session_exit:345]
[10/03/13 22:02:02.332 AAA5] [333] : Session exit 710 [onep_lisp_session_exit:151]
[10/03/13 22:02:02.332 AAA6] [333] : teste-rcp3902-710: Lisp session_exit done [onep_session_manager_session_exit:345]
[10/03/13 22:02:02.332 AAA7] [333] : Session exit 710l [onep_vty_session_exit:2078]
[10/03/13 22:02:02.332 AAA8] [333] : teste-rcp3902-710: VTY session_exit done [onep_session_manager_session_exit:345]
[10/03/13 22:02:02.332 AAA9] [333] : ONEP Location: Ignoring session exit
[onep_location_event_session_exit:1143]
[10/03/13 22:02:02.332 AAAA] [333] : teste-rcp3902-710: Location session_exit done [onep_session_manager_session_exit:345]
[10/03/13 22:02:02.332 AAAB] [333] : teste-rcp3902-710: Topology session_exit done [onep_session_manager_session_exit:345]
[10/03/13 22:02:02.332 AAAC] [333] : Session exit 710
[onep_onefw_session_exit:2143]
[10/03/13 22:02:02.332 AAAD] [333] : teste-rcp3902-710: OneFW session_exit done [onep_session_manager_session_exit:345]
[10/03/13 22:02:02.332 AAAE] [333] : ONEP Pathtrace: session exit
[onep_pathtrace_event_session_exit:804]
[10/03/13 22:02:02.332 AAAF] [333] : teste-rcp3902-710: Pathtrace session_exit done [onep_session_manager_session_exit:345]
[10/03/13 22:02:02.332 AAB0] [333] : ONEP Routing: session exit [onep_rtg_svc_session_exit:129]
[10/03/13 22:02:02.332 AAB1] [333] : teste-rcp3902-710: Routing session_exit done [onep_session_manager_session_exit:345]
[10/03/13 22:02:02.333 AAB2] [492] : teste-rcp3902-710: [0x7F5E14B8F468][2C6] removed [network_element_remove_app_cb:218]
[10/03/13 22:02:02.333 AAB3] [492] : service=0, table=0, session handle (key)=0x2C6 [onep_ha_ctx_remove:260]
[10/03/13 22:02:02.333 AAB4] [492] : removed app name teste session handle 0x2C6 [onep_ha_ctx_remove:271]
[10/03/13 22:02:02.333 AAB5] [333] : teste-rcp3902-710: session_update thread [4294967295] [onep_session_manager_session_update:297]
[10/03/13 22:02:02.333 AAB6] [333] : Fail to find handle [710] [network_element_find_app_by_handle:530]
[10/03/13 22:02:02.333 AAB7] [333] : teste-rcp3902-710: session_update fail [710] [onep_session_manager_session_update:305]

Subject: RE: onePK and CSR1000v
Replied by: Joseph Clarke on 04-10-2013 09:12:42 AM
OnePK API calls are not reflected in the running configuration.  You need to use other operational commands to see the results.  If you run "show policy-map interface gi2" you should see the onePK policy applied.

Subject: RE: onePK and CSR1000v
Replied by: Tiago Primini on 04-10-2013 05:00:50 PM
But if application stops the policy applied in the interface disappears. It's normal? Do I have to apply some additional funcionality in order to maintain all policies configured in my app with onePK?

Thks.

Subject: RE: onePK and CSR1000v
Replied by: Joseph Clarke on 04-10-2013 05:02:19 PM
Yes, that's normal.  Currently, onePK changes only last as long as the application.  OnePK was not originally designed as a provisioning API.  We are working on a configuration management API that will allow one to make these changes persistent.

Attachments

    Outcomes