def test(self):
        detected_distro = distro.detect()
        parser = ConfigParser.ConfigParser()
        config_file = self.datadir + '/services.cfg'
        parser.read(config_file)
        services_list = parser.get(detected_distro.name, 'services').split(',')
        if 'PowerNV' in open('/proc/cpuinfo', 'r').read():
            services_list.extend(['opal_errd', 'opal-prd'])
        else:
            services_list.extend(['rtas_errd'])
        services_failed = []
        runner = process.run

        for service in services_list:
            service_obj = SpecificServiceManager(service, runner)
            self.log.info("Checking %s service" % service)
            if service_obj.is_enabled() is False:
                self.log.info("%s service Not Found !!!" % service)
                services_failed.append(service)
                continue
            original_status = service_obj.status()
            if original_status is True:
                service_obj.stop()
                if not wait_for(lambda: not service_obj.status(), 10):
                    self.log.info("Fail to stop %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.start()
                wait_for(service_obj.status, 10)
            else:
                service_obj.start()
                if not wait_for(service_obj.status, 10):
                    self.log.info("Fail to start %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.stop()
                wait_for(lambda: not service_obj.status(), 10)
            if not service_obj.status() is original_status:
                self.log.info("Fail to restore original status of the %s"
                              "service" % service)
                services_failed.append(service)

        if services_failed:
            self.fail("List of services failed: %s" % services_failed)
        else:
            self.log.info("All Services Passed the ON/OFF test")
Exemple #2
0
    def test(self):
        detected_distro = distro.detect()
        parser = ConfigParser.ConfigParser()
        config_file = self.datadir + '/services.cfg'
        parser.read(config_file)
        services_list = parser.get(detected_distro.name, 'services').split(',')
        if 'PowerNV' in open('/proc/cpuinfo', 'r').read():
            services_list.extend(['opal_errd', 'opal-prd'])
        else:
            services_list.extend(['rtas_errd'])
        services_failed = []
        runner = process.run

        for service in services_list:
            service_obj = SpecificServiceManager(service, runner)
            self.log.info("Checking %s service" % service)
            if service_obj.is_enabled() is False:
                self.log.info("%s service Not Found !!!" % service)
                services_failed.append(service)
                continue
            original_status = service_obj.status()
            if original_status is True:
                service_obj.stop()
                if not wait_for(lambda: not service_obj.status(), 10):
                    self.log.info("Fail to stop %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.start()
                wait_for(service_obj.status, 10)
            else:
                service_obj.start()
                if not wait_for(service_obj.status, 10):
                    self.log.info("Fail to start %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.stop()
                wait_for(lambda: not service_obj.status(), 10)
            if not service_obj.status() is original_status:
                self.log.info("Fail to restore original status of the %s"
                              "service" % service)
                services_failed.append(service)

        if services_failed:
            self.fail("List of services failed: %s" % services_failed)
        else:
            self.log.info("All Services Passed the ON/OFF test")
    def test(self):
        detected_distro = distro.detect()
        parser = ConfigParser.ConfigParser()
        parser.read(self.get_data('services.cfg'))
        services_list = parser.get(detected_distro.name, 'services').split(',')

        smm = SoftwareManager()
        deps = []

        if detected_distro.name == 'SuSE':
            deps.extend(['ppc64-diag', 'libvirt-daemon'])
            if detected_distro.version >= 15:
                services_list.append('firewalld')
            else:
                services_list.append('SuSEfirewall2')

        for package in deps:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel(' %s is needed for the test to be run' % package)

        if 'PowerNV' in open('/proc/cpuinfo', 'r').read():
            services_list.extend(['opal_errd', 'opal-prd'])
            if os.path.exists('/proc/device-tree/bmc'):
                services_list.remove('opal_errd')
        else:
            services_list.extend(['rtas_errd'])
        if 'Ubuntu' in detected_distro.name:
            if detected_distro.version >= 17:
                services_list.remove('networking')
        services_failed = []
        runner = process.run

        for service in services_list:
            service_obj = SpecificServiceManager(service, runner)
            self.log.info("Checking %s service" % service)
            if service_obj.is_enabled() is False:
                self.log.info("%s service Not Found !!!" % service)
                services_failed.append(service)
                continue
            original_status = service_obj.status()
            if original_status is True:
                service_obj.stop()
                if not wait_for(lambda: not service_obj.status(), 10):
                    self.log.info("Fail to stop %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.start()
                wait_for(service_obj.status, 10)
            else:
                service_obj.start()
                if not wait_for(service_obj.status, 10):
                    self.log.info("Fail to start %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.stop()
                wait_for(lambda: not service_obj.status(), 10)
            if not service_obj.status() is original_status:
                self.log.info("Fail to restore original status of the %s"
                              "service" % service)
                services_failed.append(service)

        if services_failed:
            self.fail("List of services failed: %s" % services_failed)
        else:
            self.log.info("All Services Passed the ON/OFF test")
    def test(self):
        detected_distro = distro.detect()
        parser = ConfigParser.ConfigParser()
        parser.read(self.get_data('services.cfg'))
        services_list = parser.get(detected_distro.name, 'services').split(',')

        smm = SoftwareManager()
        deps = []

        if detected_distro.name == 'SuSE':
            deps.extend(['ppc64-diag', 'libvirt-daemon'])
            if detected_distro.version >= 15:
                services_list.append('firewalld')
            else:
                services_list.append('SuSEfirewall2')
        elif detected_distro.name == 'Ubuntu':
            deps.extend(['opal-prd'])
            if detected_distro.version >= 17:
                services_list.remove('networking')

        for package in deps:
            if not smm.check_installed(package) and not smm.install(package):
                self.cancel(' %s is needed for the test to be run' % package)

        if 'PowerNV' in open('/proc/cpuinfo', 'r').read():
            services_list.extend(['opal_errd', 'opal-prd'])
            if os.path.exists('/proc/device-tree/bmc'):
                services_list.remove('opal_errd')
        else:
            services_list.extend(['rtas_errd'])
        services_failed = []
        runner = process.run

        for service in services_list:
            service_obj = SpecificServiceManager(service, runner)
            self.log.info("Checking %s service" % service)
            if service_obj.is_enabled() is False:
                self.log.info("%s service Not Found !!!" % service)
                services_failed.append(service)
                continue
            original_status = service_obj.status()
            if original_status is True:
                service_obj.stop()
                if not wait_for(lambda: not service_obj.status(), 10):
                    self.log.info("Fail to stop %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.start()
                wait_for(service_obj.status, 10)
            else:
                service_obj.start()
                if not wait_for(service_obj.status, 10):
                    self.log.info("Fail to start %s service" % service)
                    services_failed.append(service)
                    continue
                service_obj.stop()
                wait_for(lambda: not service_obj.status(), 10)
            if not service_obj.status() is original_status:
                self.log.info("Fail to restore original status of the %s"
                              "service" % service)
                services_failed.append(service)

        if services_failed:
            self.fail("List of services failed: %s" % services_failed)
        else:
            self.log.info("All Services Passed the ON/OFF test")