Messages refactoring
diff --git a/cfg_checker/cfg_check.py b/cfg_checker/cfg_check.py
index 9389817..b8243ff 100644
--- a/cfg_checker/cfg_check.py
+++ b/cfg_checker/cfg_check.py
@@ -1,6 +1,5 @@
import argparse
import os
-import reclass
import sys
import traceback
diff --git a/cfg_checker/common/exception.py b/cfg_checker/common/exception.py
index 157c466..8e8b818 100644
--- a/cfg_checker/common/exception.py
+++ b/cfg_checker/common/exception.py
@@ -12,22 +12,22 @@
# TODO: get and log traceback
# prettify message
- self.message = "CheckerException: {}".format(message)
+ self.message = "# CheckerException: {}".format(message)
class ConfigException(CheckerException):
def __init__(self, message, *args, **kwargs):
super(ConfigException, self).__init__(message, *args, **kwargs)
- self.message = "Configuration error: {}".format(message)
+ self.message = "# Configuration error: {}".format(message)
class SaltException(CheckerException):
def __init__(self, message, *args, **kwargs):
super(SaltException, self).__init__(message, *args, **kwargs)
- self.message = "Salt error: {}".format(message)
+ self.message = "# Salt error: {}".format(message)
class InvalidReturnException(CheckerException):
def __init__(self, message, *args, **kwargs):
super(InvalidReturnException, self).__init__(message, *args, **kwargs)
- self.message = "Unexpected return value: {}".format(message)
+ self.message = "# Unexpected return value: {}".format(message)
diff --git a/cfg_checker/common/other.py b/cfg_checker/common/other.py
index 1ff5adf..47cb865 100644
--- a/cfg_checker/common/other.py
+++ b/cfg_checker/common/other.py
@@ -33,7 +33,7 @@
:param message: True if validate should return error check message
:return: False if checks failed, True if all checks passed
"""
- _message = "Validation passed"
+ _message = "# Validation passed"
def _result():
return (True, _message) if message else True
@@ -45,11 +45,11 @@
return _result()
else:
# log warning here
- _message = "Node code is unknown, '{}'. " \
- "Please, update map".format(_code)
+ _message = "# Node code is unknown, '{}'. " \
+ "# Please, update map".format(_code)
else:
# log warning here
- _message = "Node name is invalid, '{}'".format(fqdn)
+ _message = "# Node name is invalid, '{}'".format(fqdn)
# put other checks here
@@ -88,7 +88,7 @@
with open(os.path.join(pkg_dir, nodes_list)) as _f:
_list.extend(_f.read().splitlines())
except IOError as e:
- raise ConfigException("Error while loading file, '{}': "
+ raise ConfigException("# Error while loading file, '{}': "
"{}".format(e.filename, e.strerror))
else:
_list.extend(self.node_string_to_list(env))
diff --git a/cfg_checker/common/salt_utils.py b/cfg_checker/common/salt_utils.py
index 4aba178..4955fae 100644
--- a/cfg_checker/common/salt_utils.py
+++ b/cfg_checker/common/salt_utils.py
@@ -19,7 +19,7 @@
_json = json.loads(_raw)
except ValueError as e:
raise SaltException(
- "Return value is not a json: '{}'".format(_raw)
+ "# Return value is not a json: '{}'".format(_raw)
)
return _json["local"]
@@ -47,7 +47,7 @@
logger_cli.debug("### Calling salt: '{}'".format(_ssh_cmd))
_result = shell(_ssh_cmd)
if len(_result) < 1:
- raise InvalidReturnException("Empty value returned for '{}".format(
+ raise InvalidReturnException("# Empty value returned for '{}".format(
_ssh_cmd
))
else:
@@ -88,7 +88,7 @@
def get(self, path='', headers=default_headers, cookies=None):
_path = os.path.join(self.uri, path)
- logger.debug("GET '{}'\nHeaders: '{}'\nCookies: {}".format(
+ logger.debug("# GET '{}'\nHeaders: '{}'\nCookies: {}".format(
_path,
headers,
cookies
@@ -107,7 +107,7 @@
_data = str(data).replace(self._pass, "*****")
else:
_data = data
- logger.debug("POST '{}'\nHeaders: '{}'\nCookies: {}\nBody: {}".format(
+ logger.debug("# POST '{}'\nHeaders: '{}'\nCookies: {}\nBody: {}".format(
_path,
headers,
cookies,
@@ -132,7 +132,7 @@
'eauth': 'pam'
}
self._pass = _pass
- logger.debug("Logging in to salt master...")
+ logger.debug("# Logging in to salt master...")
_response = self.post(login_payload, path='login')
if _response.ok:
@@ -143,7 +143,7 @@
return self._auth['response']['token']
else:
raise EnvironmentError(
- "HTTP:{}, Not authorized?".format(_response.status_code)
+ "# HTTP:{}, Not authorized?".format(_response.status_code)
)
def salt_request(self, fn, *args, **kwargs):
@@ -159,7 +159,7 @@
if _len < 1024:
_content = _response.content
logger.debug(
- "Response (HTTP {}/{}), {}: {}".format(
+ "# Response (HTTP {}/{}), {}: {}".format(
_response.status_code,
_response.reason,
_len,
@@ -170,7 +170,7 @@
return _response.json()['return']
else:
raise EnvironmentError(
- "Salt Error: HTTP:{}, '{}'".format(
+ "# Salt Error: HTTP:{}, '{}'".format(
_response.status_code,
_response.reason
)
@@ -214,7 +214,7 @@
return _response[0]
else:
raise EnvironmentError(
- "Unexpected response from from salt-api/LocalClient: "
+ "# Unexpected response from from salt-api/LocalClient: "
"{}".format(_response)
)
@@ -233,7 +233,7 @@
return _response[0]
else:
raise EnvironmentError(
- "Unexpected response from from salt-api/RunnerClient: "
+ "# Unexpected response from from salt-api/RunnerClient: "
"{}".format(_response)
)
@@ -254,7 +254,7 @@
return _response
else:
raise EnvironmentError(
- "Salt Error: '{}'".format(_response['return']))
+ "# Salt Error: '{}'".format(_response['return']))
def pillar_request(self, node_target, pillar_submodule, argument):
# example cli: 'salt "ctl01*" pillar.keys rsyslog'
@@ -320,7 +320,7 @@
:return: json result from salt test.ping
"""
if config.skip_nodes:
- logger.info("Nodes to be skipped: {0}".format(config.skip_nodes))
+ logger.info("# Nodes to be skipped: {0}".format(config.skip_nodes))
return self.cmd(
'* and not ' + list_to_target_string(
config.skip_nodes,
diff --git a/cfg_checker/common/settings.py b/cfg_checker/common/settings.py
index 39aeff2..30cc7f2 100644
--- a/cfg_checker/common/settings.py
+++ b/cfg_checker/common/settings.py
@@ -75,7 +75,7 @@
logger_cli.info("# Loading env vars from '{}'".format(_config_path))
else:
raise ConfigException(
- "Failed to load enviroment vars from '{}'".format(
+ "# Failed to load enviroment vars from '{}'".format(
_config_path
)
)
@@ -96,7 +96,7 @@
# if there was errors, report them
if _errors:
raise ConfigException(
- "Environment file failed validation in lines: {}".format(
+ "# Environment file failed validation in lines: {}".format(
"\n".join(_errors)
)
)
diff --git a/cfg_checker/network_checks.py b/cfg_checker/network_checks.py
index 7daa673..d5bb9d5 100644
--- a/cfg_checker/network_checks.py
+++ b/cfg_checker/network_checks.py
@@ -35,7 +35,7 @@
key,
len(self.nodes[key]['networks'].keys())
))
- logger_cli.info("-> Done collecting networks data")
+ logger_cli.info("-> done collecting networks data")
# dump collected data to speed up coding
# with open('dump.json', 'w+') as ff: