open-switch / opx-cps

https://openswitch.net
6 stars 15 forks source link

opx-cps

This repository contains the CPS object library files, and provides a microservice data-centric API allowing applications to communicate with each other between threads, processes, or diverse locations.

A high-level list of CPS features include:

Lookup and binary to text translation and object introspection is also available.

Applications define objects through (optionally YANG-based) object models. These object models are converted into binary (C accessible) object keys and object attributes that can be used in conjunction with the C-based CPS APIs. There are adaptions on top of CPS that allow these objects and APIs to be converted to different languages like Python.

With the object keys and attributes applications can:

API documentation

The CPS API is documented through Doxygen. To generate CPS Doxygen content, at the top level of your source directory (one level underneath opx-cps), run the opx-cps/doc/cps_gen_doc.sh command.

git clone git@github.com:open-switch/opx-cps.git
cd opx-cps
(cd .. ; sh -x opx-cps/doc/cps_gen_doc.sh )
firefox workspace/cps-api-doc/c-cpp-doc/html/index.html

Packages

See Architecture for more information on the CPS module.

Debugging tools

cps_model_info

This tool is useful to get all information about CPS objects on the target. It is used to get the attributes of a specific CPS object, or first-level contents of a given YANG path of the CPS object (as defined in the YANG model).

Usage

cps\_model\_info CPS Object Path as defined in the YANG model

Examples

root@OPX:~# cps_model_info

base-packet
base-pas
base-acl
if
base-qos
base-if-phy
root@OPX:~# cps_model_info base-if-phy

base-if-phy/front-panel-port
        Attribute Type =  list
        Description =  This map contains the front panel ports and the NPU ports associated with with the front panel ports.

Registered to CPS with qualifier:  target

Process Owner:  base_nas_front_panel_ports.py

base-if-phy/hardware-port
        Attribute Type =  list
        Description =  This entity holds the details of which front panel port corresponds to a specific NPU/hardware port. This list is not dynamic and therefore will not change for a single instance of a product.

Registered to CPS with qualifier:  target

Process Owner:  base_nas_front_panel_ports.py
root@OPX:~# cps_model_info base-if-phy/physical

base-if-phy/physical/phy-mode
        Attribute Type =  leaf
        Data Type =  enum
        Description =  Port PHY mode, Ethernet or FC

Registered to CPS with qualifier:  target

Process Owner:  base_nas

base-if-phy/physical/hardware-port-id
        Attribute Type =  leaf
        Data Type =  uint32_t
        Description =  This is the physical hardware port

Registered to CPS with qualifier:  target

Process Owner:  base_nas

cps_get_oid.py

This tool is used to get data from a CPS Object Service provider.

Usage

cps\_get\_oid.py qualifier CPS Object Path as defined in the YANG model

CPS Object Path can be determined from the cps\_model\_info tool.

Qualifier: target/observed/proposed

Examples

root@OPX:~# cps_get_oid.py target base-if-phy/physical hardware-port-id=125

Key: 1.17.1114163.1114115.1114116.
base-if-phy/physical/breakout-capabilities = 4,2,4
base-if-phy/physical/fanout-mode = 4
base-if-phy/physical/npu-id = 0
base-if-phy/physical/hardware-port-list = 125,126,127,128
base-if-phy/physical/hardware-port-id = 125
base-if-phy/physical/speed = 6
base-if-phy/physical/supported-speed = 3,4,6
base-if-phy/physical/port-id = 125
base-if-phy/physical/phy-media = 1
base-if-phy/physical/front-panel-number = 25
base-if-phy/physical/loopback = 0
root@OPX:~#

cps_set_oid.py

This tool is used to do transactions on a given CPS object.

Usage

cps\_set\_oid.py qualifier operation CPS Object Path as defined in the YANG model CPS Object attr=value

CPS Object Path and its attributes can be determined from the cps\_model\_info tool.

Qualifier: target/observed/proposed

Operation: create/set/delete

Examples

root@OPX:/usr/bin# cps_set_oid.py target create base-if-phy/physical hardware-port-id=26 admin-state=2

cps_trace_events.py

This tool is used to subscribe/listen for CPS events on the target.

Usage

cps\_trace\_events.py qualifier CPS Object Path as defined in the YANG model

CPS Object Path can be determined from the cps\_model\_info tool.

Examples

root@OPX:~# cps_trace_events.py observed dell-base-if-cmn/if/interfaces-state/interface
Key : 2.19.44.2883618.2883611.2883586.
 Registering for observed dell-base-if-cmn/if/interfaces-state/interface
1.2.131094.131075.
Key: 1.2.131094.131075.
cps/connection-entry/ip = 127.0.0.1:6379
cps/connection-entry/connection-state = 1
cps/connection-entry/group = 127.0.0.1:6379

2.19.44.2883618.2883611.2883586.
Key: 2.19.44.2883618.2883611.2883586.
if/interfaces-state/interface/name = e101-025-0
if/interfaces-state/interface/if-index = 41
if/interfaces-state/interface/admin-status = 2

cps_send_event.py

This tool is used to publish/send CPS events on the target.

Usage

cps\_send\_event.py operation qualifier CPS Object Path as defined in the YANG model CPS Object attr=value

CPS Object Path and its attributes can be determined from the cps\_model\_info tool.

Qualifier: target/observed/proposed

Operation: create/set/delete

Examples

root@OPX:/usr/bin# cps_send_event.py create observed  dell-base-if-cmn/if/interfaces-state/interface  if/interfaces-state/interface/name=e101-007-0 if/interfaces-state/interface/oper-status=2

© 2018 OpenSwitch project. All information is contributed to and made available by OPX under the Creative Commons Attribution 4.0 International License (available at http://creativecommons.org/licenses/by/4.0/).