summaryrefslogtreecommitdiff
path: root/cloudinit/distros/__init__.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-11-12 14:30:08 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-11-12 14:30:08 -0800
commit82e90789f11b5371b352a477b75cad0c5d1457ec (patch)
treebfe3fc01c2f70f8af2f438cdc32e50a820e76baa /cloudinit/distros/__init__.py
parentbbe325c902ef3a3b8845cd3c1bb8bee0c3c74a89 (diff)
downloadvyos-cloud-init-82e90789f11b5371b352a477b75cad0c5d1457ec.tar.gz
vyos-cloud-init-82e90789f11b5371b352a477b75cad0c5d1457ec.zip
Cleanup of /etc/hosts ordering and pep8/pylint adjustments.
Fix how the comparison of a fqdn and its aliases was done via sorting instead of existence checking which is the better way to check if a alias already exists as well as cleanup the new files pep8/pylint issues. LP: #1078097
Diffstat (limited to 'cloudinit/distros/__init__.py')
-rw-r--r--cloudinit/distros/__init__.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index fa7cc1ca..4bde2393 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -189,15 +189,20 @@ class Distro(object):
else:
need_change = True
for entry in prev_info:
- if sorted(entry) == sorted([fqdn, hostname]):
- # Exists already, leave it be
- need_change = False
- break
+ entry_fqdn = None
+ entry_aliases = []
+ if len(entry) >= 1:
+ entry_fqdn = entry[0]
+ if len(entry) >= 2:
+ entry_aliases = entry[1:]
+ if entry_fqdn is not None and entry_fqdn == fqdn:
+ if hostname in entry_aliases:
+ # Exists already, leave it be
+ need_change = False
if need_change:
- # Doesn't exist, change the first
- # entry to be this entry
+ # Doesn't exist, add that entry in...
new_entries = list(prev_info)
- new_entries[0] = [fqdn, hostname]
+ new_entries.append([fqdn, hostname])
eh.del_entries(local_ip)
for entry in new_entries:
if len(entry) == 1: