
    Vh                         d dl mZmZmZ eZd dlZd dlZd dlZd dl	Z	d dl
mZ d dlmZmZ d dlmZmZ d dlmZ d dlmZ d dlmZ  e       Z G d	 d
e      Zy)    )absolute_importdivisionprint_functionN)AnsibleError)to_bytesto_text)
ConnectionConnectionError)urlsplit)
ActionBase)Displayc                   D     e Zd Zd fd	Zd Zd Zd Zd Zd Zd Z	 xZ
S )	ActionModulec                    d}d }| j                  |       | j                  j                  j                  d      d   }t        t
        |   |      }|dk7  r#d|d<   d| j                  j                  z  |d	<   |S 	 | j                  j                  d
   }| j                  j                  j                  d      }	|	| j                  |      }	n| j                  |	      }	| j                  j                  j                  d      }
|
d}
|| j                  j                  }t        |      }|j!                  d      }	 | j#                  |||	|
|      }|du r||d<   |	|d<   |S 	 	 |j'                  ||	|
|       ||d<   |	|d<   |S # t        $ r}dd|z  dcY d }~S d }~ww xY w# t$        $ r}d|z  |d	<   Y d }~Vd }~ww xY w# t$        $ r}d|d<   d|z  |d	<   Y d }~cd }~ww xY w)NF.)	task_varsnetwork_cliTfailedzrconnection type %s is not valid for net_get module, please use fully qualified name of network_cli connection typemsgsrczmissing required argument: %s)r   r   destprotocolscppersistent_command_timeoutchangeddestinationz0Warning: %s idempotency check failed. Check destsourcer   prototimeoutzException received: %s)_get_network_os_play_context
connectionsplitsuperr   run_taskargsKeyErrorget_get_default_dest_handle_dest_path_connectionsocket_pathr	   
get_option_handle_existing_file	Exceptionget_file)selftmpr   r   r/   persistent_connectionresultr   excr   r    connsock_timeout	__class__s                l/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/ansible/netcommon/plugins/action/net_get.pyr'   zActionModule.run   s"   Y' $ 2 2 = = C CC H L|T..C M1#F8R$$//0 5M
 M	**//%(C zz""6*<))#.D))$/D 

##J/=E**66K+&'CD	U00sD%VG%$+y!(,}%  	;MM$e\MZ
 $y $}U  	6< 	>  	UNQTTF5M	U
  	;#F84s:F5M	;sN   <F =$F# $G 	F FF F #	F>,F99F>	G!
GG!c                     | j                         }t        j                  j                  |      st	        d      j
                  r|}|S | j                  j                  |d|      }|S )Nr    )_get_working_pathospathisabsr   scheme_loaderpath_dwim_relative)r4   r   working_pathdsts       r<   r-   zActionModule._handle_dest_path[   sX    --/77==(6"2"9"9C 
 ,,11,DIC
    c                 8    t        j                  d|      }|d   S )Nz/|:r   )rer%   )r4   src_pathfilename_lists      r<   _get_src_filename_from_pathz(ActionModule._get_src_filename_from_pathe   s    1R  rH   c                 V    | j                         }| j                  |      }|d|}|S )N/)r?   rM   )r4   rK   	dest_path	src_fnamefilenames        r<   r,   zActionModule._get_default_desti   s/    **,	44X>	'3rH   c                 P   t         j                  j                  |      sy| j                  j	                         }t        t        j                               }t         j                  j                  ||      }	 |j                  ||||       	 t        |d      5 }|j                         }ddd       t        |d      5 }|j                         }ddd       t%        j&                         }t)        d      }|j+                  |       |j-                         }t%        j&                         }t)        d      }|j+                  |       |j-                         }t        j                  |       ||k(  ryy# t        $ r`}	t        |	      }
|
j                  d      r9t         j                  j                  |      rt        j                  |       Y d}	~	yY d}	~	Od}	~	ww xY w# 1 sw Y   ;xY w# 1 sw Y   #xY w# t         t"        f$ r t        j                  |        w xY w)	z
        Determines whether the source and destination file match.

        :return: False if source and dest both exist and have matching sha1 sums, True otherwise.
        Tr   zNo such file or directoryNrsurrogate_or_strict)errorsF)r@   rA   existsrD   get_basedirstruuiduuid4joinr3   r
   r   endswithremoveopenreadIOErrorOSErrorhashlibsha1r   updatedigest)r4   r9   r   r   r    r!   cwdrR   tmp_dest_filer8   errorfnew_contentold_contentrd   old_content_bchecksum_oldnew_content_bchecksum_news                      r<   r1   z"ActionModule._handle_existing_fileo   s    ww~~d#ll&&(tzz|$S(3	MM)	  	mS) 'Qffh'dC 'Affh' ||~ 5JKM"{{}||~ 5JKM"{{}
		- <'9  	CLE~~9:77>>-0IIm, ;	' '' '! 	IIm$	sU   9E9 G? G%,G?  G2G? 9	G"AGG"%G/*G? 2G<7G? ?&H%c                     | j                   j                         }| j                  j                   | j                  j                  j                  }|S )N)rD   rX   r(   _role
_role_path)r4   rg   s     r<   r?   zActionModule._get_working_path   s>    ll&&(::'**""--C
rH   c                    d| j                   j                  v rI| j                   j                  d   r0t        j                  d       | j                   j                  d   }|S | j                  j
                  r-t        j                  d       | j                  j
                  }|S d|j                  di       v r'|d   d   rt        j                  d       |d   d   }|S t        d      )N
network_osz%Getting network OS from task argumentz!Getting network OS from inventoryansible_factszGetting network OS from factz1ansible_network_os must be specified on this host)r(   r)   displayvvvvr#   ru   r+   r   )r4   r   ru   s      r<   r"   zActionModule._get_network_os   s    4::??*tzz|/LLL@A6J  **LL<=++66J  IMM/2>>/*<8LL78"?3LAJ  RSSrH   )NN)__name__
__module____qualname__r'   r-   rM   r,   r1   r?   r"   __classcell__)r;   s   @r<   r   r      s(    >@!/brH   r   )
__future__r   r   r   type__metaclass__rc   r@   rJ   rZ   ansible.errorsr   ansible.module_utils._textr   r   ansible.module_utils.connectionr	   r
   +ansible.module_utils.six.moves.urllib.parser   ansible.plugins.actionr   ansible.utils.displayr   rw   r    rH   r<   <module>r      sJ   
 A @   	 	  ' 8 G @ - ) )\: \rH   