def setUp(self):
     '''
     Function for preliminary set-up to execute the test
     '''
     self.err_paths = []
     self.device_list = []
     smm = SoftwareManager()
     for pkg in ["lsscsi", "pciutils"]:
         if not smm.check_installed(pkg) and not smm.install(pkg):
             self.cancel("%s is not installed" % pkg)
     self.wwids = self.params.get('wwids', default='')
     self.pci_device = self.params.get("pci_devices", default='')
     self.count = int(self.params.get("count", default=1))
     system_pci_adress = pci.get_pci_addresses()
     system_wwids = multipath.get_multipath_wwids()
     if self.wwids:
         self.wwids = self.wwids.split(' ')
         for wwid in self.wwids:
             if wwid not in system_wwids:
                 self.cancel("%s not present in the system", wwid)
             for path in multipath.get_paths(wwid):
                 self.device_list.append(path)
     elif self.pci_device:
         self.pci_device = self.pci_device.split(' ')
         for pci_id in self.pci_device:
             if pci_id not in system_pci_adress:
                 self.cancel("%s not present in the system", pci_id)
             cmd = "ls -l /dev/disk/by-path/"
             output = process.system_output(cmd).decode('utf-8')
             for line in output.splitlines():
                 if pci_id in line and 'part' not in line:
                     self.device_list.append(line.split('/')[-1])
     else:
         self.cancel("please provide pci adrees or wwids of scsi disk")
    def setUp(self):
        """
        test parameters
        """
        self.switch_name = self.params.get("switch_name", '*', default=None)
        self.userid = self.params.get("userid", '*', default=None)
        self.password = self.params.get("password", '*', default=None)
        self.wwids = self.params.get("wwids", default=None).split(" ")
        self.sbt = int(self.params.get("sbt", '*', default=10))
        self.lbt = int(self.params.get("lbt", '*', default=250))
        self.count = int(self.params.get("count", '*', default="2"))
        self.prompt = ">"
        self.verify_sleep_time = 20
        self.port_ids = []
        self.host = []
        self.dic = {}
        system_wwids = multipath.get_multipath_wwids()
        for wwid in self.wwids:
            paths = []
            if wwid not in system_wwids:
                self.wwids.remove(wwid)
                continue
            paths = multipath.get_paths(wwid)
            for path in paths:
                self.host.append(self.get_fc_host(path))
        self.host = list(dict.fromkeys(self.host))
        self.log.info("AllHostValues: %s" % self.host)

        self.switch_login(self.switch_name, self.userid, self.password)
        for host in self.host:
            port_id = self.get_switch_port(host)
            self.port_ids.append(port_id)
            self.dic[port_id] = host
        self.log.info("AllSwitchPorts:%s " % self.port_ids)
