def check_multipath_devices(ip, slave_multipath_disks_count):
        """Check if multipath devices contain SLAVE_MULTIPATH_DISKS_COUNT of
        disks. If yes return True, if no - False.

        :rtype: bool
        """
        cmd = "multipath -l -v2"

        ssh_manager.update_connection(ip, SSH_FUEL_CREDENTIALS['login'],
                                      SSH_FUEL_CREDENTIALS['password'],
                                      keys=ssh_manager._get_keys())
        ssh_manager.get_remote(ip)
        result = ssh_manager.execute_on_remote(
            ip=ip,
            cmd=cmd,
            err_msg="Failed to check multipath on node {}".format(ip)
        )
        multipath_info = [res.rstrip() for res in result['stdout']]
        disk = re.compile('(?P<id>^[\d|\w]+)\s+(?P<dm>dm-\d+)')
        status = re.compile(
            '\d+:\d+:\d+:\d+\s+(?P<devnode>\w+)'
            '\s+\d+:\d+\s+(?P<dm_status>\w+)'
            '\s+(?P<path_status>\w+)'
            '\s+(?P<online_status>\w+)'
        )
        dm = None
        disks = dict()
        for line in multipath_info:
            m = re.match(disk, line)
            if m:
                dm = m.group('dm')
                disks[dm] = []
                continue

            m = re.search(status, line)
            if m:
                disks[dm].append(m.group('devnode'))
                assert_equal(
                    m.group('dm_status'),
                    'active',
                    "Device {0} is in '{1}' status on {2}".format(
                        m.group('devnode'), m.group('dm_status'), dm))
                assert_equal(
                    m.group('online_status'),
                    'running',
                    "Device {0} is in '{1}' status on {2}".format(
                        m.group('devnode'), m.group('online_status'), dm))
        for disk in disks:
            assert_equal(len(disks[disk]),
                         slave_multipath_disks_count,
                         "{0}: wrong path count: {1}. Must be {2}".format(
                             disk, len(disk), slave_multipath_disks_count))
Ejemplo n.º 2
0
    def get_os_root_multipath_count(ip):
        """Returns count of root partitions on multipath devices.

        :rtype: int
        """
        cmd = "lsblk -lo NAME,TYPE,MOUNTPOINT | grep '/$' | grep -c lvm"

        ssh_manager.update_connection(ip)
        ssh_manager.get_remote(ip)
        result = ssh_manager.execute_on_remote(
            ip=ip,
            cmd=cmd,
            err_msg="Failed to check lsblk on node {}".format(ip))
        return int(result['stdout_str'])
Ejemplo n.º 3
0
    def get_os_root_multipath_count(ip):
        """Returns count of root partitions on multipath devices.

        :rtype: int
        """
        cmd = "lsblk -lo NAME,TYPE,MOUNTPOINT | grep '/$' | grep lvm | wc -l"

        ssh_manager.update_connection(ip, login='******',
                                      keys=ssh_manager._get_keys())
        ssh_manager.get_remote(ip)
        result = ssh_manager.execute_on_remote(
            ip=ip,
            cmd=cmd,
            err_msg="Failed to check lsblk on node {}".format(ip))
        return int(result['stdout_str'])
Ejemplo n.º 4
0
    def check_multipath_devices(ip, slave_multipath_disks_count):
        """Check if multipath devices contain SLAVE_MULTIPATH_DISKS_COUNT of
        disks. If yes return True, if no - False.

        :rtype: bool
        """
        cmd = "multipath -l -v2"

        ssh_manager.update_connection(ip,
                                      SSH_FUEL_CREDENTIALS['login'],
                                      SSH_FUEL_CREDENTIALS['password'],
                                      keys=ssh_manager._get_keys())
        ssh_manager.get_remote(ip)
        result = ssh_manager.execute_on_remote(
            ip=ip,
            cmd=cmd,
            err_msg="Failed to check multipath on node {}".format(ip))
        multipath_info = [res.rstrip() for res in result['stdout']]
        disk = re.compile('(?P<id>^[\d|\w]+)\s+(?P<dm>dm-\d+)')
        status = re.compile('\d+:\d+:\d+:\d+\s+(?P<devnode>\w+)'
                            '\s+\d+:\d+\s+(?P<dm_status>\w+)'
                            '\s+(?P<path_status>\w+)'
                            '\s+(?P<online_status>\w+)')
        dm = None
        disks = dict()
        for line in multipath_info:
            m = re.match(disk, line)
            if m:
                dm = m.group('dm')
                disks[dm] = []
                continue

            m = re.search(status, line)
            if m:
                disks[dm].append(m.group('devnode'))
                assert_equal(
                    m.group('dm_status'), 'active',
                    "Device {0} is in '{1}' status on {2}".format(
                        m.group('devnode'), m.group('dm_status'), dm))
                assert_equal(
                    m.group('online_status'), 'running',
                    "Device {0} is in '{1}' status on {2}".format(
                        m.group('devnode'), m.group('online_status'), dm))
        for disk in disks:
            assert_equal(
                len(disks[disk]), slave_multipath_disks_count,
                "{0}: wrong path count: {1}. Must be {2}".format(
                    disk, len(disk), slave_multipath_disks_count))