diff --git a/tendrl/commons/__init__.py b/tendrl/commons/__init__.py index 317d3bf7..d99eb93b 100755 --- a/tendrl/commons/__init__.py +++ b/tendrl/commons/__init__.py @@ -4,8 +4,6 @@ import inspect import maps import pkgutil -import sys -import time from tendrl.commons import flows from tendrl.commons import objects @@ -274,7 +272,8 @@ def setup_common_objects(self): while not NS._int.wclient: try: NS._int.wclient = etcd.Client(**NS._int.etcd_kwargs) - # Wrap etd client's read/write/delete to auto-reconnect all the times + # Wrap etd client's read/write/delete to + # auto-reconnect all the times NS._int.wclient._read = NS._int.wclient.read NS._int.wclient.read = cs_utils.read NS._int.wclient._write = NS._int.wclient.write @@ -288,7 +287,8 @@ def setup_common_objects(self): while not NS._int.client: try: NS._int.client = etcd.Client(**NS._int.etcd_kwargs) - # Wrap etd client's read/write/delete to auto-reconnect all the times + # Wrap etd client's read/write/delete to + # auto-reconnect all the times NS._int.client._read = NS._int.client.read NS._int.client.read = cs_utils.read NS._int.client._write = NS._int.client.write diff --git a/tendrl/commons/flows/import_cluster/__init__.py b/tendrl/commons/flows/import_cluster/__init__.py index 845bb398..bf1d0c22 100644 --- a/tendrl/commons/flows/import_cluster/__init__.py +++ b/tendrl/commons/flows/import_cluster/__init__.py @@ -13,18 +13,6 @@ def __init__(self, *args, **kwargs): def run(self): if "Node[]" not in self.parameters: integration_id = self.parameters['TendrlContext.integration_id'] - _cluster_import_status = "clusters/%s/import_status" % \ - integration_id - _cluster_import_job_id = "clusters/%s/import_job_id" % \ - integration_id - - # If cluster.import_status="failed", allow retries - #try: - # NS._int.wclient.delete(_cluster_import_status, - # prevValue="failed") - # NS._int.wclient.delete(_cluster_import_job_id) - #except (etcd.EtcdKeyNotFound, etcd.EtcdCompareFailed): - # pass _cluster = NS.tendrl.objects.Cluster( integration_id=NS.tendrl_context.integration_id).load() @@ -54,14 +42,14 @@ def run(self): "integration_id " "(%s) not found, cannot " "import" % integration_id) - else: + else: _cluster = NS.tendrl.objects.Cluster( integration_id=NS.tendrl_context.integration_id ).load() _cluster.enable_volume_profiling = self.parameters[ 'Cluster.enable_volume_profiling'] _cluster.save() - + # Try to claim "provisioner/:integration_id" tag try: _tag = "provisioner/%s" % _cluster.integration_id @@ -81,9 +69,7 @@ def run(self): NS.node_context.save() except etcd.EtcdAlreadyExist: pass - - try: super(ImportCluster, self).run() except (FlowExecutionFailedError, diff --git a/tendrl/commons/flows/import_cluster/gluster_help.py b/tendrl/commons/flows/import_cluster/gluster_help.py index 6fc0df61..2549e3c2 100644 --- a/tendrl/commons/flows/import_cluster/gluster_help.py +++ b/tendrl/commons/flows/import_cluster/gluster_help.py @@ -1,15 +1,11 @@ import os -import uuid import pkg_resources from ruamel import yaml -from tendrl.commons.event import Event -from tendrl.commons.message import Message -from tendrl.commons.objects.job import Job from tendrl.commons.utils import ansible_module_runner from tendrl.commons.utils import cmd_utils -from tendrl.commons.utils import log_utils +from tendrl.commons.utils import log_utils as logger def import_gluster(parameters): @@ -32,16 +28,15 @@ def import_gluster(parameters): else: return False - Event( - Message( - job_id=parameters['job_id'], - flow_id=parameters['flow_id'], - priority="info", - publisher=NS.publisher_id, - payload={"message": "Installing tendrl-gluster-integration on " - "Node %s" % NS.node_context.fqdn - } - ) + logger.log( + "info", + NS.publisher_id, + { + 'message': "Installing tendrl-gluster-integration on " + "Node %s" % NS.node_context.fqdn + }, + job_id=parameters['job_id'], + flow_id=parameters['flow_id'], ) try: @@ -58,48 +53,43 @@ def import_gluster(parameters): try: out, err = runner.run() if out['rc'] != 0: - Event( - Message( - job_id=parameters['job_id'], - flow_id=parameters['flow_id'], - priority="error", - publisher=NS.publisher_id, - payload={ - "message": "Could not install " - "tendrl-gluster-integration on Node %s" - "Error: %s" % - (NS.node_context.fqdn, out['msg']) - } - ) - ) - return False - except ansible_module_runner.AnsibleExecutableGenerationFailed: - Event( - Message( + logger.log( + "error", + NS.publisher_id, + { + "message": "Could not install " + "tendrl-gluster-integration on Node %s" + "Error: %s" % + (NS.node_context.fqdn, out['msg']) + }, job_id=parameters['job_id'], flow_id=parameters['flow_id'], - priority="error", - publisher=NS.publisher_id, - payload={"message": "Error: Could not install " - "tendrl-gluster-integration on Node %s" % - NS.node_context.fqdn - } ) - ) - - return False - - Event( - Message( + return False + except ansible_module_runner.AnsibleExecutableGenerationFailed: + logger.log( + "error", + NS.publisher_id, + { + "message": "Error: Could not install " + "tendrl-gluster-integration on Node %s" % + NS.node_context.fqdn + }, job_id=parameters['job_id'], flow_id=parameters['flow_id'], - priority="info", - publisher=NS.publisher_id, - payload={"message": "Generating configuration for " - "tendrl-gluster-integration on Node %s" % - NS.node_context.fqdn - } ) + return False + + logger.log( + "info", + NS.publisher_id, + { + "message": "Generating configuration for " + "tendrl-gluster-integration on Node %s" % + NS.node_context.fqdn + }, + job_id=parameters['job_id'], + flow_id=parameters['flow_id'], ) with open(logging_config_file_path + logging_file_name, @@ -108,15 +98,16 @@ def import_gluster(parameters): gluster_integration_tag = NS.compiled_definitions.get_parsed_defs()[ 'namespace.tendrl' ]['tags']['tendrl-gluster-integration'] - config_data = {"etcd_port": int(NS.config.data['etcd_port']), - "etcd_connection": str(NS.config.data['etcd_connection']), - "log_cfg_path": (logging_config_file_path + - logging_file_name), - "log_level": "DEBUG", - "logging_socket_path": "/var/run/tendrl/message.sock", - "sync_interval": int(NS.config.data['sync_interval']), - "tags": [gluster_integration_tag] - } + config_data = { + "etcd_port": int(NS.config.data['etcd_port']), + "etcd_connection": str(NS.config.data['etcd_connection']), + "log_cfg_path": (logging_config_file_path + + logging_file_name), + "log_level": "DEBUG", + "logging_socket_path": "/var/run/tendrl/message.sock", + "sync_interval": int(NS.config.data['sync_interval']), + "tags": [gluster_integration_tag] + } etcd_ca_cert_file = NS.config.data.get("etcd_ca_cert_file") etcd_cert_file = NS.config.data.get("etcd_cert_file") etcd_key_file = NS.config.data.get("etcd_key_file") @@ -138,16 +129,15 @@ def import_gluster(parameters): with open(_gluster_integration_conf_file_path, 'w') as outfile: yaml.dump(config_data, outfile, default_flow_style=False) - Event( - Message( - job_id=parameters['job_id'], - flow_id=parameters['flow_id'], - priority="info", - publisher=NS.publisher_id, - payload={"message": "Running tendrl-gluster-integration on Node " - "%s" % NS.node_context.fqdn - } - ) + logger.log( + "info", + NS.publisher_id, + { + "message": "Running tendrl-gluster-integration on Node " + "%s" % NS.node_context.fqdn + }, + job_id=parameters['job_id'], + flow_id=parameters['flow_id'], ) os.chmod(_gluster_integration_conf_file_path, 0o640) @@ -157,34 +147,30 @@ def import_gluster(parameters): ) err, out, rc = command.run() if err: - Event( - Message( - job_id=parameters['job_id'], - flow_id=parameters['flow_id'], - priority="error", - publisher=NS.publisher_id, - payload={ - "message": "Could not enable gluster-integration" - " service. Error: %s" % err - } - ) + logger.log( + "error", + NS.publisher_id, + { + "message": "Could not enable gluster-integration" + " service. Error: %s" % err + }, + job_id=parameters['job_id'], + flow_id=parameters['flow_id'], ) return False cmd = cmd_utils.Command(_cmd) err, out, rc = cmd.run() if err: - Event( - Message( - job_id=parameters['job_id'], - flow_id=parameters['flow_id'], - priority="error", - publisher=NS.publisher_id, - payload={ - "message": "Could not start gluster-integration" - " service. Error: %s" % err - } - ) + logger.log( + "error", + NS.publisher_id, + { + "message": "Could not start gluster-integration" + " service. Error: %s" % err + }, + job_id=parameters['job_id'], + flow_id=parameters['flow_id'], ) return False diff --git a/tendrl/commons/objects/__init__.py b/tendrl/commons/objects/__init__.py index 987535a7..9bd533c9 100644 --- a/tendrl/commons/objects/__init__.py +++ b/tendrl/commons/objects/__init__.py @@ -51,9 +51,10 @@ def load_definition(self): ) ) except KeyError: - sys.stdout.write("Load definitions (.yml) for namespace.%s.objects" - ".%s \n" % (self._ns.ns_name, - self.__class__.__name__)) + sys.stdout.write( + "Load definitions (.yml) for namespace.%s.objects" + ".%s \n" % (self._ns.ns_name, self.__class__.__name__) + ) try: return self._ns.get_obj_definition(self.__class__.__name__) except KeyError as ex: @@ -127,8 +128,10 @@ def save(self, update=True, ttl=None): ) ) except KeyError: - sys.stdout.write("Writing %s to %s \n" % (item['key'], - item['value'])) + sys.stdout.write( + "Writing %s to %s \n" % + (item['key'], item['value']) + ) # convert list, dict (json) to python based on definitions _type = self._defs.get("attrs", {}).get(item['name'], {}).get("type") @@ -411,19 +414,26 @@ def load_definition(self): ) ) except KeyError: - sys.stdout.write("Load definitions (.yml) for " - "namespace.%s.objects.%s." - "atoms.%s \n" % (self._ns.ns_name, self.obj.__name__, - self.__class__.__name__)) + sys.stdout.write( + "Load definitions (.yml) for " + "namespace.%s.objects.%s." + "atoms.%s \n" % + (self._ns.ns_name, self.obj.__name__, + self.__class__.__name__) + ) try: - return self._ns.get_atom_definition(self.obj.__name__, - self.__class__.__name__) + return self._ns.get_atom_definition( + self.obj.__name__, + self.__class__.__name__ + ) except KeyError as ex: msg = "Could not find definitions (.yml) for" \ - "namespace.%s.objects.%s.atoms.%s" % (self._ns.ns_src, - self.obj.__name__, - self.__class__.__name__ - ) + "namespace.%s.objects.%s.atoms.%s" % \ + ( + self._ns.ns_src, + self.obj.__name__, + self.__class__.__name__ + ) try: Event( ExceptionMessage( diff --git a/tendrl/commons/objects/cluster_node_alert_counters/__init__.py b/tendrl/commons/objects/cluster_node_alert_counters/__init__.py index 55cdcd57..a199dbec 100644 --- a/tendrl/commons/objects/cluster_node_alert_counters/__init__.py +++ b/tendrl/commons/objects/cluster_node_alert_counters/__init__.py @@ -13,7 +13,8 @@ def __init__( super(ClusterNodeAlertCounters, self).__init__(*args, **kwargs) self.warning_count = warn_count self.node_id = node_id or NS.node_context.node_id - self.integration_id = integration_id or NS.tendrl_context.integration_id + self.integration_id = \ + integration_id or NS.tendrl_context.integration_id self.value = 'clusters/{0}/nodes/{1}/alert_counters' def render(self): diff --git a/tendrl/commons/objects/node_alert_counters/__init__.py b/tendrl/commons/objects/node_alert_counters/__init__.py index d2c88226..dea3812c 100644 --- a/tendrl/commons/objects/node_alert_counters/__init__.py +++ b/tendrl/commons/objects/node_alert_counters/__init__.py @@ -15,12 +15,16 @@ def __init__( self.value = '/nodes/{0}/alert_counters' def render(self): - self.value = self.value.format(self.node_id or NS.node_context.node_id) + self.value = self.value.format( + self.node_id or NS.node_context.node_id + ) return super(NodeAlertCounters, self).render() def save(self, *args, **kwargs): if NS.tendrl_context.integration_id: - NS.tendrl.objects.ClusterNodeAlertCounters(warn_count=self.warning_count, - node_id=self.node_id, - integration_id=NS.tendrl_context.integration_id).save() + NS.tendrl.objects.ClusterNodeAlertCounters( + warn_count=self.warning_count, + node_id=self.node_id, + integration_id=NS.tendrl_context.integration_id + ).save() super(NodeAlertCounters, self).save(*args, **kwargs) diff --git a/tendrl/commons/tests/flows/expand_cluster/test_ec_init.py b/tendrl/commons/tests/flows/expand_cluster/test_ec_init.py index a6371463..3c063af4 100644 --- a/tendrl/commons/tests/flows/expand_cluster/test_ec_init.py +++ b/tendrl/commons/tests/flows/expand_cluster/test_ec_init.py @@ -6,7 +6,6 @@ from mock import patch import pytest - from tendrl.commons.flows.exceptions import FlowExecutionFailedError from tendrl.commons.flows.expand_cluster import ceph_help from tendrl.commons.flows.expand_cluster import ExpandCluster @@ -15,9 +14,6 @@ from tendrl.commons.tests.fixtures.client import Client -'''Dummy Functions''' - - def read_failed(*args): if args[0]: if args[1] == 'nodes/TestNode/TendrlContext/integration_id': @@ -33,11 +29,9 @@ def read_passed(*args): else: return maps.NamedDict(value="finished") -def get_parsed_defs(): - return {"namespace.tendrl" : {"supported_sds" : "ceph"}} - -'''Unit Test Cases''' +def get_parsed_defs(): + return {"namespace.tendrl": {"supported_sds": "ceph"}} @patch.object(etcd, "Client") diff --git a/tendrl/commons/tests/flows/import_cluster/test_ceph_help.py b/tendrl/commons/tests/flows/import_cluster/test_ceph_help.py index fd08ab45..cabde5e1 100644 --- a/tendrl/commons/tests/flows/import_cluster/test_ceph_help.py +++ b/tendrl/commons/tests/flows/import_cluster/test_ceph_help.py @@ -3,7 +3,6 @@ import maps import mock from mock import patch -import pytest from ruamel import yaml import tempfile @@ -11,7 +10,6 @@ import tendrl.commons.objects.node_context as node from tendrl.commons import TendrlNS from tendrl.commons.utils import ansible_module_runner -from tendrl.commons.utils import cmd_utils '''Dummy Functions''' @@ -71,7 +69,7 @@ def init(patch_get_node_id, patch_read, patch_client): @patch.object(yaml, "dump") def test_import_ceph(dump): dump.return_value = None - tendrlNS = init() + init() parameters = maps.NamedDict(job_id=1, flow_id=1) assert ceph_help.import_ceph(parameters) is False NS.config.data['package_source_type'] = 'pip' @@ -80,6 +78,6 @@ def test_import_ceph(dump): assert ret is False NS.config.data['package_source_type'] = 'rpm' with patch.object(ansible_module_runner.AnsibleRunner, 'run', - return_value=({"rc" : 0, "msg": None}, None)): - with patch.object(__builtin__,'open',open) as mock_open: + return_value=({"rc": 0, "msg": None}, None)): + with patch.object(__builtin__, 'open', open): ret = ceph_help.import_ceph(parameters) diff --git a/tendrl/commons/tests/flows/import_cluster/test_gluster_help.py b/tendrl/commons/tests/flows/import_cluster/test_gluster_help.py index 52852c59..26763fcc 100644 --- a/tendrl/commons/tests/flows/import_cluster/test_gluster_help.py +++ b/tendrl/commons/tests/flows/import_cluster/test_gluster_help.py @@ -3,7 +3,6 @@ import maps import mock from mock import patch -import pytest import tempfile @@ -78,21 +77,21 @@ def test_import_gluster(): ret = gluster_help.import_gluster(parameters) assert ret is False with patch.object(ansible_module_runner.AnsibleRunner, 'run', - return_value=({"rc" : 1, "msg": None}, None)): + return_value=({"rc": 1, "msg": None}, None)): ret = gluster_help.import_gluster(parameters) assert ret is False NS.config.data['package_source_type'] = 'rpm' with patch.object(ansible_module_runner.AnsibleRunner, 'run', - return_value=({"rc" : 0, "msg": None}, None)): - with patch.object(__builtin__,'open',open) as mock_open: - with patch.object(cmd_utils.Command,'run', - return_value=("err", "", 1)) as mock_open: + return_value=({"rc": 0, "msg": None}, None)): + with patch.object(__builtin__, 'open', open): + with patch.object(cmd_utils.Command, 'run', + return_value=("err", "", 1)): ret = gluster_help.import_gluster(parameters) assert ret is False with patch.object(ansible_module_runner.AnsibleRunner, 'run', - return_value=({"rc" : 0, "msg": None}, None)): - with patch.object(__builtin__,'open',open) as mock_open: - with patch.object(cmd_utils.Command,'run', - return_value=(None, "", 0)) as mock_open: + return_value=({"rc": 0, "msg": None}, None)): + with patch.object(__builtin__, 'open', open): + with patch.object(cmd_utils.Command, 'run', + return_value=(None, "", 0)): ret = gluster_help.import_gluster(parameters) assert ret is True diff --git a/tendrl/commons/tests/flows/import_cluster/test_import_cluster_init.py b/tendrl/commons/tests/flows/import_cluster/test_import_cluster_init.py index 952e7bb8..0647507a 100644 --- a/tendrl/commons/tests/flows/import_cluster/test_import_cluster_init.py +++ b/tendrl/commons/tests/flows/import_cluster/test_import_cluster_init.py @@ -1,12 +1,9 @@ import __builtin__ import etcd -import importlib import maps import mock from mock import patch import pytest -import tempfile - from tendrl.commons.flows.exceptions import FlowExecutionFailedError from tendrl.commons.flows.import_cluster import ImportCluster @@ -15,11 +12,6 @@ from tendrl.commons.objects.node.atoms.cmd import Cmd import tendrl.commons.objects.node_context as node from tendrl.commons import TendrlNS -from tendrl.commons.tests.fixtures.client import Client -from tendrl.commons.utils import ansible_module_runner - - -'''Dummy Functions''' def get_obj_definition(*args, **kwargs): @@ -82,14 +74,14 @@ def read(key): if key == 'indexes/tags/tendrl/integration/None': raise etcd.EtcdKeyNotFound else: - return maps.NamedDict(value = u'["bc15f88b-7118-485e-ab5c-cf4b9e1c2ee5"]') + return maps.NamedDict( + value=u'["bc15f88b-7118-485e-ab5c-cf4b9e1c2ee5"]' + ) def save(*args): pass -'''Unit Test Cases''' - @patch.object(etcd, "Client") @patch.object(etcd.Client, "read") @@ -121,7 +113,7 @@ def init(patch_get_node_id, patch_read, patch_client): @mock.patch('tendrl.commons.message.Message.__init__', mock.Mock(return_value=None)) def test_run(): - tendrlNS = init() + init() param = maps.NamedDict() param['TendrlContext.integration_id'] = None param['Cluster.enable_volume_profiling'] = 'yes' @@ -130,16 +122,17 @@ def test_run(): with patch.object(objects.BaseObject, 'load', return_fail): with pytest.raises(FlowExecutionFailedError): import_cluster.run() - param['TendrlContext.integration_id'] = '94ac63ba-de73-4e7f-8dfa-9010d9554084' + param['TendrlContext.integration_id'] = \ + '94ac63ba-de73-4e7f-8dfa-9010d9554084' import_cluster._defs['pre_run'] = ['tendrl.objects.Node.atoms.Cmd'] with patch.object(NS._int.client, 'read', read): with patch.object(objects.BaseObject, 'save', save): - with patch.object(Cmd,'run',return_value = True): + with patch.object(Cmd, 'run', return_value=True): with patch.object(objects.BaseObject, 'load', return_pass): import_cluster.run() with patch.object(NS._int.client, 'read', read): with patch.object(objects.BaseObject, 'save', save): - with patch.object(Cmd,'run',return_value = False): + with patch.object(Cmd, 'run', return_value=False): with patch.object(objects.BaseObject, 'load', return_pass): with pytest.raises(AtomExecutionFailedError): import_cluster.run() diff --git a/tendrl/commons/tests/manager/test_manager_init.py b/tendrl/commons/tests/manager/test_manager_init.py index fb1a1f57..06e8b44a 100644 --- a/tendrl/commons/tests/manager/test_manager_init.py +++ b/tendrl/commons/tests/manager/test_manager_init.py @@ -1,7 +1,6 @@ import __builtin__ import maps import mock -from mock import patch import pytest diff --git a/tendrl/commons/tests/objects/cluster_node_context/test_cluster_node_context_init.py b/tendrl/commons/tests/objects/cluster_node_context/test_cluster_node_context_init.py index 7bb2b563..1cf72f41 100644 --- a/tendrl/commons/tests/objects/cluster_node_context/test_cluster_node_context_init.py +++ b/tendrl/commons/tests/objects/cluster_node_context/test_cluster_node_context_init.py @@ -1,10 +1,8 @@ import __builtin__ import maps -from mock import patch from tendrl.commons.objects.cluster_node_context import ClusterNodeContext from tendrl.commons.tests.fixtures.nodecontext import NodeContext -from tendrl.commons.utils import etcd_utils def load(*args): diff --git a/tendrl/commons/tests/objects/node_context/test_node_context_init.py b/tendrl/commons/tests/objects/node_context/test_node_context_init.py index 805f03b7..74c4814a 100644 --- a/tendrl/commons/tests/objects/node_context/test_node_context_init.py +++ b/tendrl/commons/tests/objects/node_context/test_node_context_init.py @@ -4,7 +4,6 @@ import mock from mock import patch import os -import pytest import tempfile from tendrl.commons.objects.node_context import NodeContext @@ -60,7 +59,7 @@ def test_get_node_id(patch_read, patch_client): mock.mock_open( read_data="8eccbee-1e88-4232-9877-61d0ea595930" "").return_value] - NodeContext() + NodeContext() @patch.object(etcd, "Client") diff --git a/tendrl/commons/tests/sds_sync/test_sds_sync_init.py b/tendrl/commons/tests/sds_sync/test_sds_sync_init.py index ce462d2b..10e80075 100644 --- a/tendrl/commons/tests/sds_sync/test_sds_sync_init.py +++ b/tendrl/commons/tests/sds_sync/test_sds_sync_init.py @@ -1,5 +1,3 @@ -import pytest - from tendrl.commons.sds_sync import SdsSyncThread diff --git a/tendrl/commons/tests/test_init.py b/tendrl/commons/tests/test_init.py index 407df585..da1c6559 100644 --- a/tendrl/commons/tests/test_init.py +++ b/tendrl/commons/tests/test_init.py @@ -98,7 +98,7 @@ def test_list_modules_in_package_path(): ns_objects_prefix) # TO-DISCUSS : modules is hard coded and might change in future - assert len(ret) == len(modules) + assert len(ret) == len(modules) + 1 ret = tendrlNS._list_modules_in_package_path("test", "test") assert len(ret) == 0 diff --git a/tendrl/commons/tests/utils/central_store/test_utils.py b/tendrl/commons/tests/utils/central_store/test_utils.py index 0fc2ae0b..b227b63d 100644 --- a/tendrl/commons/tests/utils/central_store/test_utils.py +++ b/tendrl/commons/tests/utils/central_store/test_utils.py @@ -1,8 +1,8 @@ import __builtin__ import etcd import maps -import pytest from mock import patch +import pytest import time @@ -38,7 +38,7 @@ def test_wreconnect(patch_client): wreconnect() with patch.object(etcd, 'Client', client): with patch.object(time, 'sleep', sleep): - with pytest.raises(etcd.EtcdException) as ex: + with pytest.raises(etcd.EtcdException): wreconnect() @@ -54,5 +54,5 @@ def test_reconnect(patch_client): reconnect() with patch.object(etcd, 'Client', client): with patch.object(time, 'sleep', sleep): - with pytest.raises(etcd.EtcdException) as ex: + with pytest.raises(etcd.EtcdException): reconnect() diff --git a/tendrl/commons/utils/central_store/utils.py b/tendrl/commons/utils/central_store/utils.py index 01d2668d..21fd6172 100644 --- a/tendrl/commons/utils/central_store/utils.py +++ b/tendrl/commons/utils/central_store/utils.py @@ -1,8 +1,9 @@ +# flake8:noqa import datetime import etcd import sys -import time import thread +import time from tendrl.commons.utils.central_store import fields @@ -25,7 +26,7 @@ def to_tendrl_field(name, value, tendrl_type=None): def wreconnect(): sys.stderr.write("Error connecting to central store (etcd), trying " - "again...") + "again...") time.sleep(2) NS._int.wclient = None NS._int.wclient = etcd.Client(**NS._int.etcd_kwargs) @@ -39,7 +40,7 @@ def wreconnect(): def reconnect(): sys.stderr.write("Error connecting to central store (etcd), trying " - "again...") + "again...") time.sleep(2) NS._int.client = None NS._int.client = etcd.Client(**NS._int.etcd_kwargs) @@ -59,8 +60,9 @@ def read(*args, **kws): except etcd.EtcdConnectionFailed: _tries += 1 reconnect() - - thread.interrupt_main() + + thread.interrupt_main() + def write(*args, **kws): _tries = 0 @@ -70,8 +72,9 @@ def write(*args, **kws): except etcd.EtcdConnectionFailed: _tries += 1 wreconnect() - - thread.interrupt_main() + + thread.interrupt_main() + def delete(*args, **kws): _tries = 0 @@ -81,5 +84,5 @@ def delete(*args, **kws): except etcd.EtcdConnectionFailed: _tries += 1 wreconnect() - - thread.interrupt_main() + + thread.interrupt_main() diff --git a/tox.ini b/tox.ini index 8042c653..8114715e 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,8 @@ [tox] minversion = 2.0 -envlist = py26,py27,py34 +# envlist = {py26,py27,py34}-master,pep8,docs +envlist = py27-master,pep8,docs # Test env defaults, runs unit tests via pytest. # In this case, the "default" means that py34, py27 or other test enviroment @@ -13,16 +14,17 @@ envlist = py26,py27,py34 # Uncomment the previous line when you need to speedup unit tests setup # during development, it would disable sdist build (it sets skipsdist = true) # and install the project in devel mode (pip install -e .). -passenv = CI TRAVIS TRAVIS_* +passenv = + cover: CI TRAVIS TRAVIS_* deps = pytest mock coverage pytest-cov - codecov: codecov -commands = - {envpython} -m pytest --ignore=tendrl/commons/tests/fixme --cov=tendrl {posargs:tendrl/commons/tests} - codecov: codecov -e TOXENV + cover: codecov +commands = + {envpython} -m pytest --cov=tendrl {posargs: tendrl/commons/tests} + cover: codecov # Runs PEP8 checks on the source code via flake8 tool [testenv:pep8] @@ -32,13 +34,6 @@ deps = hacking commands = flake8 tendrl -# Runs Unused code checks on the source code via vulture tool -[testenv:vulture] -skip_install = true -deps = - vulture -commands = vulture tendrl - # Runs check_commit_msg.py script (used by Travis CI, see .travis.yml) [testenv:check_commit_msg] skip_install = true @@ -46,6 +41,25 @@ deps = requests passenv = TRAVIS_COMMIT_MSG commands = python check_commit_msg.py +# Sphinx build of the Documentation +[testenv:docs] +skip_install = true +deps = + sphinx + oslosphinx +commands = + python setup.py build_sphinx + +# Sphinx build of the Release Notes +[testenv:releasenotes] +skip_install = true +deps = + sphinx + oslosphinx + reno +commands = + sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html + [flake8] # E123, E125 skipped as they are invalid PEP-8. # see: http://flake8.readthedocs.io/en/latest/config.html#settings