@ -113,11 +113,9 @@ class DistributionFiles:
# only the distribution name is set, the version is assumed to be correct from platform.dist()
# only the distribution name is set, the version is assumed to be correct from platform.dist()
if self . SEARCH_STRING [ name ] in dist_file_content :
if self . SEARCH_STRING [ name ] in dist_file_content :
# this sets distribution=RedHat if 'Red Hat' shows up in data
# this sets distribution=RedHat if 'Red Hat' shows up in data
# self.facts['distribution'] = name
dist_file_dict [ ' distribution ' ] = name
dist_file_dict [ ' distribution ' ] = name
else :
else :
# this sets distribution to what's in the data, e.g. CentOS, Scientific, ...
# this sets distribution to what's in the data, e.g. CentOS, Scientific, ...
# self.facts['distribution'] = dist_file_content.split()[0]
dist_file_dict [ ' distribution ' ] = dist_file_content . split ( ) [ 0 ]
dist_file_dict [ ' distribution ' ] = dist_file_content . split ( ) [ 0 ]
return True , dist_file_dict
return True , dist_file_dict
@ -126,15 +124,14 @@ class DistributionFiles:
if self . OS_RELEASE_ALIAS [ name ] in dist_file_content :
if self . OS_RELEASE_ALIAS [ name ] in dist_file_content :
dist_file_dict [ ' distribution ' ] = name
dist_file_dict [ ' distribution ' ] = name
return True , dist_file_dict
return True , dist_file_dict
return False , dist_file_dict
# call a dedicated function for parsing the file content
# call a dedicated function for parsing the file content
# TODO: replace with a map or a class
# TODO: replace with a map or a class
try :
try :
# FIXME: most of these dont actually look at the dist file contents, but random other stuff
# FIXME: most of these dont actually look at the dist file contents, but random other stuff
distfunc_name = ' parse_distribution_file_ ' + name
distfunc_name = ' parse_distribution_file_ ' + name
# print('distfunc_name: %s' % distfunc_name)
distfunc = getattr ( self , distfunc_name )
distfunc = getattr ( self , distfunc_name )
# print('distfunc: %s' % distfunc)
parsed , dist_file_dict = distfunc ( name , dist_file_content , path , collected_facts )
parsed , dist_file_dict = distfunc ( name , dist_file_content , path , collected_facts )
return parsed , dist_file_dict
return parsed , dist_file_dict
except AttributeError as exc :
except AttributeError as exc :
@ -180,31 +177,29 @@ class DistributionFiles:
# /etc/os-release with a different name
# /etc/os-release with a different name
if has_dist_file and allow_empty :
if has_dist_file and allow_empty :
dist_file_facts [ ' distribution ' ] = name
dist_file_facts [ ' distribution ' ] = name
dist_file_facts [ ' distribution_file_path ' ] = path
dist_file_facts [ ' distribution_file_variety ' ] = name
break
break
if not has_dist_file :
if not has_dist_file :
# keep looking
# keep looking
continue
continue
# first valid os dist file we find we count
# FIXME: coreos and a few other bits expect this
# self.facts['distribution'] = name
dist_file_facts [ ' distribution ' ] = name
dist_file_facts [ ' distribution_file_variety ' ] = name
dist_file_facts [ ' distribution_file_path ' ] = path
parsed_dist_file , parsed_dist_file_facts = self . _parse_dist_file ( name , dist_file_content , path , dist_file_facts )
parsed_dist_file , parsed_dist_file_facts = self . _parse_dist_file ( name , dist_file_content , path , dist_file_facts )
dist_file_facts [ ' distribution_file_parsed ' ] = parsed_dist_file
# finally found the right os dist file and were able to parse it
# finally found the right os dit file and were able to parse it
if parsed_dist_file :
if parsed_dist_file :
dist_file_facts [ ' distribution ' ] = name
dist_file_facts [ ' distribution_file_path ' ] = path
# distribution and file_variety are the same here, but distribution
# will be changed/mapped to a more specific name.
# ie, dist=Fedora, file_variety=RedHat
dist_file_facts [ ' distribution_file_variety ' ] = name
dist_file_facts [ ' distribution_file_parsed ' ] = parsed_dist_file
dist_file_facts . update ( parsed_dist_file_facts )
dist_file_facts . update ( parsed_dist_file_facts )
break
break
return dist_file_facts
return dist_file_facts
# distribution_facts.update(dist_file_facts)
# return distribution_facts
# TODO: FIXME: split distro file parsing into its own module or class
# TODO: FIXME: split distro file parsing into its own module or class
def parse_distribution_file_Slackware ( self , name , data , path , collected_facts ) :
def parse_distribution_file_Slackware ( self , name , data , path , collected_facts ) :
@ -338,7 +333,7 @@ class DistributionFiles:
na_facts = { }
na_facts = { }
for line in data . splitlines ( ) :
for line in data . splitlines ( ) :
distribution = re . search ( " ^NAME=(.*) " , line )
distribution = re . search ( " ^NAME=(.*) " , line )
if distribution and collected_facts[ ' distribution ' ] == ' NA ' :
if distribution and name == ' NA ' :
na_facts [ ' distribution ' ] = distribution . group ( 1 ) . strip ( ' " ' )
na_facts [ ' distribution ' ] = distribution . group ( 1 ) . strip ( ' " ' )
version = re . search ( " ^VERSION=(.*) " , line )
version = re . search ( " ^VERSION=(.*) " , line )
if version and collected_facts [ ' distribution_version ' ] == ' NA ' :
if version and collected_facts [ ' distribution_version ' ] == ' NA ' :
@ -532,11 +527,8 @@ class Distribution(object):
def get_distribution_SunOS ( self ) :
def get_distribution_SunOS ( self ) :
sunos_facts = { }
sunos_facts = { }
# print('platform.release: %s' % distribution_release)
data = get_file_content ( ' /etc/release ' ) . splitlines ( ) [ 0 ]
data = get_file_content ( ' /etc/release ' ) . splitlines ( ) [ 0 ]
# print('get_file_content: data=%s' % data)
if ' Solaris ' in data :
if ' Solaris ' in data :
ora_prefix = ' '
ora_prefix = ' '
if ' Oracle Solaris ' in data :
if ' Oracle Solaris ' in data :
@ -550,8 +542,6 @@ class Distribution(object):
uname_v = get_uname_version ( self . module )
uname_v = get_uname_version ( self . module )
distribution_version = None
distribution_version = None
# print('uname_v: %s' % uname_v)
if ' SmartOS ' in data :
if ' SmartOS ' in data :
sunos_facts [ ' distribution ' ] = ' SmartOS '
sunos_facts [ ' distribution ' ] = ' SmartOS '
if _file_exists ( ' /etc/product ' ) :
if _file_exists ( ' /etc/product ' ) :
@ -567,7 +557,6 @@ class Distribution(object):
sunos_facts [ ' distribution ' ] = ' Nexenta '
sunos_facts [ ' distribution ' ] = ' Nexenta '
distribution_version = data . split ( ) [ - 1 ] . lstrip ( ' v ' )
distribution_version = data . split ( ) [ - 1 ] . lstrip ( ' v ' )
# print('sunos_facts: %s' % sunos_facts)
if sunos_facts . get ( ' distribution ' , ' ' ) in ( ' SmartOS ' , ' OpenIndiana ' , ' OmniOS ' , ' Nexenta ' ) :
if sunos_facts . get ( ' distribution ' , ' ' ) in ( ' SmartOS ' , ' OpenIndiana ' , ' OmniOS ' , ' Nexenta ' ) :
sunos_facts [ ' distribution_release ' ] = data . strip ( )
sunos_facts [ ' distribution_release ' ] = data . strip ( )
if distribution_version is not None :
if distribution_version is not None :