-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issues/525-2
- Loading branch information
Showing
9 changed files
with
394 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ | |
from . import eap | ||
from . import brms | ||
from . import karaf | ||
from . import cpu | ||
from . import date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Copyright (c) 2018 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public License, | ||
# version 3 (GPLv3). There is NO WARRANTY for this software, express or | ||
# implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3 | ||
# along with this software; if not, see | ||
# https://www.gnu.org/licenses/gpl-3.0.txt. | ||
|
||
"""Initial processing of the shell output from the cpu role.""" | ||
|
||
import logging | ||
from scanner.network.processing import process | ||
|
||
logger = logging.getLogger(__name__) # pylint: disable=invalid-name | ||
|
||
# pylint: disable=too-few-public-methods | ||
|
||
# #### Processors #### | ||
|
||
|
||
class ProcessCpuModelVer(process.Processor): | ||
"""Process the model version of the cpu.""" | ||
|
||
KEY = 'cpu_model_ver' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Pass the output back through.""" | ||
return output['stdout_lines'] | ||
|
||
|
||
class ProcessCpuCpuFamily(process.Processor): | ||
"""Process the cpu family.""" | ||
|
||
KEY = 'cpu_cpu_family' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Pass the output back through.""" | ||
return output['stdout_lines'] | ||
|
||
|
||
class ProcessCpuVendorId(process.Processor): | ||
"""Process the vendor id of the cpu.""" | ||
|
||
KEY = 'cpu_vendor_id' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Pass the output back through.""" | ||
return output['stdout_lines'] | ||
|
||
|
||
class ProcessCpuModelName(process.Processor): | ||
"""Process the model name of the cpu.""" | ||
|
||
KEY = 'cpu_model_name' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Pass the output back through.""" | ||
return output['stdout_lines'] | ||
|
||
|
||
class ProcessCpuBogomips(process.Processor): | ||
"""Process the bogomips of the cpu.""" | ||
|
||
KEY = 'cpu_bogomips' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Pass the output back through.""" | ||
return output['stdout_lines'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright (c) 2018 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public License, | ||
# version 3 (GPLv3). There is NO WARRANTY for this software, express or | ||
# implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3 | ||
# along with this software; if not, see | ||
# https://www.gnu.org/licenses/gpl-3.0.txt. | ||
|
||
"""Initial processing of the shell output from the date role.""" | ||
|
||
import logging | ||
from scanner.network.processing import process | ||
|
||
logger = logging.getLogger(__name__) # pylint: disable=invalid-name | ||
|
||
# pylint: disable=too-few-public-methods | ||
|
||
# #### Processors #### | ||
|
||
|
||
class ProcessDateDate(process.Processor): | ||
"""Process the date fact.""" | ||
|
||
KEY = 'date_date' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Pass the output back through.""" | ||
return output['stdout_lines'] | ||
|
||
|
||
class ProcessDateFilesystemCreate(process.Processor): | ||
"""Process the date filesystem create fact.""" | ||
|
||
KEY = 'date_filesystem_create' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Pass the output back through.""" | ||
return output['stdout_lines'] | ||
|
||
|
||
class ProcessDateMachineId(process.Processor): | ||
"""Process the date machine id fact.""" | ||
|
||
KEY = 'date_machine_id' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Pass the output back through.""" | ||
return output['stdout_lines'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Copyright (c) 2018 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public License, | ||
# version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
# implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
# along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
|
||
|
||
"""Unit tests for initial processing of cpu facts.""" | ||
|
||
|
||
import unittest | ||
from scanner.network.processing import cpu | ||
from scanner.network.processing.test_util import ansible_result | ||
|
||
|
||
class TestProcessCpuModelVer(unittest.TestCase): | ||
"""Test ProcessCpuModelVer.""" | ||
|
||
def test_success_case(self): | ||
"""Found cpu model ver.""" | ||
self.assertEqual( | ||
cpu.ProcessCpuModelVer.process( | ||
ansible_result('a\nb\nc')), | ||
['a', 'b', 'c']) | ||
|
||
def test_not_found(self): | ||
"""Did not find cpu model ver.""" | ||
self.assertEqual( | ||
cpu.ProcessCpuModelVer.process( | ||
ansible_result('')), | ||
[]) | ||
|
||
|
||
class TestProcessCpuCpuFamily(unittest.TestCase): | ||
"""Test ProcessCpuCpuFamily.""" | ||
|
||
def test_success_case(self): | ||
"""Found cpu family.""" | ||
self.assertEqual( | ||
cpu.ProcessCpuCpuFamily.process( | ||
ansible_result('a\nb\nc')), | ||
['a', 'b', 'c']) | ||
|
||
def test__not_found(self): | ||
"""Did not find cpu family.""" | ||
self.assertEqual( | ||
cpu.ProcessCpuCpuFamily.process( | ||
ansible_result('')), | ||
[]) | ||
|
||
|
||
class TestProcessCpuVendorId(unittest.TestCase): | ||
"""Test ProcessCpuVendorId.""" | ||
|
||
def test_success_case(self): | ||
"""Found cpu vendor id.""" | ||
self.assertEqual( | ||
cpu.ProcessCpuVendorId.process( | ||
ansible_result('a\nb\nc')), | ||
['a', 'b', 'c']) | ||
|
||
def test__not_found(self): | ||
"""Did not find cpu vendor id.""" | ||
self.assertEqual( | ||
cpu.ProcessCpuVendorId.process( | ||
ansible_result('')), | ||
[]) | ||
|
||
|
||
class TestProcessCpuModelName(unittest.TestCase): | ||
"""Test ProcessCpuModelName.""" | ||
|
||
def test_success_case(self): | ||
"""Found cpu model name.""" | ||
self.assertEqual( | ||
cpu.ProcessCpuModelName.process( | ||
ansible_result('a\nb\nc')), | ||
['a', 'b', 'c']) | ||
|
||
def test__not_found(self): | ||
"""Did not find cpu model name.""" | ||
self.assertEqual( | ||
cpu.ProcessCpuModelName.process( | ||
ansible_result('')), | ||
[]) | ||
|
||
|
||
class TestProcessCpuBogomips(unittest.TestCase): | ||
"""Test ProcessCpuBogomips.""" | ||
|
||
def test_success_case(self): | ||
"""Found cpu bogomips.""" | ||
self.assertEqual( | ||
cpu.ProcessCpuBogomips.process( | ||
ansible_result('a\nb\nc')), | ||
['a', 'b', 'c']) | ||
|
||
def test__not_found(self): | ||
"""Did not find cpu bogomips.""" | ||
self.assertEqual( | ||
cpu.ProcessCpuBogomips.process( | ||
ansible_result('')), | ||
[]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright (c) 2018 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public License, | ||
# version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
# implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
# along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
|
||
|
||
"""Unit tests for initial processing of date facts.""" | ||
|
||
|
||
import unittest | ||
from scanner.network.processing import date | ||
from scanner.network.processing.test_util import ansible_result | ||
|
||
|
||
class TestProcessDateDate(unittest.TestCase): | ||
"""Test ProcessDateDate.""" | ||
|
||
def test_success_case(self): | ||
"""Found date.""" | ||
self.assertEqual( | ||
date.ProcessDateDate.process( | ||
ansible_result('a\nb\nc')), | ||
['a', 'b', 'c']) | ||
|
||
def test_not_found(self): | ||
"""Did not find date.""" | ||
self.assertEqual( | ||
date.ProcessDateDate.process( | ||
ansible_result('')), | ||
[]) | ||
|
||
|
||
class ProcessDateFilesystemCreate(unittest.TestCase): | ||
"""Test ProcessDateFilesystemCreate.""" | ||
|
||
def test_success_case(self): | ||
"""Found date file system create.""" | ||
self.assertEqual( | ||
date.ProcessDateFilesystemCreate.process( | ||
ansible_result('a\nb\nc')), | ||
['a', 'b', 'c']) | ||
|
||
def test_not_found(self): | ||
"""Did not find date file system create.""" | ||
self.assertEqual( | ||
date.ProcessDateFilesystemCreate.process( | ||
ansible_result('')), | ||
[]) | ||
|
||
|
||
class ProcessDateMachineId(unittest.TestCase): | ||
"""Test ProcessDateFilesystemCreate.""" | ||
|
||
def test_success_case(self): | ||
"""Found date machine id.""" | ||
self.assertEqual( | ||
date.ProcessDateMachineId.process( | ||
ansible_result('a\nb\nc')), | ||
['a', 'b', 'c']) | ||
|
||
def test_not_found(self): | ||
"""Did not find date file system create.""" | ||
self.assertEqual( | ||
date.ProcessDateMachineId.process( | ||
ansible_result('')), | ||
[]) |
Oops, something went wrong.