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
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
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
def is_up(self): self.mounts = Mounts() return self.mounts.has_mount(self.device, self.mount_point)
class Fs(BaseFs): """ AIX fs resource driver. """ def __init__(self, **kwargs): self.mounts = None super(Fs, self).__init__(**kwargs) def set_fsck_h(self): self.fsck_h = { 'jfs': { 'bin': 'fsck', 'cmd': ['fsck', '-p', '-V', 'jfs', self.device] }, 'jfs2': { 'bin': 'fsck', 'cmd': ['fsck', '-p', '-V', 'jfs2', self.device] }, } def is_up(self): self.mounts = Mounts() return self.mounts.has_mount(self.device, self.mount_point) 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 def mplist(self): dev = self.realdev() if dev is None: return set() return self._mplist([dev]) def _mplist(self, devs): mps = set() return mps def sub_devs(self): dev = self.realdev() if dev is None: return set() return set() def can_check_writable(self): return True 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 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