MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyc
�
d�bc@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddl	mZddlZddljjZddljjZddljjjZddljjjZddljjjZddlmZddl m!Z!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(m)Z)m*Z*ddlm+Z+d	d
gZ,e
j-d�Z.e&d�Z/d
�Z0d�Z1d�Z2d�Z3d�Z4d�Z5d�Z6d�Z7d�Z8d�Z9d�Z:dZ;e
j-d�Z<e=a>dZ?dZ@e
j-de
jA�ZBdZCdZDdZEd ZFe
j-d!�ZGd"ZHd#ZId$eJfd%��YZKdS(&i����N(tgetpwall(tOSUtilError(tustrtarray_to_bytes(t	CryptUtil(tFlexibleVersion(t
RouteEntrytNetworkInterfaceCardtAddFirewallRules(tCommandErrors3/lib/udev/rules.d/75-persistent-net-generator.ruless)/etc/udev/rules.d/70-persistent-net.ruless^[^\d\.]*([\d\.]+).*$s1.4.21cCs|r|jdd�n|S(sY
    If 'wait' is True, adds the wait option (-w) to the given iptables command line
    is-w(tinsert(twaittcommand((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt	_add_waitAscCs
ddgS(Ntiptabless	--version((((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_iptables_version_commandJscCstj||d|�S(NR(Rtget_accept_tcp_rule(RRtdestination((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyRNscCstj||||�S(N(Rtget_iptables_accept_command(RRRt	owner_uid((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_firewall_accept_commandRscCstj|||�S(N(Rtget_iptables_drop_command(RRR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_firewall_drop_commandVscCst|dddddg�S(NRs-ttsecuritys-Ls-nxv(R
(R((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_firewall_list_commandZsc
Cs%t|ddddddddg�S(NRs-tRs-LtOUTPUTs--zeros-nxv(R
(R((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_firewall_packets_command^scCs=t|dddtjdd|dddd	d
ddd
g�S(NRs-tRRs-ds-pttcps-mt	conntracks	--ctstatesINVALID,NEWs-jtACCEPT(R
RtDELETE_COMMAND(RR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt,get_firewall_delete_conntrack_accept_commandds$cCstjtj|d|�S(NR(RRR(RR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_delete_accept_tcp_rulejscCsCt|dddtjdd|dddd	d
t|�ddg�S(
NRs-tRRs-ds-pRs-mtowners--uid-owners-jR(R
RRtstr(RRR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt(get_firewall_delete_owner_accept_commandns*cCs=t|dddtjdd|dddd	d
ddd
g�S(NRs-tRRs-ds-pRs-mRs	--ctstatesINVALID,NEWs-jtDROP(R
RR(RR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt*get_firewall_delete_conntrack_drop_commandss$s'^\s*(\d+)\s+(\d+)\s+DROP\s+.*{0}[^\d]*$s^cpu .*sdmidecode --string system-uuids/sys/class/dmi/id/product_uuids5^\s*[A-F0-9]{8}(?:\-[A-F0-9]{4}){3}\-[A-F0-9]{12}\s*$i�i�i'�is^\d+:\s+(\w+):\s+(.*)$s/sys/bus/vmbus/devices/s$f8b3781a-1e82-4818-a1c3-63d806ec15bbt
DefaultOSUtilcBsseZd�Zed��Zed��Zed��Zdjd�Zd�Z	d�Z
d�Zd�Zd	�Z
ed
��Zd�Zd�Zd
�Zed��Zd�Zdjdjd�Zddd�Zd�Zeed�Zd�Zed��Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!dd �Z"de#djdjd!d"�Z$e#djd#�Z%e#d$�Z&d%�Z'd&�Z(d'd(�Z)dje#d)�Z*e#d*�Z+d+�Z,djd,�Z-djd-�Z.d.�Z/d/�Z0ed0��Z1d1�Z2d2�Z3ed3��Z4ed4��Z5ed5��Z6d6�Z7d7�Z8d8�Z9d9�Z:ed:��Z;d;�Z<d<�Z=d=�Z>d>�Z?d?�Z@d@�ZAdA�ZBdB�ZCdC�ZDdD�ZEdE�ZFdF�ZGdG�ZHdH�ZIdI�ZJdJ�ZKedK��ZLedL��ZMdM�ZNdN�ZOdO�ZPdPd!dQ�ZQdR�ZRdS�ZSdT�ZTdU�ZUedV��ZVedW��ZWdX�ZXdY�ZYdZ�ZZed[��Z[d\�Z\d]�Z]d^�Z^d_�Z_d`�Z`eada��Zbedb��Zcedc��Zdedd�Zeede��Zfedf��Zgee#dg��Zhee#edh��Ziedjdi��ZjRS(kcCs7d|_d|_t|_t|_|j�|_dS(Ns/etc/waagent.conf(tagent_conf_file_pathtNonetselinuxtFalsetdisable_route_warningtjit_enabledtget_service_nametservice_name(tself((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt__init__�s
				cCsdS(Ntwaagent((((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR-�scCsdS(Ns/lib/systemd/system((((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt"get_systemd_unit_file_install_path�scCsdS(Ns	/usr/sbin((((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_agent_bin_path�scCs2ts
dSy�|j�}yytjt|��}tjtj|��}xE|j	d�D]4}|j
|�}|dk	rYt|j
d��SqYWWn[tk
r�}t|t�r�|jdks�|jdkr�dStjdt|��dSXdSWn6tk
r-}tatjdjt|���dSXdS(	Nis
iiis#Failed to get firewall packets: {0}i����s.Unable to retrieve firewall packets dropped{0}(t_enable_firewalltget_firewall_will_waitt	shellutiltrun_commandRtretcompiletPACKET_PATTERNtformattsplittmatchR(tinttgroupt	Exceptiont
isinstanceR	t
returncodetloggertwarnRR*(R/tdst_ipRtoutputtpatterntlinetmte((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_firewall_dropped_packets�s,-cCs�ytjt��}WnAtk
rY}djt|��}tj|�t|��nXtj	|�}|dkr�dj|�}tj|�t|��nt|jd��t
kr�dnd}|S(Ns,Unable to determine version of iptables: {0}s0iptables did not return version information: {0}is-wt(R6R7RR@R;RRCRDt_IPTABLES_VERSION_PATTERNR=R(RR?t_IPTABLES_LOCKING_VERSION(R/RFRJtmsgRIR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR5�s

!cCs�xztdd�D]i}ytj|�}Wqtk
rx}|jdkrNdS|jdkrytdj|���qyqXqWdS(s�
        Continually execute the delete operation until the return
        code is non-zero or the limit has been reached.
        iidNis$invalid firewall deletion rule '{0}'(trangeR6R7R	RBR@R;(R/truletitrcRJ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt_delete_rule�scCs�ts
tSyo|j�}|jt||��|jt||��|jt|||��|jt||��tSWn6t	k
r�}tat
jdjt
|���tSXdS(NsBUnable to remove firewall -- no further attempts will be made: {0}(R4R*R5RTRR R#R%tTrueR@RCtinfoR;R(R/REtuidRRJ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytremove_firewall�scCs\y&|j�}|jt||��Wn/tk
rW}tjdjt|���nXdS(NsNUnable to remove legacy firewall rule, won't try removing it again. Error: {0}(R5RTRR@RCRVR;R(R/RERterror((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytremove_legacy_firewall_rulesc	Cs�ts
tSyS|j�}y7t|tj|�}tj|�tj	d�t
SWnTtk
r�}|jdkr�|j
||�d}tj|�t|��q�nXytj|||�Wn)tk
r�}tjt|���nXtjd�y/tjt|��}tjdj|��Wn/tk
rW}tjdjt|���nXt
SWn6tk
r�}tatjdjt|���tSXdS(NsFirewall appears establishedis@please upgrade iptables to a version that supports the -C options.Successfully added Azure fabric firewall rulessFirewall rules:
{0}s"Listing firewall rules failed: {0}sEUnable to establish firewall -- no further attempts will be made: {0}(R4R*R5RRt
CHECK_COMMANDR6R7RCtverboseRUR	RBRXRDR@tadd_iptables_rulesRRVRR;(	R/RERWRt	drop_ruleRJRORYRF((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytenable_firewalls@



 cCstj|�s|S|jd�}djtj|ddd�tj|ddd�tj|ddd�|d|dg�S(s�
        Azure stores the instance ID with an incorrect byte ordering for the
        first parts. For example, the ID returned by the metadata service:

            D0DF4C54-4ECB-4A4B-9954-5BDF3ED5C3B8

        will be found as:

            544CDFD0-CB4E-4B4A-9954-5BDF3ED5C3B8

        This code corrects the byte order such that it is consistent with
        that returned by the metadata service.
        t-itwidthiiii(tUUID_PATTERNR=R<tjointtextutiltswap_hexstring(tinstance_idtparts((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt_correct_instance_id>scCso|j�}tjdj|��tjdj|��|j�|j�kpn|j�|j|�j�kS(s�
        Compare two instance IDs for equality, but allow that some IDs
        may have been persisted using the incorrect byte ordering.
        scurrent instance id: {0}s former instance id: {0}(tget_instance_idRCR\R;tlowerRh(R/tid_thattid_this((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytis_current_instance_idZs
cCs|jS(N(R'(R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_agent_conf_file_pathescCswtjjt�r*tjt�j�}n:tjt	�\}}|dks`t
j|�dkrddS|j
|j��S(s�
        Azure records a UUID as the instance ID
        First check /sys/class/dmi/id/product_uuid.
        If that is missing, then extracts from dmidecode
        If nothing works (for old VMs), return the empty string
        iRLN(tostpathtisfiletPRODUCT_ID_FILEtfileutilt	read_filetstripR6trun_get_outputt
DMIDECODE_CMDRbR=R(Rh(R/tsRS((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyRihs!cCs*ytj|�SWntk
r%dSXdS(N(tpwdtgetpwnamtKeyErrorR((tusername((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt
get_userentryys
cCs�tj�rtS|j|�}d}y;tjdd�}|dk	r_t|j�d�}nWnt	k
ru}nX|dkr�d}n|dkr�|d|kr�t
StSdS(s�
        Check whether use is a system user. 
        If reset sys user is allowed in conf, return False
        Otherwise, check whether UID is less than UID_MIN
        tUID_MINs/etc/login.defsiidiN(tconftget_allow_reset_sys_userR*R}R(Rstget_line_startingwithR>R<tIOErrorRU(R/R|t	userentrytuidmint
uidmin_defRJ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytis_sys_user�s 			cCs�|j|�}|dk	r/tjd|�dS|dk	rSdd|d|g}ndd|g}|dk	r�|jd|g�n|j|ddj|��dS(	s5
        Create user account with 'username'
        s%User {0} already exists, skip useraddNtuseradds-ms-es-cterr_msgs!Failed to create user account:{0}(R}R(RCRVtextendt _run_command_raising_OSUtilErrorR;(R/R|t
expirationtcommentR�tcmd((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR��sii
cCsh|j|�r'tdj|���ntj|||�}|jdd||gddj|��dS(Ns1User {0} is a system user, will not set password.tusermods-pR�sFailed to set password for {0}(R�RR;Rdtgen_password_hashR�(R/R|tpasswordtcrypt_idtsalt_lentpasswd_hash((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytchpasswd�s	cCst�S(N(R(R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt	get_users�sc
Cs�tj�}tjj|d�}|s
tjj|�s�tj|�tjj|tjd�}dj	|�}tj
||�nd}|r�dj	|�}ndj	|�}tjj|�s�tj
||�tkr�tj
|dj	|��ntj|d�n�tjj|�r�y`tj|�}	|	jd�}
g|
D]}||krD|^qD}
tj|dj|
��Wq�tk
r�}td	j	|���q�XndS(
NR1tsudoerss
#includedir {0}
s{0} ALL=(ALL) NOPASSWD: ALLs{0} ALL=(ALL) ALLs{0}
i s
sFailed to remove sudoer: {0}(Rtget_sudoers_dirRoRpRctisdirRstmkdirtpardirR;tappend_fileR(Rqtfindstr_in_fileR*tchmodRtR<t
write_fileR�R(
R/R|tnopasswdtremovetsudoers_dirtsudoers_wagenttsudoers_filetinclude_sudoers_dirtsudoertcontentR�txRJ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytconf_sudoer�s0
%cCs�ytj�}tj|�}|jd�}g|D]}|jd�s4|^q4}|jdd�tj|dj|��Wn(t	k
r�}t
dj|���nXdS(Ns
sroot:isroot:*LOCK*:14600::::::s"Failed to delete root password:{0}(Rtget_passwd_file_pathRsRtR<t
startswithR
R�RcR�RR;(R/tpasswd_file_pathtpasswd_contenttpasswdR�t
new_passwdRJ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytdel_root_password�s(cCs.tj�}tjj|jd|��}|S(Ns$HOME(Rtget_home_dirRoRptnormpathtreplace(tfilepaththomeRp((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt
_norm_path�scCs$|\}}|j|�}tjj|�}tj|ddd|�tj�}tjj||d�}tjj	|�s�t
dj|���ntj
||�|d}ttj��}	|	j|�}
tj||
�|j|d�|j|d�tj|d�tj|d	�d
S(s.
        Deploy id_rsa and id_rsa.pub
        tmodei�R!s.prvsCan't find {0}.prvs.pubs#unconfined_u:object_r:ssh_home_t:s0i�i�N(R�RoRptdirnameRsR�Rtget_lib_dirRcRqRR;tshutiltcopyfileRtget_openssl_cmdtget_pubkey_from_prvR�tset_selinux_contextR�(R/R|tkeypairRpt
thumbprinttdir_pathtlib_dirtprv_pathtpub_patht	crytputiltpub((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytdeploy_ssh_keypair�s"
cCs&ttj��}|j||�dS(N(RRR�t
crt_to_ssh(R/t
input_filetoutput_filet	cryptutil((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytopenssl_to_opensshscCs�|\}}}|dkr*td��nttj��}|j|�}tjj|�}t	j
|ddd|�|dk	r�|jd�s�tdj|���n|j
d�s�|d7}nt	j||�n�|dk	r�tj�}tjj||d�}	tjj|	�s3td	j|���ntjj||d
�}
|j|	�}t	j|
|�|j|
d�|j|
|�t	j|
d�ntd
��|j|d�t	j||�t	j|d�dS(s'
        Deploy authorized_key
        sPublic key path is NoneR�i�R!sssh-sBad public key: {0}s
s.crtsCan't find {0}.crts.pubs#unconfined_u:object_r:ssh_home_t:s0i�s-SSH public key Fingerprint and Value are Nonei�N(R(RRRR�R�RoRpR�RsR�R�R;tendswithR�R�RcRqtget_pubkey_from_crtR�R�R�tchowner(R/R|tpubkeyRpR�tvalueR�R�R�tcrt_pathR�R�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytdeploy_ssh_pubkeys:
	cCsI|jdkrBtjddt�dkr6t|_qBt|_n|jS(sX
        Checks and sets self.selinux = True if SELinux is available on system.
        swhich getenforcetchk_erriN(R)R(R6trunR*RU(R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytis_selinux_system+s
cCs4|j�r,tjd�d}|jd�StSdS(sS
        Calls shell command 'getenforce' and returns True if 'Enforcing'.
        t
getenforceit	EnforcingN(R�R6RvR�R*(R/RF((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytis_selinux_enforcing6s
cCs}|j�rytjj|�s8tjdj|��dSy tjd||gdt	�Wntj
k
rt}|jSXdSdS(sa
        Calls shell 'chcon' with 'path' and 'con' context.
        Returns exit result.
        sPath does not exist: {0}itchcont	log_erroriN(R�RoRptexistsRCRYR;R6R7RUR	RB(R/Rptcontcmd_err((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR�@s cCs�|rdnd}tj�}tj|�jd�}tj|d|�tj|d|�tj|dttj���tj	|dj
|��tjdj
|r�dnd	��tjd
�dS(Ntnotyess
tPasswordAuthenticationtChallengeResponseAuthenticationtClientAliveIntervals.{0} SSH password-based authentication methods.tDisabledtEnableds8Configured SSH client probing to keep connections alive.(Rtget_sshd_conf_file_pathRsRtR<Rdtset_ssh_configR"tget_ssh_client_alive_intervalR�RcRCRVR;(R/tdisable_passwordtoptiontconf_file_patht	conf_file((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt	conf_sshdPss/devcCs�d}tj|�}xOg|D]}tj||�^qD](}|dk	r;dj|jd��Sq;Wdj||�}tddj|�d|��dS(Ns,(sr[0-9]|hd[c-z]|cdrom[0-9]|cd[0-9]|vd[b-z])s/dev/{0}isJThe following devices were found, but none matched the pattern [{0}]: {1}
ROs!Failed to get dvd device from {0}tinner(RotlistdirR8R=R(R;R?R(R/tdev_dirRGtdevice_listtdevtdvdtinner_detail((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_dvd_device\s,ic	Csb|dkr|j�}n|dkr6tj�}ntjd�d}|j||�}|dk	r~tjd||�dSt	j
j|�s�t	j|�nd}x�t
d|�D]�}	|j||ddddd	gd
t�\}
}|
dkr	tjd�dStjd
|	|d|�|	|kr�tj|�q�q�W|r^tdd|��ndS(Ntmountis{0} is already mounted at {1}RLR�s-otros-tsudf,iso9660,vfatR�isSuccessfully mounted dvds5Mounting dvd failed [retry {0}/{1}, sleeping {2} sec]sFailed to mount dvd deviceR�(R(R�Rtget_dvd_mount_pointR6Rvtget_mount_pointRCRVRoRpR�tmakedirsRPR�R*RDttimetsleepR(R/t	max_retryR�t
dvd_devicetmount_pointt
sleep_timet
mount_listtexistingterrtretrytreturn_code((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt	mount_dvdgs:	
cCs^|dkrtj�}n|j|d|�}|rZ|dkrZtdj|���ndS(NR�is#Failed to unmount dvd device at {0}(R(RR�tumountRR;(R/R�R�R((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt
umount_dvd�s
cCs�|j�}|jdd�d}d}tj||�r>dSytjd|g�WnItjk
r�}|r�dj|j|j	|j
�}t|��q�nXdS(Nt/is	(vd[b-z])tejects7Failed to eject dvd: ret={0}
[stdout]
{1}

[stderr]
{2}(R�trsplitR8tsearchR6R7R	R;RBtstdouttstderrR(R/R�R�R�RGR�RO((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt	eject_dvd�scCs>y|j�Wn)tk
r9}tjdj|��nXdS(Ns Could not load ATAPI driver: {0}(tload_atapiix_modR@RCRDR;(R/RJ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyttry_load_atapiix_mod�scCs�|j�rdStjd�\}}|dkr@td��ntjjd|jd�d�}tjj|�s�tdj	|���ntjd|�\}}|dkr�td	��n|jd
d�s�td��ndS(
Nsuname -risFailed to call uname -rs/lib/moduless
skernel/drivers/ata/ata_piix.kosCan't find module file:{0}sinsmod s,Error calling insmod for ATAPI CD-ROM driverR�is"Failed to load ATAPI CD-ROM driver(
tis_atapiix_mod_loadedR6RvR@RoRpRcRuRqR;(R/trettkern_versiontmod_pathRF((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR�s	icCspxitd|�D]X}tjddt�}|dkrHtjd�tS||dkrtjd�qqWtS(Nislsmod | grep ata_piixR�s2Module driver for ATAPI CD-ROM is already present.i(	RPR6R�R*RCRVRUR�R�(R/R�RR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR�s
c	Cs�|sg}ndg}|j|||g�ytj|d|�}WnAtjk
r�}dj||j|j|j�}|j|fSXd|fS(NR�R�s-[{0}] returned {1}:
 stdout: {2}

stderr: {3}i(R�R6R7R	R;RBRR
(	R/tdeviceR�R�R�R�RFR�tdetail((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR��s		cCs>ytjd|gd|�Wntjk
r9}|jSXdS(NRR�i(R6R7R	RB(R/R�R�R�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR�s
cCs*tjddt�tjddt�dS(Ns-iptables -D INPUT -p udp --dport 68 -j ACCEPTR�s-iptables -I INPUT -p udp --dport 68 -j ACCEPT(R6R�R*(R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytallow_dhcp_broadcast�scCs�|dkrt}ntj�}x�|D]�}tj|�}tjj||�}tjj	|�rttj
|�ntjj	|�r(tjd||�t
j||�q(q(WdS(NsMove rules file {0} to {1}(R(t__RULES_FILES__RR�Rst	base_nameRoRpRcRqR�RCRDR�tmove(R/trules_filesR�tsrct	file_nametdest((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytremove_rules_files�s	
cCs�|dkrt}ntj�}x�|D]z}tj|�}tjj||�}tjj	|�rjq(ntjj	|�r(t
jd||�tj
||�q(q(WdS(NsMove rules file {0} to {1}(R(RRR�RsRRoRpRcRqRCRDR�R(R/RR�RtfilenameR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytrestore_rules_files�s	
cCs(|j�}|j|�}tj|�S(sg
        Convenience function, returns mac addr bound to
        first non-loopback interface.
        (tget_if_namet
get_if_macRdthexstr_to_bytearray(R/tifnametaddr((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_mac_addrscCs�tjtjtjtj�}tjd|d ddjd��}tj|j	�t
|�}|j�djg|dd!D]}d	t
j|�^q~�S(
s=
        Return the mac-address bound to the socket.
        t256siti�slatin-1RLiis%02X(tsockettAF_INETt
SOCK_DGRAMtIPPROTO_UDPtstructtpacktencodetfcntltioctltfilenotIOCTL_SIOCGIFHWADDRtcloseRcRdt
str_to_ord(R/R%tsocktparamRVtchar((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR#
s'
cCs,tj�d}|dkr"dnd}|S(s�
        Return the sizeof struct ifinfo. On 64-bit platforms the size is 40 bytes;
        on 32-bit platforms the size is 32 bytes.
        it32biti i((tplatformtarchitecture(t
python_arctstruct_size((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt_get_struct_ifconf_sizescCsrd}tj�}||}tjdd|�}tjd||j�d�}tjtjtjtj	�}t
j|j�t
|�}tjd|�d}|j�||kr�tjd|�nt|�}	i}
x�td||�D]|}|	||t!jdd�d}t|�dkr�|jd�}
|
|
krjtj|	|d	|d
!�|
|
<qjq�q�W|
S(s�
        Return a dictionary mapping from interface name to IPv4 address.
        Interfaces without a name are ignored.
        itBR)tiLis9SIOCGIFCONF returned more than {0} up network interfaces.islatin-1ii(R&R?tarrayR.R/tbuffer_infoR*R+R,R-R1R2R3tIOCTL_SIOCGIFCONFtunpackR5RCRDRRPtIFNAMSIZR<tlentdecodet	inet_ntoa(R/texpectedR>t
array_sizetbuffR8R7Rtretsizetifconf_bufftifacesRRtifacet
iface_name((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt_get_all_interfaces#s*

	
!,cCs�|j�}|j�}||kr2|||fSxG|j�D]9}|j|�s?tjdj|��|||fSq?WdS(s�
        Return the interface name, and IPv4 addr of the "primary" interface or,
        failing that, any active non-loopback interface.
        sChoosing non-primary [{0}]RL(RLRL(tget_primary_interfaceRRtkeystis_loopbackRCRVR;(R/tprimaryRORQ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_first_ifBsc	CsJd}i}|d}x=td�|jd��D] }|||j�<|d7}q2Wy@|d}|d}|d}|d}|d	}	|d
}
Wn.tk
r�dj|�}tj|�gSXg}xv|dD]j}
|
jd�}t|�dkr�t||||||||
||||	�}|j	|�q�q�W|S(s�
        Construct a list of network route entries
        :param list(str) proc_net_route: Route table lines, including headers, containing at least one route
        :return: List of network route objects
        :rtype: list(RouteEntry)
        icSst|�dkS(Ni(RG(th((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt<lambda>_ss	itIfacetDestinationtGatewaytFlagstMetrictMasks=/proc/net/route is missing key information; headers are [{0}](
tfilterR<RuR{R;RCRYRGRtappend(tproc_net_routetidxtcolumn_indextheader_linetheadert	idx_ifacetidx_desttidx_gwt	idx_flagst
idx_metrictidx_maskROt
route_listtentrytroutet	route_obj((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt_build_route_listTs2
"






cCsey5td��#}tttj|j���SWdQXWn)tk
r`}tjdt	|��nXgS(s	
        Return a list of strings comprising the route table, including column headers. Each line is stripped of leading
        or trailing whitespace but is otherwise unmolested.

        :return: Entries in the text route table
        :rtype: list(str)
        s/proc/net/routeNsCannot read route table [{0}](
topentlisttmapR"Rut	readlinesR@RCRYR(t
routing_tableRJ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytread_route_tablews	&cCs]g}t|�}|dkr.tjd�n+|dkrJtjd�ntj|�}|S(s�
        Construct a list of all network routes known to this system.

        :param list(str) route_table: List of text entries from route table, including headers
        :return: a list of network routes
        :rtype: list(RouteEntry)
        is"/proc/net/route is missing headerss"/proc/net/route contains no routes(RGRCRYR&Rq(troute_tableRmtcount((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_list_of_routes�s	c	s>d�d�d
}|js+tjd�ntj�}��fd�}tt|tj|���}t	|�dkr�d�}t
|d|�}|j}n|d
krd}|js:td	��L}|j
�}tjd
�tjdj|��tjd�t|_Wd
QXq:ntjdj|��t|_|S(s
        Get the name of the primary interface, which is the one with the
        default route attached to it; if there are multiple default routes,
        the primary has the lowest Metric.
        :return: the interface which has the default route
        it00000000s-Examine /proc/net/route for primary interfacecs&|j�ko%t|j��@�kS(N(RR>tflags(Ro(tDEFAULT_DESTtRTF_GATEWAY(sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt
is_default�sicSs
t|j�S(N(R>tmetric(Ro((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt
get_metric�stkeyRLs/proc/net/routesOCould not determine primary interface, please ensure /proc/net/route is corrects Contents of /proc/net/route:
{0}s1Primary interface examination will retry silentlyNsPrimary interface is [{0}](R(R+RCRVR&RwRsR`RzRGtmint	interfaceRrtreadRDR;RUR*(	R/tprimary_interfaceRxRt
candidatesR�t
primary_routetrouting_table_fhtrouting_table_text((R}R~sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyRS�s0			

	cCs|j�|kS(s�
        Indicate whether the specified interface is the primary.
        :param ifname: the name of the interface - eth0, lo, etc.
        :return: True if this interface binds the default route
        (RS(R/R%((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytis_primary_interface�scCs�tjtjtjtj�}|dd}tj|j�t|�}tj	d|dd!�\}|d@dk}|j
s�tjdj
|||��n|j�|S(s=
        Determine if a named interface is loopback.
        R)itHiiis2interface [{0}] has flags [{1}], is loopback [{2}](R*R+R,R-R1R2R3tIOCTL_SIOCGIFFLAGSR.RER+RCRVR;R5(R/R%Rxtifname_bufftresultR|t
isloopback((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyRU�s	
cCsdS(s�
        OS specific, this should return the decoded endpoint of
        the wireserver from option 245 in the dhcp leases file
        if it exists on disk.
        :return: The endpoint if available, or None
        N(R((R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_dhcp_lease_endpoint�sc	Cs|d}d}d}d}d}d}tjd�}tjdj|��x�tj|�D]�}t|�j�}	||	krYd}
d}t	}x�|	j
�D]�}
|
j|�r�d}
t	}q�||
krZd|
kr�t}q;yV|
j
d	d
�djd�}tjj||�}|tjj�kr6t}nWq;tjd
j|
��q;Xq�||
kr�tjdj|
|dk	|��|r;|
dk	r;|
}tjdj|��q;q�|j|
�}|dk	r�djt|jd�d�t|jd�d�t|jd�d�t|jd
�d��}
q�q�WqYqYW|dk	rktjdj|��n
tjd�|S(s�
        Try to discover and decode the wireserver endpoint in the
        specified dhcp leases path.
        :param pathglob: The path containing dhcp lease files
        :return: The endpoint if available, otherwise None
        tleasesoption unknown-245texpiret}s%Y/%m/%d %H:%M:%SsV\s*option\s+unknown-245\s+([0-9a-fA-F]+):([0-9a-fA-F]+):([0-9a-fA-F]+):([0-9a-fA-F]+);s looking for leases in path [{0}]tnevert ii����t;s"could not parse expiry token '{0}'s$dhcp entry:{0}, 245:{1}, expired:{2}sfound endpoint [{0}]s{0}.{1}.{2}.{3}iiiiscached endpoint found [{0}]scached endpoint not foundN(R(R8R9RCRVR;tglobRrR�RUt
splitlinesR�R*R<RutdatetimetstrptimetutcnowRYR=R>R?(tpathglobtendpointtHEADER_LEASEtHEADER_OPTION_245t
HEADER_EXPIREtFOOTER_LEASEtFORMAT_DATETIMEt
option_245_ret
lease_filetleasestcached_endpointtoption_245_matchtexpiredRHt
expire_stringtexpire_date((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_endpoint_from_leases_path�s\			
)
cCs�ybdddg}tj|�}x9|jd�D](}|jd�sU|jd�r1tSq1WtSWn3tk
r�}tjdt	|�t	|��tSXdS(NtipRotshows
s0.0.0.0 sdefault s-Cannot get the routing table. {0} failed: {1}(
R6R7R<R�R*RUR	RCRDR(R/t	route_cmdtroutesRoRJ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytis_missing_default_route'scCsUd}t}xB|sP|j�d}t|�dk}|stjd�qqW|S(NRLii(R*RWRGR�R�(R/tif_nametif_found((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR"3s	cCs|j�dS(Ni(RW(R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_ip4_addr=scCsBy)ddddd|g}tj|�SWntk
r=dSXdS(NR�Rotadds255.255.255.255R�RL(R6R7R	(R/R%R�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytset_route_for_dhcp_broadcast@s

cCsAy)ddddd|g}tj|�Wntk
r<nXdS(NR�Rotdels255.255.255.255R�(R6R7R	(R/R%R�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytremove_route_for_dhcp_broadcastGs

cCstS(N(RU(R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytis_dhcp_availableNscCstS(N(R*(R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytis_dhcp_enabledQscCsdS(N((R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytstop_dhcp_serviceTscCsdS(N((R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytstart_dhcp_serviceWscCsdS(N((R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt
start_networkZscCsdS(N((R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytstart_agent_service]scCsdS(N((R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytstop_agent_service`scCsdS(N((R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytregister_agent_servicecscCsdS(N((R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytunregister_agent_servicefscCsdS(N((R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytrestart_ssh_serviceiscCsBy)ddd|d|g}tj|�SWntk
r=dSXdS(s&
        Add specified route 
        R�RoR�tviaRLN(R6R7R	(R/tnettmasktgatewayR�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt	route_addls

cCs#g|j�D]}t|�^q
S(N(R<R>(ttexttn((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt_text_to_pid_listvscCs5ytjtj|��SWntk
r0}gSXdS(N(R&R�R6R7R	(Rt	exception((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt
_get_dhcp_pidzscCs|jddg�S(Ntpidoftdhclient(R�(R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_dhcp_pid�scCs-tjd|�|jd|gdt�dS(Ns
/etc/hostnamethostnameR�(RsR�t_run_command_without_raisingR*(R/R�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytset_hostname�scCstd}dddg}xX|D]P}tjj|�s:qntj||�rPdStj|ddj|��qWdS(Ns7^[^#]*?send\s*host-name.*?(<hostname>|gethostname[(,)])s/etc/dhcp/dhclient.confs/etc/dhcp3/dhclient.confs/etc/dhclient.confssend host-namessend host-name "{0}";(RoRpRqRstfindre_in_filetupdate_conf_fileR;(R/R�tautosendtdhclient_filesR�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytset_dhcp_hostname�s
	icCs�|d}x�td|�D]�}tjdj|�d||krJdgng�}|dkrcdStjdj||��||kr�tjdj|��tj|�qtjd�qWdS(Nisifdown {0} && ifup {0}texpected_errorsis&failed to restart {0}: return code {1}sretrying in {0} secondssexceeded restart retries(	RPR6R�R;RCRDRVR�R�(R/R%tretriesRtretry_limittattemptR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt
restart_if�s
3cCs7|j|�|j|�|j�}|j|�dS(N(R�tset_hostname_recordR"R�(R/R�R%((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytpublish_hostname�s

cCs@x9tjd�D](}|jd�r|j||�qqWdS(Ns
/sys/blocktsd(RoR�R�tset_block_device_timeout(R/ttimeoutR�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytset_scsi_disks_timeout�scCs�|dk	r�|dk	r�dj|�}tj|�}|j�dj�}||kr�tj||�tjd||�q�ndS(Ns/sys/block/{0}/device/timeoutis,Set block dev timeout: {0} with timeout: {1}(	R(R;RsRtR�trstripR�RCRV(R/R�R�t	file_pathR�toriginal((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR��s	cCsi|re|rexV|jd�D]B}tj||�r|j�}t|�dkrZ|dSdSqWndS(s�
        Example of mountlist:
            /dev/sda1 on / type ext4 (rw)
            proc on /proc type proc (rw)
            sysfs on /sys type sysfs (rw)
            devpts on /dev/pts type devpts (rw,gid=5,mode=620)
            tmpfs on /dev/shm type tmpfs
            (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
            none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
            /dev/sdb1 on /mnt/resource type ext4 (rw)
        s
iN(R<R8RRGR((R/t	mountlistRRnttokens((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR��s%ccsntjjt�rjxUtjt�D]A}tjtjjt|d��}|jd�}||fVq"WndS(s�
        Enumerate all storage device IDs.

        Args:
            None

        Returns:
            Iterator[Tuple[str, str]]: VmBus and storage devices.
        t	device_ids{}
N(	RoRpR�tSTORAGE_DEVICE_PATHR�RsRtRcRu(tvmbustdeviceidtguid((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt_enumerate_device_id�s
!c
Csdd}tjdj||��y	xtj�D]�\}}|j|�sV||kr/x�tjt	|�D]�\}}}|j
d�}|ddkr�||ks�|dj
d�ddkr�|d}|SxJ|D]B}	d|	kr�d|	j
d�dkr�|	j
d�d	}|Sq�WqjWq/q/WWn5ttfk
r_}
tj
d
||t|
��nXdS(s
        Search the filesystem for a device by ID or prefix.

        Args:
            gen1_device_prefix (str): Gen1 resource disk prefix.
            gen2_device_id (str): Gen2 resource device ID.

        Returns:
            str: The found device.
        s%Searching gen1 prefix {0} or gen2 {1}Ri����tblocki����t:t1iis(Error getting device for {0} or {1}: {2}N(R(RCRVR;R&R�R�RotwalkR�R<tOSErrorR�RDR(tgen1_device_prefixtgen2_device_idRR�R�troottdirstfilestroot_path_partstdtexc((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytsearch_for_resource_disk�s&
#

% cCsy|dkrd
Sd}|dkr5d}|d}ndj||�}tjd|dt�}tjd	j|��|S(s>
        Return device name attached to ide port 'n'.
        iR{it00000001is
{0}-000{1}R�R�sFound device: {0}N(R(R;R&R�tGEN2_DEVICE_IDRCRV(R/tport_idtg0R�R((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytdevice_for_ide_ports
		cCstjtj�d|�dS(Ntcontents(RsR�Rtget_published_hostname(R/R�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR�scCs�tj�}tjj|�su|j�}|dkrRtjd�t	j
�}ntjd||�|j|�ntj
|�}|S(Ns.Retrieving hostname using socket.gethostname()sLPublished hostname record does not exist, creating [{0}] with hostname [{1}](RRRoRpR�t_get_cloud_init_hostnameR(RCRVR*tgethostnameR�RsRt(R/thostname_recordR�trecord((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_hostname_records
cCs�d}ydtjj|�ritjd|�t|d��}tj|�}WdQXd|kri|dSnWn)tk
r�}tj	dt
|��nXdS(s�
        Retrieves the hostname set by cloud-init; returns None if cloud-init did not set the hostname or if there is an
        error retrieving it.
        s /var/lib/cloud/data/set-hostnamesRetrieving hostname from {0}trNR�sError retrieving hostname: {0}(RoRpR�RCRVRrtjsontloadR@RDRR((t
hostname_filetfile_t
hostname_infoR�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR,s
cCse|j|�r"tjd|�n|jddg�|jddd|g�|j|dt�dS(Ns){0} is a system user. Will not delete it.ttouchs
/var/run/utmptuserdels-fs-rR�(R�RCRYR�R�RU(R/R|((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytdel_accountGs
cCstj|�jd�S(Nsutf-8(tbase64t	b64decodeRH(R/tdata((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytdecode_customdataOscCstjd�tjd�dS(NtSC_PAGE_SIZEt
SC_PHYS_PAGESiii(Rotsysconf(R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt
get_total_memRscCs
tj�S(N(tmultiprocessingt	cpu_count(R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_processor_coresVscCshy t|�}tj|d�WnAttfk
r:tStk
rc}|jtjkr_t	StSXt	S(Ni(
R>Rotkillt
ValueErrort	TypeErrorR*R�terrnotEPERMRU(R/tpidtos_error((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytcheck_pid_aliveYscCs
tjdkS(Nii I(tsystmaxsize(R/((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytis_64bitescCsUd}ytjd�}Wn5ttfk
rP}tjdj|j���nX|S(sE
        Get the contents of /proc/stat.
        # cpu  813599 3940 909253 154538746 874851 0 6589 0 0 0
        # cpu0 401094 1516 453006 77276738 452939 0 3312 0 0 0
        # cpu1 412505 2423 456246 77262007 421912 0 3276 0 0 0

        :return: A single string with the contents of /proc/stat
        :rtype: str
        s
/proc/statsCouldn't read /proc/stat: {0}N(	R(RsRtR�R�RCRDR;tstrerror(tresultstex((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt_get_proc_statiscCsrd}tj�}|dk	rnxM|j�D]<}tj|�r+td�|j�dd!D��}Pq+q+Wn|S(s�
        Compute the number of USER_HZ units of time that have elapsed in all categories, across all cores, since boot.

        :return: int
        icss|]}t|�VqdS(N(R>(t.0RR((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pys	<genexpr>�siiN(R&R*R(R�tALL_CPUS_REGEXR=tsumR<(t
system_cput	proc_statRH((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pytget_total_cpu_ticks_since_boot}s cCsi}ddddg}dddddg}dddddg}ytj|�}Wn7tjk
r�}tjdt|��|r�d	SiSX|r�d
�}||�}	||�}
dj||||	||
�S|j||�|j||t	j
d�|j||t	jd
�|SdS(s%
        Capture NIC state (IPv4 and IPv6 addresses plus link state).

        :return: By default returns a dictionary of NIC state objects, with the NIC name as key. If as_string is True
                 returns the state as a string
        :rtype: dict(str,NetworkInformationCard)
        R�s-as-otlinks-4taddresss-6s"Could not fetch NIC link info: {0}RLcSs5ytj|�SWntjk
r0}t|�SXdS(N(R6R7R	R"(Rt
command_error((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR7�ss9Executing {0}:
{1}
Executing {2}:
{3}
Executing {4}:
{5}
san IPv4 addresssan IPv6 addressN(R6R7R	RCR\RR;t_update_nic_state_allt_update_nic_stateRtadd_ipv4tadd_ipv6(R/t	as_stringtstatetall_commandtinet_commandt
inet6_commandt
all_outputR3R7tinet_outputtinet6_output((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt
get_nic_state�s$	cCs^xW|j�D]I}tj|�}|r
|jd�}t||jd��||<q
q
WdS(Nii(R�tIP_COMMAND_OUTPUTR=R?R(R9tcommand_outputRnR�tname((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR4�s
c	Cs�y�tj|�}x}|j�D]o}tj|�}|r|jd�}||krr||||jd��q�tjdj||��qqWWn8tj	k
r�}tjddj
|�t|��nXdS(s�
        Update the state of NICs based on the output of a specified ip subcommand.

        :param dict(str, NetworkInterfaceCard) state: Dictionary of NIC state objects
        :param str ip_command: The ip command to run
        :param handler: A method on the NetworkInterfaceCard class
        :param str description: Description of the particular information being added to the state
        iis'Interface {0} has {1} but no link states[{0}] failed: {1}R�N(R6R7R�RAR=R?RCRYR;R	RcR"(	R9t
ip_commandthandlertdescriptionRFRnR�tinterface_nameR3((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR5�s
	$cCs/ytj|d|�Wntk
r*nXdS(NR�(R6R7R@(R�R�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR��s
cCsMxF|D]>}ytj|d|�Wqtk
rD|r@qnPqXqWdS(NR�(R6R7R@(tcommandsR�tcontinue_on_errorR�((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt&_run_multiple_commands_without_raising�s

cCs�ytj|dtd|�SWnptjk
r\}tdj||j|j|j���n4t	k
r�}tdj|dt
|����nXdS(NR�tinputs*{0}, Retcode: {1}, Output: {2}, Error: {3}s{0}, Retcode: {1}, Error: {2}i����(R6R7RUR	RR;RBRR
R@R(R�R�t	cmd_inputRJ((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR��s'N(kt__name__t
__module__R0tstaticmethodR-R2R3R(RKR5RTRXRZR_RhRmRnRiR}R�R�R�R�R*R�R�R�R�R�R�R�R�R�R�R�RURRRRRRR�RRRR!R'R#R?RRRWRqRwRzRSR�RUR�R�R�R"R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RR�RRRRRRR#tpropertyR&R*R0R@R4R5R�RJR�(((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyR&�s�	#					.						!				&		
		$		
	

			
		#	-				>		
														
			

			
	+								% 
(LRR�RR1R�R	RRoR;RyR8R�R*R.R$R�RRBtazurelinuxagent.common.conftcommonRtazurelinuxagent.common.loggerRCt%azurelinuxagent.common.utils.fileutiltutilsRst&azurelinuxagent.common.utils.shellutilR6t%azurelinuxagent.common.utils.textutilRdt azurelinuxagent.common.exceptionRtazurelinuxagent.common.futureRRt&azurelinuxagent.common.utils.cryptutilRt-azurelinuxagent.common.utils.flexible_versionRt(azurelinuxagent.common.utils.networkutilRRRR	RR9RMRNR
RRRRRRRR R#R%R:R,RUR4RwRrt
IGNORECASERbRDR�R4RFRAR�R�tobjectR&(((sI/usr/lib/python2.7/site-packages/azurelinuxagent/common/osutil/default.pyt<module>sv