+ def read_static_hosts(self):
+ log.info("Reading static hosts from %s" % self.hosts_file)
+
+ hosts = {}
+ with open(self.hosts_file) as f:
+ for line in f.readlines():
+ line = line.rstrip()
+
+ try:
+ enabled, ipaddr, hostname, domainname = line.split(",")
+ except:
+ log.warning("Could not parse line: %s" % line)
+ continue
+
+ # Skip any disabled entries
+ if not enabled == "on":
+ continue
+
+ if hostname and domainname:
+ fqdn = "%s.%s" % (hostname, domainname)
+ elif hostname:
+ fqdn = hostname
+ elif domainname:
+ fqdn = domainname
+
+ try:
+ hosts[fqdn].append(ipaddr)
+ hosts[fqdn].sort()
+ except KeyError:
+ hosts[fqdn] = [ipaddr,]
+
+ # Dump everything in the logs
+ log.debug("Static hosts:")
+ for hostname, addresses in hosts.items():
+ log.debug(" %-20s : %s" % (hostname, ", ".join(addresses)))
+
+ return hosts
+