Hcf8RddlZddlZddlmZmZmZddlmZmZm Z m Z m Z m Z m Z mZmZddlmZmZddlmZmZddlmZddlmZmZddlmZmZej<ej>e Z!d ejDd e#d eed eed e#de#de#fdZ$de%dee#efdee#dee#deee#efdeee#efde%fdZ&ejNejPejRejTejVdde,fdZ-d ejDfdZ.y)N)AnyDictList) apiconfigcontract entitlements event_logger exceptionsmessagesstatusutil)ServiceWithDependencies _dependencies)EnabledService_enabled_services) _is_attached)cli_util constants)CanEnableFailureCanEnableFailureReasoncfgserviceall_dependenciesenabled_services called_namevariant service_titlecg}g}|D cgc]} | j} } tfd|Dd} | b| jD cgc]} | j| vr | j}} | jD cgc]} | j| vr | j}} |D]} t j |j d} tj|| }tjj||}| st j|rttj|||D]f}tj||}tjj||}t j|rQtj ||tfd|Dd}|tj|}tj||j"}t j |j d} tjj||}| st j|stj||yyycc} wcc} wcc} w)Nc3BK|]}|jk(s|ywN)name).0srs 5/usr/lib/python3/dist-packages/uaclient/cli/enable.py z1prompt_for_dependency_handling..0s:q'(9:sz features.block_disable_on_enable)r path_to_value)service_being_enabledincompatible_service)msg)r(required_servicec3vK|]0}|jk(r|jr|jk7r|2ywr!)r"variant_enabled variant_name)r#r$rrs r%r&z1prompt_for_dependency_handling.._s: vv !!')  s69)r"nextincompatible_with depends_onris_config_value_truerr get_titler INCOMPATIBLE_SERVICEformatprompt_for_confirmationr IncompatibleServiceStopsEnableREQUIRED_SERVICERequiredServiceStopsEnabler.)rrrrrrrincompatible_servicesrequired_servicesr$enabled_service_names dependenciesr)cfg_block_disable_on_enableincompatible_service_titleuser_msgr+required_service_titler-to_be_enabled_titleenabled_variant_titles ` ` r%prompt_for_dependency_handlingrD"s-=>QVV>>:$:DL"33! vv.. FF! ! ",, vv22 FF  !6&*&?&?77<' #&2%;%; %& "0077"/!;8  'd.J.J/ ;;&3%? (. !-!7!7=M!N,,33"/34 ++977&3!7   %   O"w':*44S'7K , 6 6 /66! '+&?&?77<' #0077"5!68  'd.J.J/ ;;&9%: / (;"w? !  sI!I6!I" json_output json_responseprocessed_servicesfailed_serviceserrorswarningssuccessc|rm|j|j|rdnd|d<||d<||d<||d<||d<ttj|tj d yy) NrKfailureresultrGrHrIrJT)cls sort_keys)sortprintjsondumpsrDatetimeAwareJSONEncoder)rErFrGrHrIrJrKs r%print_json_outputrV~s!/6)I h.@ *++: '("( h$, j! JJ11  z pro enablereturnc &g}g}g}g}tjddd}|jdk(}tj|} t |dd} |j } | r| rtjdd | tj tj|t+|j,sbtj.} | | j&|j#d | j&| j0dt3||||||dyt |dg} t5j6| |\}}t9|j:}t=|j>}d }t5j@||D]I}t5jB||| ||jD|jF|| |jId}tjKd|tjKd| |j(}|jL}|jDs tO|||||| | |rtUjV}n'tUjVtjX}|j[|_.|j_|\}}taj`||s|tc|tdr|jfk| |jfj&|j#||j#d||jfj&|jfj(d|jhtjjlk(r|j#|| tjRj|jLn.|r|j#||j r1| tjnj|jLn0| tjpj|jL|js}|r+d |d<| tjtjd|jwd|jxjId nE|sC|A|j#|| tjRj|jL||z}L|rpd}||z }t5j||||jF"}| |j&|j#d d|j&|j0|jzd!tj~|}|jt3||||||||rd#SdS#tjtjf$r`tj!d d |j#d tj$j&tj$j(dY]wxYw#tj$rZ}tjQ|| |j&| tjRj|d}Yd}~d}~wwxYw#tj$r}|j#|| |j&| tjRj||j#d||j&|j0|jzd!d}Yd}~d}~wwxYw)$z^Perform the enable action on a named entitlement. @return: 0 on success, 1 otherwise rKF)_schema_versionrN needs_rebootrSr --access-only --variant)option1option2zFailed to refresh contractT)exc_infosystem)typemessage message_code)rKr)r extra_args) assume_yes allow_betar access_onlyrgzEnabling entitlement %sz Variant: %s)rrr)titleNr)rcrrdrer[install) operationmessage_operation post_enable)rcrrdreadditional_info)rrir)Ar JSON_SCHEMA_VERSIONr5r&create_interactive_only_print_functiongetattrrjr InvalidOptionCombinationr REFRESH_CONTRACT_ENABLErrefreshConnectivityErrorUbuntuProErrorLOGwarningappendE_REFRESH_CONTRACT_FAILUREr*r"ris_attached_and_contract_validContractExpiredErrormsg_coderVr get_valid_entitlement_namesrrrservicesorder_entitlements_for_enablingentitlement_factoryrhbetagetdebugrkrD exception ENABLE_FAILEDrProgressWrapperCLIEnableDisableProgresscalculate_total_enable_steps total_stepsenabler isinstancerrdreasonrIS_BETAACCESS_ENABLED_TMPL ENABLED_TMPL_check_for_rebootENABLE_REBOOT_REQUIRED_TMPLemit messagingrq*create_enable_entitlements_not_found_errorUAContractClientupdate_activity_token)argsrkwargsrGrHrIrJrFrEinteractive_only_printrrj expired_errnamesentitlements_foundentitlements_not_foundrrretent_nameent real_name ent_titleeprogressent_retrent_reboot_requirederrcontract_clients r% action_enablers]O FH(;;M ++'K &LLdIr*G""K;11#[  8;;<     ; ; 557 {/  &?? + 4 4           D)R (E 00<(->>$S)22 C @@ uOl..sHgN yy #zz,/   +X6 -)HH II  .$$ )#"+$O ..0..557$'#C#C#EH !jj2OGV MMc "&v'78>>-*6>>+=+=>#**84MM$-'/'-~~'9'9,2NN,?,? ==$:$B$BB+11(;&**11 1B"))(3##* 44;;#));L+ --443994E'*&;&;&=#&48M.1* <<CC&/D  '):):=)I&&x0&**11 1B 7NCKun11EE "   sww'  77 # ##6   //4O))+1}  ( (**C*C D   04 @ #>>BB ( C C H H    L,,  a &quu-&**11 1B R((   " "8 , "155 ) "&&--I->  MM%' uu$%JJ'('8'8  C sF U<X/JY2W?Y/AY**Y/2\B\  \c |jdtj}|jttj |_tjjtjd|_ d|_ tj|j_tj |j"_|j%dddtj&jd j)t+j,|   |j%d dtj.jd|j%ddtj0|j%ddtj2|j%ddddgdtj4jd|j%ddtj6|S)Nr)help)actionzenable [])r"commandrstore+z, rl)options)rnargsrz --assume-yes store_true)r)rrr]z--betaz--formatclirS)default)rchoicesrrr^) add_parserr CLI_ROOT_ENABLE set_defaultsrCLI_ENABLE_DESC descriptionr USAGE_TMPLr5NAMEusageprogCLI_ARGS _positionalsrk CLI_FLAGS _optionals add_argumentCLI_ENABLE_SERVICEjoinr valid_servicesCLI_ASSUME_YESCLI_ENABLE_ACCESS_ONLYCLI_ENABLE_BETACLI_FORMAT_DESCCLI_ENABLE_VARIANT) subparsersrparsers r%rrs  " "8(2J2J " KF }-!11F''.. ^^%C/FLFK ( 1 1F&00F   ' ' . . ,"="=#"FG /      $ $ + +H + =    , ,  H,D,D   % % , ,U , ;  G(*E*E MrW)/rSloggingtypingrrruaclientrrrr r r r r r+uaclient.api.u.pro.services.dependencies.v1rr-uaclient.api.u.pro.status.enabled_services.v1rr(uaclient.api.u.pro.status.is_attached.v1r uaclient.clirr(uaclient.entitlements.entitlement_statusrr getLoggerreplace_top_level_logger_name__name__rzUAConfigstrrDboolrVverify_json_format_args assert_rootassert_attached&_raise_enable_disable_unattached_errorassert_lock_fileintrrrWr%rs ""   B, g:::8DEY Y Y23Y>* Y  Y  YYx  S> S  #Y  c3h  4S>"   8 !! (IIJ<(bSb)K"bJ++rW