
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!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   
