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.excError if zfs_getprop(self.device, 'mountpoint') == "legacy": self.mount_generic() else: self.mount_zfs_native()
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.excError 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): self.Mounts = None Res.Mount.start(self) m = re.match("<(\w+)>", self.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.mount_point = re.sub("<\w+>", zonepath, self.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.excError 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.excError
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.excError # the prop change has mounted the dataset return ret, out, err = self.vcall([rcEnv.syspaths.zfs, 'mount', self.device]) if ret != 0: ret, out, err = self.vcall([rcEnv.syspaths.zfs, 'mount', '-O', self.device]) if ret != 0: raise ex.excError 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.excError if self.is_up() is True: return try: os.unlink(self.mount_point+"/.opensvc") except: pass ret, out, err = self.vcall([rcEnv.syspaths.zfs, 'mount', self.device]) if ret != 0: ret, out, err = self.vcall([rcEnv.syspaths.zfs, 'mount', '-O', self.device]) if ret != 0: raise ex.excError 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)