f- FUdZddlZddlZddlmZddlmZmZddlm Z ddl m Z ddl m Z mZddlmZdd lmZd gZeZej*eZd d d edeededededgedgdZe ed<eeZdZdZdZdede de deddf dZy)z``. Snap ``commands`` is a dictionary or list of individual snap commands to run on the target system. These commands can be used to create snap users, install snaps and provide snap configuration. .. note:: If 'side-loading' private/unpublished snaps on an instance, it is best to create a snap seed directory and seed.yaml manifest in **/var/lib/snapd/seed/** which snapd automatically installs on startup. ax snap: assertions: 00: | signed_assertion_blob_here 02: | signed_assertion_blob_here commands: 00: snap create-user --sudoer --known @mydomain.com 01: snap install canonical-livepatch 02: canonical-livepatch enable ay # Convenience: the snap command can be omitted when specifying commands # as a list and 'snap' will automatically be prepended. # The following commands are equivalent: snap: commands: 00: ['install', 'vlc'] 01: ['snap', 'install', 'vlc'] 02: snap install vlc 03: 'snap install vlc' z # You can use a list of commands snap: commands: - ['install', 'vlc'] - ['snap', 'install', 'vlc'] - snap install vlc - 'snap install vlc' z # You can use a list of assertions snap: assertions: - signed_assertion_blob_here - | signed_assertion_blob_here snap)idnametitle descriptiondistrosexamples frequencyactivate_by_schema_keysmetac|sytjdt|tr|j }n+t|t st dj|td|g}dj|}|D]*}tjd|jddd ,tj||jd tj|d y) aImport list of assertions. Import assertions by concatenating each assertion into a string separated by a ' '. Write this string to a instance file and then invoke `snap ack /path/to/file` and check for errors. If snap exits 0, then all assertions are imported. Nz'Importing user-provided snap assertionsz8assertion parameter was not a list or dict: {assertions}) assertionsack zSnap acking: %srzutf-8T)capture)LOGdebug isinstancedictvalueslist TypeErrorformatSNAP_CMDjoinsplitr write_fileencoder)rassertions_filesnap_cmdcombinedasrts :/usr/lib/python3/dist-packages/cloudinit/config/cc_snap.pyadd_assertionsr1vs II78*d#&&(  D ) F M M% N   %1Hyy$H< #TZZ%5a%:;< OOOX__W%=>IIh%cn|sytjdt|tr,t |j Dcgc]\}}| }}}n+t|t stdj|td|}g}|D]*}t|t} tj||,|r7dj|}tjt|t!|ycc}}w#tj$r$}|jt|Yd}~d}~wwxYw) aHRun the provided commands provided in snap:commands configuration. Commands are run individually. Any errors are collected and reported after attempting all commands. @param commands: A list or dict containing commands to run. Keys of a dict will be used to order the commands provided as dict values. Nz#Running user-provided snap commandsz5commands parameter was not a list or dict: {commands})commandsr)shellz.Failures running snap commands: {cmd_failures}) cmd_failures)rr r!r"sorteditemsr$r%r&r strrProcessExecutionErrorappendrlogexc RuntimeError) r4_vfixed_snap_commandsr6commandr5emsgs r0 run_commandsrDs$ II34(D!"()9":;$!QA;; $ ' C J J! K   /vx@L&(7C( ( IIgU +( ?FF%G  C3 #<)) (   A ' ' (s C7$C==D4D//D4rcfgcloudargsreturnc^|jdi}|stjd|ytj|t |jdgt jj|jjdt|jdgy)Nrz8Skipping module named %s, no 'snap' key in configurationrzsnapd.assertionsr4) getrr rwait_for_snap_seededr1ospathr(paths get_ipath_currD)rrErFrGcfgins r0handlerQs GGFB E  F  e$ ,#  U[[..02DE:r*+r2) __doc__loggingrLtextwrapr cloudinitrrcloudinit.cloudrcloudinit.configrcloudinit.config.schemarr cloudinit.settingsr cloudinit.subpr rr getLogger__name__rr__annotations__r'r1rDr9r$rQr2r0r_s C  !#<+/ *  g!   D <           O1d &xmWjWt t  &<$ N , ,6 ,% ,t , ,r2