示例#1
0
 def get_service_config(self):
     fstab = Fstab()
     fstab.read(self.__FSTAB)
     configurations = []
     for l in fstab.get_rozofs_lines():
         o = l.get_rozofs_options()
         configurations.append(RozofsMountConfig(o["host"], o["path"],
                                                 o["instance"],
                                                 o["mountpoint"]))
     return configurations
示例#2
0
 def _remove_mountpoint(self, config):
     fstab = Fstab()
     fstab.read(self.__FSTAB)
     mount_path = self._mount_path(config.export_host, config.export_path)
     if os.path.exists(config.mountpoint):
         os.rmdir(config.mountpoint)
     # remove the line from fstab
     newlines = [l for l in fstab.lines if l.directory != config.mountpoint]
     fstab.lines = newlines
     fstab.write(self.__FSTAB)
示例#3
0
    def _add_mountpoint(self, config, instance):
        fstab = Fstab()
        fstab.read(self.__FSTAB)

        mount_path = self._mount_path(config.export_host, config.export_path)

        # Create mountpoint
        if not os.path.exists(config.mountpoint):
            os.makedirs(config.mountpoint)
        else:
            if not os.path.isdir(config.mountpoint):
                raise Exception('mountpoint: %s is not a directory.'
                                 % config.mountpoint)
                # Check if empty
        # add a line to fstab
        if not config.options:
            stroptions=""
        else:
            stroptions = ',' + ','.join(config.options)
        
        fstab.lines.append(Line(self.__FSTAB_LINE % (config.mountpoint,
                                                     config.export_host,
                                                     config.export_path,
                                                     instance,
                                                     stroptions)))
        fstab.write(self.__FSTAB)
示例#4
0
 def _list_mountpoint(self):
     fstab = Fstab()
     fstab.read(self.__FSTAB)
     return [l.directory for l in fstab.get_rozofs_lines()]