def testReadAutmountEntryWithExtraWhitespace(self): """Extra whitespace doesn't break the parsing.""" parser = file_formats.FilesAutomountMapParser() file_entry = 'scratch fileserver:/scratch' map_entry = parser._ReadEntry(file_entry) self.assertEqual(map_entry.key, 'scratch') self.assertEqual(map_entry.options, None) self.assertEqual(map_entry.location, 'fileserver:/scratch')
def testReadAutomountEntry(self): """We correctly parse a typical entry in /etc/auto.* format.""" parser = file_formats.FilesAutomountMapParser() file_entry = 'scratch -tcp,rw,intr,bg fileserver:/scratch' map_entry = parser._ReadEntry(file_entry) self.assertEqual(map_entry.key, 'scratch') self.assertEqual(map_entry.options, '-tcp,rw,intr,bg') self.assertEqual(map_entry.location, 'fileserver:/scratch')
def __init__(self, conf, map_name=None, automount_mountpoint=None): if map_name is None: map_name = config.MAP_AUTOMOUNT super(FilesAutomountMapHandler, self).__init__( conf, map_name, automount_mountpoint=automount_mountpoint) self.map_parser = file_formats.FilesAutomountMapParser() if automount_mountpoint is None: # we are dealing with the master map self.CACHE_FILENAME = 'auto.master' else: # turn /auto into auto.auto, and /usr/local into /auto.usr_local automount_mountpoint = automount_mountpoint.lstrip('/') self.CACHE_FILENAME = 'auto.%s' % automount_mountpoint.replace('/', '_')
def testReadBadAutomountEntry(self): """Cope with empty data.""" parser = file_formats.FilesAutomountMapParser() file_entry = '' map_entry = parser._ReadEntry(file_entry) self.assertEqual(None, map_entry)
def GetParser(self): """Returns a MapParser to parse FilesAutomount cache.""" return file_formats.FilesAutomountMapParser()