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)
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)
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)
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)
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)
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)