oB]c@sdZddlmZddlmZddlZdgZejeZ dZ dZ dZ d Z d Zd d d ZdS(s LXD --- **Summary:** configure lxd with ``lxd init`` and optionally lxd-bridge This module configures lxd with user specified options using ``lxd init``. If lxd is not present on the system but lxd configuration is provided, then lxd will be installed. If the selected storage backend is zfs, then zfs will be installed if missing. If network bridge configuration is provided, then lxd-bridge will be configured accordingly. **Internal name:** ``cc_lxd`` **Module frequency:** per instance **Supported distros:** ubuntu **Config keys**:: lxd: init: network_address: network_port: storage_backend: storage_create_device: storage_create_loop: storage_pool: trust_password: bridge: mode: name: ipv4_address: ipv4_netmask: ipv4_dhcp_first: ipv4_dhcp_last: ipv4_dhcp_leases: ipv4_nat: ipv6_address: ipv6_netmask: ipv6_nat: domain: i(tlog(tutilNtubuntutlxdbr0c Cs|jd}|s)|jd|dSt|tsR|jdt|dS|jd}t|ts|jdt|i}n|jdi}t|ts|jdt|i}ng}tjds|jdn|jdd kr)tjd  r)|jd nt |ryy|j j |Wqytj k ru} |jd || dSXn|r d*} tj dddgdddg} xP| D]H} |j| r| jd| jddt|| fgqqWtj | nd} |r|jdt}tjjdrtj| rt|}yd|jd| djg|jD]\} }d| |f^qd}tj dg|Wn%tk rtj|d| nXtjd|jdtj d dd!gqt|\}}td"|d#t|d$t|d%t||r|jd&d'j|t|n|r|jd(d'j|t|qn|rtd)| ndS(+Ntlxds8Skipping module named %s, not present or disabled by cfgs-lxd config must be a dictionary. found a '%s'tinits2lxd/init config must be a dictionary. found a '%s'tbridges4lxd/bridge config must be a dictionary. found a '%s'tstorage_backendtzfsszfsutils-linuxs!failed to install packages %s: %stnetwork_addresst network_porttstorage_create_devicetstorage_create_loopt storage_poolttrust_passwordt waitreadys --timeout=300s--autos--%s=%st_t-sdebconf-communicatetnames/etc/default/lxd-bridgesSetting lxd debconf via s s set %s %ssFailed to run '%s' for lxd withs Running dpkg-reconfigure for lxdsdpkg-reconfigures--frontend=noninteractivetnet_nametdid_inittcreatetattachsCreating lxd bridge: %st s!Setting up default lxd bridge: %ss*Unable to configure lxd bridge without %s.(R R RR R R R( tgettdebugt isinstancetdicttwarningttypeRtwhichtappendtlentdistrotinstall_packagestProcessExecutionErrortsubptextendtreplacetstrt_DEFAULT_NETWORK_NAMEtostpathtexiststbridge_to_debconftjointitemst Exceptiontlogexctdel_filet bridge_to_cmdtmaybe_cleanup_defaulttboolt_lxct RuntimeError(RtcfgtcloudRtargstlxd_cfgtinit_cfgt bridge_cfgtpackagestexct init_keystcmdtkt dconf_commRtdebconftvtdatat cmd_createt cmd_attach((s;/usr/lib/python2.7/site-packages/cloudinit/config/cc_lxd.pythandle=s         %   .  3          cCsi}|jddkr2d|d0s   f 2 2