
    f9              
       D   U d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZ dd	lmZmZ dd
lmZ dZdZddddddiZdZdgZdddee ed       ed       ed      gedgdZeed<    ee      Z  ej8                  e      Zdeded ed!e d"df
d#Z!d$ Z"y)%z&install and configure landscape client    N)chain)dedent)	ConfigObj)subp
type_utilsutil)Cloud)Config)
MetaSchemaget_meta_doc)PER_INSTANCEz/etc/landscape/client.confz/etc/default/landscape-clientclientinfoz.https://landscape.canonical.com/message-systemz#http://landscape.canonical.com/pingz/var/lib/landscape/client)	log_levelurlping_url	data_patha  This 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            # Minimum viable config requires account_name and computer_title
            landscape:
                client:
                    computer_title: kiosk 1
                    account_name: Joe's Biz
            aW             # To install landscape-client from a PPA, specify apt.sources
           apt:
               sources:
                 trunk-testing-ppa:
                   source: ppa:landscape/self-hosted-beta
           landscape:
               client:
                 account_name: myaccount
                 computer_title: himom
           	landscape)idnametitledescriptiondistrosexamples	frequencyactivate_by_schema_keysmetar   cfgcloudargsreturnc                 (   |j                  di       }t        |t              s.t        dj	                  t        j                  |                  |sy|j                  j                  dg       t        t        |g}t        t        t        t        |      d   j                               D cg c]  \  }}d|j!                  dd	       |g c}}       }t#        j"                  d
dg|z          t%        j&                  t(        d       yc c}}w )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
    r   zR'landscape' key existed in config, but not a dictionary type, is a {_type} instead)_typeNzlandscape-clientr   z--_-zlandscape-configz--silentzRUN=1
)get
isinstancedictRuntimeErrorformatr   obj_namedistroinstall_packagesLSC_BUILTIN_CFGLSC_CLIENT_CFG_FILElistr   sortedmerge_togetheritemsreplacer   r   
write_fileLS_DEFAULT_FILE)	r   r!   r"   r#   ls_cloudcfg
merge_datakv
cmd_paramss	            ?/usr/lib/python3/dist-packages/cloudinit/config/cc_landscape.pyhandler@   u   s    ''+r*KkD*$$*F ))+6 %+ %
 	
 	LL!!#5"67 	J  #":.x8>>@Aq aiiS)*+Q/	
	J 	II!:.;<OOOY/s   /!Dc                     t        i       }| D ]A  }|st        |t               r|j                  |       (|j                  t        |             C |S )zu
    merge together ConfigObj objects or things that ConfigObj() will take in
    later entries override earlier
    )r   r*   merge)objsr!   objs      r?   r5   r5      sN    
 B-C &c9%IIcNIIin%& J    )#__doc__logging	itertoolsr   textwrapr   	configobjr   	cloudinitr   r   r   cloudinit.cloudr	   cloudinit.configr
   cloudinit.config.schemar   r   cloudinit.settingsr   r2   r9   r1   MODULE_DESCRIPTIONr   r    __annotations__	getLogger__name__LOGstrr3   r@   r5    rE   r?   <module>rW      s	   -     , , ! # < +2 1 ?90	 0 * 5%	
" 		
 	
	
7(R  +}a1j 1f t
g!&0 &06 &0% &0t &0 &0RrE   