܍~cuddlZddlZddlZddlZddlmZddlmZddlm Z ej e Z dZ dZdZdZdd Zd Zd Zd Zd ZdS)N)subp)GuestCustEventEnum)GuestCustStateEnumz/var/log/cloud-init.logqueryNicsSupported connectedcN|sdSd}d} td|tjd|gdg\}}|r|}nK#t$r>}tdt|Yd}~nd}~wwxYw||fS)NzError sending the RPC commandzSending RPC command: %szvmware-rpctoolr)rcszFailed to send RPC command)loggerdebugrrstrip Exception exception)rpcouterres U/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/guestcust_util.pysend_rpcrs t C )C .444Y 0#6QC@@@ c  **,,C  1222 :sA A B "4BB cpd}|rtdz|z}nt}d|||fz}t|\}}||fS)Nr @zdeployPkg.update.state %d %d %s)CLOUDINIT_LOG_FILEr) custstate custerror errormessagemessagerrrs rset_customization_statusr5sOG%$s*\9$ +y)W.M MC#JS# :c|sdSd}tj|sdSt|d5}||}dddn #1swxYwY|S)zReads the NICS from the specified file path and returns the content @param nicsfilepath: Absolute file path to the NICS.txt file. Nir)ospathexistsopenread) nicsfilepath NICS_SIZEfpnicss rget_nics_to_enabler*Bs tI 7>>, ' 't lC "Bwwy!!""""""""""""""" KsAA!Ac|stddSd}d}d}td|D]}td|t t jtj|\}}|stj ||z`|tkrtddStd|D]j}t t jtj |\}}|r*|tkrtd|dStj |ktd|dS) Nz No Nics foundrz(Trying to connect interfaces, attempt %dz-NICS connection status query is not supportedzNICS are connected on %d secondz2Can't connect network interfaces after %d attempts)r warningranger rrGUESTCUST_STATE_RUNNINGrGUESTCUST_EVENT_ENABLE_NICStimesleepQUERY_NICS_SUPPORTEDGUESTCUST_EVENT_QUERY_NICSNICS_STATUS_CONNECTEDinfo)r)enableNicsWaitRetriesenableNicsWaitCountenableNicsWaitSecondsattemptr_errcounts r enable_nicsr>Ws~ '''122.. ?III.  6  :   d   J*-BB C C C  & & & NNJ K K K FF1122 . .E2":"=KS$  s333 =uEEE J, - - - - . NN<rctjdstd|Sddd||g} tj|}n#tj$r}|jdkr0tdd||n;td||jt||cYd }~Sd }~wwxYw|}tj d |j }|rE| d  }td |||ntd ||||S)a$Return the value of [section] key from VMTools configuration. @param section: String of section to read from VMTools config @returns: String value from key in [section] or defaultVal if [section] is not present or vmware-toolbox-cmd is not installed. zvmware-toolbox-cmdz9vmware-toolbox-cmd not installed, returning default valueconfiggetEzRvmware-toolbox-cmd returned 69 (unavailable) for cmd: %s. Return default value: %s zFailed running %s[%s]Nz ([^=]+)=(.*)zGet tools config: [%s] %s = %szrUrYrrras    8 $ $/+# ,    *'''T---dr