/usr/lib/python3/dist-packages/uaclient/__pycache__
NameSizeModeActions
actions.cpython-310.pyc113810644editdlrm
apt.cpython-310.pyc283670644editdlrm
apt_news.cpython-310.pyc73460644editdlrm
config.cpython-310.pyc137600644editdlrm
contract.cpython-310.pyc248990644editdlrm
contract_data_types.cpython-310.pyc80680644editdlrm
data_types.cpython-310.pyc147880644editdlrm
defaults.cpython-310.pyc29130644editdlrm
event_logger.cpython-310.pyc78400644editdlrm
exceptions.cpython-310.pyc250390644editdlrm
gpg.cpython-310.pyc10250644editdlrm
livepatch.cpython-310.pyc106950644editdlrm
lock.cpython-310.pyc46350644editdlrm
log.cpython-310.pyc46330644editdlrm
secret_manager.cpython-310.pyc12560644editdlrm
security_status.cpython-310.pyc165980644editdlrm
snap.cpython-310.pyc64710644editdlrm
status.cpython-310.pyc183610644editdlrm
system.cpython-310.pyc227620644editdlrm
types.cpython-310.pyc4720644editdlrm
update_contract_info.cpython-310.pyc13320644editdlrm
upgrade_lts_contract.cpython-310.pyc29920644editdlrm
util.cpython-310.pyc135250644editdlrm
version.cpython-310.pyc24990644editdlrm
yaml.cpython-310.pyc11780644editdlrm
__init__.cpython-310.pyc1440644editdlrm
Edit: /usr/lib/python3/dist-packages/uaclient/__pycache__/actions.cpython-310.pyc (11381B)
o SKjS;@sTddlZddlZddlZddlZddlZddlZddlZddlmZm Z ddl m Z m Z m Z mZmZmZmZmZddl mZddl mZmZddl mZddl mZmZmZddlmZmZmZm Z dd l!m"Z"m#Z#dd l$m%Z%m&Z&m'Z'm(Z(m)Z)e*Z+e,e-e.Z/d Z0d Z1d e j2dej3dejfddZ4 d8d e j2deej5dej3dejde6f ddZ7 d8d e j2de8de6de6ddf ddZ9 d9d e j2de j:ddfddZ;dd ddd!d e j2d"e8d#e6d$e8de6d%e ee8f d&d'Zddfd1d2Z?d e j2fd3d4Z@d e j2d5e8fd6d7ZAdS);N)ListOptional)apicloudsconfigcontract entitlements event_logger exceptions livepatch)log)messagessecret_manager)status)systemtimerutil)APPARMOR_PROFILESCLOUD_BUILD_INFODEFAULT_CONFIG_FILEDEFAULT_LOG_PREFIX) machine_tokennotices)AttachmentDataattachment_data_filemachine_id_fileonly_series_check_marker_filetimer_jobs_state_file)zapt-news.servicezesm-cache.servicezua-timer.servicezua-timer.timerzua-auto-attach.pathzua-auto-attach.servicezua-reboot-cmds.servicezubuntu-advantage.service cfgcontract_client attached_atcCs<ddlm}tt|dtj|d|||dS)Nrupdate_motd_messagesr!r)uaclient.timer.update_messagingr#rwriter ua_statusrupdate_activity_token)rr r!r#r*2/usr/lib/python3/dist-packages/uaclient/actions.py_handle_partial_attach9s   r,Fservices_to_be_enabledsilentc CsDd}g}g}z'|D]"}t||j|j|d\} } || M}| s$||jq tj|jdq WnJtjyH} zt|jt |||| d} ~ wtj yY||jd}Ynt yw} zd}||j|| WYd} ~ nd} ~ ww|st |||t ||rtj ddt||Ddtjdd|DddS) NT)rnamevariantr.)serviceFcSs,g|]\}}|tjjt|tdfqS)) error_msglog_path)r UNEXPECTED_ERRORformatstrpro_logget_user_or_root_log_file_path).0r/ exceptionr*r*r+ rsz,_enable_default_services..)failed_servicescSsg|]}|tjfqSr*)r !E_ATTACH_FAILURE_DEFAULT_SERVICES)r9r/r*r*r+r;s)enable_entitlement_by_namer/r0appendeventservice_processedr ConnectivityErrorservice_failedr,UbuntuProError Exceptionservices_failedAttachFailureUnknownErrorzipAttachFailureDefaultServices) rr-r r!r.retr<unexpected_errorsenable_by_default_serviceent_retreasonexcer*r*r+_enable_default_servicesFs^       rQtoken allow_enablereturnc Csddlm}ddlm}tj|t|}t |}t j j t j jd}|j||d} tj} | didi} tdd | d gD} | d id id d} | rzt| }Wn tjyiYn&wt| }|j|jkr~tj|j|jdtjtjj|j|jdt !| |!| z||Wntj"y}z|#|d}~wwtj$%| didt$|}t&!||rt '||(}t)|||||dt*!t+|d||t,-dS)aC Common functionality to take a token and attach via contract backend :raise ConnectivityError: On unexpected connectivity issues to contract server or inability to access identity doc from metadata service. :raise ContractAPIError: On unexpected errors when talking to the contract server. r)+check_entitlement_apt_directives_are_uniquer")tz)contract_token attachment_dtmachineTokenInfo contractInfocss,|]}|ddkr|d|fVqdS)typesupportN)get)r9rPr*r*r+ s z$attach_with_token..resourceEntitlementsr\ affordances onlySeriesN)releaseseries_codename machineId)rr-r r!r.r$).uaclient.entitlementsrUr&r#rsecrets add_secretrget_machine_token_filerUAContractClientdatetimenowtimezoneutcadd_contract_machinerget_release_infoseriesr]dictget_distro_infor MissingSeriesInDistroInfoFileeolAttachFailureRestrictedReleaserbrcraddNoticeLIMITED_TO_RELEASErr'%EntitlementsAPTDirectivesAreNotUniquedeleteget_machine_id cache_clearrget_enabled_by_default_servicesrrQrrrstart)rrRrSr.rUr#machine_token_filer r!new_machine_tokencurrent_seriesrZsupport_resource only_seriesallowed_releasecurrent_releaserP machine_idr-r*r*r+attach_with_tokens                  rTcloudcCs||}t|||ddS)a\ :raise ConnectivityError: On unexpected connectivity issues to contract server or inability to access identity doc from metadata service. :raise ContractAPIError: On unexpected errors when talking to the contract server. :raise NonAutoAttachImageError: If this cloud type does not have auto-attach support. )rRrSN)acquire_pro_tokenr)rrrSrRr*r*r+ auto_attachs r) access_onlyr0r. extra_argsr/rr0rc Csftj|||||d}|sttjj|jd|t \}}|r/|s/ttj j|jd||fS)z Constructs an entitlement based on the name provided. Passes kwargs onto the entitlement constructor. :raise EntitlementNotFoundError: If no entitlement with the given name is found, then raises this error. )rr/r0rr)title) rentitlement_factoryr@infor ENABLING_TMPLr5renablerProgressWrapper ENABLED_TMPL) rr/rr0r.r entitlementrMrNr*r*r+r>sr>)simulate_with_tokenshow_allrrcCs:|rtj|||d\}}||fStj||d}d}||fS)z6 Construct the current Pro status dictionary. )rrRrrrr)r(simulate_statusr)rrrrrJr*r*r+rs   rfilenamec Csgd}d}d}z t|\}}Wn'tjy8}ztdt|td|t|WYd}~dSd}~ww|r[g}| dD] }t ||rO| |qBt|d |dSdS)z Helper which gets ubuntu_pro apparmor logs from the kernel from the last day and writes them to the specified filename. ) journalctlz-bz-kz--since=1 day agoz7apparmor=\".*(profile=\"ubuntu_pro_|name=\"ubuntu_pro_)Nz!Failed to collect kernel logs: %s{}-error )rsubpr ProcessExecutionErrorLOGwarningr6 write_filer5splitresearchr?join)rcmd apparmor_re kernel_logs_rP apparmor_logs kernel_liner*r*r+_write_apparmor_logs_to_file0s$$  r return_codesc Csrz tj||d\}}Wntjy,}ztd|t|WYd}~dSd}~wwt|d||dS)zCHelper which runs a command and writes output or error to filename.)rcsrNzstdout: {} stderr: {})rrrr rrr5r6)rrrouterrrPr*r*r+_write_command_output_to_fileIs$ rcs,jptjtjjtgfddtjDS)Nc3s(|]}t|tjjr|jVqdSN) issubclassrrepoRepoEntitlement repo_file)r9entitlement_clsr%r*r+r^^s  z#_get_state_files..) cfg_pathrlog_filerua_filepathrrENTITLEMENT_CLASSESr%r*r%r+_get_state_filesWs r output_dirc Cstdd|tdtjd|tdd|tdd|td d d d tDd |tD]}td|d||ddgdq9t|dd\}}td|t j |t j dt }td|t |t|}t rtdtntg}t|D]D\}} tj| rtd| qzt t| } ttj|d|| Wqty} ztd| t| WYd} ~ qd} ~ ww|ttdD]L} tj | r&zt| } Wnty} ztd| t| WYd} ~ qd} ~ wwt | } t rt| | ttj|tj!| | qt"d|t#D]1} tj | r`z t$%| |Wq0ty_} ztd| t| WYd} ~ q0d} ~ wwq0dS) zG Write all relevant Ubuntu Pro logs to the specified directory zcloud-idz{}/cloud-id.txtz {} statusz{}/livepatch-status.txtzsystemctl list-timers --allz{}/systemd-timers.txtzujournalctl --boot=0 -o short-precise -u cloud-init-local.service -u cloud-init-config.service -u cloud-config.servicez{}/cloud-init-journal.txtzjournalctl -o short-precise {} cSsg|] }d|vrd|qS)z.servicez-u {})r5)r9sr*r*r+r;sz collect_logs..z{}/pro-journal.txtzsystemctl status {}z {}/{}.txtr)rFrz{}/pro-status.json)clsz{}/environment_vars.jsonNz$Skipping symlinked user log file: %sz user{}.logz&Failed to collect user log file: %s %s*zFailed to load file: %s %sz{}/apparmor_logs.txtzFailed to copy file: %s %s)&rr5r LIVEPATCH_CMDr UA_SERVICESrrrjsondumpsrDatetimeAwareJSONEncoderget_pro_environmentrwe_are_currently_rootr7get_all_user_log_filesUSER_LOG_COLLECTED_LIMITget_user_log_file enumerateosrislinkrrredact_sensitive_logs load_filerEr6globrisfilebasenamerrshutilcopy) rrr1 pro_statusrenv_vars state_filesuser_log_files log_file_idxrcontentrPfr*r*r+ collect_logsfs            r)F)Tr)Brjrrloggingrrrtypingrruaclientrrrrrr r r r r7r rrr(rrruaclient.defaultsrrrruaclient.filesrruaclient.files.state_filesrrrrrget_event_loggerr@ getLoggerreplace_top_level_logger_name__name__rrrUAConfigrir,EnableByDefaultServiceboolrQr6rAutoAttachInstancerr>rintrrrr*r*r*r+s(     F b   %