Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/opx/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/opx/opx_cps.pyo

�
�Udac@`s,ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlm
Z
dd
lmZy.ddlZddlZddlZeZWnek
r�eZnXd�Zd�Zdddd�Zd�Zd�Zd�Zd�Zedkr(e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys)
---
module: opx_cps
version_added: "2.7"
author: "Senthil Kumar Ganesan (@skg-net)"
short_description: CPS operations on networking device running Openswitch (OPX)
description:
  -  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.
options:
  module_name:
    description:
      - Yang path to be configured.
  attr_type:
    description:
      - Attribute Yang type.
  attr_data:
    description:
      - Attribute Yang path and their corresponding data.
  operation:
    description:
      - Operation to be performed on the object.
    default: create
    choices: ['delete', 'create', 'set', 'action', 'get']
  db:
    description:
      - Queries/Writes the specified yang path from/to the db.
    type: bool
    default: 'no'
  qualifier:
    description:
      - A qualifier provides the type of object data to retrieve or act on.
    default: target
    choices: ['target', 'observed', 'proposed', 'realtime', 'registration', 'running', 'startup']
  commit_event:
    description:
      - Attempts to force the auto-commit event to the specified yang object.
    type: bool
    default: 'no'
requirements:
    - "cps"
    - "cps_object"
    - "cps_utils"
s�
- 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"
s�
response:
  description: Output from the CPS transaction.
               Output of CPS Get operation if CPS set/create/delete not done.
  returned: when a CPS transaction is successfully performed.
  type: list
  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"
    }]
cps_curr_config:
  description: Returns the CPS Get output i.e. the running configuration
               before CPS operation of set/delete is performed
  returned: when CPS operations set, delete
  type: dict
  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"
    }]
diff:
  description: The actual configuration that will be pushed comparing
               the running configuration and input attributes
  returned: when CPS operations set, delete
  type: dict
  sample:
    {
        "cps/key_data": {
            "if/interfaces/interface/name": "br230"
        },
        "dell-if/if/interfaces/interface/untagged-ports": [
            "e101-007-0"
        ]
    }
db:
  description: Denotes if CPS DB transaction was performed
  returned: when db is set to True in module options
  type: bool
  sample: True
commit_event:
  description: Denotes if auto-commit event is set
  returned: when commit_event is set to True in module options
  type: bool
  sample: True
(t
AnsibleModule(t	iteritems(t	dict_diffNcC`s�g}|r�xt|D]i}t|�}|r|d}i}||d<tj|�dtj|d�|d<|j|�qqWn|S(Ntkeytdatat/i(tconvert_cps_raw_datatcpst
qual_from_keyt
name_from_keytappend(traw_listt	resp_listtraw_elemtprocessed_elementtraw_keytindividual_element((sG/usr/lib/python2.7/site-packages/ansible/modules/network/opx/opx_cps.pytconvert_cps_raw_list�s


cC`sDi}tjd|�}x%|dD]}|j|�||<q#W|S(NtobjR(t
cps_objectt	CPSObjectt
get_attr_data(RtdRtattr((sG/usr/lib/python2.7/site-packages/ansible/modules/network/opx/opx_cps.pyR�s
c
C`s�tjd|d|�}|r1|jd|�n|rjx0t|�D]\}}	tjj||	�qDWnx�t|�D]�\}}	|jd�}
t|
�}|dkr�|j	|
|	|d�qwt
|	t�r)|	jd�}t|�dks|	jd�r|j
||	�q9|j
||�qw|j
||	�qwW|rltj|j�d	�|jd	t�n|jd	t�|r�tj|j�t�|jd
t�n|S(Ntmoduletqualtopert,iiit{tdbscommit-event(RRtset_propertyR	t	cps_utilstcps_attr_types_maptadd_typetsplittlentadd_embed_attrt
isinstancetstrt
startswithtadd_attrRtset_ownership_typetget_keytTruetFalsetset_auto_commit_event(
tmodule_namet	qualifiert	attr_typet	attr_datat	operationR%tcommit_eventRRtvaltembed_attrstembed_attrs_lentval_list((sG/usr/lib/python2.7/site-packages/ansible/modules/network/opx/opx_cps.pytparse_cps_parameters�s2!cC`sHt�}|j�}g}tj|g|�t|�}||d<|S(Ntresponse(tdicttgetRR(RtRESULTRtlR((sG/usr/lib/python2.7/site-packages/ansible/modules/network/opx/opx_cps.pytcps_get�s	
cC`s�t�}i|jd�d6|j�d6}tj|g�rbt|dg�|d<t|d<nd|jd�}t|��|S(NR"R:tchangeRAtchangedsTransaction error while (RBtget_propertyRCRttransactionRR3tRuntimeError(RRDtcht	error_msg((sG/usr/lib/python2.7/site-packages/ansible/modules/network/opx/opx_cps.pytcps_transactions	#
cC`sPt�}x@t|�D]2\}}|dkr>|j|�q|||<qW|S(Nscps/key_data(RBR	tupdate(tattrstresRR<((sG/usr/lib/python2.7/site-packages/ansible/modules/network/opx/opx_cps.pytparse_key_datas	cC`s�tdtdtdddddddd	d
ddd
g�dtdtdd�dtdtdd�dtdtdd�dtdtddddddddddg�dtdtdtdd�dtdtdtdd��}td|dt�}ts|jdd�n|jd}|jd}|jd}|jd}|jd}|jd}|jd}tdtdtdt�}	|r�t|	d<n|r�t|	d<ny�t||||d||�}
t|
�}|dkr�|	j	|�n�|}t�}
|r�|d r�|d d!d"}
d#}|dkr�t
|
�}t
|�}t||�}|r�||kr�||||<q�n|r�||
kr�||kr�||j	|
|�q�|
|||<n|	j	i|d$6�nt|||||||�}t�}|dkr0|
rEt|�}qEn|rEt|�}n|rm|
rm|j	i|d d 6�n|j	i|d d%6�|	j	|�Wn@t
k
r�}|jdtt|�j�d&t|��nX|j|	�d'S((s/
    main entry point for module execution
    R7trequiredtdefaultttargetttypeR.tchoicestobservedtproposedtrealtimetregistrationtrunningtstartupR6R8RBR9R:tcreatetdeletetsettactionRCR%tboolR;t
argument_spectsupports_check_modetmsgs$CPS library required for this moduleRHRAiRscps/key_datatdifftcps_curr_configs: N(RBR4R3RtHAS_CPSt	fail_jsontparamsR@RFRORRR
RNt	ExceptionR.RVt__name__t	exit_json(RcR R7R6R8R9R:R%R;RDtget_objtcurr_configRftcfgtkey_dtconfigst
attributesRRQte((sG/usr/lib/python2.7/site-packages/ansible/modules/network/opx/opx_cps.pytmain$s�	








		
1t__main__( t
__future__RRRRVt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicRtansible.module_utils.sixR	t)ansible.module_utils.network.common.utilsR
RRR'R3RhtImportErrorR4RRtNoneR@RFRNRRRuRl(((sG/usr/lib/python2.7/site-packages/ansible/modules/network/opx/opx_cps.pyt<module>s6


.#A


			)	
	
		e

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]