
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
\me              	   @   s   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
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eZ dZeeeeddddZdd ZdS )z;Autoinstall: Support ubuntu live-server autoinstall syntax.    N)dedent)Cloud)Config)
MetaSchemaSchemaProblemSchemaValidationErrorget_meta_doc)PER_ONCE)subpZubuntuZ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 adherance 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distrosZexamplesZ	frequencyZactivate_by_schema_keys	subiquityubuntu-desktop-installer)r   cfgcloudargsreturnc             C   s|   d|krt jd|  d S tddg\}}d }xtD ]}tj||r2|}q2W |sdt jddjt d S t| t jd| d S )Nr   z?Skipping module named %s, no 'autoinstall' key in configurationZ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
   LIVE_INSTALLER_SNAPSresearchZwarningjoinvalidate_config_schema)r   r   r   r   Z	snap_list_Zinstaller_presentZ	snap_name r    +/usr/lib/python3.6/cc_ubuntu_autoinstall.pyhandleM   s&    
r"   c             C   s|   | d }t |ts.ttddt|j gd|krHttddgn0t |jdtsxttddt|d j gdS )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   Zautoinstall_cfgr    r    r!   r   i   s    
r   )r   r   )__doc__Zloggingr   textwrapr   Zcloudinit.cloudr   Zcloudinit.configr   Zcloudinit.config.schemar   r   r   r   Zcloudinit.settingsr	   Zcloudinit.subpr
   Z	getLoggerr'   r   r   metar   strr   r"   r   r    r    r    r!   <module>   s0   
