a 'Dg; @sUdZddlZddlmZddlmZddlmZmZm Z ddl m Z ddl m Z ddlmZdd lmZd Zd d d dddiZddgedgdZeed<eeZee e eddddZddZdS)z&install and configure landscape clientN)chain) ConfigObj)subp type_utilsutil)Cloud)Config) MetaSchema) PER_INSTANCEz/etc/landscape/client.confclientinfoz.https://landscape.canonical.com/message-systemz#http://landscape.canonical.com/pingz/var/lib/landscape/client)Z log_levelurlZping_urlZ data_pathZ cc_landscapeZubuntu landscape)idZdistrosZ frequencyZactivate_by_schema_keysmeta)namecfgcloudargsreturnc Cs|di}t|ts,tdjt|d|s4dS|jdgt t |g}t t ddt t|dD}z*tjgd d gd td d g|Wn\tjy}zB|jdkrtdn d|}tt|t||WYd}~n d}~00dS)z Basically turn a top level 'landscape' entry with a 'client' dict and render it to ConfigObj format under '[client]' section in /etc/landscape/client.conf rzR'landscape' key existed in config, but not a dictionary type, is a {_type} instead)Z_typeNzlandscape-clientcSs&g|]\}}d|dd|gqS)z--_-)replace).0kvrA/usr/lib/python3.9/site-packages/cloudinit/config/cc_landscape.py Iszhandle..r )landscape-config--silentz--is-registered)Zrcsrr rz&Client already registered to LandscapezFailure registering client: )get isinstancedict RuntimeErrorformatrZobj_nameZdistroZinstall_packagesLSC_BUILTIN_CFGLSC_CLIENT_CFG_FILElistrsortedmerge_togetheritemsrZProcessExecutionErrorZ exit_codeLOGZwarningrZlogexc) rrrrZ ls_cloudcfgZ merge_dataZ cmd_paramsemsgrrrhandle,s@       r0cCs@ti}|D].}|sq t|tr,||q |t|q |S)zu merge together ConfigObj objects or things that ConfigObj() will take in later entries override earlier )rr#merge)Zobjsrobjrrrr+]s  r+)__doc__Zlogging itertoolsrZ configobjrZ cloudinitrrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemar Zcloudinit.settingsr r(r'r__annotations__Z getLogger__name__r-strr)r0r+rrrr s0        1