summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/distros/__init__.py9
-rw-r--r--cloudinit/distros/arch.py7
-rw-r--r--cloudinit/distros/debian.py7
-rw-r--r--cloudinit/distros/freebsd.py5
-rw-r--r--cloudinit/distros/gentoo.py7
-rw-r--r--cloudinit/distros/sles.py7
6 files changed, 6 insertions, 36 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index bf465442..5eab780b 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -86,7 +86,7 @@ class Distro(object):
def set_hostname(self, hostname, fqdn=None):
writeable_hostname = self._select_hostname(hostname, fqdn)
self._write_hostname(writeable_hostname, self.hostname_conf_fn)
- self._apply_hostname(hostname)
+ self._apply_hostname(writeable_hostname)
@abc.abstractmethod
def package_command(self, cmd, args=None, pkgs=None):
@@ -160,9 +160,12 @@ class Distro(object):
util.logexc(LOG, "Failed to non-persistently adjust the system "
"hostname to %s", hostname)
- @abc.abstractmethod
def _select_hostname(self, hostname, fqdn):
- raise NotImplementedError()
+ # Prefer the short hostname over the long
+ # fully qualified domain name
+ if not hostname:
+ return fqdn
+ return hostname
@staticmethod
def expand_osfamily(family_list):
diff --git a/cloudinit/distros/arch.py b/cloudinit/distros/arch.py
index 005a0dd4..68bf1aab 100644
--- a/cloudinit/distros/arch.py
+++ b/cloudinit/distros/arch.py
@@ -118,13 +118,6 @@ class Distro(distros.Distro):
return False
return True
- def _select_hostname(self, hostname, fqdn):
- # Prefer the short hostname over the long
- # fully qualified domain name
- if not hostname:
- return fqdn
- return hostname
-
def _write_hostname(self, your_hostname, out_fn):
conf = None
try:
diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py
index 010be67d..b09eb094 100644
--- a/cloudinit/distros/debian.py
+++ b/cloudinit/distros/debian.py
@@ -86,13 +86,6 @@ class Distro(distros.Distro):
else:
return distros.Distro._bring_up_interfaces(self, device_names)
- def _select_hostname(self, hostname, fqdn):
- # Prefer the short hostname over the long
- # fully qualified domain name
- if not hostname:
- return fqdn
- return hostname
-
def _write_hostname(self, your_hostname, out_fn):
conf = None
try:
diff --git a/cloudinit/distros/freebsd.py b/cloudinit/distros/freebsd.py
index 9216510e..f1b4a256 100644
--- a/cloudinit/distros/freebsd.py
+++ b/cloudinit/distros/freebsd.py
@@ -150,11 +150,6 @@ class Distro(distros.Distro):
return default
return hostname
- def _select_hostname(self, hostname, fqdn):
- if not hostname:
- return fqdn
- return hostname
-
def _write_hostname(self, hostname, filename):
self.updatercconf('hostname', hostname)
diff --git a/cloudinit/distros/gentoo.py b/cloudinit/distros/gentoo.py
index 45c2e658..09dd0d73 100644
--- a/cloudinit/distros/gentoo.py
+++ b/cloudinit/distros/gentoo.py
@@ -97,13 +97,6 @@ class Distro(distros.Distro):
else:
return distros.Distro._bring_up_interfaces(self, device_names)
- def _select_hostname(self, hostname, fqdn):
- # Prefer the short hostname over the long
- # fully qualified domain name
- if not hostname:
- return fqdn
- return hostname
-
def _write_hostname(self, your_hostname, out_fn):
conf = None
try:
diff --git a/cloudinit/distros/sles.py b/cloudinit/distros/sles.py
index 9788a1ba..43682a12 100644
--- a/cloudinit/distros/sles.py
+++ b/cloudinit/distros/sles.py
@@ -115,13 +115,6 @@ class Distro(distros.Distro):
conf.set_hostname(hostname)
util.write_file(out_fn, str(conf), 0644)
- def _select_hostname(self, hostname, fqdn):
- # Prefer the short hostname over the long
- # fully qualified domain name
- if not hostname:
- return fqdn
- return hostname
-
def _read_system_hostname(self):
host_fn = self.hostname_conf_fn
return (host_fn, self._read_hostname(host_fn))