<s> """<STR_LIT>""" <EOL> import logging <EOL> from ceph_deploy import exc <EOL> from ceph_deploy . util import versions <EOL> from ceph_deploy . hosts import debian , centos , fedora , suse , remotes , rhel <EOL> from ceph_deploy . connection import get_connection <EOL> logger = logging . getLogger ( ) <EOL> def get ( hostname , <EOL> username = None , <EOL> fallback = None , <EOL> detect_sudo = True , <EOL> use_rhceph = False , <EOL> callbacks = None ) : <EOL> """<STR_LIT>""" <EOL> conn = get_connection ( <EOL> hostname , <EOL> username = username , <EOL> logger = logging . getLogger ( hostname ) , <EOL> detect_sudo = detect_sudo <EOL> ) <EOL> try : <EOL> conn . import_module ( remotes ) <EOL> except IOError as error : <EOL> if '<STR_LIT>' in getattr ( error , '<STR_LIT:message>' , '<STR_LIT>' ) : <EOL> raise RuntimeError ( '<STR_LIT>' % hostname ) <EOL> distro_name , release , codename = conn . remote_module . platform_information ( ) <EOL> if not codename or not _get_distro ( distro_name ) : <EOL> raise exc . UnsupportedPlatform ( <EOL> distro = distro_name , <EOL> codename = codename , <EOL> release = release ) <EOL> machine_type = conn . remote_module . machine_type ( ) <EOL> module = _get_distro ( distro_name , use_rhceph = use_rhceph ) <EOL> module . name = distro_name <EOL> module . normalized_name = _normalized_distro_name ( distro_name ) <EOL> module . normalized_release = _normalized_release ( release ) <EOL> module . distro = module . normalized_name <EOL> module . is_el = module . normalized_name in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> module . is_rpm = module . normalized_name in [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> module . is_deb = not module . is_rpm <EOL> module . release = release <EOL> module . codename = codename <EOL> module . conn = conn <EOL> module . machine_type = machine_type <EOL> module . init = module . choose_init ( module ) <EOL> module . packager = module . get_packager ( module ) <EOL> if callbacks : <EOL> for c in callbacks : <EOL> c ( module ) <EOL> return module <EOL> def _get_distro ( distro , fallback = None , use_rhceph = False ) : <EOL> if not distro : <EOL> return <EOL> distro = _normalized_distro_name ( distro ) <EOL> distributions = { <EOL> '<STR_LIT>' : debian , <EOL> '<STR_LIT>' : debian , <EOL> '<STR_LIT>' : centos , <EOL> '<STR_LIT>' : centos , <EOL> '<STR_LIT>' : centos , <EOL> '<STR_LIT>' : fedora , <EOL> '<STR_LIT>' : suse , <EOL> } <EOL> if distro == '<STR_LIT>' and use_rhceph : <EOL> return rhel <EOL> else : <EOL> return distributions . get ( distro ) or _get_distro ( fallback ) <EOL> def _normalized_distro_name ( distro ) : <EOL> distro = distro . lower ( ) <EOL> if distro . startswith ( ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> return '<STR_LIT>' <EOL> elif distro . startswith ( ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> return '<STR_LIT>' <EOL> elif distro . startswith ( ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> return '<STR_LIT>' <EOL> elif distro . startswith ( '<STR_LIT>' ) : <EOL> return '<STR_LIT>' <EOL> elif distro . startswith ( '<STR_LIT>' ) : <EOL> return '<STR_LIT>' <EOL> return distro <EOL> def _normalized_release ( release ) : <EOL> """<STR_LIT>""" <EOL> return versions . NormalizedVersion ( release ) </s>
