Current File : //lib/python2.7/site-packages/cloudinit/config/cc_ssh_import_id.pyo |
�
oB�]c @ sT d Z d d l m Z d d l m Z d d l Z d d g Z d � Z d � Z d S( 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����( t ug_util( t utilNt ubuntut debianc C s� t | � d k rU | d } g } t | � d k rA | d } n t | | | � d St j | | j � \ } } g } x/| j � D]!\ } }
g } |
d r� t j | d g � } n5 y |
d } Wn$ t k
r� | j d | � q� n Xy2 t j
| � } g | D] } t | � ^ q} Wn$ t k
rD| j d | � q� n Xt | � sWq� n y t | | | � Wq� t k
r�}
t j | d | | � | j
|
� q� Xq� Wt | � r�| d � n d S( Ni i t defaultt
ssh_import_ids+ User %s is not configured for ssh_import_ids5 User %s is not correctly configured for ssh_import_ids ssh-import-id failed for: %s %s( t lent import_ssh_idsR t normalize_users_groupst distrot itemsR t get_cfg_option_listt Exceptiont debugt
uniq_merget strt logexct append( t _namet cfgt cloudt logt argst usert idst userst _groupst elistt user_cfgt
import_idst it exc( ( sE /usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_import_id.pyt handle) sF
#
c C s� | o | s# | j d | | � d Sy t j | � Wn t k
rO } | � n Xd d | d g | } | j d | � y t j | d t �Wn/ t j k
r� } t j | d | � | � n Xd S( Ns( empty user(%s) or ids(%s). not importingt sudos -Hus
ssh-import-ids Importing ssh ids for user %s.t captures* Failed to run command to import %s ssh ids( R
t pwdt getpwnamt KeyErrorR t subpt Falset ProcessExecutionErrorR ( R R R R t cmd( ( sE /usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_import_id.pyR Y s
( t __doc__t cloudinit.distrosR t cloudinitR R# t distrosR R ( ( ( sE /usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_import_id.pyt <module> s 0