Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/module_utils/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/module_utils/netapp_module.pyo

�
�Udac@s;dZddljjZd�Zdefd��YZdS(s* Support class for NetApp ansible modules i����NcCs|dkrdSt|�tkrOt|�tkrO|j�}|j�}nt|�tkr�t|�tkr�g|D]*}t|�tkr�|j�n|^qz}g|D]*}t|�tkr�|j�n|^q�}|j�|j�n||k||kS(s�
    Python 3 does not have a cmp function, this will do the cmp.
    :param a: first object to check
    :param b: second object to check
    :return:
    i����N(tNonettypetstrtlowertlisttsort(tatbtx((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pytcmp"s$$77

tNetAppModulecBs�eZdZd�Zd�Zd�Zd�Zddd�Zd�Z	d�Z
ed��Zed	��Z
ed
�Zd�ZRS(
s�
    Common class for NetApp modules
    set of support functions to derive actions based
    on the current state of the system, and a desired state
    cCset�|_t|_idd6|_t�|_t�|_t�|_t�|_	t�|_
dS(Nsnot intializedtname(RtlogtFalsetchangedt
parameterstdicttzapi_string_keystzapi_bool_keystzapi_list_keyst
zapi_int_keyst
zapi_required(tself((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pyt__init__?s	cCsHt�|_x2|D]*}||dk	r|||j|<qqW|jS(N(RRR(Rtansible_paramstparam((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pytset_parametersIs

cCs<|dkrdS|r*|dkr&tStS|r4dSdSdS(s�
        Convert boolean values to string or vice-versa
        If from_zapi = True, value is converted from string (as it appears in ZAPI) to boolean
        If from_zapi = False, value is converted from boolean to string
        For get() method, from_zapi = True
        For modify(), create(), from_zapi = False
        :param from_zapi: convert the value from ZAPI or to ZAPI acceptable type
        :param value: value of the boolean attribute
        :return: string or boolean
        ttruetfalseN(RtTrueR
(Rt	from_zapitvalue((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pytget_value_for_boolPs
cCs.|dkrdS|r t|�St|�SdS(s�
        Convert integer values to string or vice-versa
        If from_zapi = True, value is converted from string (as it appears in ZAPI) to integer
        If from_zapi = False, value is converted from integer to string
        For get() method, from_zapi = True
        For modify(), create(), from_zapi = False
        :param from_zapi: convert the value from ZAPI or to ZAPI acceptable type
        :param value: value of the integer attribute
        :return: string or integer
        N(RtintR(RRR((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pytget_value_for_intbs

cCsw|r<|dkrgSg|j�D]}|j�^q#Sn7tjj|�}x|D]}|j||�qUW|SdS(s,
        Convert a python list() to NaElement or vice-versa
        If from_zapi = True, value is converted from NaElement (parent-children structure) to list()
        If from_zapi = False, value is converted from list() to NaElement
        :param zapi_parent: ZAPI parent key or the ZAPI parent NaElement
        :param zapi_child: ZAPI child key
        :param data: list() to be converted to NaElement parent-children object
        :param from_zapi: convert the value from ZAPI or to ZAPI acceptable type
        :return: list() or NaElement
        N(Rtget_childrentget_contenttnetapp_utilstzapit	NaElementt
add_new_child(RRtzapi_parentt
zapi_childtdatatitem((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pytget_value_for_listts&
cCstd|kr|d}nd}|dkr;|dkr;dS|dk	rW|dkrWdSt|_|dk	rpdSdS(sq takes a desired state and a current state, and return an action:
            create, delete, None
            eg:
            is_present = 'absent'
            some_object = self.get_object(source)
            if some_object is not None:
                is_present = 'present'
            action = cd_action(current=is_present, desired = self.desired.state())
        tstatetpresenttabsenttdeletetcreateN(RRR(Rtcurrenttdesiredt
desired_state((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pyt
get_cd_action�s

	cCs�t�}t}x�|D]{}||kr||kr�||dk	r�||||kro||||<t}q�||||<q�||||<qqW||fS(N(RR
RR(RR3R4tkeys_to_comparetupdated_valuest
is_changedtkey((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pytcompare_and_update_values�s	
	cCsdS(s} TODO: raise an error if keys do not match
            with the exception of:
            new_name, state in desired
        N((R3R4((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pyt
check_keys�scCsog|D]}||kr|^q}g|D]}||kr,|^q,}|sV|rg|r`|S|SngSdS(s� compares two lists and return a list of elements that are either the desired elements or elements that are
            modified from the current state depending on the get_list_diff flag
            :param: current: current item attribute in ONTAP
            :param: desired: attributes from playbook
            :param: get_list_diff: specifies whether to have a diff of desired list w.r.t current list for an attribute
            :return: list of attributes to be modified
            :rtype: list
        N((R3R4t
get_list_diffR,tdesired_diff_listtcurrent_diff_list((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pyt
compare_lists�s
%%cCs�t�}|dkr|S|j||�x�|j�D]�\}}||kr6||dk	r6t|�tkr�|j||||�}|r�|||<q�q�t|||�dkr�||||<q�q6q6W|r�t|_	n|S(s� takes two dicts of attributes and return a dict of attributes that are
            not in the current state
            It is expected that all attributes of interest are listed in current and
            desired.
            :param: current: current attributes in ONTAP
            :param: desired: attributes from playbook
            :param: get_list_diff: specifies whether to have a diff of desired list w.r.t current list for an attribute
            :return: dict of attributes to be modified
            :rtype: dict

            NOTE: depending on the attribute, the caller may need to do a modify or a
            different operation (eg move volume if the modified attribute is an
            aggregate name)
        iN(
RRR<titemsRRR@R	RR(RR3R4R=tmodifiedR:Rt
modified_list((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pytget_modified_attributes�s	cCsa|dkr|dkrdS|dk	r8|dk	r8tS|dkrT|dk	rTtSt|_tS(sW takes a source and target object, and returns True
            if a rename is required
            eg:
            source = self.get_object(source_name)
            target = self.get_object(target_name)
            action = is_rename_action(source, target)
            :return: None for error, True for rename action, False otherwise
        N(RR
RR(Rtsourcettarget((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pytis_rename_action�s		N(t__name__t
__module__t__doc__RRR R"RR-R6R;tstaticmethodR<R@R
RDRG(((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pyR
8s	
					$(RJtansible.module_utils.netapptmodule_utilstnetappR%R	tobjectR
(((sF/usr/lib/python2.7/site-packages/ansible/module_utils/netapp_module.pyt<module>s	

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