Example #3
0
    def setUp(self):
        """
        Set up.
        """
        # Install needed packages
        dist = distro.detect()
        pkg_name = ""
        svc_name = ""
        if dist.name == 'Ubuntu':
            pkg_name += "multipath-tools"
            svc_name = "multipath-tools"
        elif dist.name == 'SuSE':
            pkg_name += "multipath-tools"
            svc_name = "multipathd"
        else:
            pkg_name += "device-mapper-multipath"
            svc_name = "multipathd"

        smm = SoftwareManager()
        if not smm.check_installed(pkg_name) and not smm.install(pkg_name):
            self.skip("Can not install %s" % pkg_name)

        # Create service object
        self.mpath_svc = service.SpecificServiceManager(svc_name)
        self.mpath_svc.restart()

        # Check if multipath devices are present in system
        self.wwids = multipath.get_multipath_wwids()
        if self.wwids == ['']:
            self.skip("No Multipath Devices")

        # Take a backup of current config file
        self.mpath_file = "/etc/multipath.conf"
        if os.path.isfile(self.mpath_file):
            shutil.copyfile(self.mpath_file, "%s.bkp" % self.mpath_file)

        self.mpath_list = []

        # Find all details of multipath devices
        for wwid in self.wwids:
            if wwid not in process.system_output('multipath -ll',
                                                 ignore_status=True,
                                                 shell=True):
                continue
            self.mpath_dic = {}
            self.mpath_dic["wwid"] = wwid
            self.mpath_dic["name"] = multipath.get_mpath_name(wwid)
            self.mpath_dic["paths"] = multipath.get_paths(wwid)
            self.mpath_dic["policy"] = multipath.get_policy(wwid)
            self.mpath_dic["size"] = multipath.get_size(wwid)
            self.mpath_list.append(self.mpath_dic)
        pprint(self.mpath_list)
    def setUp(self):
        """
        Set up.
        """
        # Install needed packages
        dist = distro.detect()
        pkg_name = ""
        svc_name = ""
        if dist.name == 'Ubuntu':
            pkg_name += "multipath-tools"
            svc_name = "multipath-tools"
        elif dist.name == 'SuSE':
            pkg_name += "multipath-tools"
            svc_name = "multipathd"
        else:
            pkg_name += "device-mapper-multipath"
            svc_name = "multipathd"

        smm = SoftwareManager()
        if not smm.check_installed(pkg_name) and not smm.install(pkg_name):
            self.cancel("Can not install %s" % pkg_name)

        # Create service object
        self.mpath_svc = service.SpecificServiceManager(svc_name)
        self.mpath_svc.restart()

        # Check if multipath devices are present in system
        self.wwids = multipath.get_multipath_wwids()
        if self.wwids == ['']:
            self.cancel("No Multipath Devices")

        # Take a backup of current config file
        self.mpath_file = "/etc/multipath.conf"
        if os.path.isfile(self.mpath_file):
            shutil.copyfile(self.mpath_file, "%s.bkp" % self.mpath_file)

        self.mpath_list = []

        # Find all details of multipath devices
        for wwid in self.wwids:
            if wwid not in process.system_output('multipath -ll',
                                                 ignore_status=True,
                                                 shell=True):
                continue
            self.mpath_dic = {}
            self.mpath_dic["wwid"] = wwid
            self.mpath_dic["name"] = multipath.get_mpath_name(wwid)
            self.mpath_dic["paths"] = multipath.get_paths(wwid)
            self.mpath_dic["policy"] = multipath.get_policy(wwid)
            self.mpath_dic["size"] = multipath.get_size(wwid)
            self.mpath_list.append(self.mpath_dic)
        pprint(self.mpath_list)
    def setUp(self):
        """
        Set up.
        """
        self.policy = self.params.get('policy', default='service-time')
        self.policies = ["service-time", "round-robin", "queue-length"]
        # We will remove and add the policy back, so that this becomes
        # the last member of the list. This is done so that in the
        # policy change test later, this policy is set in the last
        # iteration.
        self.policies.remove(self.policy)
        self.policies.append(self.policy)
        # Install needed packages
        dist = distro.detect()
        pkg_name = ""
        svc_name = ""
        if dist.name == 'Ubuntu':
            pkg_name += "multipath-tools"
            svc_name = "multipath-tools"
        elif dist.name == 'SuSE':
            pkg_name += "multipath-tools"
            svc_name = "multipathd"
        else:
            pkg_name += "device-mapper-multipath"
            svc_name = "multipathd"

        smm = SoftwareManager()
        if not smm.check_installed(pkg_name) and not smm.install(pkg_name):
            self.cancel("Can not install %s" % pkg_name)

        # Check if given multipath devices are present in system
        self.wwids = self.params.get('wwids', default='').split(',')
        system_wwids = multipath.get_multipath_wwids()
        wwids_to_remove = []
        for wwid in self.wwids:
            if wwid not in system_wwids:
                self.log.info("%s not present in the system", wwid)
                wwids_to_remove.append(wwid)
        for wwid in wwids_to_remove:
            self.wwids.remove(wwid)
        if self.wwids == []:
            self.cancel("No Multipath Devices Given")

        # Create service object
        self.mpath_svc = service.SpecificServiceManager(svc_name)
        self.mpath_svc.restart()
        wait.wait_for(self.mpath_svc.status, timeout=10)

        # Take a backup of current config file
        self.mpath_file = "/etc/multipath.conf"
        if os.path.isfile(self.mpath_file):
            shutil.copyfile(self.mpath_file, "%s.bkp" % self.mpath_file)

        self.mpath_list = []

        # Find all details of multipath devices
        for wwid in self.wwids:
            if wwid not in process.system_output('multipath -ll',
                                                 ignore_status=True,
                                                 shell=True).decode("utf-8"):
                continue
            self.mpath_dic = {}
            self.mpath_dic["wwid"] = wwid
            self.mpath_dic["name"] = multipath.get_mpath_name(wwid)
            self.mpath_dic["paths"] = multipath.get_paths(wwid)
            self.mpath_dic["policy"] = multipath.get_policy(wwid)
            self.mpath_dic["size"] = multipath.get_size(wwid)
            self.mpath_list.append(self.mpath_dic)
        pprint(self.mpath_list)
 def setUp(self):
     """
     Verifies if we have list of packages installed on OS
     and also skips the test if user gives the current OS boot disk as
     disk input it may erase the data
     :param disk: test disk where the disk operations can be done
     :param fs: type of filesystem to create
     :param dir: path of the directory to mount the disk device
     """
     smm = SoftwareManager()
     pkg = ""
     if 'ppc' not in platform.processor():
         self.cancel("Processor is not ppc64")
     self.disk = self.params.get('disk', default=None)
     self.dirs = self.params.get('dir', default=self.workdir)
     self.fstype = self.params.get('fs', default='ext4')
     self.log.info("disk: %s, dir: %s, fstype: %s", self.disk, self.dirs,
                   self.fstype)
     if not self.disk:
         self.cancel("No disk input, please update yaml and re-run")
     cmd = "df --output=source"
     if self.disk in process.system_output(cmd, ignore_status=True) \
             .decode("utf-8"):
         self.cancel("Given disk is os boot disk,"
                     "it will be harmful to run this test")
     pkg_list = ["lshw"]
     self.distro = distro.detect().name
     if self.distro == 'Ubuntu':
         pkg_list.append("hwinfo")
     if self.fstype == 'ext4':
         pkg_list.append('e2fsprogs')
     if self.fstype == 'xfs':
         pkg_list.append('xfsprogs')
     if self.fstype == 'btrfs':
         ver = int(distro.detect().version)
         rel = int(distro.detect().release)
         if distro.detect().name == 'rhel':
             if (ver == 7 and rel >= 4) or ver > 7:
                 self.cancel("btrfs is not supported with \
                             RHEL 7.4 onwards")
         if self.distro == 'Ubuntu':
             pkg_list.append("btrfs-tools")
     for pkg in pkg_list:
         if pkg and not smm.check_installed(pkg) and not smm.install(pkg):
             self.cancel(
                 "Package %s is missing and could not be installed" % pkg)
     self.disk_nodes = []
     self.disk_base = os.path.basename(self.disk)
     if multipath.is_path_a_multipath(self.disk_base):
         self.mpath = True
         self.disk_abs = self.disk_base
         all_wwids = multipath.get_multipath_wwids()
         for wwid in all_wwids:
             paths = multipath.get_paths(wwid)
             for path in paths:
                 if path == self.disk_abs:
                     #wwid of mpath our disk is on
                     mwwid = wwid
         self.disk_nodes = multipath.get_paths(mwwid)
     else:
         self.mpath = False
         self.disk_abs = self.disk_base
         self.disk_nodes.append(self.disk_base)
    def setUp(self):
        """
        Set up.
        """
        self.policy = self.params.get('policy', default='service-time')
        self.policies = ["service-time", "round-robin", "queue-length"]
        # We will remove and add the policy back, so that this becomes
        # the last member of the list. This is done so that in the
        # policy change test later, this policy is set in the last
        # iteration.
        self.policies.remove(self.policy)
        self.policies.append(self.policy)
        # Install needed packages
        dist = distro.detect()
        pkg_name = ""
        svc_name = ""
        if dist.name == 'Ubuntu':
            pkg_name += "multipath-tools"
            svc_name = "multipath-tools"
        elif dist.name == 'SuSE':
            pkg_name += "multipath-tools"
            svc_name = "multipathd"
        else:
            pkg_name += "device-mapper-multipath"
            svc_name = "multipathd"

        smm = SoftwareManager()
        if not smm.check_installed(pkg_name) and not smm.install(pkg_name):
            self.cancel("Can not install %s" % pkg_name)

        # Check if given multipath devices are present in system
        self.wwids = self.params.get('wwids', default='').split(',')
        system_wwids = multipath.get_multipath_wwids()
        wwids_to_remove = []
        for wwid in self.wwids:
            if wwid not in system_wwids:
                self.log.info("%s not present in the system" % wwid)
                wwids_to_remove.append(wwid)
        for wwid in wwids_to_remove:
            self.wwids.remove(wwid)
        if self.wwids == []:
            self.cancel("No Multipath Devices Given")

        # Create service object
        self.mpath_svc = service.SpecificServiceManager(svc_name)
        self.mpath_svc.restart()
        wait.wait_for(self.mpath_svc.status, timeout=10)

        # Take a backup of current config file
        self.mpath_file = "/etc/multipath.conf"
        if os.path.isfile(self.mpath_file):
            shutil.copyfile(self.mpath_file, "%s.bkp" % self.mpath_file)

        self.mpath_list = []

        # Find all details of multipath devices
        for wwid in self.wwids:
            if wwid not in process.system_output('multipath -ll',
                                                 ignore_status=True,
                                                 shell=True):
                continue
            self.mpath_dic = {}
            self.mpath_dic["wwid"] = wwid
            self.mpath_dic["name"] = multipath.get_mpath_name(wwid)
            self.mpath_dic["paths"] = multipath.get_paths(wwid)
            self.mpath_dic["policy"] = multipath.get_policy(wwid)
            self.mpath_dic["size"] = multipath.get_size(wwid)
            self.mpath_list.append(self.mpath_dic)
        pprint(self.mpath_list)