404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.188.99.207: ~ $
3

\�me�H�	@s,UdZddlZddlZddlmZddlmZmZddlm	Z	m
Z
mZddlm
Z
ddlmZddlmZmZdd	lmZeje�Zd
ZdZdgZd
ddeeed�ed�ed�gedgd�Zeee�Zeeed�dd�Zeee
edd�dd�Z dd�Z!dd�Z"dd �Z#d(d#d$�Z$eeeed%�d&d'�Z%dS))z>LXD: configure lxd with ``lxd init`` and optionally lxd-bridge�N)�dedent)�List�Tuple)�safeyaml�subp�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�PER_INSTANCEZlxdbr0aeThis 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 userspace utility is
not installed, it will be installed. If network bridge configuration is
provided, then lxd-bridge will be configured accordingly.
ZubuntuZcc_lxdZLXDz9Configure LXD with ``lxd init`` and optionally lxd-bridgez�            # Simplest working directory backed LXD configuration
            lxd:
              init:
                storage_backend: dir
            a            # LXD init showcasing cloud-init's LXD config options
            lxd:
              init:
                network_address: 0.0.0.0
                network_port: 8443
                storage_backend: zfs
                storage_pool: datapool
                storage_create_loop: 10
              bridge:
                mode: new
                mtu: 1500
                name: lxdbr0
                ipv4_address: 10.0.8.1
                ipv4_netmask: 24
                ipv4_dhcp_first: 10.0.8.2
                ipv4_dhcp_last: 10.0.8.3
                ipv4_dhcp_leases: 250
                ipv4_nat: true
                ipv6_address: fd98:9e0:3744::1
                ipv6_netmask: 64
                ipv6_nat: true
                domain: lxd
            a�            # For more complex non-iteractive LXD configuration of networks,
            # storage_pools, profiles, projects, clusters and core config,
            # `lxd:preseed` config will be passed as stdin to the command:
            #  lxd init --preseed
            # See https://documentation.ubuntu.com/lxd/en/latest/howto/initialize/#non-interactive-configuration or
            # run: lxd init --dump to see viable preseed YAML allowed.
            #
            # Preseed settings configuring the LXD daemon for HTTPS connections
            # on 192.168.1.1 port 9999, a nested profile which allows for
            # LXD nesting on containers and a limited project allowing for
            # RBAC approach when defining behavior for sub projects.
            lxd:
              preseed: |
                config:
                  core.https_address: 192.168.1.1:9999
                networks:
                  - config:
                      ipv4.address: 10.42.42.1/24
                      ipv4.nat: true
                      ipv6.address: fd42:4242:4242:4242::1/64
                      ipv6.nat: true
                    description: ""
                    name: lxdbr0
                    type: bridge
                    project: default
                storage_pools:
                  - config:
                      size: 5GiB
                      source: /var/snap/lxd/common/lxd/disks/default.img
                    description: ""
                    name: default
                    driver: zfs
                profiles:
                  - config: {}
                    description: Default LXD profile
                    devices:
                      eth0:
                        name: eth0
                        network: lxdbr0
                        type: nic
                      root:
                        path: /
                        pool: default
                        type: disk
                    name: default
                  - config: {}
                    security.nesting: true
                    devices:
                      eth0:
                        name: eth0
                        network: lxdbr0
                        type: nic
                      root:
                        path: /
                        pool: default
                        type: disk
                    name: nested
                projects:
                  - config:
                      features.images: true
                      features.networks: true
                      features.profiles: true
                      features.storage.volumes: true
                    description: Default LXD project
                    name: default
                  - config:
                      features.images: false
                      features.networks: true
                      features.profiles: false
                      features.storage.volumes: false
                    description: Limited Access LXD project
                    name: limited


            �lxd)�id�name�title�description�distrosZexamplesZ	frequencyZactivate_by_schema_keys)�init_cfg�
