Fix: RuntimeWarning when using analyze

Change-Id: Ie0e5c67cf2daf04b63d36fb7f28658bbf4471a80
This commit is contained in:
Dmitry Sutyagin 2016-12-14 16:18:24 -08:00
parent 9169d0cd13
commit 6988c468d8
3 changed files with 18 additions and 13 deletions

View File

@ -4,7 +4,7 @@
%global pypi_name timmy %global pypi_name timmy
Name: python-%{pypi_name} Name: python-%{pypi_name}
Version: 1.25.4 Version: 1.25.5
Release: 1%{?dist}~mos0 Release: 1%{?dist}~mos0
Summary: Log collector tool for OpenStack Fuel Summary: Log collector tool for OpenStack Fuel
@ -107,6 +107,9 @@ popd
%changelog %changelog
* Wed Dec 14 2016 Dmitry Sutyagin <dsutyagin@mirantis.com> - 1.25.5
- Fix: RuntimeWarning when using analyze
* Mon Dec 12 2016 Dmitry Sutyagin <dsutyagin@mirantis.com> - 1.25.4 * Mon Dec 12 2016 Dmitry Sutyagin <dsutyagin@mirantis.com> - 1.25.4
- Change: compact analyze output, minor refactor - Change: compact analyze output, minor refactor

View File

@ -15,12 +15,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from timmy.analyze_health import GREEN, UNKNOWN, YELLOW, RED
from timmy.env import project_name
import imp
import logging import logging
import os import os
import sys import sys
import timmy
from timmy.analyze_health import GREEN, UNKNOWN, YELLOW, RED
from timmy.env import project_name
logger = logging.getLogger(project_name) logger = logging.getLogger(project_name)
@ -32,14 +32,16 @@ def analyze(node_manager):
fn_mapping = {} fn_mapping = {}
modules_dir = 'analyze_modules' modules_dir = 'analyze_modules'
modules_path = os.path.join(os.path.dirname(__file__), modules_dir) scan_path = os.path.join(os.path.dirname(__file__), modules_dir)
module_paths = m = [] base_path = os.path.split(timmy.__path__[0])[0]
for item in os.walk(modules_path): for item in os.walk(scan_path):
m.extend([os.sep.join([item[0], f]) for f in item[2] if is_module(f)]) for module_path in [m for m in item[2] if is_module(m)]:
for module_path in module_paths: module_full_path = os.path.join(scan_path, module_path)
module_name = os.path.basename(module_path) module_rel_path = os.path.relpath(module_full_path, base_path)
module = imp.load_source(module_name, module_path) module_rel_path_noext = os.path.splitext(module_rel_path)[0]
module.register(fn_mapping) module_name = module_rel_path_noext.replace(os.path.sep, '.')
module = __import__(module_name, fromlist=[project_name])
module.register(fn_mapping)
results = {} results = {}
for node in node_manager.nodes.values(): for node in node_manager.nodes.values():

View File

@ -16,7 +16,7 @@
# under the License. # under the License.
project_name = 'timmy' project_name = 'timmy'
version = '1.25.4' version = '1.25.5'
if __name__ == '__main__': if __name__ == '__main__':
import sys import sys