
    Vh#                        d dl mZ d dlZd dlZd dlZd dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZ  G d	 d
e      Zy)    )annotationsN)	constants)AnsibleActionFail)get_action_args_with_defaults)boolean)
ActionBase)
merge_hashc                  >     e Zd ZdZddZddZddZd	d
 fdZ xZS )ActionModuleTc                   | j                   j                  j                         }|t        j                  vr	 | j
                  j                  j                  d      }|dvr;|j                  dd       }|ddgd fvr!| j                  j                  d|d|       |j                  d	d       }|!| j                  j                  d
|d|       |j                  dd       }|!| j                  j                  d|d|       t        d |j                         D              }| j                   j"                  j%                  || j                   j&                        j(                  }t+        ||| j                   j,                  | j.                  | j                   j0                  j2                  j4                        }|S # t        $ r, | j
                  j                  j                  d      d   }Y w xY w)Nzansible.netcommon..)network_clihttpapinetconfgather_subsetallzNot passing subset(z) to gather_timeoutzNot passing timeout(filterzNot passing filter(c              3  0   K   | ]  \  }}|	||f  y w)N ).0kvs      S/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/action/gather_facts.py	<genexpr>z0ActionModule._get_module_args.<locals>.<genexpr>2   s     M41aq}AMs   
	)collection_list)action_groups)_taskargscopyC_ACTION_SETUP_connectionansible_nameremoveprefixAttributeError
_load_namesplitpop_displaywarningdictitems_shared_loader_objmodule_loaderfind_plugin_with_contextcollectionsresolved_fqcnr   module_defaults_templar_parent_play_action_groups)	selffact_module	task_varsmod_argsnamesubsettimeoutfact_filterresolved_fact_modules	            r   _get_module_argszActionModule._get_module_args   s   ::??'') aoo-B''44AABVW @@!ot<%%$!77MM))FT_*`all#3T:G"%%R]&^_",,x6K&%%U`&ab M8>>+;MM  $66DD]])?)?  ^  

- 	 1 (DJJ,F,F**,,22AA

 ; " B''2288=bABs   %G 1G87G8c                    |j                  di       |j                  dg       |j                  dg       d}t        ||d      S )z# builds the final result to return ansible_factswarningsdeprecations)rD   rE   rF   	append_rp)
list_merge)getr	   )r9   resulttask_resultfiltered_ress       r   _combine_task_resultz!ActionModule._combine_task_result@   sF     )___bA#
B7'OONB?
 &,;GG    c           
        d|vry|j                  |j                  d             | j                  j                  j	                  d|j	                  d|j	                  di       j	                  d                  }|rt
        j                  j                  d|      }||v r|j                  ||          n|st        d| d	      t        |      j                  t        t
        j                              r| j                  j                  d
       yyt        |      j                  t        t
        j                              s|j                  d       yy)z{ Updates the module list when 'smart' is used, lookup network os mappings or use setup, warn when things seem inconsistent smartN
network_osansible_network_osrD   CONNECTION_FACTS_MODULES	variableszSNo fact modules available and we could not find a fact module for your network OS (z9), try setting one via the `FACTS_MODULES` configuration.zDetected 'setup' module and a network OS is set, the output when running it will reflect 'localhost' and not the target when a netwoking connection plugin is used.zansible.legacy.setup)r*   indexr   r    rI   r"   configget_config_valueappendr   setintersectionr#   r+   r,   )r9   modulesr;   rQ   connection_maps        r   _handle_smartzActionModule._handle_smartK   sN    '!GMM'*+ZZ__((y}}EY[d[h[hixz|[}  \B  \B  CO  \P  8Q  R
XX667Q]f6gN^+~j9:'*}  I  ~J Ja )a b b 7|((Q__)=>%% 'h i ?
 W**3q+?@NN12 ArN   c                d   t         t        |   ||      }i |d<   t        t        j
                  j                  d|            }| j                  ||       |j                  d| j                  j                  j                  dd             }i }i }|t        |      dkD  rd}nd}nt        |      }| j                  j                  j                  d	d       }| j                  j                  }	|s|D ]k  }
| j                  |
|      }| j!                  |
||d
      }|j                  dd      r|||
<   B|j                  dd      r|||
<   Z| j#                  ||      }m | j%                  | j&                  j(                  j*                         noi }|D ]  }
| j                  |
|      }|rd	|vrt-        |      | j                  _        n(|	dk7  r|	| j                  _        nd| j                  _        | j.                  j1                  d|
z         | j!                  |
||d
      ||
<    |r|D ]  }||   d   t2        j4                  j7                  ||   d         d}| j!                  d||d
      }|j                  dd      dk(  rG|j                  dd      r|||<   n*|j                  dd      r|||<   n| j#                  ||      }||=  n,t9        j:                  d        t9        j:                  d       |r| j                  j                  |	k7  r|	| j                  _        |rFddj=                  |j?                               z  |d<   ||d<   t        |      t        |      k(  rd|d<   |r/d|d<   ddj=                  |j?                               z  |d<   ||d<   d|d   d<   d|d<   |S )NrD   FACTS_MODULESrT   ansible_facts_parallelparallel   TFr   )module_namemodule_argsr;   
wrap_asyncfailedskippedr   z
Running %sansible_job_idresults_file)jid
_async_dirzansible.legacy.async_statusfinishedg?g      ?z'The following modules were skipped: %s
z, msgskipped_modulesz,The following modules failed to execute: %s
failed_modules_ansible_facts_gathered_ansible_verbose_override) superr   runlistr"   rW   rX   r^   r*   r   r    lenr   rI   	async_valrB   _execute_modulerM   _remove_tmp_pathr$   _shelltmpdirintr+   vvvvospathdirnametimesleepjoinkeys)r9   tmpr;   rJ   r\   rb   rg   rh   r?   rw   r:   r<   resjobsmodule	poll_args	__class__s                   r   rt   zActionModule.runf   s   |T.sI>"$ qxx00I0VW7I.==!94::??;N;Nz[_;`a7|a x(H**//%%&6=JJ((	& 
D00iH**{PXdmz*  A778U+*-F;'WWY.+.GK(!66vsCF
D !!$"2"2"9"9"@"@A D& P00iH /x?+.w<DJJ(!^+4DJJ(+,DJJ(""<+#=>%)%9%9k_gs|  JN%9  &O[!P " $F(,V5E(FVXV]V]VeVefjkqfr  tB  gC  WD  !EI..;Xfo  |E  RW.  XCwwz1-2778U3-0F6N WWY6.1GFO%)%>%>vs%KF L

3$ JJsO! & ::9,#,DJJ F$))T[T`T`TbJcdF5M(/F$%7|s7|+$(y!#F8KtyyY_YdYdYfOghF5M'-F#$ >B 9: /3*+rN   )r:   strr;   dict[str, t.Any]returnr   )rJ   r   rK   r   r   r   )r\   ru   r;   r   )NN)r   zt.Optional[str]r;   zt.Optional[dict[str, t.Any]]r   r   )	__name__
__module____qualname___supports_check_moderB   rM   r^   rt   __classcell__)r   s   @r   r   r      s&    (T	H36b brN   r   )
__future__r   r~   r   typingtansibler   r"   ansible.errorsr   ansible.executor.module_commonr   )ansible.module_utils.parsing.convert_boolr   ansible.plugins.actionr   ansible.utils.varsr	   r   r   rN   r   <module>r      s3    # 	   " , H = - )v: vrN   