# opx_cps – CPS operations on networking device running Openswitch (OPX)

New in version 2.7.

- Synopsis
- Requirements
- Parameters
- Examples
- Return Values
- Status

## Synopsis

- Executes the given operation on the YANG object, using CPS API in the networking device running OpenSwitch (OPX). It uses the YANG models provided in https://github.com/open-switch/opx-base-model.

## Requirements

The below requirements are needed on the host that executes this module.

- cps
- cps_object
- cps_utils

## Parameters

Parameter | Choices/Defaults | Comments
--- | --- | ---
attr_data - |  | Attribute Yang path and their corresponding data.
attr_type - |  | Attribute Yang type.

commit_event
boolean

Choices:
- no ←
- yes

Attempts to force the auto-commit event to the specified yang object.

db
boolean

Choices:
- no ←
- yes

Queries/Writes the specified yang path from/to the db.

module_name - |  | Yang path to be configured.

operation
-

Choices:
- delete
- create ←
- set
- action
- get

Operation to be performed on the object.

qualifier
-

Choices:
- target ←
- observed
- proposed
- realtime
- registration
- running
- startup

A qualifier provides the type of object data to retrieve or act on.

## Examples

    - name: Create VLAN
      opx_cps:
        module_name: "dell-base-if-cmn/if/interfaces/interface"
        attr_data: {
             "base-if-vlan/if/interfaces/interface/id": 230,
             "if/interfaces/interface/name": "br230",
             "if/interfaces/interface/type": "ianaift:l2vlan"
        }
        operation: "create"
    - name: Get VLAN
      opx_cps:
        module_name: "dell-base-if-cmn/if/interfaces/interface"
        attr_data: {
             "if/interfaces/interface/name": "br230",
        }
        operation: "get"
    - name: Modify some attributes in VLAN
      opx_cps:
        module_name: "dell-base-if-cmn/if/interfaces/interface"
        attr_data: {
             "cps/key_data":
                { "if/interfaces/interface/name": "br230" },
             "dell-if/if/interfaces/interface/untagged-ports": ["e101-008-0"],
        }
        operation: "set"
    - name: Delete VLAN
      opx_cps:
        module_name: "dell-base-if-cmn/if/interfaces/interface"
        attr_data: {
             "if/interfaces/interface/name": "br230",
        }
        operation: "delete"

## Return Values

Common return values are documented here, the following are the fields unique to this module:

Key | Returned | Description
--- | --- | ---
commit_event boolean | when commit_event is set to True in module options | Denotes if auto-commit event is set Sample: True

cps_curr_config
dictionary

when CPS operations set, delete

Returns the CPS Get output i.e. the running configuration before CPS operation of set/delete is performed
Sample:
[{'data': {'base-if-vlan/if/interfaces/interface/id': 230, 'cps/key_data': {'if/interfaces/interface/name': 'br230'}, 'dell-base-if-cmn/if/interfaces/interface/if-index': 44, 'dell-if/if/interfaces/interface/learning-mode': 1, 'dell-if/if/interfaces/interface/mtu': 1532, 'dell-if/if/interfaces/interface/phys-address': '', 'dell-if/if/interfaces/interface/vlan-type': 1, 'if/interfaces/interface/enabled': 0, 'if/interfaces/interface/type': 'ianaift:l2vlan'}, 'key': 'target/dell-base-if-cmn/if/interfaces/interface'}]

db boolean | when db is set to True in module options | Denotes if CPS DB transaction was performed Sample: True
diff dictionary | when CPS operations set, delete | The actual configuration that will be pushed comparing the running configuration and input attributes Sample: {'cps/key_data': {'if/interfaces/interface/name': 'br230'}, 'dell-if/if/interfaces/interface/untagged-ports': ['e101-007-0']}

response
list

when a CPS transaction is successfully performed.

Output from the CPS transaction. Output of CPS Get operation if CPS set/create/delete not done.
Sample:
[{'data': {'base-if-vlan/if/interfaces/interface/id': 230, 'cps/object-group/return-code': 0, 'dell-base-if-cmn/if/interfaces/interface/if-index': 46, 'if/interfaces/interface/name': 'br230', 'if/interfaces/interface/type': 'ianaift:l2vlan'}, 'key': 'target/dell-base-if-cmn/if/interfaces/interface'}]

## Status

- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]

### Authors

- Senthil Kumar Ganesan (@skg-net)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.