Anons79 Mini Shell

Directory : /proc/self/root/lib/python2.7/site-packages/ansible/module_utils/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/ansible/module_utils/oneview.pyo

�
�Udac@`s�ddlmZmZmZddlZddlZddlZddlZddlZdZ
yddlmZe
ZWn#ek
r�ej�Z
eZnXddlmZddlmZmZddlmZddlmZd�Zdd	�Zd
�Zd�Zdefd
��YZ de fd��YZ!de fd��YZ"de fd��YZ#ej$ej%�de&fd��Y�Z'dS(i(tabsolute_importtdivisiontprint_functionN(t
OneViewClient(tsix(t
AnsibleModuletmissing_required_lib(t	to_native(tMappingcC`sZi}|s|SxC|D];}t|t�r<|j|�qt|t|dd�<qW|S(s�
    Transforms a list into a dictionary, putting values as keys.

    :arg list list_: List of values
    :return: dict: dictionary built
    terrorstsurrogate_or_strict(t
isinstanceRtupdatetTrueR(tlist_trettvalue((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyttransform_list_to_dict3s
c
C`s|dkrgn|}|s"|Stjg|D]}|||j�f^q/�}tj�}x�|D]�}||}||kr�x:|D]2}	|	|kr�||	dkr�|j|	�q�q�W||||<||j|�qg|||<qgWt|j��S(s�
    Merge two lists by the key. It basically:

    1. Adds the items that are present on updated_list and are absent on original_list.

    2. Removes items that are absent on updated_list and are present on original_list.

    3. For all items that are in both lists, overwrites the values from the original item by the updated item.

    :arg list original_list: original list.
    :arg list updated_list: list with changes.
    :arg str key: unique identifier.
    :arg list ignore_when_null: list with the keys from the updated items that should be ignored in the merge,
        if its values are null.
    :return: list: Lists merged.
    N(tNonetcollectionstOrderedDicttcopytpopRtlisttvalues(
t
original_listtupdated_listtkeytignore_when_nulltit	items_maptmerged_itemstitemtitem_keytignored_key((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pytmerge_list_by_keyIs2


cC`s0t|t�r"tj|dt�St|�SdS(Nt	sort_keys(RRtjsontdumpsR
tstr(tobj((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyt_str_sortedqscC`s4t|t�r*|j�r*t|�}nt|�S(s�
    Convert value to string to enhance the comparison.

    :arg value: Any object type.

    :return: str: Converted value.
    (Rtfloatt
is_integertintR'(R((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyt_standardize_valuexstOneViewModuleExceptioncB`seZdZd�ZRS(s�
    OneView base Exception.

    Attributes:
       msg (str): Exception message.
       oneview_response (dict): OneView rest response.
   cC`s�d|_d|_t|tj�r0||_n3||_|rct|t�rc|jd�|_n|jr�tj	||j|j�ntj	||j�dS(Ntmessage(
Rtmsgtoneview_responseRRtstring_typestdicttgett	Exceptiont__init__(tselftdata((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyR6�s				(t__name__t
__module__t__doc__R6(((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyR.�stOneViewModuleTaskErrorcB`seZdZdd�ZRS(s�
    OneView Task Error Exception.

    Attributes:
       msg (str): Exception message.
       error_code (str): A code which uniquely identifies the specific error.
    cC`s#tt|�j|�||_dS(N(tsuperR<R6t
error_code(R7R0R>((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyR6�sN(R9R:R;RR6(((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyR<�stOneViewModuleValueErrorcB`seZdZRS(s�
    OneView Value Error.
    The exception is raised when the data contains an inappropriate value.

    Attributes:
       msg (str): Exception message.
    (R9R:R;(((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyR?�stOneViewModuleResourceNotFoundcB`seZdZRS(s�
    OneView Resource Not Found Exception.
    The exception is raised when an associated resource was not found.

    Attributes:
       msg (str): Exception message.
    (R9R:R;(((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyR@�stOneViewModuleBasecB`s:eZdZdZdZdZdZdZededd�d	edd
�dedd
�dedd
d
e	�dedd�dedd
��Z
ededdde	��Zd"Z
d"ed�Zd�Zd�Zd�Zejd��Zd�Zdd�Zd�Zdd�Zd�Zd �Zd!�ZRS(#sResource created successfully.sResource updated successfully.sResource deleted successfully.sResource is already present.sResource is already absent.sDifference found at key '{0}'. tconfigttypetpaththostnameR'tusernametpasswordtno_logtapi_versionR,timage_streamer_hostnamet
validate_etagtbooltdefaultcC`s�|j||�}td|dt�|_|j�|j�|jjjd�|_|jjjd�|_	|jjjd�p�i|_
t|jjjd��|_||_
dS(s�
        OneViewModuleBase constructor.

        :arg dict additional_arg_spec: Additional argument spec definition.
        :arg bool validate_etag_support: Enables support to eTag validation.
        t
argument_spectsupports_check_modetstateR8tparamstoptionsN(t_build_argument_specRtFalsetmodulet_check_hpe_oneview_sdkt_create_oneview_clientRQR4RPR8tfacts_paramsRRRtvalidate_etag_support(R7tadditional_arg_specRYRN((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyR6�s

cC`sLt�}|j|j�|r2|j|j�n|rH|j|�n|S(N(R3RtONEVIEW_COMMON_ARGStONEVIEW_VALIDATE_ETAG_ARGS(R7RZRYtmerged_arg_spec((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyRS�s	cC`s,ts(|jjdtd�dt�ndS(NR0t	hpOneViewt	exception(tHAS_HPE_ONEVIEWRUt	fail_jsonRtHPE_ONEVIEW_IMP_ERR(R7((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyRVsc
C`s�|jjjd�r�td|jjddtd|jjdd|jjd�d|jjdd|jjd	�}t|�|_n>|jjd
s�tj�|_ntj|jjd
�|_dS(NREtiptcredentialstuserNameRFRGRItimage_streamer_ipRJRB(RURQR4R3Rtoneview_clienttfrom_environment_variablestfrom_json_file(R7RB((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyRWs)cC`sdS(s3
        Abstract method, must be implemented by the inheritor.

        This method is called from the run method. It should contains the module logic

        :return: dict: It must return a dictionary with the attributes for the module result,
            such as ansible_facts, msg and changed.
        N((R7((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pytexecute_modules
cC`s�ym|jr7|jjjd�s7|jjj�q7n|j�}d|kr\t|d<n|jj	|�WnNt
k
r�}djd�|jD��}|jj
d|dtj��nXdS(s
        Common implementation of the OneView run modules.

        It calls the inheritor 'execute_module' function and sends the return to the Ansible.

        It handles any OneViewModuleException in order to signal a failure to Ansible, with a descriptive error message.

        RKtchangeds; cs`s|]}t|�VqdS(N(R(t.0te((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pys	<genexpr>5sR0R_N(RYRURQR4Rgt
connectiontdisable_etag_validationRjRTt	exit_jsonR.tjointargsRat	tracebackt
format_exc(R7tresultR_t	error_msg((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pytruns		
tdeletecC`sJ|r1t|j|�|�itd6|jd6Sitd6|jd6SdS(s�
        Generic implementation of the absent state for the OneView resources.

        It checks if the resource needs to be removed.

        :arg dict resource: Resource to delete.
        :arg str method: Function of the OneView client that will be called for resource deletion.
            Usually delete or remove.
        :return: A dictionary with the expected arguments for the AnsibleModule.exit_json
        RkR0N(tgetattrtresource_clientR
tMSG_DELETEDRTtMSG_ALREADY_ABSENT(R7tresourcetmethod((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pytresource_absent8scC`s'|jjd|�}|r#|dSdS(s�
        Generic get by name implementation.

        :arg str name: Resource name to search for.

        :return: The resource found or None.
        tnameiN(Rztget_byR(R7R�Ru((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pytget_by_nameJstcreatec	C`s�t}d|jkr1|jjd�|jd<n|sdt|j|�|j�}|j}t}n[|j�}|j|j�|j	||�r�|j
}n!|jj|�}t}|j}td|d|di||6�S(s
        Generic implementation of the present state for the OneView resources.

        It checks if the resource needs to be created or updated.

        :arg dict resource: Resource to create or update.
        :arg str fact_name: Name of the fact returned to the Ansible.
        :arg str create_method: Function of the OneView client that will be called for resource creation.
            Usually create or add.
        :return: A dictionary with the expected arguments for the AnsibleModule.exit_json
        tnewNameR�R0Rkt
ansible_facts(
RTR8RRyRztMSG_CREATEDR
RRtcomparetMSG_ALREADY_PRESENTtMSG_UPDATEDR3(R7R}t	fact_namet
create_methodRkR0tmerged_data((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pytresource_presentUs$
			cC`s�|dkrg}n|d|}tddddd|�}|ddksjt|d�t|�kr�|jj|d|�|d|<t|d	<|j|d
<n|S(s�
        Generic implementation of the scopes update PATCH for the OneView resources.
        It checks if the resource needs to be updated with the current scopes.
        This method is meant to be run after ensuring the present state.
        :arg dict state: Dict containing the data from the last state results in the resource.
            It needs to have the 'msg', 'changed', and 'ansible_facts' entries.
        :arg str fact_name: Name of the fact returned to the Ansible.
        :arg list scope_uris: List with all the scope URIs to be added to the resource.
        :return: A dictionary with the expected arguments for the AnsibleModule.exit_json
        R�t	operationtreplaceRDs
/scopeUrisRt	scopeUristuriRkR0N(RR3tsetRztpatchR
R�(R7RPR�t
scope_urisR}toperation_data((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pytresource_scopes_set|s	,!
cC`s�|}|}dj||�}|rC|rC|jjd|�tSxY|D]Q}||kr�||dk	r�|jj|jj|�|�tSqJ||r�||r�qJqJt||t�r|j||||�s�|jj|jj|�|�tSqJt||t	�rW|j
||||�s�|jj|jj|�|�tSqJt||�t||�krJ|jj|jj|�|�tSqJWxW|j�D]I}||kr�||dk	r�|jj|jj|�|�tSq�q�Wt
S(s?
        Recursively compares dictionary contents equivalence, ignoring types and elements order.
        Particularities of the comparison:
            - Inexistent key = None
            - These values are considered equal: None, empty, False
            - Lists are compared value by value after a sort, if they have same size.
            - Each element is converted to str before the comparison.
        :arg dict first_resource: first dictionary
        :arg dict second_resource: second dictionary
        :return: bool: True when equal, False when different.
        s resource1 = {0}, resource2 = {1}sresource1 and not resource2. N(tformatRUtlogRTRtMSG_DIFF_AT_KEYRRR�Rtcompare_listR-tkeysR
(R7tfirst_resourcetsecond_resourcet	resource1t	resource2tdebug_resourcesR((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyR��s<

      cC`se|}|}dj||�}|s<|jjd|�tSt|�t|�krl|jjd|�tSt|dt�}t|dt�}x�t|�D]�\}}t|t	�r�|j
|||�s]|jjd|�tSq�t|t�r)|j|||�s]|jjd|�tSq�t
|�t
||�kr�|jjd|�tSq�WtS(s�
        Recursively compares lists contents equivalence, ignoring types and element orders.
        Lists with same size are compared value by value after a sort,
        each element is converted to str before the comparison.
        :arg list first_resource: first list
        :arg list second_resource: second list
        :return: True when equal; False when different.
        s resource1 = {0}, resource2 = {1}sresource 2 is null. s!resources have different length. Rsresources are different. slists are different. svalues are different. (R�RUR�RTtlentsortedR)t	enumerateRRR�RR�R-R
(R7R�R�R�R�R�Rtval((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyR��s0
N(R9R:R�R�R{R�R|R�R3R
R[R\RRzRTR6RSRVRWtabctabstractmethodRjRwRR�R�R�R�R�(((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyRA�s6	
				'		8((t
__future__RRRR�RR%tosRsRRbthpOneView.oneview_clientRR
R`tImportErrorRtRTtansible.module_utilsRtansible.module_utils.basicRRtansible.module_utils._textRt/ansible.module_utils.common._collections_compatRRR#R)R-R5R.R<R?R@t
add_metaclasstABCMetatobjectRA(((s@/usr/lib/python2.7/site-packages/ansible/module_utils/oneview.pyt<module>s4


	(		

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