def __str__(self):
return self.__name
- def add_server(self, dnstype, name):
+ def add_server(self, dnstype, name, addr=None):
n = str(name).lower().rstrip(".")
if n not in self.__vlserver_names:
- s = vlserver(n)
+ s = vlserver(n, addr)
self.__vlserver_names[n] = s
self.__vlservers.append(s)
verbose("Couldn't find any AFSDB records\n")
# Then parse the local afsdb file
- # ... TODO ...
+ #
+ # There is a problem here: the CellServDB file is liable to contain
+ # accented characters that aren't UTF-8, so we *have* to be set an
+ # appropriate encoding otherwise Python will raise an exception.
+ # Unfortunately, the character set for this file has not been
+ # standardised...
+ #
+ verbose("-- Searching CellServDB for cell: ", self.__name, " --\n")
+ found_cell = False
+ for line in open("/etc/openafs/CellServDB", "r", encoding="iso8859_1"):
+ line = str(line.rstrip())
+ if line == "":
+ continue
+ comment_ix = line.find("#")
+ if comment_ix == 0:
+ continue
+ comment = ""
+ if comment_ix > 0:
+ comment = line[comment_ix + 1:].lstrip()
+ line = line[:comment_ix].rstrip()
+ if line[0] == ">":
+ # New cell name
+ if found_cell:
+ break
+ if line[1:] == self.__name:
+ found_cell = True
+ continue
+ if found_cell:
+ self.add_server("CellServDB", comment, line)
self.__looked_up = True