܍~cp 6UdZddlZddlmZddlmZddlmZddlm Z ddl m Z m Z m Z ddlmZdd lmZdd lmZmZdd lmZd Zd ZddddddiZdZdgZdddeeededgedgdZeed<eeZdeded ed!ed"ed#df d$Z d%Z!dS)&z&install and configure landscape clientN)BytesIO)Logger)dedent) ConfigObj)subp type_utilsutil)Cloud)Config) MetaSchema get_meta_doc) PER_INSTANCEz/etc/landscape/client.confz/etc/default/landscape-clientclientinfoz.https://landscape.canonical.com/message-systemz#http://landscape.canonical.com/pingz/var/lib/landscape/client) log_levelurlping_url data_pathaThis module installs and configures ``landscape-client``. The landscape client will only be installed if the key ``landscape`` is present in config. Landscape client configuration is given under the ``client`` key under the main ``landscape`` config key. The config parameters are not interpreted by cloud-init, but rather are converted into a ConfigObj formatted file and written out to the `[client]` section in ``/etc/landscape/client.conf``. The following default client config is provided, but can be overridden:: landscape: client: log_level: "info" url: "https://landscape.canonical.com/message-system" ping_url: "http://landscape.canoncial.com/ping" data_path: "/var/lib/landscape/client" .. note:: see landscape documentation for client config keys .. note:: if ``tags`` is defined, its contents should be a string delimited with ``,`` rather than a list ubuntu cc_landscape Landscapez&Install and configure landscape clienta # To discover additional supported client keys, run # man landscape-config. landscape: client: url: "https://landscape.canonical.com/message-system" ping_url: "http://landscape.canonical.com/ping" data_path: "/var/lib/landscape/client" http_proxy: "http://my.proxy.com/foobar" https_proxy: "https://my.proxy.com/foobar" tags: "server,cloud" computer_title: "footitle" registration_key: "fookey" account_name: "fooaccount" z # Any keys below `client` are optional and the default values will # be used. landscape: client: {} landscape)idnametitle descriptiondistrosexamples frequencyactivate_by_schema_keysmetarcfgcloudlogargsreturnc|di}t|ts5tdt j||sdS|jdtt|g}t|}t}| |tjt jttjt||dttjt,dt/jgddS) 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)_typeN)landscape-clientz!Wrote landscape config file to %szRUN=1 )servicer)restart)get isinstancedict RuntimeErrorformatrobj_namedistroinstall_packagesLSC_BUILTIN_CFGLSC_CLIENT_CFG_FILEmerge_togetherrwriter ensure_dirospathdirname write_filegetvaluedebugLS_DEFAULT_FILEr) rr"r#r$r% ls_cloudcfg merge_datamergedcontentss ?/usr/lib/python3/dist-packages/cloudinit/config/cc_landscape.pyhandlerEgsG''+r**K kD * *  $$*F )+66%+%%    L!!"7888 J J ' 'FyyH LLOBGOO$788999O'):):)<)<===II13FGGGOOY///I88899999cti}|D]R}|st|tr||0|t|S|S)zu merge together ConfigObj objects or things that ConfigObj() will take in later entries override earlier )rr-merge)objsr"objs rDr6r6sl B--C&&   c9 % % & IIcNNNN IIinn % % % % JrF)"__doc__r9iorloggingrtextwrapr configobjr cloudinitrrr cloudinit.cloudr cloudinit.configr cloudinit.config.schemar r cloudinit.settingsrr5r?r4MODULE_DESCRIPTIONrr!__annotations__strlistrEr6rFrDrZs-,, ,,,,,,,,,,!!!!!!######<<<<<<<<++++++21 ?90 0 *   5%   "    %6 +}E##j###J ,t  &: &:&:#(&:/5&:=A&: &:&:&:&:R     rF