3 cj$@sUdZddlZddlZddlmZddlmZmZddlm Z ddl m Z ddl m Z mZddlmZejeZdd d d d gd Zdddddgd dddddgd ddddd gd dZxd:D]Zedee<qWxd;D]Zedee<qWdZddd d!d"ddddddddd#gZd$d%d&eeeed'gd(d)gd*Ze eeZd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Ze e e e!dd7d8d9Z"dS)t|dD]0\}}t|}|dj|d}tj||ddqWdS)a- Adds certificates to the system. To actually apply the new certificates you must also call the appropriate distro-specific utility such as L{update_ca_certs}. @param distro_cfg: A hash providing _distro_ca_certs_configs function. @param certs: A list of certificate strings. Nr#) cert_indexi)mode) enumeratestrformatr write_file)r/Zcertsr2cZcert_file_contentsZcert_file_namer,r,r- add_ca_certss r9cCs@|dkrt|n*|d krs(     r>cCs:|ddkrdStjdtj|dtj|ddS)z Removes all default trusted CA certificates from the system. @param distro_cfg: A hash providing _distro_ca_certs_configs function. r NzDeleting system CA certificatesr )LOGdebugrZdelete_dir_contents)r/r,r,r-r=s   r=)rr+cloudargsreturncCsd|krtjddddnd|kr2tjd|dSd|krLd|krLtjd |jd|jd}t|jj}d |krtjd dd d|jd |jd drtjdt |jj|d|krtj |d}|rtjdt |t ||tjdt |dS)au Call to handle ca_cert sections in cloud-config file. @param name: The module name "ca_cert" from cloud.cfg @param cfg: A nested dict containing the entire cloud config contents. @param cloud: The L{CloudInit} object in use. @param log: Pre-initialized Python logger object to use for logging. @param args: Any module arguments from cloud.cfg zca-certszKey 'ca-certs'z22.1zUse 'ca_certs' instead.)Z deprecatedZdeprecated_versionZ extra_messagerz       rR)rrrrrr)rr)#__doc__Zloggingr'textwraprZ cloudinitrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarrZcloudinit.settingsr Z getLogger__name__rKr&r$rPZMODULE_DESCRIPTIONr"metar.r0r9r?r>r=r5listrRr,r,r,r-s         '