fix misc intellij inspection warnings

docstring, pep8
also disable some intellij warnings

Change-Id: Ie1fa59452e8332aca649a830a7dfaecdb06ef78a
This commit is contained in:
Eyal 2016-03-24 11:27:13 +02:00
parent 695152957c
commit 4032243abb
32 changed files with 62 additions and 45 deletions

View File

@ -8,6 +8,7 @@ lxml>=2.3
python-ceilometerclient>=2.2.1 # Apache-2.0
python-cinderclient>=1.3.1 # Apache-2.0
python-dateutil>=2.4.2
python-keystoneclient!=1.8.0,!=2.1.0,>=1.6.0 # Apache-2.0
python-novaclient>=2.26.0
networkx>=1.10
oslo.config>=2.7.0 # Apache-2.0

View File

@ -27,7 +27,7 @@ OPTS = [
cfg.StrOpt('aodh_version', default='2', help='Aodh version'),
cfg.FloatOpt('nova_version', default='2.0', help='Nova version'),
cfg.StrOpt('cinder_version', default='1', help='Cinder version'),
]
]
def ceilometer_client(conf):
@ -39,7 +39,7 @@ def ceilometer_client(conf):
session=keystone_client.get_session(conf),
region_name=auth_config.region_name,
interface=auth_config.interface,
)
)
LOG.info('Ceilometer client created')
return client
except Exception as e:
@ -55,7 +55,7 @@ def nova_client(conf):
session=keystone_client.get_session(conf),
region_name=auth_config.region_name,
interface=auth_config.interface,
)
)
LOG.info('Nova client created')
return client
except Exception as e:

View File

@ -70,7 +70,7 @@ class RaiseAlarm(base.Recipe):
'affected_resource_id': action_spec.targets[TFields.TARGET],
'name': action_spec.properties[TFields.ALARM_NAME],
'event_type': event_type,
}
}
notify_step = ActionStepWrapper(NOTIFY, notify_params)
return notify_step

View File

@ -153,7 +153,7 @@ class ScenarioEvaluator(object):
targets = action_spec.targets
real_ids = {
target: match[target_id] for target, target_id in targets.items()
}
}
revised_spec = ActionSpecs(action_spec.type,
real_ids,
action_spec.properties)

View File

@ -134,7 +134,7 @@ def _get_edges_to_mapped_vertices(graph, vertex_id):
"""Get all edges (to/from) vertex where neighbor has a MAPPED_V_ID
:type graph: driver.Graph
:type vertex_id: driver.Vertex
:type vertex_id: str
:rtype: set of driver.Edge
"""
subgraph_edges_to_mapped_vertices = []

View File

@ -99,7 +99,7 @@ def create_edge(source_id,
EConst.UPDATE_TIMESTAMP: update_timestamp,
EConst.IS_DELETED: is_deleted,
EConst.RELATIONSHIP_TYPE: relationship_type,
}
}
if metadata:
properties.update(metadata)
properties = dict(

View File

@ -19,6 +19,7 @@ import os
from keystoneauth1 import exceptions as ka_exception
from keystoneauth1 import identity as ka_identity
from keystoneauth1 import loading as ka_loading
# noinspection PyPackageRequirements
from keystoneclient.v3 import client as ks_client_v3
from oslo_config import cfg
from oslo_log import log
@ -122,6 +123,7 @@ def setup_keystoneauth(conf):
ka_loading.load_auth_from_conf_options(conf, CFG_GROUP)
# noinspection PyClassHasNoInit
class LegacyVitrageKeystoneLoader(ka_loading.BaseLoader):
@property
def plugin_class(self):

View File

@ -33,7 +33,7 @@ def get_client(transport, target, version_cap=None, serializer=None):
return messaging.RPCClient(transport,
target,
version_cap=version_cap,
serializer=None)
serializer=serializer)
def get_server(target, endpoints, transport, serializer=None):
@ -42,4 +42,4 @@ def get_server(target, endpoints, transport, serializer=None):
target,
endpoints,
executor='eventlet',
serializer=None)
serializer=serializer)

