|
|
|
@ -151,6 +151,7 @@ class Facts(object):
|
|
|
|
|
self.get_user_facts()
|
|
|
|
|
self.get_local_facts()
|
|
|
|
|
self.get_env_facts()
|
|
|
|
|
self.get_dns_facts()
|
|
|
|
|
|
|
|
|
|
def populate(self):
|
|
|
|
|
return self.facts
|
|
|
|
@ -632,6 +633,37 @@ class Facts(object):
|
|
|
|
|
for k,v in os.environ.iteritems():
|
|
|
|
|
self.facts['env'][k] = v
|
|
|
|
|
|
|
|
|
|
def get_dns_facts(self):
|
|
|
|
|
self.facts['dns'] = {}
|
|
|
|
|
for line in get_file_lines('/etc/resolv.conf'):
|
|
|
|
|
if line.startswith('#') or line.startswith(';') or line.strip() == '':
|
|
|
|
|
continue
|
|
|
|
|
tokens = line.split()
|
|
|
|
|
if len(tokens) == 0:
|
|
|
|
|
continue
|
|
|
|
|
if tokens[0] == 'nameserver':
|
|
|
|
|
self.facts['dns']['nameservers'] = []
|
|
|
|
|
for nameserver in tokens[1:]:
|
|
|
|
|
self.facts['dns']['nameservers'].append(nameserver)
|
|
|
|
|
elif tokens[0] == 'domain':
|
|
|
|
|
self.facts['dns']['domain'] = tokens[1]
|
|
|
|
|
elif tokens[0] == 'search':
|
|
|
|
|
self.facts['dns']['search'] = []
|
|
|
|
|
for suffix in tokens[1:]:
|
|
|
|
|
self.facts['dns']['search'].append(suffix)
|
|
|
|
|
elif tokens[0] == 'sortlist':
|
|
|
|
|
self.facts['dns']['sortlist'] = []
|
|
|
|
|
for address in tokens[1:]:
|
|
|
|
|
self.facts['dns']['sortlist'].append(address)
|
|
|
|
|
elif tokens[0] == 'options':
|
|
|
|
|
self.facts['dns']['options'] = {}
|
|
|
|
|
for option in tokens[1:]:
|
|
|
|
|
option_tokens = option.split(':', 1)
|
|
|
|
|
if len(option_tokens) == 0:
|
|
|
|
|
continue
|
|
|
|
|
val = len(option_tokens) == 2 and option_tokens[1] or True
|
|
|
|
|
self.facts['dns']['options'][option_tokens[0]] = val
|
|
|
|
|
|
|
|
|
|
class Hardware(Facts):
|
|
|
|
|
"""
|
|
|
|
|
This is a generic Hardware subclass of Facts. This should be further
|
|
|
|
|