コード例 #1
0
 def stop(self):
     if self.mounts is None:
         self.mounts = Mounts()
     if self.is_up() is False:
         self.log.info("%s is already umounted" % self.label)
         return
     for i in range(3):
         ret = try_umount(self)
         if ret == 0: break
     if ret != 0:
         self.log.error('failed to umount %s' % self.mount_point)
         raise ex.Error
     self.mounts = None
コード例 #2
0
    def realdev(self):
        try:
            mode = os.stat(self.device)[ST_MODE]
        except:
            self.log.debug("can not stat %s" % self.device)
            return None
        if S_ISBLK(mode):
            dev = self.device
        else:
            mnt = getmount(self.device)
            if self.mounts is None:
                self.mounts = Mounts()
            m = self.mounts.has_param("mnt", mnt)
            if m is None:
                self.log.debug(
                    "can't find dev %(dev)s mounted in %(mnt)s in mnttab" %
                    dict(mnt=mnt, dev=self.device))
                return None
            dev = m.dev

        return dev
コード例 #3
0
 def start(self):
     if self.mounts is None:
         self.mounts = Mounts()
     super(Fs, self).start()
     if self.is_up() is True:
         self.log.info("%s is already mounted" % self.label)
         return 0
     self.fsck()
     if not os.path.exists(self.mount_point):
         os.makedirs(self.mount_point, 0o755)
     if self.fs_type != "":
         fstype = ['-v', self.fs_type]
     else:
         fstype = []
     if self.mount_options != "":
         mntopt = ['-o', self.mount_options]
     else:
         mntopt = []
     cmd = ['mount'] + fstype + mntopt + [self.device, self.mount_point]
     (ret, out, err) = self.vcall(cmd)
     if ret != 0:
         raise ex.Error
     self.mounts = None
     self.can_rollback = True
コード例 #4
0
 def is_up(self):
     self.mounts = Mounts()
     return self.mounts.has_mount(self.device, self.mount_point)