ó 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.pyts    0