-
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.
Add entitlements to fingerprinting engine. (#794)
- Loading branch information
1 parent
b28535d
commit ea0afc2
Showing
13 changed files
with
164 additions
and
24 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
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
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 |
---|---|---|
|
@@ -15,3 +15,4 @@ | |
from . import karaf | ||
from . import cpu | ||
from . import date | ||
from . import subman |
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,36 @@ | ||
# 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 subman 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 ProcessSubmanConsumed(process.Processor): | ||
"""Process the subman_consumed fact.""" | ||
|
||
KEY = 'subman_consumed' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Pass the output back through.""" | ||
entitlements_data = [] | ||
entitlements = output.get('stdout_lines', []) | ||
for entitlement in entitlements: | ||
name, entitlement_id = entitlement.split(' - ') | ||
entitlement_dict = {'name': name, 'entitlement_id': entitlement_id} | ||
entitlements_data.append(entitlement_dict) | ||
return entitlements_data |
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,36 @@ | ||
# 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 subman facts.""" | ||
|
||
|
||
import unittest | ||
from scanner.network.processing import subman | ||
from scanner.network.processing.test_util import ansible_result | ||
|
||
|
||
class TestProcessSubmanConsumed(unittest.TestCase): | ||
"""Test ProcessSubmanConsumed.""" | ||
|
||
def test_success_case(self): | ||
"""Found subman_consumed.""" | ||
self.assertEqual( | ||
subman.ProcessSubmanConsumed.process( | ||
ansible_result('subnameA - 1\nsubnameB - 2\nsubnameC - 3')), | ||
[{'name': 'subnameA', 'entitlement_id': '1'}, | ||
{'name': 'subnameB', 'entitlement_id': '2'}, | ||
{'name': 'subnameC', 'entitlement_id': '3'}]) | ||
|
||
def test_not_found(self): | ||
"""Did not find subman_consumed.""" | ||
self.assertEqual( | ||
subman.ProcessSubmanConsumed.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