def test(self, connection, params):
        """ Perform test """

        filename = 'packages_generic.yaml'
        path = os.path.sep.join([self.datadir, filename])
        if not os.path.exists(path):
            raise SkipException(
                'packages list %s not provided, skipping this test' % path)
        else:
            fd = open(path)
            required_packages = load_yaml(fd)
            if not required_packages:
                raise SkipException(
                    'package list was not provided in %s, skipping this test' %
                    path)
            else:
                self.log.append({'required_packages': required_packages})

        # we get a full list of packages installed here
        sin, sout, serr = connection.exec_command("rpm -qa")
        packages_result = sout.read()
        packages_list = packages_result.splitlines()

        test_conclusion = True

        for required_package in required_packages:
            p = re.compile(required_package, re.DOTALL)
            search_result = p.search(packages_result)
            if search_result == None:
                test_conclusion = False
                self.log.append({'package NOT found': required_package})
            else:
                self.log.append({'package found': search_result.group()})

        if test_conclusion is False:
            self.log.append({'comment': packages_list})
            self.log.append({
                'result': 'failed',
                'comment': 'Failed to get package set'
            })
        else:
            self.log.append({'result': 'passed'})
        return self.log
    def test(self, connection, params):
        """ Perform test """

        filename = 'packages_generic.yaml'
        path = os.path.sep.join([self.datadir, filename])
        if not os.path.exists(path):
            raise SkipException('packages list %s not provided, skipping this test' % path)
        else:
            fd = open(path)
            required_packages = load_yaml(fd)
            if not required_packages:
                raise SkipException('package list was not provided in %s, skipping this test' % path)
            else:
                self.log.append({'required_packages': required_packages})

        # we get a full list of packages installed here
        sin, sout, serr = connection.exec_command("rpm -qa")
        packages_result = sout.read()
        packages_list = packages_result.splitlines()

        test_conclusion = True

        for required_package in required_packages:
            p = re.compile(required_package, re.DOTALL)
            search_result = p.search(packages_result)
            if search_result == None:
                test_conclusion = False
                self.log.append({'package NOT found': required_package})
            else:
                self.log.append({'package found': search_result.group()})

        if test_conclusion is False:
            self.log.append({'comment': packages_list})
            self.log.append({'result': 'failed', 'comment': 'Failed to get package set'})
        else:
            self.log.append({'result': 'passed'})
        return self.log
示例#3
0
 def required_packages(self, params):
     '''return set of required packages'''
     with open(self.package_list_filename(params)) as fd:
         ret = set(load_yaml(fd))
     return ret
示例#4
0
 def required_packages(self, params):
     '''return set of required packages'''
     with open(self.package_list_filename(params)) as fd:
         ret = set(load_yaml(fd))
     return ret