def __init__(self, options, data=None): self.type = 'dm' self.data = data or {} self._vol = {} self._pool = {} self._dev = {} self.options = options self.hostname = socket.gethostname() self._binary = misc.check_binary(MDADM) self.default_pool_name = SSM_DM_DEFAULT_POOL self.attrs = [ 'dev_name', 'pool_name', 'dev_free', 'dev_used', 'dev_size' ] if not self._binary: return self.problem = problem.ProblemSet(options) self.mounts = misc.get_mounts('/dev/md') mdnumber = misc.get_dmnumber("md") for line in misc.get_partitions(): devname = '/dev/' + line[3] devsize = int(line[2]) if line[0] == mdnumber: self._vol[devname] = self.get_volume_data(devname) for dev in misc.get_slaves(os.path.basename(devname)): self._dev[dev] = self.get_device_data(dev, devsize)
def __init__(self, options, data=None): self.type = 'template' self.data = data or {} self.options = options self.output = None self.default_pool_name = SSM_TEMPLATE_DEFAULT_POOL self.problem = problem.ProblemSet(options)
def __init__(self, options, data=None): self.type = 'lvm' self.data = data or {} self.attrs = [] self.output = None self.options = options self.binary = misc.check_binary('lvm') self.default_pool_name = SSM_LVM_DEFAULT_POOL self.problem = problem.ProblemSet(options)
def __init__(self, options, data=None): self.type = 'multipath' self.data = data or {} self._dev = {} self.options = options self.output = None self.problem = problem.ProblemSet(options) for mp_dev in self.get_mp_devices(): mpname = self.get_real_device(mp_dev) self._dev[mp_dev] = self.get_volume_data(mp_dev) for devname in self._dev[mp_dev]['nodes']: self._dev[devname] = self.get_device_data(devname, mpname, 0)
def __init__(self, options, data=None): self.type = 'multipath' self.data = data or {} self._dev = {} self.options = options self.output = None self.problem = problem.ProblemSet(options) self.swaps = misc.get_swaps() self.mounts = misc.get_mounts('{0}/mapper'.format(DM_DEV_DIR)) for mp_dev in self.get_mp_devices(): mpname = self.get_real_device(mp_dev) self._dev[mp_dev] = self.get_volume_data(mp_dev) for devname in self._dev[mp_dev]['nodes']: self._dev[devname] = self.get_device_data(devname, mpname, 0)
def __init__(self, options, data=None): self.type = 'multipath' self.data = data or {} self._vol = {} self._pool = {} self._dev = {} self.options = options self.output = None self.default_pool_name = SSM_MULTIPATH_DEFAULT_POOL self.problem = problem.ProblemSet(options) for vol in self.get_volumes_list(): volname = self.get_real_device(vol) self._vol[vol] = self.get_volume_data(vol) #self._dev[volname] = self.get_device_data(volname, None, 0) for devname in self._vol[vol]['nodes']: self._dev[devname] = self.get_device_data(devname, volname, 0)
def __init__(self, options, data=None): self.type = 'crypt' self.data = data or {} self.output = None self.options = options self.mounts = misc.get_mounts('{0}/mapper'.format(DM_DEV_DIR)) self.default_pool_name = SSM_CRYPT_DEFAULT_POOL self.problem = problem.ProblemSet(options) if not misc.check_binary('dmsetup') or \ not misc.check_binary('cryptsetup'): return command = ['dmsetup', 'table'] self.output = misc.run(command, stderr=False)[1] for line in self.output.split("\n"): if not line or line == "No devices found": break dm = {} array = line.split() dm['type'] = array[3] if dm['type'] != 'crypt': continue dm['vol_size'] = str(int(array[2]) / 2.0) devname = re.sub(":$", "", "{0}/mapper/{1}".format(DM_DEV_DIR, array[0])) dm['dm_name'] = devname dm['pool_name'] = 'dm-crypt' dm['dev_name'] = misc.get_real_device(devname) dm['real_dev'] = dm['dev_name'] if dm['real_dev'] in self.mounts: dm['mount'] = self.mounts[dm['real_dev']]['mp'] # Check if the device really exists in the system. In some cases # (tests) DM_DEV_DIR can lie to us, if that is the case, simple # ignore the device. if not os.path.exists(devname): continue command = ['cryptsetup', 'status', devname] self._parse_cryptsetup(command, dm) self.data[dm['dev_name']] = dm
def __init__(self, options, data=None): self.type = 'btrfs' self.data = data or {} self.options = options self.default_pool_name = SSM_BTRFS_DEFAULT_POOL self._vol = {} self._pool = {} self._dev = {} self._snap = {} self._subvolumes = {} self._binary = misc.check_binary('btrfs') self.problem = problem.ProblemSet(options) self.modified_list_version = True if not self._binary: return self.mounts = misc.get_mounts('/dev/') command = ['btrfs', 'filesystem', 'show'] self.output = misc.run(command, stderr=False)[1] vol = {} pool = {} dev = {} partitions = {} fs_size = pool_size = fs_used = 0 pool_name = '' for line in misc.get_partitions(): partitions[line[3]] = line for line in self.output.strip().split("\n"): if not line: continue array = line.split() if array[0] == 'Label:': if len(vol) > 0: self._store_data(vol, pool, fs_used, fs_size, pool_size, pool_name) vol = {} pool = {} fs_size = pool_size = 0 pool_name = '' label = array[1].strip("'") uuid = array[3] pool['uuid'] = vol['uuid'] = uuid try: fallback = False vol['real_dev'] = misc.get_device_by_uuid(uuid) if vol['real_dev'] in self.mounts: pool['mount'] = self.mounts[vol['real_dev']]['mp'] vol['mount'] = self.mounts[vol['real_dev']]['mp'] else: for dev_i in self.mounts: found = re.findall( r'{0}:/.*'.format(vol['real_dev']), dev_i) if found: pool['mount'] = self.mounts[found[0]]['mp'] break except OSError: # udev is "hard-to-work-with" sometimes so this is fallback fallback = True vol['real_dev'] = "" if label != 'none': vol['label'] = label vol['ID'] = 0 elif array[0] == 'Total': pool['dev_count'] = array[2] fs_used = get_real_number(array[6]) elif array[0] == 'devid': dev['dev_name'] = array[7] if not pool_name: pool_name = self._find_uniq_pool_name(label, array[7]) dev['pool_name'] = pool_name # Fallback in case we could not find real_dev by uuid if fallback and 'mount' not in pool: if dev['dev_name'] in self.mounts: pool['mount'] = self.mounts[dev['dev_name']]['mp'] vol['real_dev'] = dev['dev_name'] if 'root' in self.mounts[dev['dev_name']]: if self.mounts[dev['dev_name']]['root'] == '/': vol['mount'] = self.mounts[ dev['dev_name']]['mp'] else: for dev_i in self.mounts: found = re.findall( r'{0}:/.*'.format(dev['dev_name']), dev_i) if found: pool['mount'] = self.mounts[found[0]]['mp'] break dev_used = get_real_number(array[5]) dev['dev_used'] = str(dev_used) fs_size += get_real_number(array[3]) dev_size = \ int(partitions[dev['dev_name'].rpartition("/")[-1]][2]) pool_size += dev_size dev['dev_free'] = dev_size - dev_used self._dev[dev['dev_name']] = dev dev = {} if len(vol) > 0: self._store_data(vol, pool, fs_used, fs_size, pool_size, pool_name)