-
Notifications
You must be signed in to change notification settings - Fork 30
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/301
- Loading branch information
Showing
11 changed files
with
417 additions
and
14 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 |
---|---|---|
@@ -1,22 +1,40 @@ | ||
import * as types from '../constants/credentialsConstants'; | ||
import credentialsApi from '../../services/credentialsApi'; | ||
|
||
const loadCredentialsSuccess = data => ({ | ||
const credentialsError = (bool, message) => ({ | ||
type: types.LOAD_CREDENTIALS_ERROR, | ||
error: bool, | ||
message: message | ||
}); | ||
|
||
const credentialsLoading = bool => ({ | ||
type: types.LOAD_CREDENTIALS_LOADING, | ||
loading: bool | ||
}); | ||
|
||
const credentialsSuccess = data => ({ | ||
type: types.LOAD_CREDENTIALS_SUCCESS, | ||
data | ||
}); | ||
|
||
const getCredentials = () => { | ||
return function(dispatch) { | ||
dispatch(credentialsLoading(true)); | ||
return credentialsApi | ||
.getCredentials() | ||
.then(success => { | ||
dispatch(loadCredentialsSuccess(success)); | ||
dispatch(credentialsSuccess(success)); | ||
}) | ||
.catch(error => { | ||
throw error; | ||
}); | ||
dispatch(credentialsError(true, error.message)); | ||
}) | ||
.finally(() => dispatch(credentialsLoading(false))); | ||
}; | ||
}; | ||
|
||
export { loadCredentialsSuccess, getCredentials }; | ||
export { | ||
credentialsError, | ||
credentialsLoading, | ||
credentialsSuccess, | ||
getCredentials | ||
}; |
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 |
---|---|---|
@@ -1,22 +1,35 @@ | ||
import * as types from '../constants/scansConstants'; | ||
import scansApi from '../../services/scansApi'; | ||
|
||
const loadScansSuccess = data => ({ | ||
const scansError = (bool, message) => ({ | ||
type: types.LOAD_SCANS_ERROR, | ||
error: bool, | ||
message: message | ||
}); | ||
|
||
const scansLoading = bool => ({ | ||
type: types.LOAD_SCANS_LOADING, | ||
loading: bool | ||
}); | ||
|
||
const scansSuccess = data => ({ | ||
type: types.LOAD_SCANS_SUCCESS, | ||
data | ||
}); | ||
|
||
const getScans = () => { | ||
return function(dispatch) { | ||
dispatch(scansLoading(true)); | ||
return scansApi | ||
.getScans() | ||
.then(success => { | ||
dispatch(loadScansSuccess(success)); | ||
dispatch(scansSuccess(success)); | ||
}) | ||
.catch(error => { | ||
throw error; | ||
}); | ||
dispatch(scansError(true, error.message)); | ||
}) | ||
.finally(() => dispatch(scansLoading(false))); | ||
}; | ||
}; | ||
|
||
export { loadScansSuccess, getScans }; | ||
export { scansError, scansLoading, scansSuccess, getScans }; |
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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
const LOAD_CREDENTIALS_ERROR = 'LOAD_CREDENTIALS_ERROR'; | ||
const LOAD_CREDENTIALS_LOADING = 'LOAD_CREDENTIALS_LOADING'; | ||
const LOAD_CREDENTIALS_SUCCESS = 'LOAD_CREDENTIALS_SUCCESS'; | ||
|
||
export { LOAD_CREDENTIALS_SUCCESS }; | ||
export { | ||
LOAD_CREDENTIALS_ERROR, | ||
LOAD_CREDENTIALS_LOADING, | ||
LOAD_CREDENTIALS_SUCCESS | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
const LOAD_SCANS_ERROR = 'LOAD_SCANS_ERROR'; | ||
const LOAD_SCANS_LOADING = 'LOAD_SCANS_LOADING'; | ||
const LOAD_SCANS_SUCCESS = 'LOAD_SCANS_SUCCESS'; | ||
|
||
export { LOAD_SCANS_SUCCESS }; | ||
export { LOAD_SCANS_ERROR, LOAD_SCANS_LOADING, LOAD_SCANS_SUCCESS }; |
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 |
---|---|---|
|
@@ -11,3 +11,4 @@ | |
|
||
# flake8: noqa | ||
from . import eap | ||
from . import karaf |
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,114 @@ | ||
# 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 jboss_fuse_on_karaf role.""" | ||
|
||
import logging | ||
from scanner.network.processing import process | ||
|
||
logger = logging.getLogger(__name__) # pylint: disable=invalid-name | ||
|
||
# pylint: disable=too-few-public-methods | ||
|
||
# #### Processors #### | ||
|
||
FIND_WARNING = 'find: WARNING: Hard link count is wrong for /proc: this may' \ | ||
' be a bug in your filesystem driver.' | ||
|
||
|
||
class ProcessKarafRunningProcesses(process.Processor): | ||
"""Process a list of Jboss Fuse on Karaf processes.""" | ||
|
||
KEY = 'karaf_running_processes' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Preserve the output except for a known issue.""" | ||
if FIND_WARNING in output['stdout']: | ||
logging.error('Find command failed') | ||
return process.NO_DATA | ||
|
||
return output['stdout'].strip() | ||
|
||
|
||
class ProcessFindKaraf(process.Processor): | ||
"""Process the results of a find command.""" | ||
|
||
KEY = 'karaf_find_karaf_jar' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Return the command's output.""" | ||
print('\n\n\nProcessFindKaraf )line 50): \n') | ||
print(str(output['stdout_lines'])) | ||
return output['stdout_lines'] | ||
|
||
|
||
class ProcessLocateKaraf(process.Processor): | ||
"""Process the output of 'locate jboss.fuse-on-karaf.karaf-home'.""" | ||
|
||
KEY = 'karaf_locate_karaf_jar' | ||
|
||
DEPS = ['have_locate'] | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Pass the output back through.""" | ||
return output['stdout_lines'] | ||
|
||
|
||
class InitLineFinder(process.Processor): | ||
"""Process the output of an init system. | ||
For both chkconfig and systemctl list-unit-files, we look for | ||
lines where the first (whitespace-delineated) element contains | ||
'jboss' or 'fuse'. | ||
""" | ||
|
||
# This same code is in eap but I wasn't sure how to make the keyword an | ||
# argument since it is in a class (without doing an __init__) | ||
KEY = None | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Find lines where the first element contains 'jboss' or 'fuse'.""" | ||
matches = [] | ||
|
||
for line in output['stdout_lines']: | ||
if not line: | ||
continue | ||
|
||
start = line.split()[0] | ||
if 'jboss' in start or 'fuse' in start: | ||
matches.append(line.strip()) | ||
|
||
return matches | ||
|
||
|
||
class ProcessJbossFuseChkconfig(InitLineFinder): | ||
"""Process the output of 'chkconfig'.""" | ||
|
||
KEY = 'jboss_fuse_chkconfig' | ||
|
||
|
||
class ProcessJbossFuseSystemctl(InitLineFinder): | ||
"""Process the output of 'systemctl list-unit-files'.""" | ||
|
||
KEY = 'jboss_fuse_systemctl_unit_files' | ||
|
||
|
||
class ProcessKarafHomeBinFuse(process.Processor): | ||
"""Process karaf home indicators to detect Fuse-on-Karaf.""" | ||
|
||
KEY = 'karaf_home_bin_fuse' | ||
|
||
@staticmethod | ||
def process(output): | ||
"""Pass the output back through.""" | ||
return output['stdout_lines'] |
Oops, something went wrong.