View File

@ -67,7 +67,7 @@ class CinderVolumeTransformer(BaseResourceTransformer):
}
def __init__(self, transformers):
self.transformers = transformers
super(CinderVolumeTransformer, self).__init__(transformers)
def _create_entity_vertex(self, entity_event):
sync_mode = entity_event[SyncProps.SYNC_MODE]

View File

@ -18,7 +18,9 @@ from oslo_log import log
import requests
from vitrage.common.constants import SynchronizerProperties as SyncProps
# noinspection PyProtectedMember
from vitrage.i18n import _LE
# noinspection PyProtectedMember
from vitrage.i18n import _LW
from vitrage.synchronizer.plugins.base.alarm.synchronizer \
import BaseAlarmSynchronizer

View File

@ -45,7 +45,7 @@ class HostTransformer(BaseResourceTransformer):
}
def __init__(self, transformers):
self.transformers = transformers
super(HostTransformer, self).__init__(transformers)
def _create_entity_vertex(self, entity_event):

View File

@ -81,7 +81,7 @@ class InstanceTransformer(BaseResourceTransformer):
}
def __init__(self, transformers):
self.transformers = transformers
super(InstanceTransformer, self).__init__(transformers)
def _create_entity_vertex(self, entity_event):

View File

@ -65,7 +65,7 @@ class ZoneTransformer(BaseResourceTransformer):
}
def __init__(self, transformers):
self.transformers = transformers
super(ZoneTransformer, self).__init__(transformers)
def _create_entity_vertex(self, entity_event):

View File

@ -36,7 +36,7 @@ class StaticPhysicalTransformer(BaseResourceTransformer):
RELATIONSHIPS_SECTION = 'relationships'
def __init__(self, transformers):
self.transformers = transformers
super(StaticPhysicalTransformer, self).__init__(transformers)
self._register_relations_direction()
def _create_entity_vertex(self, entity_event):

View File

