Esempio n. 1
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)
Esempio n. 2
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"]))
     return configurations
Esempio n. 3
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"]))
     return configurations
Esempio n. 4
0
 def _add_mountpoint(self, export_host, export_path, instance):
     fstab = Fstab()
     fstab.read(self.__FSTAB)
     mount_path = self._mount_path(export_host, export_path)
     if not os.path.exists(mount_path):
         os.makedirs(mount_path)
     # add a line to fstab
     fstab.lines.append(Line(self.__FSTAB_LINE % (mount_path, export_host, export_path, instance)))
     fstab.write(self.__FSTAB)
Esempio n. 5
0
    def _add_mountpoint(self, export_host, export_path, instance, options):
        fstab = Fstab()
        fstab.read(self.__FSTAB)
        mount_path = self._mount_path(export_host, export_path)
        if not os.path.exists(mount_path):
            os.makedirs(mount_path)
        # add a line to fstab
        if not options:
            stroptions = ""
        else:
            stroptions = "," + ",".join(options)

        fstab.lines.append(Line(self.__FSTAB_LINE % (mount_path, export_host, export_path, instance, stroptions)))
        fstab.write(self.__FSTAB)
Esempio n. 6
0
 def _remove_mountpoint(self, export_host, export_path):
     fstab = Fstab()
     fstab.read(self.__FSTAB)
     mount_path = self._mount_path(export_host, export_path)
     if os.path.exists(mount_path):
         os.rmdir(mount_path)
     # remove the line from fstab
     newlines = [l for l in fstab.lines if l.directory != mount_path]
     fstab.lines = newlines
     fstab.write(self.__FSTAB)
Esempio n. 7
0
 def _remove_mountpoint(self, export_host, export_path):
     fstab = Fstab()
     fstab.read(self.__FSTAB)
     mount_path = self._mount_path(export_host, export_path)
     if os.path.exists(mount_path):
         os.rmdir(mount_path)
     # remove the line from fstab
     newlines = [l for l in fstab.lines if l.directory != mount_path]
     fstab.lines = newlines
     fstab.write(self.__FSTAB)
Esempio n. 8
0
 def _add_mountpoint(self, export_host, export_path, instance):
     fstab = Fstab()
     fstab.read(self.__FSTAB)
     mount_path = self._mount_path(export_host, export_path)
     if not os.path.exists(mount_path):
         os.makedirs(mount_path)
     # add a line to fstab
     fstab.lines.append(
         Line(self.__FSTAB_LINE %
              (mount_path, export_host, export_path, instance)))
     fstab.write(self.__FSTAB)
Esempio n. 9
0
 def _add_mountpoint(self, export_host, export_path, instance, options):
     fstab = Fstab()
     fstab.read(self.__FSTAB)
     mount_path = self._mount_path(export_host, export_path)
     if not os.path.exists(mount_path):
         os.makedirs(mount_path)
     # add a line to fstab
     if not options:
         stroptions=""
     else:
         stroptions = ',' + ','.join(options)
     
     fstab.lines.append(Line(self.__FSTAB_LINE % (mount_path, export_host, export_path, instance, stroptions)))
     fstab.write(self.__FSTAB)
Esempio n. 10
0
 def _list_mountpoint(self):
     fstab = Fstab()
     fstab.read(self.__FSTAB)
     return [l.directory for l in fstab.get_rozofs_lines()]
Esempio n. 11
0
 def _list_mountpoint(self):
     fstab = Fstab()
     fstab.read(self.__FSTAB)
     return [l.directory for l in fstab.get_rozofs_lines()]