From a09fc4584e3c756e82aa7b040fe9ff4feef6f51a Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 29 Apr 2011 16:20:13 -0600 Subject: [PATCH] Clean up hostname grain a bit --- salt/grains/core.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/salt/grains/core.py b/salt/grains/core.py index d3d828c093..a0fa13b52d 100644 --- a/salt/grains/core.py +++ b/salt/grains/core.py @@ -129,9 +129,11 @@ def hostname(): stdout=subprocess.PIPE).communicate()[0].strip() domain = subprocess.Popen(['dnsdomainname'], stdout=subprocess.PIPE).communicate()[0].strip() - return {'host': host, - 'domain': domain, - 'fqdn': host + '.' + domain} + grains = {'host': host} + if domain: + grains['domain'] = domain + grains['fqdn'] = host + '.' + domain + return grains def path(): '''