Remove six
Replace the following items with Python 3 style code. - six.PY2 - six.add_metaclass - six.string_types - six.text_type - six.moves - six.StringIO - six.wraps - six.integer_types Story: 2008305 Task: 41191 Change-Id: I68710421b69d4049c9e990451da491dc14251fb5
This commit is contained in:
parent
b7179b7dc2
commit
c84e98d6b6
@ -17,7 +17,7 @@ import threading
|
|||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
from six.moves.queue import Queue
|
from queue import Queue
|
||||||
|
|
||||||
import monasca_agent.collector.checks
|
import monasca_agent.collector.checks
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
|
import urllib
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
# project
|
# project
|
||||||
import monasca_agent.collector.checks as checks
|
import monasca_agent.collector.checks as checks
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from six.moves.urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from six.moves.urllib.parse import urlunparse
|
from urllib.parse import urlunparse
|
||||||
|
|
||||||
from monasca_agent.collector.checks import AgentCheck
|
from monasca_agent.collector.checks import AgentCheck
|
||||||
from monasca_agent.collector.checks import utils
|
from monasca_agent.collector.checks import utils
|
||||||
|
@ -15,7 +15,7 @@ from datetime import datetime
|
|||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
|
|
||||||
from six.moves.urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from monasca_agent.collector.checks import AgentCheck
|
from monasca_agent.collector.checks import AgentCheck
|
||||||
|
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import urllib
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
from monasca_agent.collector.checks import AgentCheck
|
from monasca_agent.collector.checks import AgentCheck
|
||||||
from monasca_agent.common.util import headers
|
from monasca_agent.common.util import headers
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import urllib
|
||||||
|
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
from monasca_agent.collector.checks import AgentCheck
|
from monasca_agent.collector.checks import AgentCheck
|
||||||
from monasca_agent.collector.checks.utils import add_basic_auth
|
from monasca_agent.collector.checks.utils import add_basic_auth
|
||||||
|
@ -16,7 +16,6 @@ import os
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from six import text_type
|
|
||||||
|
|
||||||
import monasca_agent.collector.checks as checks
|
import monasca_agent.collector.checks as checks
|
||||||
|
|
||||||
@ -78,7 +77,7 @@ class Crash(checks.AgentCheck):
|
|||||||
|
|
||||||
# Return the date-/timestamp of the most recent crash
|
# Return the date-/timestamp of the most recent crash
|
||||||
if dump_count == 1:
|
if dump_count == 1:
|
||||||
value_meta = {'latest': text_type(dt)}
|
value_meta = {'latest': str(dt)}
|
||||||
|
|
||||||
log.debug('dump_count: %s', dump_count)
|
log.debug('dump_count: %s', dump_count)
|
||||||
self.gauge('crash.dump_count', dump_count, dimensions=dimensions,
|
self.gauge('crash.dump_count', dump_count, dimensions=dimensions,
|
||||||
|
@ -15,8 +15,8 @@ import json
|
|||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import urllib
|
||||||
|
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
from monasca_agent.collector.checks import AgentCheck
|
from monasca_agent.collector.checks import AgentCheck
|
||||||
from monasca_agent.collector.checks.utils import add_basic_auth
|
from monasca_agent.collector.checks.utils import add_basic_auth
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from six.moves import urllib
|
import urllib
|
||||||
|
|
||||||
|
|
||||||
from monasca_agent.collector.checks import AgentCheck
|
from monasca_agent.collector.checks import AgentCheck
|
||||||
|
@ -22,9 +22,9 @@ import socket
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
from httplib2 import Http
|
from httplib2 import Http
|
||||||
from httplib2 import HttpLib2Error
|
from httplib2 import HttpLib2Error
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
import monasca_agent.collector.checks.services_checks as services_checks
|
import monasca_agent.collector.checks.services_checks as services_checks
|
||||||
import monasca_agent.common.config as cfg
|
import monasca_agent.common.config as cfg
|
||||||
|
@ -16,8 +16,6 @@ from glob import glob
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from six import moves
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from xml.etree.ElementTree import ElementTree
|
from xml.etree.ElementTree import ElementTree
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -103,7 +101,7 @@ class Jenkins(AgentCheck):
|
|||||||
if len(dirs) > 0:
|
if len(dirs) > 0:
|
||||||
dirs = sorted(dirs, reverse=True)
|
dirs = sorted(dirs, reverse=True)
|
||||||
# We try to get the last valid build
|
# We try to get the last valid build
|
||||||
for index in moves.range(0, len(dirs) - 1):
|
for index in range(0, len(dirs) - 1):
|
||||||
dir_name = dirs[index]
|
dir_name = dirs[index]
|
||||||
try:
|
try:
|
||||||
timestamp = self._extract_timestamp(dir_name)
|
timestamp = self._extract_timestamp(dir_name)
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
import collections
|
import collections
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
import monasca_agent.collector.checks as checks
|
import monasca_agent.collector.checks as checks
|
||||||
|
|
||||||
@ -66,11 +65,11 @@ class KafkaCheck(checks.AgentCheck):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
for group, topics in raw_val.items():
|
for group, topics in raw_val.items():
|
||||||
assert isinstance(group, six.string_types)
|
assert isinstance(group, str)
|
||||||
if isinstance(topics, dict):
|
if isinstance(topics, dict):
|
||||||
self.log.info("Found old config format, discarding partition list")
|
self.log.info("Found old config format, discarding partition list")
|
||||||
topics = list(topics.keys())
|
topics = list(topics.keys())
|
||||||
assert isinstance(topics[0], six.string_types)
|
assert isinstance(topics[0], str)
|
||||||
consumer_groups[group] = topics
|
consumer_groups[group] = topics
|
||||||
return consumer_groups
|
return consumer_groups
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import re
|
import re
|
||||||
|
import urllib
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
from monasca_agent.collector.checks import AgentCheck
|
from monasca_agent.collector.checks import AgentCheck
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# 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 six.moves import urllib
|
import urllib
|
||||||
|
|
||||||
from monasca_agent.collector.checks import AgentCheck
|
from monasca_agent.collector.checks import AgentCheck
|
||||||
from monasca_agent.collector.checks.utils import add_basic_auth
|
from monasca_agent.collector.checks.utils import add_basic_auth
|
||||||
|
@ -17,8 +17,6 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from six import text_type
|
|
||||||
|
|
||||||
import monasca_agent.collector.checks as checks
|
import monasca_agent.collector.checks as checks
|
||||||
|
|
||||||
GAUGE = "gauge"
|
GAUGE = "gauge"
|
||||||
@ -256,7 +254,7 @@ class MySql(checks.AgentCheck):
|
|||||||
return self._collect_type(key, dict, float)
|
return self._collect_type(key, dict, float)
|
||||||
|
|
||||||
def _collect_string(self, key, dict):
|
def _collect_string(self, key, dict):
|
||||||
return self._collect_type(key, dict, text_type)
|
return self._collect_type(key, dict, str)
|
||||||
|
|
||||||
def _collect_type(self, key, dict, the_type):
|
def _collect_type(self, key, dict, the_type):
|
||||||
self.log.debug("Collecting data with %s" % key)
|
self.log.debug("Collecting data with %s" % key)
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import urllib
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
from monasca_agent.collector.checks import AgentCheck
|
from monasca_agent.collector.checks import AgentCheck
|
||||||
from monasca_agent.collector.checks.utils import add_basic_auth
|
from monasca_agent.collector.checks.utils import add_basic_auth
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
import urllib
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
import monasca_agent.collector.checks as checks
|
import monasca_agent.collector.checks as checks
|
||||||
|
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import functools
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from requests.packages.urllib3 import exceptions
|
from requests.packages.urllib3 import exceptions
|
||||||
import six
|
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import monasca_agent.collector.checks as checks
|
import monasca_agent.collector.checks as checks
|
||||||
@ -186,7 +186,7 @@ class SolidFire(checks.AgentCheck):
|
|||||||
def retry(exc_tuple, tries=5, delay=1, backoff=2):
|
def retry(exc_tuple, tries=5, delay=1, backoff=2):
|
||||||
# Retry decorator used for issuing API requests.
|
# Retry decorator used for issuing API requests.
|
||||||
def retry_dec(f):
|
def retry_dec(f):
|
||||||
@six.wraps(f)
|
@functools.wraps(f)
|
||||||
def func_retry(*args, **kwargs):
|
def func_retry(*args, **kwargs):
|
||||||
_tries, _delay = tries, delay
|
_tries, _delay = tries, delay
|
||||||
while _tries > 1:
|
while _tries > 1:
|
||||||
|
@ -18,8 +18,7 @@ import itertools
|
|||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
from xmlrpc import client as xmlrpc_client
|
||||||
from six.moves import xmlrpc_client
|
|
||||||
|
|
||||||
# 3p
|
# 3p
|
||||||
import supervisor.xmlrpc
|
import supervisor.xmlrpc
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
from six.moves import urllib
|
|
||||||
import socket
|
import socket
|
||||||
|
import urllib
|
||||||
|
|
||||||
import monasca_agent.collector.checks as checks
|
import monasca_agent.collector.checks as checks
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ class SwiftRecon(checks.AgentCheck):
|
|||||||
url = base_url + recon_type
|
url = base_url + recon_type
|
||||||
try:
|
try:
|
||||||
body = urllib.request.urlopen(url, timeout=timeout).read()
|
body = urllib.request.urlopen(url, timeout=timeout).read()
|
||||||
if six.PY3 and isinstance(body, six.binary_type):
|
if isinstance(body, bytes):
|
||||||
body = body.decode('utf8')
|
body = body.decode('utf8')
|
||||||
content = json.loads(body)
|
content = json.loads(body)
|
||||||
self.log.debug("-> %s: %s" % (url, content))
|
self.log.debug("-> %s: %s" % (url, content))
|
||||||
@ -180,7 +179,7 @@ class SwiftRecon(checks.AgentCheck):
|
|||||||
continue
|
continue
|
||||||
dimensions['device'] = drive['device']
|
dimensions['device'] = drive['device']
|
||||||
for stat in ('mounted', 'size', 'used', 'avail'):
|
for stat in ('mounted', 'size', 'used', 'avail'):
|
||||||
if isinstance(drive[stat], six.string_types) and \
|
if isinstance(drive[stat], str) and \
|
||||||
not drive[stat].isdigit():
|
not drive[stat].isdigit():
|
||||||
continue
|
continue
|
||||||
self.gauge('swift_recon.disk_usage.{0}'.format(stat),
|
self.gauge('swift_recon.disk_usage.{0}'.format(stat),
|
||||||
|
@ -39,8 +39,8 @@ import re
|
|||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
|
from io import StringIO
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from six import StringIO
|
|
||||||
|
|
||||||
from monasca_agent.collector.checks import AgentCheck
|
from monasca_agent.collector.checks import AgentCheck
|
||||||
|
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
# Core modules
|
# Core modules
|
||||||
import glob
|
import glob
|
||||||
|
import io
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import pstats
|
import pstats
|
||||||
import signal
|
import signal
|
||||||
import six
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ class CollectorDaemon(monasca_agent.common.daemon.Daemon):
|
|||||||
if config.get('profile', False) and profiled:
|
if config.get('profile', False) and profiled:
|
||||||
try:
|
try:
|
||||||
profiler.disable()
|
profiler.disable()
|
||||||
s = six.StringIO()
|
s = io.StringIO()
|
||||||
ps = pstats.Stats(profiler, stream=s).sort_stats("cumulative")
|
ps = pstats.Stats(profiler, stream=s).sort_stats("cumulative")
|
||||||
ps.print_stats()
|
ps.print_stats()
|
||||||
log.debug(s.getvalue())
|
log.debug(s.getvalue())
|
||||||
|
@ -20,7 +20,6 @@ import logging
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
import six
|
|
||||||
|
|
||||||
from monasca_agent.collector.virt import inspector as virt_inspector
|
from monasca_agent.collector.virt import inspector as virt_inspector
|
||||||
|
|
||||||
@ -87,7 +86,7 @@ class LibvirtInspector(virt_inspector.Inspector):
|
|||||||
return self._get_connection().lookupByUUIDString(instance.UUIDString())
|
return self._get_connection().lookupByUUIDString(instance.UUIDString())
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if not libvirt or not isinstance(ex, libvirt.libvirtError):
|
if not libvirt or not isinstance(ex, libvirt.libvirtError):
|
||||||
raise virt_inspector.InspectorException(six.text_type(ex))
|
raise virt_inspector.InspectorException(str(ex))
|
||||||
error_code = ex.get_error_code()
|
error_code = ex.get_error_code()
|
||||||
if (error_code == libvirt.VIR_ERR_SYSTEM_ERROR and
|
if (error_code == libvirt.VIR_ERR_SYSTEM_ERROR and
|
||||||
ex.get_error_domain() in (libvirt.VIR_FROM_REMOTE,
|
ex.get_error_domain() in (libvirt.VIR_FROM_REMOTE,
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from monasca_agent.common import exceptions
|
from monasca_agent.common import exceptions
|
||||||
@ -30,8 +29,7 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
# Make this a singleton class so we don't get the config every time
|
# Make this a singleton class so we don't get the config every time
|
||||||
# the class is created
|
# the class is created
|
||||||
@six.add_metaclass(singleton.Singleton)
|
class Config(object, metaclass=singleton.Singleton):
|
||||||
class Config(object):
|
|
||||||
|
|
||||||
def __init__(self, configFile=None):
|
def __init__(self, configFile=None):
|
||||||
# importing it here, in order to avoid a circular import
|
# importing it here, in order to avoid a circular import
|
||||||
@ -107,7 +105,7 @@ class Config(object):
|
|||||||
def get_config(self, sections='Main'):
|
def get_config(self, sections='Main'):
|
||||||
"""Get the config info."""
|
"""Get the config info."""
|
||||||
section_list = []
|
section_list = []
|
||||||
if isinstance(sections, six.string_types):
|
if isinstance(sections, str):
|
||||||
section_list.append(sections)
|
section_list.append(sections)
|
||||||
elif isinstance(sections, list):
|
elif isinstance(sections, list):
|
||||||
section_list.extend(sections)
|
section_list.extend(sections)
|
||||||
|
@ -13,11 +13,10 @@
|
|||||||
|
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
import json
|
import json
|
||||||
from six.moves.urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
from six.moves.urllib.request import build_opener
|
from urllib.request import build_opener
|
||||||
from six.moves.urllib.request import ProxyHandler
|
from urllib.request import ProxyHandler
|
||||||
from six.moves.urllib.request import Request
|
from urllib.request import Request
|
||||||
from six import PY3
|
|
||||||
|
|
||||||
|
|
||||||
def post_headers(payload):
|
def post_headers(payload):
|
||||||
@ -41,8 +40,7 @@ def http_emitter(message, log, url):
|
|||||||
partial_payload.append(measurement)
|
partial_payload.append(measurement)
|
||||||
|
|
||||||
payload = json.dumps(partial_payload)
|
payload = json.dumps(partial_payload)
|
||||||
if PY3:
|
payload = payload.encode('utf-8')
|
||||||
payload = payload.encode('utf-8')
|
|
||||||
url = "%s/intake" % url
|
url = "%s/intake" % url
|
||||||
headers = post_headers(payload)
|
headers = post_headers(payload)
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import logging
|
|||||||
from keystoneauth1 import identity
|
from keystoneauth1 import identity
|
||||||
from keystoneauth1 import session
|
from keystoneauth1 import session
|
||||||
from keystoneclient import discover
|
from keystoneclient import discover
|
||||||
import six
|
|
||||||
|
|
||||||
from monasca_agent.common import singleton
|
from monasca_agent.common import singleton
|
||||||
from monasca_agent import version as ma_version
|
from monasca_agent import version as ma_version
|
||||||
@ -244,8 +243,7 @@ def get_args(config):
|
|||||||
return clean_args
|
return clean_args
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(singleton.Singleton)
|
class Keystone(object, metaclass=singleton.Singleton):
|
||||||
class Keystone(object):
|
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self._config = get_args(config)
|
self._config = get_args(config)
|
||||||
|
@ -34,7 +34,6 @@ import logging
|
|||||||
import logging.handlers
|
import logging.handlers
|
||||||
from numbers import Number
|
from numbers import Number
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from six import integer_types
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -45,7 +44,7 @@ VALID_HOSTNAME_RFC_1123_PATTERN = re.compile(
|
|||||||
MAX_HOSTNAME_LEN = 255
|
MAX_HOSTNAME_LEN = 255
|
||||||
LOGGING_MAX_BYTES = 5 * 1024 * 1024
|
LOGGING_MAX_BYTES = 5 * 1024 * 1024
|
||||||
|
|
||||||
NumericTypes = (float,) + integer_types
|
NumericTypes = (float,) + (int,)
|
||||||
|
|
||||||
import monasca_agent.common.config as configuration
|
import monasca_agent.common.config as configuration
|
||||||
from monasca_agent.common.exceptions import PathNotFound
|
from monasca_agent.common.exceptions import PathNotFound
|
||||||
|
@ -24,8 +24,6 @@ import signal
|
|||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from six import text_type
|
|
||||||
|
|
||||||
# set up logging before importing any other components
|
# set up logging before importing any other components
|
||||||
import monasca_agent.common.util as util
|
import monasca_agent.common.util as util
|
||||||
util.initialize_logging('forwarder')
|
util.initialize_logging('forwarder')
|
||||||
@ -222,10 +220,10 @@ def main():
|
|||||||
skip_ssl_validation = False
|
skip_ssl_validation = False
|
||||||
use_simple_http_client = False
|
use_simple_http_client = False
|
||||||
|
|
||||||
if text_type(tornado.options.options.sslcheck) == u"0":
|
if str(tornado.options.options.sslcheck) == u"0":
|
||||||
skip_ssl_validation = True
|
skip_ssl_validation = True
|
||||||
|
|
||||||
if text_type(tornado.options.options.use_simple_http_client) == u"1":
|
if str(tornado.options.options.use_simple_http_client) == u"1":
|
||||||
use_simple_http_client = True
|
use_simple_http_client = True
|
||||||
|
|
||||||
# If we don't have any arguments, run the server.
|
# If we don't have any arguments, run the server.
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import urllib
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
import monasca_setup.agent_config
|
import monasca_setup.agent_config
|
||||||
import monasca_setup.detection
|
import monasca_setup.detection
|
||||||
|
@ -11,11 +11,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import configparser
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from six.moves import configparser
|
|
||||||
|
|
||||||
from monasca_agent.common.psutil_wrapper import psutil
|
from monasca_agent.common.psutil_wrapper import psutil
|
||||||
import monasca_setup.agent_config
|
import monasca_setup.agent_config
|
||||||
import monasca_setup.detection
|
import monasca_setup.detection
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
uses statsd.
|
uses statsd.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import configparser
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from six.moves import configparser
|
|
||||||
|
|
||||||
import monasca_setup.agent_config
|
import monasca_setup.agent_config
|
||||||
import monasca_setup.detection
|
import monasca_setup.detection
|
||||||
|
@ -11,9 +11,9 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import configparser
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from six.moves import configparser
|
|
||||||
|
|
||||||
import monasca_setup.agent_config
|
import monasca_setup.agent_config
|
||||||
import monasca_setup.detection
|
import monasca_setup.detection
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import configparser
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from six.moves import configparser
|
|
||||||
|
|
||||||
from monasca_setup import agent_config
|
from monasca_setup import agent_config
|
||||||
from monasca_setup import detection
|
from monasca_setup import detection
|
||||||
|
@ -15,7 +15,6 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
import monasca_setup.agent_config
|
import monasca_setup.agent_config
|
||||||
import monasca_setup.detection
|
import monasca_setup.detection
|
||||||
@ -136,7 +135,7 @@ class ProcessCheck(monasca_setup.detection.Plugin):
|
|||||||
if found_process_names:
|
if found_process_names:
|
||||||
process_item['found_process_names'] = found_process_names
|
process_item['found_process_names'] = found_process_names
|
||||||
if 'exact_match' in process_item:
|
if 'exact_match' in process_item:
|
||||||
if isinstance(process_item['exact_match'], six.string_types):
|
if isinstance(process_item['exact_match'], str):
|
||||||
process_item['exact_match'] = (
|
process_item['exact_match'] = (
|
||||||
process_item['exact_match'].lower() == 'true')
|
process_item['exact_match'].lower() == 'true')
|
||||||
else:
|
else:
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import urllib
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
import monasca_setup.agent_config
|
import monasca_setup.agent_config
|
||||||
import monasca_setup.detection
|
import monasca_setup.detection
|
||||||
|
@ -11,10 +11,9 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import configparser
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from six.moves import configparser
|
|
||||||
|
|
||||||
from monasca_agent.common.psutil_wrapper import psutil
|
from monasca_agent.common.psutil_wrapper import psutil
|
||||||
import monasca_setup.agent_config
|
import monasca_setup.agent_config
|
||||||
from monasca_setup.detection import Plugin
|
from monasca_setup.detection import Plugin
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import urllib
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
from monasca_setup import agent_config
|
from monasca_setup import agent_config
|
||||||
from monasca_setup.detection.plugin import Plugin
|
from monasca_setup.detection.plugin import Plugin
|
||||||
|
@ -26,7 +26,6 @@ import socket
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from monasca_setup import agent_config
|
from monasca_setup import agent_config
|
||||||
from monasca_setup.service.detection import detect_init
|
from monasca_setup.service.detection import detect_init
|
||||||
@ -288,7 +287,7 @@ def parse_arguments(parser):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--monasca_url',
|
'--monasca_url',
|
||||||
help="Monasca API url, if not defined the url is pulled from keystone",
|
help="Monasca API url, if not defined the url is pulled from keystone",
|
||||||
type=six.text_type,
|
type=str,
|
||||||
default='')
|
default='')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--service_type',
|
'--service_type',
|
||||||
|
@ -18,7 +18,6 @@ python-memcached>=1.56 # PSF
|
|||||||
python-monascaclient>=1.7.0 # Apache-2.0
|
python-monascaclient>=1.7.0 # Apache-2.0
|
||||||
python-keystoneclient>=3.8.0 # Apache-2.0
|
python-keystoneclient>=3.8.0 # Apache-2.0
|
||||||
redis>=2.10.0 # MIT
|
redis>=2.10.0 # MIT
|
||||||
six>=1.10.0 # MIT
|
|
||||||
stevedore>=1.20.0 # Apache-2.0
|
stevedore>=1.20.0 # Apache-2.0
|
||||||
tornado>=4.5.3 # Apache-2.0
|
tornado>=4.5.3 # Apache-2.0
|
||||||
# NOTE(sdague): before allowing in >= 0.21 please be sure
|
# NOTE(sdague): before allowing in >= 0.21 please be sure
|
||||||
|
@ -18,7 +18,6 @@ from unittest import mock
|
|||||||
import unittest
|
import unittest
|
||||||
import psutil
|
import psutil
|
||||||
import json
|
import json
|
||||||
import six
|
|
||||||
|
|
||||||
from monasca_setup.detection.plugins import kibana
|
from monasca_setup.detection.plugins import kibana
|
||||||
|
|
||||||
@ -91,7 +90,7 @@ class KibanaDetectionTest(unittest.TestCase):
|
|||||||
for instance in kibana_check['instances']:
|
for instance in kibana_check['instances']:
|
||||||
self.assertIn('metrics', instance)
|
self.assertIn('metrics', instance)
|
||||||
self.assertEqual(list, type(instance['metrics']))
|
self.assertEqual(list, type(instance['metrics']))
|
||||||
six.assertCountEqual(self, _KIBANA_METRICS, instance['metrics'])
|
self.assertCountEqual(_KIBANA_METRICS, instance['metrics'])
|
||||||
|
|
||||||
def _verify_process_conf(self, process_check, kibana_user):
|
def _verify_process_conf(self, process_check, kibana_user):
|
||||||
# minimize check here, do not check how process should work
|
# minimize check here, do not check how process should work
|
||||||
@ -249,6 +248,6 @@ class KibanaDetectionTest(unittest.TestCase):
|
|||||||
conf = self.kibana_plugin.build_config()
|
conf = self.kibana_plugin.build_config()
|
||||||
self.assertIsNotNone(conf)
|
self.assertIsNotNone(conf)
|
||||||
|
|
||||||
six.assertCountEqual(self, ['kibana', 'process'], conf.keys())
|
self.assertCountEqual(['kibana', 'process'], conf.keys())
|
||||||
self._verify_kibana_conf(conf['kibana'], kibana_url)
|
self._verify_kibana_conf(conf['kibana'], kibana_url)
|
||||||
self._verify_process_conf(conf['process'], kibana_user)
|
self._verify_process_conf(conf['process'], kibana_user)
|
||||||
|
@ -17,7 +17,7 @@ import unittest
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import psutil
|
import psutil
|
||||||
import six
|
import configparser
|
||||||
|
|
||||||
from monasca_setup.detection.plugins import mon
|
from monasca_setup.detection.plugins import mon
|
||||||
|
|
||||||
@ -187,8 +187,6 @@ class TestMonPersisterDetectionPlugin(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
mod = "builtins.open"
|
mod = "builtins.open"
|
||||||
if six.PY2:
|
|
||||||
mod = "__builtin__.open"
|
|
||||||
|
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
mod,
|
mod,
|
||||||
@ -220,7 +218,7 @@ class TestMonPersisterDetectionPlugin(unittest.TestCase):
|
|||||||
rcf.assert_called_once_with(config_file)
|
rcf.assert_called_once_with(config_file)
|
||||||
self.assertTrue(iih.get_bound_port.called_once)
|
self.assertTrue(iih.get_bound_port.called_once)
|
||||||
|
|
||||||
@mock.patch('six.moves.configparser.RawConfigParser')
|
@mock.patch('configparser.RawConfigParser')
|
||||||
def test_should_detect_python_persister_has_config(self, _):
|
def test_should_detect_python_persister_has_config(self, _):
|
||||||
# NOTE(trebskit) this cannot use mocking the read of the file
|
# NOTE(trebskit) this cannot use mocking the read of the file
|
||||||
# because when either RawConfigParser or mock_open messes up with
|
# because when either RawConfigParser or mock_open messes up with
|
||||||
@ -261,8 +259,6 @@ class TestMonPersisterDetectionPlugin(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
mod = "builtins.open"
|
mod = "builtins.open"
|
||||||
if six.PY2:
|
|
||||||
mod = "__builtin__.open"
|
|
||||||
|
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
mod,
|
mod,
|
||||||
@ -501,8 +497,6 @@ class TestMonAPIDetectionPlugin(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
mod = "builtins.open"
|
mod = "builtins.open"
|
||||||
if six.PY2:
|
|
||||||
mod = "__builtin__.open"
|
|
||||||
|
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
mod,
|
mod,
|
||||||
@ -513,7 +507,7 @@ class TestMonAPIDetectionPlugin(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertTrue(self._mon_api.available)
|
self.assertTrue(self._mon_api.available)
|
||||||
|
|
||||||
@mock.patch('six.moves.configparser.RawConfigParser')
|
@mock.patch('configparser.RawConfigParser')
|
||||||
def test_should_detect_python_api_has_config(self, rcp):
|
def test_should_detect_python_api_has_config(self, rcp):
|
||||||
expected_port = 6666
|
expected_port = 6666
|
||||||
actual_port = 6666
|
actual_port = 6666
|
||||||
@ -535,7 +529,7 @@ class TestMonAPIDetectionPlugin(unittest.TestCase):
|
|||||||
self._detect(retval=[fake_processes])
|
self._detect(retval=[fake_processes])
|
||||||
self.assertTrue(self._mon_api.available)
|
self.assertTrue(self._mon_api.available)
|
||||||
|
|
||||||
@mock.patch('six.moves.configparser.RawConfigParser')
|
@mock.patch('configparser.RawConfigParser')
|
||||||
def test_should_not_detect_if_port_dont_match(self, rcp):
|
def test_should_not_detect_if_port_dont_match(self, rcp):
|
||||||
expected_port = 6666
|
expected_port = 6666
|
||||||
actual_port = 8070
|
actual_port = 8070
|
||||||
@ -569,7 +563,7 @@ class TestMonAPIDetectionPlugin(unittest.TestCase):
|
|||||||
def test_build_java_config_with_hibernate(self):
|
def test_build_java_config_with_hibernate(self):
|
||||||
self._run_java_build_config(hibernate_enabled=True)
|
self._run_java_build_config(hibernate_enabled=True)
|
||||||
|
|
||||||
@mock.patch('six.moves.configparser.RawConfigParser')
|
@mock.patch('configparser.RawConfigParser')
|
||||||
def test_build_python_config(self, rcp):
|
def test_build_python_config(self, rcp):
|
||||||
expected_port = 8070
|
expected_port = 8070
|
||||||
|
|
||||||
@ -620,8 +614,6 @@ class TestMonAPIDetectionPlugin(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
mod = "builtins.open"
|
mod = "builtins.open"
|
||||||
if six.PY2:
|
|
||||||
mod = "__builtin__.open"
|
|
||||||
|
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
mod,
|
mod,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import configparser
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import psutil
|
import psutil
|
||||||
@ -19,7 +20,6 @@ from unittest import mock
|
|||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from six.moves import configparser
|
|
||||||
|
|
||||||
from monasca_setup.detection import utils
|
from monasca_setup.detection import utils
|
||||||
from monasca_setup.detection.plugins.ovs import Ovs
|
from monasca_setup.detection.plugins.ovs import Ovs
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
import monasca_agent.common.aggregator as aggregator
|
import monasca_agent.common.aggregator as aggregator
|
||||||
import monasca_agent.common.metrics as metrics_pkg
|
import monasca_agent.common.metrics as metrics_pkg
|
||||||
@ -66,7 +65,7 @@ class TestMetricsAggregator(unittest.TestCase):
|
|||||||
value_meta=value_meta)
|
value_meta=value_meta)
|
||||||
|
|
||||||
def testValidMetricUnicodeDimensionValue(self):
|
def testValidMetricUnicodeDimensionValue(self):
|
||||||
dimensions = {six.unichr(2440): 'B', 'B': 'C', 'D': 'E'}
|
dimensions = {chr(2440): 'B', 'B': 'C', 'D': 'E'}
|
||||||
value_meta = {"This is a test": "test, test, test"}
|
value_meta = {"This is a test": "test, test, test"}
|
||||||
self.submit_metric("Foo",
|
self.submit_metric("Foo",
|
||||||
5,
|
5,
|
||||||
@ -74,7 +73,7 @@ class TestMetricsAggregator(unittest.TestCase):
|
|||||||
value_meta=value_meta)
|
value_meta=value_meta)
|
||||||
|
|
||||||
def testValidMetricUnicodeDimensionKey(self):
|
def testValidMetricUnicodeDimensionKey(self):
|
||||||
dimensions = {'A': 'B', 'B': six.unichr(920), 'D': 'E'}
|
dimensions = {'A': 'B', 'B': chr(920), 'D': 'E'}
|
||||||
value_meta = {"This is a test": "test, test, test"}
|
value_meta = {"This is a test": "test, test, test"}
|
||||||
self.submit_metric("Foo",
|
self.submit_metric("Foo",
|
||||||
5,
|
5,
|
||||||
@ -84,7 +83,7 @@ class TestMetricsAggregator(unittest.TestCase):
|
|||||||
def testValidMetricUnicodeMetricName(self):
|
def testValidMetricUnicodeMetricName(self):
|
||||||
dimensions = {'A': 'B', 'B': 'C', 'D': 'E'}
|
dimensions = {'A': 'B', 'B': 'C', 'D': 'E'}
|
||||||
value_meta = {"This is a test": "test, test, test"}
|
value_meta = {"This is a test": "test, test, test"}
|
||||||
self.submit_metric(six.unichr(6021),
|
self.submit_metric(chr(6021),
|
||||||
5,
|
5,
|
||||||
dimensions=dimensions,
|
dimensions=dimensions,
|
||||||
value_meta=value_meta)
|
value_meta=value_meta)
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
import os.path
|
import os.path
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import six
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
@ -129,5 +128,5 @@ class TestConfig(unittest.TestCase):
|
|||||||
def test_verify_common_config_opts(self):
|
def test_verify_common_config_opts(self):
|
||||||
opts = util.get_parsed_args(prog='test')
|
opts = util.get_parsed_args(prog='test')
|
||||||
opts_dict = vars(opts[0])
|
opts_dict = vars(opts[0])
|
||||||
six.assertCountEqual(self, ['config_file', 'clean', 'verbose'],
|
self.assertCountEqual(['config_file', 'clean', 'verbose'],
|
||||||
opts_dict.keys())
|
opts_dict.keys())
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
Performance tests for the agent/dogstatsd metrics aggregator.
|
Performance tests for the agent/dogstatsd metrics aggregator.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from six.moves import range
|
|
||||||
|
|
||||||
|
|
||||||
from monasca_agent.common.aggregator import MetricsAggregator
|
from monasca_agent.common.aggregator import MetricsAggregator
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
import urllib
|
||||||
import logging
|
import logging
|
||||||
logging.basicConfig()
|
logging.basicConfig()
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -18,8 +19,6 @@ import time
|
|||||||
from nose.plugins.skip import SkipTest
|
from nose.plugins.skip import SkipTest
|
||||||
from tests.common import load_check
|
from tests.common import load_check
|
||||||
|
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
|
|
||||||
PORT = 9200
|
PORT = 9200
|
||||||
MAX_WAIT = 150
|
MAX_WAIT = 150
|
||||||
|
@ -15,13 +15,13 @@ import subprocess
|
|||||||
import time
|
import time
|
||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import os
|
||||||
|
import urllib
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from tests.common import load_check, kill_subprocess
|
from tests.common import load_check, kill_subprocess
|
||||||
from nose.plugins.attrib import attr
|
from nose.plugins.attrib import attr
|
||||||
from nose.plugins.skip import SkipTest
|
from nose.plugins.skip import SkipTest
|
||||||
|
|
||||||
from six.moves import urllib
|
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig()
|
logging.basicConfig()
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from io import StringIO
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from collector.checks import LaconicFilter
|
from collector.checks import LaconicFilter
|
||||||
|
|
||||||
from six.moves import cStringIO as StringIO
|
|
||||||
|
|
||||||
|
|
||||||
class TestLaconic(unittest.TestCase):
|
class TestLaconic(unittest.TestCase):
|
||||||
|
@ -15,7 +15,6 @@ import time
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import nose.tools as nt
|
import nose.tools as nt
|
||||||
from six.moves import range
|
|
||||||
|
|
||||||
from monasca_agent.common.aggregator import MetricsAggregator
|
from monasca_agent.common.aggregator import MetricsAggregator
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import binascii
|
|||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
from nose.plugins.skip import SkipTest
|
from nose.plugins.skip import SkipTest
|
||||||
from six.moves import range
|
|
||||||
|
|
||||||
class TestPostfix(unittest.TestCase):
|
class TestPostfix(unittest.TestCase):
|
||||||
#
|
#
|
||||||
|
@ -10,13 +10,11 @@
|
|||||||
# 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 functools import reduce
|
|
||||||
import logging
|
import logging
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from six.moves import reduce
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
logger = logging.getLogger(__file__)
|
logger = logging.getLogger(__file__)
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from datetime import timedelta, datetime
|
from datetime import timedelta, datetime
|
||||||
|
|
||||||
from six.moves import range
|
|
||||||
|
|
||||||
from monasca_agent.forwarder.transaction import Transaction, TransactionManager
|
from monasca_agent.forwarder.transaction import Transaction, TransactionManager
|
||||||
from monasca_agent.forwarder.daemon import MAX_QUEUE_SIZE, THROTTLING_DELAY
|
from monasca_agent.forwarder.daemon import MAX_QUEUE_SIZE, THROTTLING_DELAY
|
||||||
|
|
||||||
|
@ -11,8 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
from io import StringIO
|
||||||
from six import StringIO
|
|
||||||
|
|
||||||
from tests.common import get_check
|
from tests.common import get_check
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user