o i©¹ds™ã@sÎddlZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl mZddlmZddlmZdd lmZdd lmZmZmZmZdd lmZeeeee d œZGd d„dƒZdS)éN)Úquote)Úload)Ú InitSystem)ÚJujuSSH)ÚSSHControlPersist)ÚLocalTransport)Ú OCTransport)ÚSaltStackMaster)ÚCommandTimeoutExceptionÚConnectionExceptionÚUnsupportedHostExceptionÚInvalidTransportException)Ú parse_version)ÚlocalÚcontrol_persistÚocÚ saltstackÚjujuc@s°eZdZ  dgdd„Zedd„ƒZdd„Zd d „Zd d „Zed d„ƒZ dd„Z dd„Z dd„Z dd„Z dhdd„Zedd„ƒZdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zdhd.d/„Zd0d1„Zd2d3„Zd4d5„Zd6d7„Z  did9d:„Zd;d<„Zd=d>„Z d?d@„Z!dAdB„Z"dCdD„Z#dEdF„Z$dGdH„Z%dIdJ„Z&dKdL„Z'dMdN„Z(dOdP„Z)dQdR„Z*dSdT„Z+dUdV„Z,dWdX„Z-dYdZ„Z.d[d\„Z/d]d^„Z0d_d`„Z1dadb„Z2dcdd„Z3dedf„Z4dS)jÚSosNodeNTc CsÌ| ¡|_||_|d|_| ¡|d|_|d|_|d|_|d|_d|_ d|_ d|_ d|_ i|_ i|_|p<|jj|_|jjsK|jjsK|j|j_|rQ||j_d|_d|_d|_g|_dgggg|ddœ|_d |_t d ¡|_t d ¡|_| |¡|_|jjr‰|jjd k|_z |j  |j¡Wnt!y¦}z| "d |¡‚d}~ww| #¡|_ |jj |_ |j rº|jj$rºd}|j%râ|rä|j sÉ|j &¡dS|j rÔ| '¡rÔd|j _(|j j(rÜ| )¡| *¡dSdSdS)NÚ cmdlineoptsÚtmpdirÚhostlenÚ need_sudoÚ sos_optionsFÚsos_cmd)ÚversionÚenabledÚdisabledÚoptionsÚpresetsrÚ sosreportÚsosÚsos_uiÚrootz!Unable to open remote session: %s)+ÚstripÚaddressÚcommonsÚoptsÚ_assign_config_optsrrrrrÚhostÚclusterÚhostnameÚ sos_env_varsÚ _env_varsÚpasswordÚ _passwordÚ nopasswd_sudoÚsudo_pwÚsos_pathÚ retrievedÚhash_retrievedÚ file_listÚsos_infoÚsos_binÚloggingÚ getLoggerÚsoslogÚui_logÚ_load_remote_transportÚ _transportÚ default_userÚconnectÚ ExceptionÚ log_errorÚdetermine_host_policyÚno_localÚ connectedÚ disconnectÚcheck_in_containerÚ containerizedÚcreate_sos_containerÚ_load_sos_info)Úselfr%r&r.Ú local_sudoÚ load_factsÚerr©rNú7/usr/lib/python3/dist-packages/sos/collector/sosnode.pyÚ__init__*st       ú   €þ     ÷zSosNode.__init__cCs|jr|jjSdS)NT)r=rD©rJrNrNrOrDlszSosNode.connectedcCs|j ¡dS)zDWrapper to close the remote session via our transport agent N)r=rErQrNrNrOrEsszSosNode.disconnectcCsv|jdvrd|_t|j|ƒS|jjt ¡vr t|jj|j|ƒS|jjdkr5| d|jj¡t|jjƒ‚t |j|ƒS)z…Determine the type of remote transport to load for this node, then return an instantiated instance of that transport )Ú localhostz 127.0.0.1TÚautoz6Connection failed: unknown or unsupported transport %s) r%rrr'Ú transportÚ TRANSPORTSÚkeysrAr r)rJr&rNrNrOr<xs   ÿÿ  zSosNode._load_remote_transportcCsd |j|jd|¡S)Nz {:<{}} : {}é)ÚformatÚ _hostnamer©rJÚmsgrNrNrOÚ_fmt_msg‰szSosNode._fmt_msgcCsp|js5|jrtj ¡|_|jS| d¡}|ddkr5|d d¡D]}|s&q!| d¡}|d|j|d<q!|jS)Nz env --nullÚstatusrÚoutputúú=rW)r-rÚosÚenvironÚcopyÚ run_commandÚsplit)rJÚretÚlnÚ_valrNrNrOÚenv_varsŒs  ù  zSosNode.env_varscCs`||_|j d|j¡|j d|jj¡|j d|jd¡|j dd¡|j d|jj¡dS) z>Set the manifest section that this node will write to r+ÚpolicyÚ sos_versionrÚfinal_sos_commandÚrTN)ÚmanifestÚ add_fieldrYr)Údistror6r=Úname)rJrnrNrNrOÚset_node_manifest›s zSosNode.set_node_manifestcCs<tj d¡r | d¡dStj d¡dur| d¡dSdS)zV Tries to identify if we are currently running in a container or not. z/run/.containerenvz/Found /run/.containerenv. Running in container.TÚ containerNz/Found env var 'container'. Running in containerF)raÚpathÚexistsÚ log_debugrbÚgetrQrNrNrOrF¥s   zSosNode.check_in_containercCsæ|jjrq|jj|jj| ¡|jjd}|j|dd}|ddvrf|ddkr@d|dvr3| d ¡t ‚d |dvr@| d ¡t ‚|j|j  ¡dd}|dd kr[|  d |jj ¡dS| d|d¡t ‚| d|d¡t ‚dS)zJIf the host is containerized, create the container we'll be using )ÚimageÚauthÚ force_pullT©Ú need_rootr])ré}r}zunable to retrieve auth tokenr^zHCould not pull image. Provide either a username and password or authfilezunknown: Not foundz%Specified image not found on registryrzTemporary container %s createdz*Could not start container after create: %sz&Could not create container on host: %sN) r)rGrHr'rxÚget_container_authÚforce_pull_imagerdrAr@Úrestart_sos_containerÚlog_infoÚsos_container_name)rJÚcmdÚresrfrNrNrOrH±sDý   ÿ   ÿ ÿÿÿÝzSosNode.create_sos_containercCsB|jjr|jjd |jj|jj¡S|jjd |jjp|jj¡S)zrDetermine what the auth string should be to pull the image used to deploy our temporary container Údefault) r'Ú registry_userr)ÚruntimesÚfmt_registry_credentialsÚregistry_passwordÚfmt_registry_authfileÚregistry_authfileÚcontainer_authfilerQrNrNrOr~Ùs þ ÿzSosNode.get_container_authFcCs6z|jd||d}|ddkWStyYdSw)z3Checks for the presence of fname on the remote nodezstat %sr{r]rF)rdr@)rJÚfnamer|r„rNrNrOÚ file_existsçs  ÿzSosNode.file_existscCs|jr d|jvr |jS|jS)NrR)r+r%rQrNrNrOrYïszSosNode._hostnamecCsd}t |d|¡S)zUAttempts to obfuscate sensitive information in log messages such as passwordsz>(?P(pass|key|secret|PASS|KEY|SECRET).*?=)(?P.*?\s)z\g****** )ÚreÚsub)rJr[ÚregrNrNrOÚ_sanitize_log_msgõszSosNode._sanitize_log_msgcCs|j | |¡¡dS)z:Format a ui message that includes host name and formattingN)r;Úinfor\rZrNrNrOÚui_msgûszSosNode.ui_msgcCó0t ¡dd}d|j||f}|j |¡dS)z#Used to print and log info messagesrWéú [%s:%s] %sN)ÚinspectÚstackrYr:r“©rJr[ÚcallerÚlmsgrNrNrOrÿózSosNode.log_infocCr•)z$Used to print and log error messagesrWr–r—N)r˜r™rYr:ÚerrorršrNrNrOrArzSosNode.log_errorcCs:| |¡}t ¡dd}d|j||f}|j |¡dS)z$Used to print and log debug messagesrWr–r—N)r’r˜r™rYr:Údebug)rJr[r›rNrNrOrv s zSosNode.log_debugcCs&|jjr dt|ƒS|jrd|S|S)z‚If we need to provide a sudo or root password to a command, then here we prefix the command with the correct bits zsu -c %sz sudo -S %s)r'Ú become_rootrr)rJrƒrNrNrOÚ _format_cmds  zSosNode._format_cmdc Csœd}d}|jjdur'|jj |jj¡}|dur&d |d¡}|dr&|d}n|j|jjddd}|ddkrC|d  ¡ d ¡\}}}|ryt | d¡ƒd krR|d 7}z |d | d¡d7}Wnt yx}z |  d|¡WYd}~nd}~ww||j d<|j drŽ|  d|j d¡n|j|jjksš| d¡d|_dS| d¡r§d|_d|j}|j|ddd}|ddkrÁ| |d ¡| d¡rÌ| ¡dSdS)zLQueries the node for information about the installed version of sos NÚ.rÚreleaseT©Ú use_containerr|r]rr^ú-éú.0ú-%sz%Unable to fully parse sos release: %szsos version is %sz!sos is not installed on this nodeFz4.0z sos reportz%s -lú3.6)r)Úcontainer_version_commandÚpackage_managerÚ pkg_versionÚ sos_pkg_nameÚjoinrdr$reÚlenr@rvr6rr%r'ÚprimaryrArDÚcheck_sos_versionr7Ú_load_sos_pluginsÚ_load_sos_presets) rJÚverÚrelÚpkgÚpkgsÚ_rMrƒÚsosinforNrNrOrIsN € ÿ €ÿ        ÿzSosNode._load_sos_infocCspd|j}|j|ddd}|ddkr4|d ¡D]}| ¡ d¡r3| d¡d ¡}|jd  |¡qdSdS) Nz%s --list-presetsTr¤r]rr^zname:rWr)r7rdÚ splitlinesr$Ú startswithrer6Úappend)rJrƒr„ÚlineÚpnamerNrNrOr´Os  €üzSosNode._load_sos_presetsc Cs’d}d}d}d}d}|d|}|d|}|d|} |dd} | ||¡|jd<| ||¡|jd <| | |¡|jd <| | |d ¡|jd <dS) Nz,The following plugins are currently enabled:z-The following plugins are currently disabled:z4The following options are available for ALL plugins:z+The following plugin options are available:z Profiles:z(.*?)z rrrTÚprofiles)Ú_regex_sos_helpr6) rJrºÚENABLEDÚDISABLEDÚ ALL_OPTIONSÚOPTIONSÚPROFILESÚ enableregÚdisregÚoptregÚproregrNrNrOr³Xs    zSosNode._load_sos_pluginsc Csxg}t ||tj¡D]/}| ¡D](}|s)z | | ¡d¡Wqty(Yqw| d¡}| dd„|Dƒ¡qq |S)Nrú,css |] }| ¡r| ¡VqdS©N©r$)Ú.0ÚprNrNrOÚ ts€z*SosNode._regex_sos_help..)rÚfindallÚSr»r½rer@Úextend)rJÚregexrºÚis_listr„Úresultr¾ÚrrNrNrOrÁis  ÿ ø zSosNode._regex_sos_helpc CsVz| d|¡|j |¡WSty*}z| d||f¡WYd}~dSd}~ww)z1Reads the specified file and returns the contentszReading file %szException while reading %s: %sNrm)rr=Ú read_filer@rA)rJÚto_readrMrNrNrOrØws€þzSosNode.read_filec Csp|jr| d|jdj¡|jdSti|jjtƒd|jj |  d¡d}|r1| d|j¡|S|  d¡t ‚)z[Attempts to identify the host installation against supported distributions zusing local policy %srjTz/etc/os-release)ÚcacheÚsysrootÚinitÚ probe_runtimeÚ remote_execÚ remote_checkzloaded policy %s for hostz4Unable to determine host installation. Ignoring node) rrr&rprr'rÛrr=rdrØrAr )rJr)rNrNrOrB€s ÿ ý zSosNode.determine_host_policyc sj‡fdd„}||ƒ}ztˆjdƒ}t|ƒ}||kWSty4}zˆ d|¡WYd}~dSd}~ww)aChecks to see if the sos installation on the node is AT LEAST the given ver. This means that if the installed version is greater than ver, this will still return True :param ver: Version number we are trying to verify is installed :type ver: ``str`` :returns: True if installed version is at least ``ver``, else False :rtype: ``bool`` c s–z-| d¡d}d}d|vrd| d¡d d¡d}t| d¡ƒdkr)|d7}||WStyJ}zˆ d||f¡|WYd}~Sd}~ww) Nr¦rrméÿÿÿÿr¢r§r¨zUnable to format '%s': %s)rer°r@rv)rµÚ_fverÚ_relrMrQrNrOÚ_format_versions €þz2SosNode.check_sos_version.._format_versionrzError checking sos version: %sNF)rr6r@rA)rJrµrãÚ_verÚ _node_verÚ _test_verrMrNrQrOr²’s  €þzSosNode.check_sos_versioncCs|jsdS|jj |¡duS)z2Checks if a given package is installed on the nodeFN)r)r¬Ú pkg_by_name)rJr·rNrNrOÚ is_installed¶szSosNode.is_installedé´c Cs¾|js2|js2| d¡z|j |j¡}|s| d¡t‚Wnty1}z| d|¡‚d}~ww|r>|jj r>|j  |¡}|rE|  |¡}d|vrKd}|rU|j } |   |¡}|j |||||¡S)ašRuns a given cmd, either via the SSH session or locally Arguments: cmd - the full command to be run timeout - time in seconds to wait for the command to complete get_pty - If a shell is absolutely needed to run a command, set this to True need_root - if a command requires root privileges, setting this to True tells sos-collector to format the command with sudo or su - as appropriate and to input the password use_container - Run this command in a container *IF* the host is containerized z-Node is disconnected, attempting to reconnectzFailed to reconnect to nodez#Error while trying to reconnect: %sNÚatomicT)rDrrvr=Ú reconnectr/r r@r)rGÚformat_container_commandr¡riÚupdaterd) rJrƒÚtimeoutÚget_ptyr|r¥ÚenvÚ reconnectedrMÚ_cmd_envrNrNrOrd¼s2   þ€þ    ÿzSosNode.run_commandcCsVz| ¡}|r | |¡n| d¡|jr| ¡|_Wn ty$Ynw| ¡dS)z.Run an sos report on the node, then collect itz'Unable to determine path of sos archiveN)Úexecute_sos_commandÚfinalize_sos_pathrAr2Úretrieve_sosreportr3r@Úcleanup)rJrtrNrNrOr ãs   € ÿ zSosNode.sosreportcCó||jdvS)z/Verifies if the given preset exists on the noder©r6)rJÚpresetrNrNrOÚ_preset_existsñózSosNode._preset_existscs&t‡fdd„|jd|jdfDƒƒS)z/Verifies if the given plugin exists on the nodec3ó|]}ˆ|vVqdSrÌrN)rÎÚs©ÚpluginrNrOrÐ÷ó€z)SosNode._plugin_exists..rr)Úanyr6©rJrÿrNrþrOÚ_plugin_existsõs ÿzSosNode._plugin_existscCr÷)z6Checks to see if the plugin is default enabled on noderrørrNrNrOÚ_check_enabledúrûzSosNode._check_enabledcCr÷)z7Checks to see if the plugin is default disabled on noderrørrNrNrOÚ_check_disabledþrûzSosNode._check_disabledcCsR| d¡d}| |¡sdS| |¡r||jjvrdS| |¡r'||jdvSdS)z÷Attempts to verify that the given option is available on the node. Note that we only get available options for enabled plugins, so if a plugin has been force-enabled we cannot validate if the plugin option is correct or notr¢rFrT)rerrr'Úenable_pluginsrr6)rJÚoptÚplugrNrNrOÚ_plugin_option_existss    zSosNode._plugin_option_existscsd ‡fdd„|Dƒ¡S)z^Returns a comma delimited list for sos plugins that are confirmed to exist on the noderËc3s|] }ˆ |¡r|VqdSrÌ©r©rÎÚorQrNrOrÐs€z,SosNode._fmt_sos_opt_list..)r¯)rJr'rNrQrOÚ_fmt_sos_opt_listszSosNode._fmt_sos_opt_listcCs ||_dS)zVExpose the node to the cluster profile determined for the environment N)r*)rJr*rNrNrOÚ set_clusters zSosNode.set_clustercsX|jjr|js |jj|_n | d|jj¡|jjr,|jjD] }||jvr+|j |¡q|jjrE|jjD]‰ˆ|jvrD|jjˆ|jˆ<q4|jjrl|jjD]‰t ‡fdd„|j Dƒƒskdˆ|jjˆf}|j  |¡qM|j  |¡r|jj |j  |¡WdƒdS1sˆwYdS|jj |j |¡WdƒdS1s¥wYdS)a+This is used to modify the sos report command run on the nodes. By default, sos report is run without any options, using this will allow the profile to specify what plugins to run or not and what options to use. This will NOT override user supplied options. zYCluster specified preset %s but user has also defined a preset. Using user specification.c3rürÌrNr ©rrNrOrÐ:rz2SosNode.update_cmd_from_cluster..ú%s=%sN)r*Ú sos_presetrùrÚ sos_pluginsrr½rÚsos_plugin_optionsrÚplugoptsÚcheck_node_is_primaryÚlockÚset_primary_optionsÚset_node_options)rJrÚoptionrNrrOÚupdate_cmd_from_clusters> þ   €  €  ÿ €  "ÿ "ÿzSosNode.update_cmd_from_clustercCsJt|jjƒ|_t|jjƒ|_t|jjƒ|_t|jjƒ|_t|jjƒ|_dS)zˆFrom the global opts configuration, assign those values locally to this node so that they may be acted on individually. N)Úlistr'Ú only_pluginsÚ skip_pluginsrrrùrQrNrNrOr(Gs zSosNode._assign_config_optscs‚ˆjd}ˆ ¡}|rd|t|ƒf}g}ˆ d¡r-ˆjjdkr-| dttˆjjƒƒ¡ˆ d¡rCˆjjrC| dttˆjjƒƒ¡ˆ d¡riˆjj rQ| d ¡ˆjj rZ| d ¡ˆjj ri| d tˆjj ƒ¡ˆ d ¡r’ˆjj r€| d td  ˆjj ¡ƒ¡ˆjjr’| dtd  ˆjj¡ƒ¡ˆ d¡r¨ˆjjr¨| dttˆjjƒƒ¡ˆ d¡s²ˆ d¡rΈjjdkrÁ| dˆjj¡ˆjjrÎ| dˆjj¡ˆ d¡rêˆjjrá| dˆjj›¡ˆjjrê| d¡ˆ ¡| dtj  ˆjjˆj¡¡}ˆjD]}ˆj|}| d|›d|r|nd›¡qÿˆjr9‡fdd„ˆjDƒ}|r9| d td  d!d"„|Dƒ¡ƒ¡ˆjrWˆ ˆj¡rO| d#tˆjƒ¡nˆ d$ˆj¡ˆj r¯‡fd%d„ˆj Dƒ}t!|ƒt!ˆj ƒkrt"t#ˆj ƒt#|ƒƒ}ˆ d&|¡ˆ $ˆj ¡} | r“| d't| ƒ¡d(|d  |¡fˆ_%ˆ &d)ˆj%¡ˆj' (d*ˆj%¡d+Sˆj)rê‡fd,d„ˆj)Dƒ} t!| ƒt!ˆj)ƒkrÙt"t#ˆj)ƒt#| ƒƒ} ˆ d-| ¡ˆ $| ¡} | rê| d.t| ƒ¡ˆj*r%‡fd/d„ˆj*Dƒ}t!|ƒt!ˆj*ƒkrt"t#ˆj*ƒt#|ƒƒ} ˆ d0| ¡ˆ $|¡}|r%| d1t|ƒ¡d(|d  |¡fˆ_%ˆ &d)ˆj%¡ˆj' (d*ˆj%¡d+S)2zZUse host facts and compare to the cluster type to modify the sos command if neededrz%s %s rªéz --threads=%sz3.7z--plugin-timeout=%sz3.8z--allow-system-changesz --no-env-varsz --since=%sz4.1z--skip-commands=%srËz--skip-files=%sz4.2z--cmd-timeout=%sz4.3z4.2-13rSz--container-runtime=%sz--namespaces=%sz4.5.2z--journal-size=z--low-priorityr z--ú rmcs8g|]}ˆ | d¡d¡rˆ | d¡d¡r|‘qS)r¢rr`)rrer r rQrNrOÚ  s ÿ þz,SosNode.finalize_sos_cmd..z-k %scss|]}|VqdSrÌrNr rNrNrOrФs€z+SosNode.finalize_sos_cmd..z --preset=%sz?Requested to enable preset %s but preset does not exist on nodecóg|] }ˆ |¡r|‘qSrNr r rQrNrOr ®ózBRequested plugins %s were requested to be enabled but do not existz--only-plugins=%sz%s %szFinal sos command set to %srlNcr!rN)rr rQrNrOr ½r"zARequested to skip plugins %s, but plugins are already not enabledz--skip-plugins=%scs.g|]}|ˆjvrˆ |¡rˆ |¡r|‘qSrN)rrrr rQrNrOr Ès ÿÿÿzORequested to enable plugins %s, but plugins are already enabled or do not existz--enable-plugins=%s)+r6Údetermine_sos_labelrr²r'Úthreadsr½ÚstrÚplugin_timeoutÚallow_system_changesÚ no_env_varsÚsinceÚ skip_commandsr¯Ú skip_filesÚ cmd_timeoutÚcontainer_runtimeÚ namespacesÚ journal_sizeÚ low_priorityrÚreplacerartr)Ú sos_bin_pathr7rrrùrúrvrr°rÚsetr rrrnrorr)rJrÚlabelÚsos_optsrrhr'ÚplugsÚnot_onlyÚonlyÚskipÚnot_skipÚskiplnÚnot_onÚenablerNrQrOÚfinalize_sos_cmdRsÒ    ÿ    ÿÿÿ ÿ  ÿ ÿ  þ  ""ÿÿ ÿ ÿ zSosNode.finalize_sos_cmdcCsŠd}||j |¡7}|jjr||sd|jjnd|jj7}|s"dS| d|¡| d¡r1d}nd}d |j d ¡d |f}d ||fS) z?Determine what, if any, label should be added to the sos reportrmz%sr©NzLabel for sos report set to %srªz--labelz--namez%s-%sr¢rr)r*Úget_node_labelr'r4rvr²r%re)rJr4ÚlcmdrNrNrOr#×s ÿ  zSosNode.determine_sos_labelcCs\|jj}|r | |d¡}| ¡d}| d|¡||_| d¡d|_|j d|j¡dS)z\Use host facts to determine if we need to change the sos path we are retrieving fromrmrzFinal sos path: %sú/ràÚcollected_archiveN) r)Úsos_path_stripr1rerr2Úarchivernro)rJrtÚpstriprNrNrOrôës  zSosNode.finalize_sos_pathcCsR|dkrdS|dkrd|vrdS|dkrdSt|ƒdkr%| d ¡dd…Sd |S) Nràz+sos report process received SIGKILL on noderWÚsudozsudo attempt failedéz4sos report terminated unexpectedly. Check disk spacerÚ zsos exited with code %s)r°re)rJÚrcÚstdoutrNrNrOÚdetermine_sos_error÷s zSosNode.determine_sos_errorc Cs–| d¡zœd}d}|j|j|jjddd|jd}|ddkr‡|d ¡D]$}t |d¡r1| ¡}|  d ¡r>|  d ¡d }q%|  d ¡rI|  ¡d }q%|r}|j   d|¡t |ƒdkrc|j   dd¡|WSt |ƒdkrs|j   dd¡|WS|j   dd¡|WS|j   dd¡|WS| |d|d¡}| d|d|df¡t|ƒ‚ty®| d¡‚tyÊ}z| d|›¡| d|›¡‚d}~ww)z2Run sos report and capture the resulting file pathzGenerating sos report...FT)rîrïr|r¥rðr]rr^z*sosreport-*tar*)z sha256 z md5 ú rWzThe checksum is: r–Úchecksumé Ú checksum_typeÚmd5é@Úsha256Úunknownz*Error running sos report. rc = %s msg = %szTimeout exceededz'Exception during sos report execution: zError running sos report: N)r”rdrr'rîr,r»Úfnmatchr$r¼rernror°rKrvr@r rAr)rJrtrMr„r¾rMrNrNrOrósZ ü     €  õ øúüÿ  €ýzSosNode.execute_sos_commandc Csœ|jd}tj || d¡d¡}z | |¡r(| d||f¡|j ||¡WS|  d|¡WdSt yM}z|  d||f¡WYd}~dSd}~ww)z7Copies the specified file from the host to our temp dirrAràzCopying remote %s to local %szFAttempting to copy remote file %s, but it does not exist on filesystemFzFailed to retrieve %s: %sN) rrartr¯rerŽrr=Ú retrieve_filervr@)rJrtÚdestdirÚdestrMrNrNrOrU0s"  ÿÿ€þzSosNode.retrieve_filec Cs¾d | ¡¡}z;t| d¡ƒdkr| d|¡WdS| |¡r9| d|¡d|}|j|dd }|d d kWS| d |¡WdSty^}z| d ||f¡WYd}~dSd}~ww)z|Removes the spciefied file from the host. This should only be used after we have retrieved the file already rmrAr§zJRefusing to remove path %s: appears to be incorrect and possibly dangerousFzRemoving file %szrm -f %sTr{r]rzHAttempting to remove remote file %s, but it does not exist on filesystemzFailed to remove %s: %sN)r¯rer°rvrŽrrdr@)rJrtrƒr„ÚerNrNrOÚ remove_fileAs*ÿ ÿ€þzSosNode.remove_filec Cs.|jrl|js |jjr"z| |j¡Wnty!| d¡YdSw| d|j¡|  d¡z|  |j¡}WntyO}z | |¡WYd}~dSd}~ww|re|  d¡|j   |j  d¡d¡d S|  d ¡dS|j ¡rw|j ¡}n d d „|j ¡Dƒd}|j d |j|f¡| d|¡dS)z+Collect the sosreport archive from the nodezFailed to make archive readableFzRetrieving sos report from %szRetrieving sos report...Nz!Successfully collected sos reportrAràTzFailed to retrieve sos reportcSsg|] }|jr| ¡‘qSrNrÍ)rÎÚxrNrNrOr tr"z.SosNode.retrieve_sosreport..z"Failed to run sos report on %s: %szFailed to run sos report. %s)r2rr'r Úmake_archive_readabler@rArr%r”rUr5r½reÚstderrÚreadrJÚ readlinesr:rž)rJrfrMrXrNrNrOrõXs>  þ  €þ     ÿzSosNode.retrieve_sosreportcCsT|jdus|jr dSd|jvr| d|j¡dS| |j¡}|s(| d¡dSdS)zuRemove the sosreport archive from the node, since we have collected it and it would be wasted space otherwiseNr zFNode sos report path %s looks incorrect. Not attempting to remove pathzFailed to remove sos report)r2rrvrYrA)rJÚremovedrNrNrOÚremove_sos_archivezs ÿ ÿzSosNode.remove_sos_archivecCsP| ¡|jrdD] }| |j|¡rnq |j ¡}|r&|j|dddSdS)zr#rôrKrórUrYrõr`rörer[rNrNrNrOr(st ÿB    (   3  $ ÿ')   ," r)rTr˜r8rarÚpipesrÚ sos.policiesrÚsos.policies.init_systemsrÚsos.collector.transports.jujurÚ(sos.collector.transports.control_persistrÚsos.collector.transports.localrÚsos.collector.transports.ocrÚ"sos.collector.transports.saltstackr Úsos.collector.exceptionsr r r r Ú sos.utilitiesrrUrrNrNrNrOÚs,          û