def is_mpath_available():
     if operation == 'block':
         if multipath.device_exists(path_dic["wwid"]) is True:
             self.log.info("%s=False, not blocked" % test_mpath)
             return False
         return True
     elif operation == 'recover':
         if multipath.device_exists(path_dic["wwid"]) is False:
             self.log.info("%s=False, not recovered" % test_mpath)
             return False
         return True
Ejemplo n.º 2
0
    def test(self):
        """
        Tests Multipath.
        """
        msg = ""
        multipath.form_conf_mpath_file()
        plcy = "path_selector \"%s 0\"" % self.policy
        multipath.form_conf_mpath_file(defaults_extra=plcy)
        for path_dic in self.mpath_list:
            self.log.debug("operating on paths: %s", path_dic["paths"])
            # Path Selector policy
            self.log.info("changing Selector policy")
            for policy in self.policies:
                cmd = "path_selector \"%s 0\"" % policy
                multipath.form_conf_mpath_file(defaults_extra=cmd)
                if multipath.get_policy(path_dic["wwid"]) != policy:
                    msg += "%s for %s fails\n" % (policy, path_dic["wwid"])

            # mutipath -f mpathX
            if not multipath.flush_path(path_dic["name"]):
                msg += "Flush of %s fails\n" % path_dic["name"]
            self.mpath_svc.restart()
            wait.wait_for(self.mpath_svc.status, timeout=10)

            # Blacklisting wwid
            self.log.info("Black listing WWIDs")
            cmd = "wwid %s" % path_dic["wwid"]
            multipath.form_conf_mpath_file(blacklist=cmd, defaults_extra=plcy)
            if multipath.device_exists(path_dic["wwid"]):
                msg += "Blacklist of %s fails\n" % path_dic["wwid"]
            else:
                multipath.form_conf_mpath_file(defaults_extra=plcy)
                if not multipath.device_exists(path_dic["wwid"]):
                    msg += "Recovery of %s fails\n" % path_dic["wwid"]

            # Blacklisting sdX
            self.log.info("Black listing individual paths")
            for disk in path_dic["paths"]:
                cmd = "devnode %s" % disk
                multipath.form_conf_mpath_file(blacklist=cmd,
                                               defaults_extra=plcy)
                if disk in multipath.get_paths(path_dic["wwid"]):
                    msg += "Blacklist of %s fails\n" % disk
            multipath.form_conf_mpath_file(defaults_extra=plcy)
        if msg:
            self.fail("Some tests failed. Find details below:\n%s" % msg)
