
    f<              
          U d Z ddl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
 ddlmZmZmZmZ ddlmZ dd	lmZ  ej(                  e      Zd
gZddd ed      e ed      gedgdZeed<    ee      Z dZdede
dededdf
dZd Zy)z;Autoinstall: Support ubuntu live-server autoinstall syntax.    N)dedent)util)Cloud)Config)
MetaSchemaSchemaProblemSchemaValidationErrorget_meta_doc)PER_ONCE)subpubuntucc_ubuntu_autoinstallzUbuntu Autoinstallz)Support Ubuntu live-server install syntaxa&          Ubuntu's autoinstall YAML supports single-system automated installs
        in either the live-server install, via the ``subiquity`` snap, or the
        next generation desktop installer, via `ubuntu-desktop-install` snap.
        When "autoinstall" directives are provided in either
        ``#cloud-config`` user-data or ``/etc/cloud/cloud.cfg.d`` validate
        minimal autoinstall schema adherence and emit a warning if the
        live-installer is not present.

        The live-installer will use autoinstall directives to seed answers to
        configuration prompts during system install to allow for a
        "touchless" or non-interactive Ubuntu system install.

        For more details on Ubuntu's autoinstaller:
            https://ubuntu.com/server/docs/install/autoinstall
    a              # Tell the live-server installer to provide dhcp6 network config
            # and LVM on a disk matching the serial number prefix CT
            autoinstall:
              version: 1
              network:
                version: 2
                ethernets:
                  enp0s31f6:
                    dhcp6: yes
              storage:
                layout:
                  name: lvm
                  match:
                    serial: CT*
        autoinstall)idnametitledescriptiondistrosexamples	frequencyactivate_by_schema_keysmeta)	subiquityzubuntu-desktop-installerr   cfgcloudargsreturnc                 j   d|vrt         j                  d|        y t        j                  |       t	        ddg      \  }}d }t
        D ]  }t        j                  ||      s|} |s*t         j                  ddj                  t
                     y t        |       t         j                  d|       y )Nr   z?Skipping module named %s, no 'autoinstall' key in configurationsnaplistzaSkipping autoinstall module. Expected one of the Ubuntu installer snap packages to be present: %sz, z8Valid autoinstall schema. Config will be processed by %s)LOGdebugr   wait_for_snap_seededr   LIVE_INSTALLER_SNAPSresearchwarningjoinvalidate_config_schema)r   r   r   r   	snap_list_installer_present	snap_names           H/usr/lib/python3/dist-packages/cloudinit/config/cc_ubuntu_autoinstall.pyhandler/   N   s    C		M	
 	e$()LIq) *	99Y	* )* 9II*+	

 	3IIB    c           
      V   | d   }t        |t              s,t        t        ddt	        |      j
                         g      d|vrt        t        dd      g      t        |j                  d      t              s/t        t        ddt	        |d         j
                         g      y)a>  Supplemental runtime schema validation for autoinstall yaml.

    Schema validation issues currently result in a warning log currently which
    can be easily ignored because warnings do not bubble up to cloud-init
    status output.

    In the case of the live-installer, we want cloud-init to raise an error
    to set overall cloud-init status to 'error' so it is more discoverable
    in installer environments.

    # TODO(Drop this validation When cloud-init schema is strict and errors)

    :raise: SchemaValidationError if any known schema values are present.
    r   zExpected dict type but found: versionzMissing required 'version' keyzautoinstall.versionzExpected int type but found: N)
isinstancedictr	   r   type__name__getint)r   autoinstall_cfgs     r.   r)   r)   k   s     -(Oot,#!_-6679
 	
 '#=*JKL
 	
 ++I6<#)_Y78AABD
 	
 =r0   )__doc__loggingr%   textwrapr   	cloudinitr   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar   r   r	   r
   cloudinit.settingsr   cloudinit.subpr   	getLoggerr6   r!   r   r   __annotations__r$   strr    r/   r)    r0   r.   <module>rG      s    B  	   ! #  ( g!* " 8	$ 	
(  -Y-j -^ t
 A  6 % t  :(
r0   