
    Vh              
       L   d dl mZmZmZ eZd dlmZ 	 d dlm	Z	 dZ
d dlmZ d dlmZmZmZmZ d dlmZ  e       Zej-                   e ed	d
d
g       ed       ed	       ed	                   dd
g dfgZg Zg Zg Z G d de      Z G d de      Zy# e$ r dZ
Y w xY w)    )absolute_importdivisionprint_function)
ActionBase)AnsibleArgSpecValidatorTF)AnsibleActionFail)ISESDKise_argument_specise_compare_equalityget_dict_result)InconsistentParametersstrpresent)typedefaultchoiceslist)r   )state	hostnamespreCheckReportIDupgradeTyper   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)UpgradeProceedc                     || _         t        |j                  d      |j                  d      |j                  d            | _        y )Nr   r   r   )r   pre_check_report_idupgrade_type)isedictget
new_object)selfparamsr   s      l/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/ise/plugins/action/upgrade_proceed.py__init__zUpgradeProceed.__init__4   s:    jj- &

+= >M2
    c                     d }| j                   j                  dd      j                  j                  dg       }t	        |d|      }|S )Nfullupgrade )familyfunctionresponsename)r   execr+   r   r   )r!   r,   resultitemss       r#   get_object_by_namez!UpgradeProceed.get_object_by_name<   sH    ]R@IIMM
 !5r%   c                 
    d }|S N )r!   idr.   s      r#   get_object_by_idzUpgradeProceed.get_object_by_idE   s    r%   c                    d }d}d}| j                   j                  d      }| j                   j                  d      }|r'| j                  |      }|d uxr t        |t              }|s)|r'| j                  |      }|d uxr t        |t              }|r%|j                  d      }|r|r||k7  rt        d      |d uxr t        |t              }||fS )NFr4   r,   z9The 'id' and 'name' params don't refer to the same object)r    r   r5   
isinstancer   r0   r   )r!   prev_obj	id_existsname_existso_idr,   _id	it_existss           r#   existszUpgradeProceed.existsJ   s    	""4(""6*,,T2H ,KHd1KIT..t4H"$.M:h3MK,,t$C[TS[,O  D(GZ$-G	8$$r%   c                 P    | j                   g d}t        fd|D              S )N))r   r   )r   r   )r   r   c              3   z   K   | ]2  \  }}t        j                  |      j                  |              4 y wr2   )r   r   ).0	ise_paramansible_paramcurrent_objrequested_objs      r#   	<genexpr>z1UpgradeProceed.requires_update.<locals>.<genexpr>i   sB      
 +M %	*M,=,=m,L 
s   8;)r    any)r!   rD   
obj_paramsrE   s    ` @r#   requires_updatezUpgradeProceed.requires_update_   s1    

  
 /9	
 
 	
r%   c                 j    | j                   j                  dd| j                        j                  }|S )Nr'   initiate_upgrade_on_p_p_a_n)r)   r*   r"   )r   r-   r    r+   )r!   r.   s     r#   createzUpgradeProceed.createp   s7     2??  
 (	 	
 r%   N)	__name__
__module____qualname__r$   r0   r5   r>   rI   rL   r3   r%   r#   r   r   3   s     

%*
"r%   r   c                   0     e Zd Z fdZd Zd fd	Z xZS )ActionModulec                 x    t         st        d      t        t        |   |i | d| _        d| _        d | _        y )NzYansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'F)ANSIBLE_UTILS_IS_INSTALLEDr   superrQ   r$   _supports_async_supports_check_mode_result)r!   argskwargs	__class__s      r#   r$   zActionModule.__init__z   sC    )#k  	lD*D;F;$$)!r%   c                 *   t        | j                  j                  t        t              dt        t
        t        t        t              | j                  j                        }|j                         \  }}| j                  _        |st        |      y )N)argument_specargspec)required_ifrequired_one_ofmutually_exclusiverequired_together)dataschemaschema_formatschema_conditionalsr,   )r   _taskrX   r   r\   r^   r_   r`   ra   actionvalidater   )r!   aavvaliderrorss       r#   _check_argspeczActionModule._check_argspec   sr    %m4# $' /#5"3	! ""
 *-&vtzz#F++ r%   c                 $   d| j                   _        t        t        |   ||      | _        d| j
                  d<   | j                          t        | j                   j                        }t        | j                   j                  |      }| j                   j                  j                  d      }d }|dk(  r|j                         \  }}|r7|j                  |      r|}|j                          nH|}|j                          n5|j                         }	|j                         \  }}
|
}|j!                          | j
                  j#                  t%        |             | j
                  j#                  |j'                                | j
                  S )NFchanged)r"   r   r   )ise_response)rf   diffrT   rQ   runrW   rl   r	   rX   r   r   r>   rI   object_present_and_differentobject_already_presentrL   object_createdupdater   	exit_json)r!   tmp	task_varsr   objr   r+   
obj_existsr8   ise_create_responsecreated_objrZ   s              r#   rq   zActionModule.run   s1   

\44S)D"'YDJJOO,TZZ__c2

##G,I%(ZZ\"Z&&x0'H446'H..0&)jjl#,/JJL)[&""$Dh78CMMO,||r%   )NN)rM   rN   rO   r$   rl   rq   __classcell__)rZ   s   @r#   rQ   rQ   y   s    ," r%   rQ   N)
__future__r   r   r   r   __metaclass__ansible.plugins.actionr   Nansible_collections.ansible.utils.plugins.module_utils.common.argspec_validater   rS   ImportErroransible.errorsr   6ansible_collections.cisco.ise.plugins.plugin_utils.iser	   r
   r   r   =ansible_collections.cisco.ise.plugins.plugin_utils.exceptionsr   r\   ru   r   r^   r_   r`   ra   objectr   rQ   r3   r%   r#   <module>r      s    A @ -& "& , 
 "#   y9+FF#5)e$	 iT"   CV CL:: :S  '!&'s   B B#"B#