Ejemplo n.º 3
0
    def test(self):
        """
        Tests Multipath.
        """
        msg = ""

        multipath.form_conf_mpath_file()
        for path_dic in self.mpath_list:
            # mutipath -f mpathX
            if not multipath.flush_path(path_dic["name"]):
                msg += "Flush of %s fails\n" % path_dic["name"]
            self.mpath_svc.restart()

            # Path Selector policy
            for policy in ["service-time", "round-robin", "queue-length"]:
                cmd = "path_selector \"%s 0\"" % policy
                multipath.form_conf_mpath_file(defaults_extra=cmd)
                if multipath.get_policy(path_dic["wwid"]) != policy:
                    msg += "%s for %s fails\n" % (policy, path_dic["wwid"])

            # Blacklist wwid
            cmd = "wwid %s" % path_dic["wwid"]
            multipath.form_conf_mpath_file(blacklist=cmd)
            if multipath.device_exists(path_dic["wwid"]):
                msg += "Blacklist of %s fails\n" % path_dic["wwid"]
            else:
                multipath.form_conf_mpath_file()
                if not multipath.device_exists(path_dic["wwid"]):
                    msg += "Recovery of %s fails\n" % path_dic["wwid"]

            # Blacklist sdX
            for disk in path_dic["paths"]:
                cmd = "devnode %s" % disk
                multipath.form_conf_mpath_file(blacklist=cmd)
                if disk in multipath.get_paths(path_dic["wwid"]):
                    msg += "Blacklist of %s fails\n" % disk

        # Print errors
        if msg:
            msg = "Following Tests Failed\n" + msg
            self.log.debug(msg)
            self.fail("Some tests failed")
    def test(self):
        """
        Tests Multipath.
        """
        msg = ""
        multipath.form_conf_mpath_file()
        plcy = "path_selector \"%s 0\"" % self.policy
        multipath.form_conf_mpath_file(defaults_extra=plcy)
        for path_dic in self.mpath_list:
            self.log.debug("operating on paths", path_dic["paths"])
            # Path Selector policy
            self.log.info("changing Selector policy")
            for policy in self.policies:
                cmd = "path_selector \"%s 0\"" % policy
                multipath.form_conf_mpath_file(defaults_extra=cmd)
                if multipath.get_policy(path_dic["wwid"]) != policy:
                    msg += "%s for %s fails\n" % (policy, path_dic["wwid"])

            # mutipath -f mpathX
            if not multipath.flush_path(path_dic["name"]):
                msg += "Flush of %s fails\n" % path_dic["name"]
            self.mpath_svc.restart()
            wait.wait_for(self.mpath_svc.status, timeout=10)

            # Blacklisting wwid
            self.log.info("Black listing WWIDs")
            cmd = "wwid %s" % path_dic["wwid"]
            multipath.form_conf_mpath_file(blacklist=cmd, defaults_extra=plcy)
            if multipath.device_exists(path_dic["wwid"]):
                msg += "Blacklist of %s fails\n" % path_dic["wwid"]
            else:
                multipath.form_conf_mpath_file(defaults_extra=plcy)
                if not multipath.device_exists(path_dic["wwid"]):
                    msg += "Recovery of %s fails\n" % path_dic["wwid"]

            # Blacklisting sdX
            self.log.info("Black listing individual paths")
            for disk in path_dic["paths"]:
                cmd = "devnode %s" % disk
                multipath.form_conf_mpath_file(blacklist=cmd,
                                               defaults_extra=plcy)
                if disk in multipath.get_paths(path_dic["wwid"]):
                    msg += "Blacklist of %s fails\n" % disk
            multipath.form_conf_mpath_file(defaults_extra=plcy)

            # Failing and reinstating individual paths eg: sdX
            self.log.info(" Failing and reinstating the individual paths")
            for path in path_dic["paths"]:
                if multipath.fail_path(path) is False:
                    msg += "test failed while failing %s\n" % path
                elif multipath.reinstate_path(path) is False:
                    msg += "test failed while reinstating %s\n" % path
            self.mpath_svc.restart()
            wait.wait_for(self.mpath_svc.status, timeout=10)

            # Failing n-1 paths for short time and reinstating back
            self.log.info("Failing and reinstating the n-1 paths")
            for path in path_dic['paths'][:-1]:
                if multipath.fail_path(path) is False:
                    msg += "%s did not failed in n-1 path fail\n" % path

            time.sleep(180)
            for path in path_dic['paths'][:-1]:
                if multipath.reinstate_path(path) is False:
                    msg += "%s failed to recover in n-1 paths fails\n" % path
            self.mpath_svc.restart()
            wait.wait_for(self.mpath_svc.status, timeout=10)

            # Failing all paths for short time and reinstating back
            self.log.info("Failing and reinstating the All paths")
            for path in path_dic['paths']:
                if multipath.fail_path(path) is False:
                    msg += "%s did not failed in all paths fail\n" % path

            time.sleep(180)
            for path in path_dic['paths']:
                if multipath.reinstate_path(path) is False:
                    msg += "%s did not recovered  in all path fail\n" % path
            self.mpath_svc.restart()
            wait.wait_for(self.mpath_svc.status, timeout=10)

        # Print errors
        if msg:
            self.fail("Some tests failed. Find details below:\n%s" % msg)
    def test(self):
        """
        Tests Multipath.
        """
        msg = ""
        multipath.form_conf_mpath_file()
        plcy = "path_selector \"%s 0\"" % self.policy
        multipath.form_conf_mpath_file(defaults_extra=plcy)
        for path_dic in self.mpath_list:
            self.log.debug("operating on paths", path_dic["paths"])
            # Path Selector policy
            self.log.info("changing Selector policy")
            for policy in self.policies:
                cmd = "path_selector \"%s 0\"" % policy
                multipath.form_conf_mpath_file(defaults_extra=cmd)
                if multipath.get_policy(path_dic["wwid"]) != policy:
                    msg += "%s for %s fails\n" % (policy, path_dic["wwid"])

            # mutipath -f mpathX
            if not multipath.flush_path(path_dic["name"]):
                msg += "Flush of %s fails\n" % path_dic["name"]
            self.mpath_svc.restart()
            wait.wait_for(self.mpath_svc.status, timeout=10)

            # Blacklisting wwid
            self.log.info("Black listing WWIDs")
            cmd = "wwid %s" % path_dic["wwid"]
            multipath.form_conf_mpath_file(blacklist=cmd, defaults_extra=plcy)
            if multipath.device_exists(path_dic["wwid"]):
                msg += "Blacklist of %s fails\n" % path_dic["wwid"]
            else:
                multipath.form_conf_mpath_file(defaults_extra=plcy)
                if not multipath.device_exists(path_dic["wwid"]):
                    msg += "Recovery of %s fails\n" % path_dic["wwid"]

            # Blacklisting sdX
            self.log.info("Black listing individual paths")
            for disk in path_dic["paths"]:
                cmd = "devnode %s" % disk
                multipath.form_conf_mpath_file(blacklist=cmd,
                                               defaults_extra=plcy)
                if disk in multipath.get_paths(path_dic["wwid"]):
                    msg += "Blacklist of %s fails\n" % disk
            multipath.form_conf_mpath_file(defaults_extra=plcy)

            # Failing and reinstating individual paths eg: sdX
            self.log.info(" Failing and reinstating the individual paths")
            for path in path_dic["paths"]:
                if multipath.fail_path(path) is False:
                    msg += "test failed while failing %s\n" % path
                elif multipath.reinstate_path(path) is False:
                    msg += "test failed while reinstating %s\n" % path
            self.mpath_svc.restart()
            wait.wait_for(self.mpath_svc.status, timeout=10)

            # Failing n-1 paths for short time and reinstating back
            self.log.info("Failing and reinstating the n-1 paths")
            for path in path_dic['paths'][:-1]:
                if multipath.fail_path(path) is False:
                    msg += "%s did not failed in n-1 path fail\n" % path

            time.sleep(180)
            for path in path_dic['paths'][:-1]:
                if multipath.reinstate_path(path) is False:
                    msg += "%s failed to recover in n-1 paths fails\n" % path
            self.mpath_svc.restart()
            wait.wait_for(self.mpath_svc.status, timeout=10)

            # Failing all paths for short time and reinstating back
            self.log.info("Failing and reinstating the All paths")
            for path in path_dic['paths']:
                if multipath.fail_path(path) is False:
                    msg += "%s did not failed in all paths fail\n" % path

            time.sleep(180)
            for path in path_dic['paths']:
                if multipath.reinstate_path(path) is False:
                    msg += "%s did not recovered  in all path fail\n" % path
            self.mpath_svc.restart()
            wait.wait_for(self.mpath_svc.status, timeout=10)

        # Print errors
        if msg:
            self.fail("Some tests failed. Find details below:\n%s" % msg)