def mount_zfs(self): zone = self.svc.oget(self.rid, "zone") if not self.encap and not zone and zfs_getprop(self.device, 'zoned') != 'off': if zfs_setprop(self.device, 'zoned', 'off', log=self.log): raise ex.Error if zfs_getprop(self.device, 'mountpoint') == "legacy": self.mount_generic() else: self.mount_zfs_native()
def mount_zfs(self): zone = self.zone or self.oget("zone") if not self.encap and not zone and \ zfs_getprop(self.device, 'zoned') != 'off': if zfs_setprop(self.device, 'zoned', 'off', log=self.log): raise ex.Error try: os.unlink(self.mount_point + "/.opensvc") except: pass if zfs_getprop(self.device, 'mountpoint') == "legacy": return self.mount_generic() else: return self.mount_zfs_native()
def start(self): super(Fs, self).start() m = re.match(r"<(\w+)>", self.raw_mount_point) if m: # the zone was not created when the service was built. now it should, # so try the redetect the zonepath zone = m.group(1) for r in self.svc.get_resources("container.zone"): if r.name == zone: zonepath = r.get_zonepath() self.raw_mount_point = re.sub(r"<\w+>", zonepath, self.raw_mount_point) self.unset_lazy("mount_point") if self.fs_type == 'zfs': if 'noaction' not in self.tags and zfs_getprop( self.device, 'canmount') != 'noauto': self.log.info( "%s should be set to canmount=noauto (zfs set canmount=noauto %s)" % (self.label, self.device)) if self.is_up() is True: self.log.info("%s is already mounted" % self.label) return if self.fs_type == 'zfs': return self.mount_zfs() return self.mount_generic()
def try_umount(self): if self.fs_type == 'zfs' and zfs_getprop(self.device, 'mountpoint') != "legacy": ret, out, err = self.vcall(['zfs', 'umount', self.device], err_to_info=True) if ret != 0: ret, out, err = self.vcall( ['zfs', 'umount', '-f', self.device], err_to_info=True) if ret != 0: raise ex.Error return (ret, out, err) = self.vcall(['umount', self.mount_point], err_to_info=True) if ret == 0: return for i in range(4): ret, out, err = self.vcall(['fuser', '-ck', self.mount_point], err_to_info=True) ret, out, err = self.vcall(['umount', self.mount_point], err_to_info=True) if ret == 0: return if self.fs_type != 'lofs': ret, out, err = self.vcall(['umount', '-f', self.mount_point], err_to_info=True) if ret == 0: return raise ex.Error
def umount_zfs(self, dev, mnt): mntprop = zfs_getprop(dev, 'mountpoint') if mntprop == "legacy": return self.umount_generic(mnt) elif mntprop != mnt: # docker data dir case, ex: dev=data/svc1 mnt=/srv/svc1/docker/zfs # and mntprop=/srv/svc1 return self.umount_generic(mnt) else: return self.umount_zfs_native(mnt)
def mount_zfs_native(self): if zfs_getprop(self.device, 'mountpoint') != self.mount_point: if not zfs_setprop(self.device, 'mountpoint', self.mount_point, log=self.log): raise ex.Error # the prop change has mounted the dataset return ret, out, err = self.vcall([Env.syspaths.zfs, 'mount', self.device]) if ret != 0: ret, out, err = self.vcall([Env.syspaths.zfs, 'mount', '-O', self.device]) if ret != 0: raise ex.Error return ret, out, err
def mount_zfs_native(self): if zfs_getprop(self.device, 'mountpoint') != self.mount_point: if not zfs_setprop( self.device, 'mountpoint', self.mount_point, log=self.log): raise ex.Error if self.is_up() is True: return try: os.unlink(self.mount_point + "/.opensvc") except: pass ret, out, err = self.vcall([Env.syspaths.zfs, 'mount', self.device]) if ret != 0: ret, out, err = self.vcall( [Env.syspaths.zfs, 'mount', '-O', self.device]) if ret != 0: raise ex.Error self.can_rollback = True
def _check_zfs_canmount(self): if 'noaction' not in self.tags and \ zfs_getprop(self.device, 'canmount') != 'noauto': self.log.info( "%s should be set to canmount=noauto (zfs set " "canmount=noauto %s)", self.label, self.device)