Esempio n. 1
0
 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()
Esempio n. 2
0
 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()
Esempio n. 3
0
    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()
Esempio n. 4
0
 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
Esempio n. 5
0
 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)
Esempio n. 6
0
 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
Esempio n. 7
0
    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
Esempio n. 8
0
 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)