�
oB�]c@sTdZddlmZddlmZddlZddgZd�Zd�ZdS( s9
SSH Import Id
-------------
**Summary:** import ssh id
This module imports ssh keys from either a public keyserver, usually launchpad
or github using ``ssh-import-id``. Keys are referenced by the username they are
associated with on the keyserver. The keyserver can be specified by prepending
either ``lp:`` for launchpad or ``gh:`` for github to the username.
**Internal name:** ``cc_ssh_import_id``
**Module frequency:** per instance
**Supported distros:** ubuntu, debian
**Config keys**::
ssh_import_id:
- user
- gh:user
- lp:user
i����(tug_util(tutilNtubuntutdebiancCs�t|�dkrU|d}g}t|�dkrA|d}nt|||�dStj||j�\}}g} x/|j�D]!\}}
g}|
dr�tj|dg�}n5y|
d}Wn$tk
r�|j d|�q�nXy2tj
|�}g|D]}t|�^q}Wn$tk
rD|j d|�q�nXt|�sWq�nyt|||�Wq�tk
r�}
tj|d||�| j
|
�q�Xq�Wt| �r�| d�ndS(Niitdefaultt
ssh_import_ids+User %s is not configured for ssh_import_ids5User %s is not correctly configured for ssh_import_idsssh-import-id failed for: %s %s(tlentimport_ssh_idsRtnormalize_users_groupstdistrotitemsRtget_cfg_option_listt Exceptiontdebugt
uniq_mergetstrtlogexctappend(t_nametcfgtcloudtlogtargstusertidstuserst_groupstelisttuser_cfgt
import_idstitexc((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_import_id.pythandle)sF
#
cCs�|o |s#|jd||�dSytj|�Wntk
rO}|�nXdd|dg|}|jd|�ytj|dt�Wn/tjk
r�}tj|d|�|�nXdS(Ns(empty user(%s) or ids(%s). not importingtsudos-Hus
ssh-import-idsImporting ssh ids for user %s.tcaptures*Failed to run command to import %s ssh ids( R
tpwdtgetpwnamtKeyErrorRtsubptFalsetProcessExecutionErrorR(RRRRtcmd((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_import_id.pyRYs
( t__doc__tcloudinit.distrosRt cloudinitRR#tdistrosR R(((sE/usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_import_id.pyt<module>s 0 |