@ -14,6 +14,7 @@
import os
from oslo_utils import timeutils
# noinspection PyPackageRequirements
from oslotest import base
import sys
@ -44,7 +45,7 @@ class BaseTest(base.BaseTestCase):
"""
return self.assertAlmostEqual(timeutils.delta_seconds(first, second),
0.0,
places=5)
places=5, msg=msg)
def assert_is_empty(self, obj):
try:

View File

@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# noinspection PyPackageRequirements
import mock
import webtest

View File

@ -28,7 +28,7 @@ import exrex
# noinspection PyPep8Naming
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN
from vitrage.tests.mocks.entity_model import BasicEntityModel as bem
from vitrage.tests.mocks.entity_model import BasicEntityModel as Bem
import vitrage.tests.mocks.utils as utils
DYNAMIC_INFO_FKEY = 'filename'
@ -112,7 +112,7 @@ class EventTraceGenerator(object):
static_specs = static_info_parsers[dynamic_spec_filename](spec)
self.name = spec.get(NAME_KEY, 'generator')
self._models = [bem(dynam_specs, details) for details in static_specs]
self._models = [Bem(dynam_specs, details) for details in static_specs]
@property
def models(self):
@ -460,5 +460,5 @@ def get_trace_generators(entity_spec_list, default_events=100):
{GENERATOR: EventTraceGenerator(entity_spec),
NUM_EVENTS: entity_spec.get(NUM_EVENTS, default_events)}
for entity_spec in entity_spec_list
]
]
return generator_spec_list

View File

@ -198,7 +198,7 @@ class GraphTestBase(base.BaseTest):
2 + num_of_hosts_per_node + num_of_hosts_per_node * \
num_of_alarms_per_host + num_of_hosts_per_node * \
num_of_vms_per_host + num_of_hosts_per_node * \
num_of_vms_per_host * num_of_alarms_per_vm + num_of_tests_per_host * \
num_of_hosts_per_node
num_of_vms_per_host * num_of_alarms_per_vm + \
num_of_tests_per_host * num_of_hosts_per_node
assert expected_graph_size == len(g), 'Graph size'
return g

View File

@ -399,7 +399,7 @@ class GraphAlgorithmTest(GraphTestBase):
Mapping(e_node_contains_switch,
e_node_to_switch, is_vertex=False)],
validate=True
)
)
self.assertEqual(
0,
len(mappings),

View File

@ -35,7 +35,7 @@ LOG = logging.getLogger(__name__)
class TestCinderVolumeTransformer(base.BaseTest):
# noinspection PyAttributeOutsideInit
# noinspection PyAttributeOutsideInit,PyPep8Naming
@classmethod
def setUpClass(cls):
cls.transformers = {}

View File

@ -16,7 +16,7 @@ from vitrage.synchronizer.plugins.nagios.synchronizer import NagiosSynchronizer
from vitrage.tests.mocks import mock_syncronizer as mock_sync
class NagiosSynchronizerWithMockData(NagiosSynchronizer):
class MockNagiosSynchronizer(NagiosSynchronizer):
"""A nagios synchronizer for tests.
Instead of calling Nagios URL to get the data, it returns the data it
@ -24,7 +24,7 @@ class NagiosSynchronizerWithMockData(NagiosSynchronizer):
"""
def __init__(self, conf):
super(NagiosSynchronizerWithMockData, self).__init__(conf)
super(MockNagiosSynchronizer, self).__init__(conf)
self.service_datas = None
def set_service_datas(self, service_datas):

View File

@ -34,9 +34,10 @@ from vitrage.tests.mocks import mock_syncronizer as mock_sync
LOG = logging.getLogger(__name__)
# noinspection PyProtectedMember
class NagiosTransformerTest(base.BaseTest):
# noinspection PyAttributeOutsideInit
# noinspection PyAttributeOutsideInit,PyPep8Naming
@classmethod
def setUpClass(cls):
cls.transformers = {}

View File

@ -11,20 +11,22 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_log import log as logging
from vitrage.synchronizer.plugins.nagios.properties import NagiosProperties \
as NagiosProps
from vitrage.synchronizer.plugins.nagios.properties import (
NagiosProperties as NagiosProps)
from vitrage.tests.mocks import utils
from vitrage.tests.unit.synchronizer.plugins.nagios.nagios_base_test \
import NagiosBaseTest
from vitrage.tests.unit.synchronizer.plugins.nagios.synchronizer_with_mock_data \
import NagiosSynchronizerWithMockData
from vitrage.tests.unit.synchronizer.plugins.nagios.mock_synchronizer import (
MockNagiosSynchronizer)
from vitrage.tests.unit.synchronizer.plugins.nagios.nagios_base_test import (
NagiosBaseTest)
LOG = logging.getLogger(__name__)
# noinspection PyProtectedMember
class NagiosSynchronizerTest(NagiosBaseTest):
OPTS = [
@ -49,7 +51,7 @@ class NagiosSynchronizerTest(NagiosBaseTest):
"""
# Setup
nagios_synchronizer = NagiosSynchronizerWithMockData(self.conf)
nagios_synchronizer = MockNagiosSynchronizer(self.conf)
# Action
service_data1 = {NagiosProps.RESOURCE_NAME: 'compute-0',
@ -160,7 +162,7 @@ class NagiosSynchronizerTest(NagiosBaseTest):
"""
# Setup
nagios_synchronizer = NagiosSynchronizerWithMockData(self.conf)
nagios_synchronizer = MockNagiosSynchronizer(self.conf)
# Action
service_data1 = {NagiosProps.RESOURCE_NAME: 'compute-0',
@ -285,7 +287,7 @@ class NagiosSynchronizerTest(NagiosBaseTest):
"""Check get_changes and get_all functionalities """
# Setup
nagios_synchronizer = NagiosSynchronizerWithMockData(self.conf)
nagios_synchronizer = MockNagiosSynchronizer(self.conf)
# Action
service_data1 = {NagiosProps.RESOURCE_NAME: 'compute-0',

View File

@ -34,9 +34,10 @@ from vitrage.tests.mocks import mock_syncronizer as mock_sync
LOG = logging.getLogger(__name__)
# noinspection PyProtectedMember
class NovaHostTransformerTest(base.BaseTest):
# noinspection PyAttributeOutsideInit
# noinspection PyAttributeOutsideInit,PyPep8Naming
@classmethod
def setUpClass(cls):
cls.transformers = {}

View File

@ -35,9 +35,10 @@ from vitrage.tests.mocks import mock_syncronizer as mock_sync
LOG = logging.getLogger(__name__)
# noinspection PyProtectedMember
class NovaInstanceTransformerTest(base.BaseTest):
# noinspection PyAttributeOutsideInit
# noinspection PyAttributeOutsideInit,PyPep8Naming
@classmethod
def setUpClass(cls):
cls.transformers = {}

View File

@ -33,12 +33,12 @@ from vitrage.tests.mocks import mock_syncronizer as mock_sync
LOG = logging.getLogger(__name__)
# noinspection PyProtectedMember
class NovaZoneTransformerTest(base.BaseTest):
# noinspection PyAttributeOutsideInit
# noinspection PyAttributeOutsideInit,PyPep8Naming
@classmethod
def setUpClass(cls):
cls.transformers = {}
host_transformer = HostTransformer(cls.transformers)
cls.transformers[NOVA_HOST_PLUGIN] = host_transformer

View File

@ -69,7 +69,7 @@ class TestStaticPhysicalSynchronizer(base.BaseTest):
'/static_plugins/changes_plugins'),
]
# noinspection PyAttributeOutsideInit
# noinspection PyAttributeOutsideInit,PyPep8Naming
@classmethod
def setUpClass(cls):
cls.conf = cfg.ConfigOpts()
@ -98,6 +98,7 @@ class TestStaticPhysicalSynchronizer(base.BaseTest):
# Test assertions
self.assertEqual(5, len(static_entities))
# noinspection PyAttributeOutsideInit
def test_get_changes(self):
# Setup
entities = self.static_physical_synchronizer.get_all(SyncMode.UPDATE)

View File

@ -34,10 +34,9 @@ LOG = logging.getLogger(__name__)
class TestStaticPhysicalTransformer(base.BaseTest):
# noinspection PyAttributeOutsideInit
# noinspection PyAttributeOutsideInit,PyPep8Naming
@classmethod
def setUpClass(cls):
cls.transformers = {}
cls.transformers[NOVA_HOST_PLUGIN] = HostTransformer(cls.transformers)
cls.transformers[STATIC_PHYSICAL_PLUGIN] = StaticPhysicalTransformer(

View File

@ -16,7 +16,9 @@
import os
# noinspection PyPackageRequirements
from tempest import config
# noinspection PyPackageRequirements
from tempest.test_discover import plugins
from vitrage_tempest_tests import config as config_rca_engine

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
# noinspection PyPackageRequirements
import testtools
from oslo_config import cfg

View File

@ -11,12 +11,13 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_log import log as logging
import vitrage_tempest_tests.tests.utils as utils
# noinspection PyPackageRequirements
import testtools
import vitrage_tempest_tests.tests.utils as utils
LOG = logging.getLogger(__name__)
CONF = cfg.CONF

View File

@ -11,12 +11,13 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_log import log as logging
import vitrage_tempest_tests.tests.utils as utils
# noinspection PyPackageRequirements
import testtools
import vitrage_tempest_tests.tests.utils as utils
LOG = logging.getLogger(__name__)
CONF = cfg.CONF