bridge_cfg�preseed_strcCs�g}t|t�s&|jdt|�j�d��t|t�sH|jdt|�j�d��t|t�sj|jdt|�j�d��|r�|sv|r�|r�dgng}||r�dgng7}|jddj|����|r�td	j|���d
S)z�Validate user-provided lxd network and bridge config option values.

    @raises: ValueError describing invalid values provided.
    z/lxd.init config must be a dictionary. found a '�'z1lxd.bridge config must be a dictionary. found a 'z.lxd.preseed config must be a string. found a 'zlxd.initz
lxd.bridgezMUnable to configure LXD. lxd.preseed config can not be provided with key(s): z, z. N)�
isinstance�dict�append�type�__name__�str�join�
ValueError)rrr�errorsZincompat_cfg�r �/usr/lib/python3.6/cc_lxd.py�supplemental_schema_validation�s"


r")r�cfg�cloud�args�returnc(CsN|jd�}|stjd|�dSt|t�s>tdt|�j�d���|jdi�}|jdd�}|jdi�}t|||�t	j
d�s�yt	j	d	d
dg�Wn2t	jk
r�}ztd|�|�WYdd}~XnXt
||�}	t|	��ry|jj|	�Wn2t	jk
�r}
ztjd|	|
�dSd}
~
XnXt	j	dd
dg�|�rFt	j	dddg|d�dS|�rd9}tj�dd}|ddk�r�tjjd|�d���r�tjd�t	j	ddd d!dd"g�td#d$�|D��}ddd%g}
x>|D]6}|j|��r�|
jd&|jd'd(�t||�fg��q�Wt	j	|
�d)}|�r8|jd*t�}tjjd+��r�t	j
|��r�t|�}y<tjd,|�d-jd.d/�|j�D��d-}t	j	d)g|d�Wn&tk
�r�tj td0|�YnXtj!d+�tjd1�t	j	d2dd3g�nht"|�\}}t#|t$|�t$|�t$|�d4�|�rtjd5d6j|��t%|�|�rJtjd7d6j|��t%|�n|�rJtd8|��dS):Nr
z8Skipping module named %s, not present or disabled by cfgz*lxd config must be a dictionary. found a 'rZinitZpreseed�ZbridgeZsnapZinstallz#Failed to install lxd from snap: %sz!failed to install packages %s: %sZ	waitreadyz
--timeout=300z	--preseed)�data�network_address�network_port�storage_backend�storage_create_device�storage_create_loop�storage_pool�trust_password�uname��lvmz
/lib/modules/z"/kernel/drivers/md/dm-thin-pool.kozqcloud-init doesn't use thinpool by default on Ubuntu due to LP #1982780. This behavior will change in the future.�lxcZstorage�create�defaultzlvm.use_thinpool=falsecss|]}|dkr|VqdS)r+Nr )�.0�keyr r r!�	<genexpr>szhandle.<locals>.<genexpr>z--autoz--%s=%s�_�-zdebconf-communicaterz/etc/default/lxd-bridgezSetting lxd debconf via %s�
cSsg|]\}}d||f�qS)z	set %s %sr )r6�k�vr r r!�
<listcomp>/szhandle.<locals>.<listcomp>zFailed to run '%s' for lxd withz Running dpkg-reconfigure for lxdzdpkg-reconfigurez--frontend=noninteractive)�net_name�did_initr4�attachzCreating lxd bridge: %s� z!Setting up default lxd bridge: %sz*Unable to configure lxd bridge without %s.)r)r*r+r,r-r.r/)&�get�LOG�debugrrrrrr"r�which�ProcessExecutionError�RuntimeError�get_required_packages�lenZdistroZinstall_packages�warningrZsystem_info�os�path�exists�tuple�extend�replacer�_DEFAULT_NETWORK_NAME�bridge_to_debconfr�items�	ExceptionZlogexcZdel_file�
bridge_to_cmd�maybe_cleanup_default�bool�_lxc)rr#r$r%Zlxd_cfgrrr�e�packages�excZ	init_keysZkernel�cmdr<Z
dconf_commr?�debconfr(�
cmd_create�
cmd_attachr r r!�handle�s�






&



racCs`i}|jd�dkr&d|d<d|d<�n6|jd�dkrVd|d<d|d	<|jd
�|d<�n|jd�dk�rJd|d<|jd
�r�|jd
�|d<|jd�r�d|d
<|jd�|d<|jd�|d<|jd�|d<|jd�|d<|jd�|d<|jdd�|d<|jd��r.d|d<|jd�|d<|jd�|d<|jdd�|d<|jd ��r\|jd �|d!<ntd"|jd���|S)#N�mode�none�falsezlxd/setup-bridger'zlxd/bridge-name�existing�truezlxd/use-existing-bridger�new�ipv4_addresszlxd/bridge-ipv4zlxd/bridge-ipv4-address�ipv4_netmaskzlxd/bridge-ipv4-netmask�ipv4_dhcp_firstzlxd/bridge-ipv4-dhcp-first�ipv4_dhcp_lastzlxd/bridge-ipv4-dhcp-lastZipv4_dhcp_leaseszlxd/bridge-ipv4-dhcp-leases�ipv4_natzlxd/bridge-ipv4-nat�ipv6_addresszlxd/bridge-ipv6zlxd/bridge-ipv6-address�ipv6_netmaskzlxd/bridge-ipv6-netmask�ipv6_natzlxd/bridge-ipv6-nat�domainzlxd/bridge-domainzinvalid bridge mode "%s")rCrH)rr^r r r!rSXsB




rScCs�|jd�dkrd#S|jdt�}g}dd|ddg}|jd�dkrFd|fS|jd�d	krftd
|jd���dd|g}|jd�r�|jd
�r�|jd|jd�|jd
�f�|jdd�dkr�|jd�|jd�r�|jd�r�d|jd�|jd�f}|jd|�n
|jd�|jd��rV|jd��rV|jd|jd�|jd�f�|jdd�dk�r`|jd�n
|jd�|jd��r�|jd|jd��|jd d$�}|d%k�r�|jd"|���||fS)&Nrbrcr�networkzattach-profiler5�eth0rergzinvalid bridge mode "%s"r4rhrizipv4.address=%s/%srlrfz
ipv4.nat=truerjrkz%s-%szipv4.dhcp.ranges=%szipv4.address=nonermrnzipv6.address=%s/%srordz
ipv6.nat=truezipv6.address=nonerpz
dns.domain=%s�mtu�zbridge.mtu=)NN���ru)rCrRrHr)rZbridge_namer_r`Z
dhcp_rangersr r r!rV�sH




rVcCsBdtjjdd�tjjdd�d�}tjdgt|�dg|d	�dS)
N�C�HOMEz/root�USER�root)�LC_ALLrwrxr3z
--force-local)Z
update_env)rL�environrCr�list)r]�envr r r!rY�srYr5rrc
Cs$|tks|rdSd}d}|r�d}y$tdd||g�tj||||�WnBtjk
r�}	z$|	jdkrh|	�tj||||�WYdd}	~	Xn"Xd}tdd	|g�tj|||�|�r d
}y&tddd
||g�tj||||�WnDtjk
�r}	z$|	jdkr�|	�tj||||�WYdd}	~	XnXdS)aNewer versions of lxc (3.0.1+) create a lxdbr0 network when
    'lxd init --auto' is run.  Older versions did not.

    By removing any that lxd-init created, we simply leave the add/attach
    code intact.

    https://github.com/canonical/lxd/issues/4649Nz"failed. Assuming it did not exist.z
succeeded.z/Detach of lxd network '%s' from profile '%s' %srqzdetach-profilertzDeletion of lxd network '%s' %s�deletez+Removal of device '%s' from profile '%s' %s�profileZdevice�remove)rRrYrDrErrGZ	exit_code)
r?r@r4rArZnic_nameZfail_assume_enoentZ	succeeded�msgrZr r r!rW�s2

"
rW)rrr&c
Cs�g}g}i}d|kr"|j|d�|rdd|krdytj|�}Wn&tjttfk
rbtjd�YnXx,|jdg�D]}|jd�rr|j|d�qrWd|kr�t	j
d�r�|jd�d|kr�t	j
d�r�|jd	�d
|kr�t	j
d�r�|jd�|S)
z&identify required packages for installr+Z
storage_poolsz|lxd.preseed string value is not YAML.  Unable to determine required storage driver packages to support storage_pools config.ZdriverZzfszzfsutils-linuxr2ZlvcreateZlvm2Zbtrfsz
mkfs.btrfszbtrfs-progs)rr�loadZ	YAMLError�	TypeErrorrrDrKrCrrF)rrr[Zstorage_driversZpreseed_cfgr.r r r!rI�s*



rI)r5rr)&�__doc__ZloggingrL�textwraprZtypingrrZ	cloudinitrrrZcloudinit.cloudrZcloudinit.configr	Zcloudinit.config.schemar
rZcloudinit.settingsrZ	getLoggerrrDrRZMODULE_DESCRIPTIONr�metarrr"r|rarSrVrYrWrIr r r r!�<module>sF
	L$1<

'

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 128 B 0644
__init__.cpython-36.pyc File 128 B 0644
cc_ansible.cpython-36.opt-1.pyc File 8.63 KB 0644
cc_ansible.cpython-36.pyc File 8.63 KB 0644
cc_apk_configure.cpython-36.opt-1.pyc File 4.51 KB 0644
cc_apk_configure.cpython-36.pyc File 4.51 KB 0644
cc_apt_configure.cpython-36.opt-1.pyc File 30.42 KB 0644
cc_apt_configure.cpython-36.pyc File 30.42 KB 0644
cc_apt_pipelining.cpython-36.opt-1.pyc File 2.44 KB 0644
cc_apt_pipelining.cpython-36.pyc File 2.44 KB 0644
cc_bootcmd.cpython-36.opt-1.pyc File 2.51 KB 0644
cc_bootcmd.cpython-36.pyc File 2.51 KB 0644
cc_byobu.cpython-36.opt-1.pyc File 3.04 KB 0644
cc_byobu.cpython-36.pyc File 3.04 KB 0644
cc_ca_certs.cpython-36.opt-1.pyc File 7.05 KB 0644
cc_ca_certs.cpython-36.pyc File 7.05 KB 0644
cc_chef.cpython-36.opt-1.pyc File 9.13 KB 0644
cc_chef.cpython-36.pyc File 9.13 KB 0644
cc_disable_ec2_metadata.cpython-36.opt-1.pyc File 1.72 KB 0644
cc_disable_ec2_metadata.cpython-36.pyc File 1.72 KB 0644
cc_disk_setup.cpython-36.opt-1.pyc File 23.1 KB 0644
cc_disk_setup.cpython-36.pyc File 23.1 KB 0644
cc_fan.cpython-36.opt-1.pyc File 2.74 KB 0644
cc_fan.cpython-36.pyc File 2.74 KB 0644
cc_final_message.cpython-36.opt-1.pyc File 3.07 KB 0644
cc_final_message.cpython-36.pyc File 3.07 KB 0644
cc_growpart.cpython-36.opt-1.pyc File 15.91 KB 0644
cc_growpart.cpython-36.pyc File 15.91 KB 0644
cc_grub_dpkg.cpython-36.opt-1.pyc File 4.92 KB 0644
cc_grub_dpkg.cpython-36.pyc File 4.92 KB 0644
cc_install_hotplug.cpython-36.opt-1.pyc File 3.25 KB 0644
cc_install_hotplug.cpython-36.pyc File 3.25 KB 0644
cc_keyboard.cpython-36.opt-1.pyc File 1.98 KB 0644
cc_keyboard.cpython-36.pyc File 1.98 KB 0644
cc_keys_to_console.cpython-36.opt-1.pyc File 3.11 KB 0644
cc_keys_to_console.cpython-36.pyc File 3.11 KB 0644
cc_landscape.cpython-36.opt-1.pyc File 4.71 KB 0644
cc_landscape.cpython-36.pyc File 4.71 KB 0644
cc_locale.cpython-36.opt-1.pyc File 1.58 KB 0644
cc_locale.cpython-36.pyc File 1.58 KB 0644
cc_lxd.cpython-36.opt-1.pyc File 13.04 KB 0644
cc_lxd.cpython-36.pyc File 13.04 KB 0644
cc_mcollective.cpython-36.opt-1.pyc File 4.24 KB 0644
cc_mcollective.cpython-36.pyc File 4.24 KB 0644
cc_migrator.cpython-36.opt-1.pyc File 2.92 KB 0644
cc_migrator.cpython-36.pyc File 2.92 KB 0644
cc_mounts.cpython-36.opt-1.pyc File 14.08 KB 0644
cc_mounts.cpython-36.pyc File 14.08 KB 0644
cc_ntp.cpython-36.opt-1.pyc File 13.15 KB 0644
cc_ntp.cpython-36.pyc File 13.15 KB 0644
cc_package_update_upgrade_install.cpython-36.opt-1.pyc File 3.78 KB 0644
cc_package_update_upgrade_install.cpython-36.pyc File 3.78 KB 0644
cc_phone_home.cpython-36.opt-1.pyc File 4.1 KB 0644
cc_phone_home.cpython-36.pyc File 4.1 KB 0644
cc_power_state_change.cpython-36.opt-1.pyc File 6.24 KB 0644
cc_power_state_change.cpython-36.pyc File 6.24 KB 0644
cc_puppet.cpython-36.opt-1.pyc File 9.46 KB 0644
cc_puppet.cpython-36.pyc File 9.46 KB 0644
cc_reset_rmc.cpython-36.opt-1.pyc File 3.59 KB 0644
cc_reset_rmc.cpython-36.pyc File 3.59 KB 0644
cc_resizefs.cpython-36.opt-1.pyc File 7.02 KB 0644
cc_resizefs.cpython-36.pyc File 7.02 KB 0644
cc_resolv_conf.cpython-36.opt-1.pyc File 4.27 KB 0644
cc_resolv_conf.cpython-36.pyc File 4.27 KB 0644
cc_rh_subscription.cpython-36.opt-1.pyc File 12.06 KB 0644
cc_rh_subscription.cpython-36.pyc File 12.06 KB 0644
cc_rightscale_userdata.cpython-36.opt-1.pyc File 2.77 KB 0644
cc_rightscale_userdata.cpython-36.pyc File 2.77 KB 0644
cc_rsyslog.cpython-36.opt-1.pyc File 10.34 KB 0644
cc_rsyslog.cpython-36.pyc File 10.34 KB 0644
cc_runcmd.cpython-36.opt-1.pyc File 2.43 KB 0644
cc_runcmd.cpython-36.pyc File 2.43 KB 0644
cc_salt_minion.cpython-36.opt-1.pyc File 4.36 KB 0644
cc_salt_minion.cpython-36.pyc File 4.36 KB 0644
cc_scripts_per_boot.cpython-36.opt-1.pyc File 1.4 KB 0644
cc_scripts_per_boot.cpython-36.pyc File 1.4 KB 0644
cc_scripts_per_instance.cpython-36.opt-1.pyc File 1.57 KB 0644
cc_scripts_per_instance.cpython-36.pyc File 1.57 KB 0644
cc_scripts_per_once.cpython-36.opt-1.pyc File 1.51 KB 0644
cc_scripts_per_once.cpython-36.pyc File 1.51 KB 0644
cc_scripts_user.cpython-36.opt-1.pyc File 1.58 KB 0644
cc_scripts_user.cpython-36.pyc File 1.58 KB 0644
cc_scripts_vendor.cpython-36.opt-1.pyc File 2.04 KB 0644
cc_scripts_vendor.cpython-36.pyc File 2.04 KB 0644
cc_seed_random.cpython-36.opt-1.pyc File 4.07 KB 0644
cc_seed_random.cpython-36.pyc File 4.07 KB 0644
cc_set_hostname.cpython-36.opt-1.pyc File 4 KB 0644
cc_set_hostname.cpython-36.pyc File 4 KB 0644
cc_set_passwords.cpython-36.opt-1.pyc File 8.4 KB 0644
cc_set_passwords.cpython-36.pyc File 8.4 KB 0644
cc_snap.cpython-36.opt-1.pyc File 5.94 KB 0644
cc_snap.cpython-36.pyc File 5.94 KB 0644
cc_spacewalk.cpython-36.opt-1.pyc File 2.87 KB 0644
cc_spacewalk.cpython-36.pyc File 2.87 KB 0644
cc_ssh.cpython-36.opt-1.pyc File 11.02 KB 0644
cc_ssh.cpython-36.pyc File 11.02 KB 0644
cc_ssh_authkey_fingerprints.cpython-36.opt-1.pyc File 3.54 KB 0644
cc_ssh_authkey_fingerprints.cpython-36.pyc File 3.54 KB 0644
cc_ssh_import_id.cpython-36.opt-1.pyc File 3.85 KB 0644
cc_ssh_import_id.cpython-36.pyc File 3.85 KB 0644
cc_timezone.cpython-36.opt-1.pyc File 1.24 KB 0644
cc_timezone.cpython-36.pyc File 1.24 KB 0644
cc_ubuntu_advantage.cpython-36.opt-1.pyc File 12.42 KB 0644
cc_ubuntu_advantage.cpython-36.pyc File 12.42 KB 0644
cc_ubuntu_autoinstall.cpython-36.opt-1.pyc File 3.89 KB 0644
cc_ubuntu_autoinstall.cpython-36.pyc File 3.89 KB 0644
cc_ubuntu_drivers.cpython-36.opt-1.pyc File 3.63 KB 0644
cc_ubuntu_drivers.cpython-36.pyc File 3.63 KB 0644
cc_update_etc_hosts.cpython-36.opt-1.pyc File 4.3 KB 0644
cc_update_etc_hosts.cpython-36.pyc File 4.3 KB 0644
cc_update_hostname.cpython-36.opt-1.pyc File 3.01 KB 0644
cc_update_hostname.cpython-36.pyc File 3.01 KB 0644
cc_users_groups.cpython-36.opt-1.pyc File 7.58 KB 0644
cc_users_groups.cpython-36.pyc File 7.58 KB 0644
cc_wireguard.cpython-36.opt-1.pyc File 8.39 KB 0644
cc_wireguard.cpython-36.pyc File 8.39 KB 0644
cc_write_files.cpython-36.opt-1.pyc File 5.61 KB 0644
cc_write_files.cpython-36.pyc File 5.61 KB 0644
cc_write_files_deferred.cpython-36.opt-1.pyc File 1.73 KB 0644
cc_write_files_deferred.cpython-36.pyc File 1.73 KB 0644
cc_yum_add_repo.cpython-36.opt-1.pyc File 6.03 KB 0644
cc_yum_add_repo.cpython-36.pyc File 6.03 KB 0644
cc_zypper_add_repo.cpython-36.opt-1.pyc File 5.66 KB 0644
cc_zypper_add_repo.cpython-36.pyc File 5.66 KB 0644
modules.cpython-36.opt-1.pyc File 7.31 KB 0644
modules.cpython-36.pyc File 7.31 KB 0644
schema.cpython-36.opt-1.pyc File 39.45 KB 0644
schema.cpython-36.pyc File 39.45 KB 0644