From be03437775a49bb183d7afa7ab231e592b407d4b Mon Sep 17 00:00:00 2001 From: Nicholas Muesch Date: Thu, 17 Jan 2019 18:43:05 -0500 Subject: [PATCH] Support Python 3 (#2837) --- .travis.yml | 2 +- ceph/datadog_checks/ceph/__init__.py | 2 +- ceph/datadog_checks/ceph/ceph.py | 12 +++--------- ceph/tests/test_ceph.py | 8 -------- ceph/tox.ini | 4 +--- 5 files changed, 6 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index a3e79d219d49e..eaff8ac727707 100644 --- a/.travis.yml +++ b/.travis.yml @@ -86,7 +86,7 @@ jobs: - stage: test env: CHECK=cassandra_nodetool PYTHON3=true - stage: test - env: CHECK=ceph + env: CHECK=ceph PYTHON3=true - stage: test env: CHECK=cisco_aci - stage: test diff --git a/ceph/datadog_checks/ceph/__init__.py b/ceph/datadog_checks/ceph/__init__.py index 6158c8c0671d8..87107fb0ee441 100644 --- a/ceph/datadog_checks/ceph/__init__.py +++ b/ceph/datadog_checks/ceph/__init__.py @@ -1,4 +1,4 @@ -from ceph import Ceph +from .ceph import Ceph __all__ = [ '__version__', diff --git a/ceph/datadog_checks/ceph/ceph.py b/ceph/datadog_checks/ceph/ceph.py index 1e73a0cb8b15c..d999707e73d4f 100644 --- a/ceph/datadog_checks/ceph/ceph.py +++ b/ceph/datadog_checks/ceph/ceph.py @@ -1,22 +1,16 @@ # (C) Datadog, Inc. 2018 # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) - -"""ceph check -Collects metrics from ceph clusters -""" - -# stdlib +from __future__ import division import os import re -# project from datadog_checks.checks import AgentCheck from datadog_checks.utils.subprocess_output import get_subprocess_output from datadog_checks.config import _is_affirmative -# third party import simplejson as json +from six import iteritems class Ceph(AgentCheck): @@ -127,7 +121,7 @@ def _extract_metrics(self, raw, tags): # so we won't send the metric osd.pct_used if 'checks' in raw['health_detail']: checks = raw['health_detail']['checks'] - for check_name, check_detail in checks.iteritems(): + for check_name, check_detail in iteritems(checks): if check_name == 'OSD_NEARFULL': health['num_near_full_osds'] = len(check_detail['detail']) if check_name == 'OSD_FULL': diff --git a/ceph/tests/test_ceph.py b/ceph/tests/test_ceph.py index 55ddfecc362e4..7e4fbb1389204 100644 --- a/ceph/tests/test_ceph.py +++ b/ceph/tests/test_ceph.py @@ -7,7 +7,6 @@ import os import copy import mock -import pytest import simplejson as json # Constants @@ -33,13 +32,6 @@ EXPECTED_SERVICE_TAGS = ['optional:tag1'] -@pytest.fixture -def aggregator(): - from datadog_checks.stubs import aggregator - aggregator.reset() - return aggregator - - def mock_data(file): filepath = os.path.join(FIXTURE_DIR, file) with open(filepath, "r") as f: diff --git a/ceph/tox.ini b/ceph/tox.ini index ea27ae534dc6e..fd553c48c8728 100644 --- a/ceph/tox.ini +++ b/ceph/tox.ini @@ -2,14 +2,12 @@ minversion = 2.0 basepython = py27 envlist = - ceph + {py27,py36}-latest flake8 [testenv] usedevelop = true platform = linux|darwin|win32 - -[testenv:ceph] deps = -e../datadog_checks_base[deps] -rrequirements-dev.txt