Merge "fix misc intellij inspection warnings"

This commit is contained in:
Jenkins 2016-03-24 13:19:22 +00:00 committed by Gerrit Code Review
commit 2f6d50b2e3
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-ceilometerclient>=2.2.1 # Apache-2.0
python-cinderclient>=1.3.1 # Apache-2.0 python-cinderclient>=1.3.1 # Apache-2.0
python-dateutil>=2.4.2 python-dateutil>=2.4.2
python-keystoneclient!=1.8.0,!=2.1.0,>=1.6.0 # Apache-2.0
python-novaclient>=2.26.0 python-novaclient>=2.26.0
networkx>=1.10 networkx>=1.10
oslo.config>=2.7.0 # Apache-2.0 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.StrOpt('aodh_version', default='2', help='Aodh version'),
cfg.FloatOpt('nova_version', default='2.0', help='Nova version'), cfg.FloatOpt('nova_version', default='2.0', help='Nova version'),
cfg.StrOpt('cinder_version', default='1', help='Cinder version'), cfg.StrOpt('cinder_version', default='1', help='Cinder version'),
] ]
def ceilometer_client(conf): def ceilometer_client(conf):
@ -39,7 +39,7 @@ def ceilometer_client(conf):
session=keystone_client.get_session(conf), session=keystone_client.get_session(conf),
region_name=auth_config.region_name, region_name=auth_config.region_name,
interface=auth_config.interface, interface=auth_config.interface,
) )
LOG.info('Ceilometer client created') LOG.info('Ceilometer client created')
return client return client
except Exception as e: except Exception as e:
@ -55,7 +55,7 @@ def nova_client(conf):
session=keystone_client.get_session(conf), session=keystone_client.get_session(conf),
region_name=auth_config.region_name, region_name=auth_config.region_name,
interface=auth_config.interface, interface=auth_config.interface,
) )
LOG.info('Nova client created') LOG.info('Nova client created')
return client return client
except Exception as e: except Exception as e:

View File

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

View File

@ -153,7 +153,7 @@ class ScenarioEvaluator(object):
targets = action_spec.targets targets = action_spec.targets
real_ids = { real_ids = {
target: match[target_id] for target, target_id in targets.items() target: match[target_id] for target, target_id in targets.items()
} }
revised_spec = ActionSpecs(action_spec.type, revised_spec = ActionSpecs(action_spec.type,
real_ids, real_ids,
action_spec.properties) 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 """Get all edges (to/from) vertex where neighbor has a MAPPED_V_ID
:type graph: driver.Graph :type graph: driver.Graph
:type vertex_id: driver.Vertex :type vertex_id: str
:rtype: set of driver.Edge :rtype: set of driver.Edge
""" """
subgraph_edges_to_mapped_vertices = [] subgraph_edges_to_mapped_vertices = []

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ import exrex
# noinspection PyPep8Naming # noinspection PyPep8Naming
from vitrage.synchronizer.plugins.nova.host import NOVA_HOST_PLUGIN 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 import vitrage.tests.mocks.utils as utils
DYNAMIC_INFO_FKEY = 'filename' DYNAMIC_INFO_FKEY = 'filename'
@ -112,7 +112,7 @@ class EventTraceGenerator(object):
static_specs = static_info_parsers[dynamic_spec_filename](spec) static_specs = static_info_parsers[dynamic_spec_filename](spec)
self.name = spec.get(NAME_KEY, 'generator') 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 @property
def models(self): def models(self):
@ -460,5 +460,5 @@ def get_trace_generators(entity_spec_list, default_events=100):
{GENERATOR: EventTraceGenerator(entity_spec), {GENERATOR: EventTraceGenerator(entity_spec),
NUM_EVENTS: entity_spec.get(NUM_EVENTS, default_events)} NUM_EVENTS: entity_spec.get(NUM_EVENTS, default_events)}
for entity_spec in entity_spec_list for entity_spec in entity_spec_list
] ]
return generator_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 * \ 2 + num_of_hosts_per_node + num_of_hosts_per_node * \
num_of_alarms_per_host + 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_hosts_per_node * \
num_of_vms_per_host * num_of_alarms_per_vm + num_of_tests_per_host * \ num_of_vms_per_host * num_of_alarms_per_vm + \
num_of_hosts_per_node num_of_tests_per_host * num_of_hosts_per_node
assert expected_graph_size == len(g), 'Graph size' assert expected_graph_size == len(g), 'Graph size'
return g return g

View File

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

View File

@ -35,7 +35,7 @@ LOG = logging.getLogger(__name__)
class TestCinderVolumeTransformer(base.BaseTest): class TestCinderVolumeTransformer(base.BaseTest):
# noinspection PyAttributeOutsideInit # noinspection PyAttributeOutsideInit,PyPep8Naming
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.transformers = {} 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 from vitrage.tests.mocks import mock_syncronizer as mock_sync
class NagiosSynchronizerWithMockData(NagiosSynchronizer): class MockNagiosSynchronizer(NagiosSynchronizer):
"""A nagios synchronizer for tests. """A nagios synchronizer for tests.
Instead of calling Nagios URL to get the data, it returns the data it 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): def __init__(self, conf):
super(NagiosSynchronizerWithMockData, self).__init__(conf) super(MockNagiosSynchronizer, self).__init__(conf)
self.service_datas = None self.service_datas = None
def set_service_datas(self, service_datas): 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__) LOG = logging.getLogger(__name__)
# noinspection PyProtectedMember
class NagiosTransformerTest(base.BaseTest): class NagiosTransformerTest(base.BaseTest):
# noinspection PyAttributeOutsideInit # noinspection PyAttributeOutsideInit,PyPep8Naming
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.transformers = {} cls.transformers = {}

View File

@ -11,20 +11,22 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# 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 oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from vitrage.synchronizer.plugins.nagios.properties import NagiosProperties \ from vitrage.synchronizer.plugins.nagios.properties import (
as NagiosProps NagiosProperties as NagiosProps)
from vitrage.tests.mocks import utils from vitrage.tests.mocks import utils
from vitrage.tests.unit.synchronizer.plugins.nagios.nagios_base_test \ from vitrage.tests.unit.synchronizer.plugins.nagios.mock_synchronizer import (
import NagiosBaseTest MockNagiosSynchronizer)
from vitrage.tests.unit.synchronizer.plugins.nagios.synchronizer_with_mock_data \ from vitrage.tests.unit.synchronizer.plugins.nagios.nagios_base_test import (
import NagiosSynchronizerWithMockData NagiosBaseTest)
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
# noinspection PyProtectedMember
class NagiosSynchronizerTest(NagiosBaseTest): class NagiosSynchronizerTest(NagiosBaseTest):
OPTS = [ OPTS = [
@ -49,7 +51,7 @@ class NagiosSynchronizerTest(NagiosBaseTest):
""" """
# Setup # Setup
nagios_synchronizer = NagiosSynchronizerWithMockData(self.conf) nagios_synchronizer = MockNagiosSynchronizer(self.conf)
# Action # Action
service_data1 = {NagiosProps.RESOURCE_NAME: 'compute-0', service_data1 = {NagiosProps.RESOURCE_NAME: 'compute-0',
@ -160,7 +162,7 @@ class NagiosSynchronizerTest(NagiosBaseTest):
""" """
# Setup # Setup
nagios_synchronizer = NagiosSynchronizerWithMockData(self.conf) nagios_synchronizer = MockNagiosSynchronizer(self.conf)
# Action # Action
service_data1 = {NagiosProps.RESOURCE_NAME: 'compute-0', service_data1 = {NagiosProps.RESOURCE_NAME: 'compute-0',
@ -285,7 +287,7 @@ class NagiosSynchronizerTest(NagiosBaseTest):
"""Check get_changes and get_all functionalities """ """Check get_changes and get_all functionalities """
# Setup # Setup
nagios_synchronizer = NagiosSynchronizerWithMockData(self.conf) nagios_synchronizer = MockNagiosSynchronizer(self.conf)
# Action # Action
service_data1 = {NagiosProps.RESOURCE_NAME: 'compute-0', 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__) LOG = logging.getLogger(__name__)
# noinspection PyProtectedMember
class NovaHostTransformerTest(base.BaseTest): class NovaHostTransformerTest(base.BaseTest):
# noinspection PyAttributeOutsideInit # noinspection PyAttributeOutsideInit,PyPep8Naming
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cls.transformers = {} cls.transformers = {}

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,9 @@
import os import os
# noinspection PyPackageRequirements
from tempest import config from tempest import config
# noinspection PyPackageRequirements
from tempest.test_discover import plugins from tempest.test_discover import plugins
from vitrage_tempest_tests import config as config_rca_engine 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 # License for the specific language governing permissions and limitations
# under the License. # under the License.
# noinspection PyPackageRequirements
import testtools import testtools
from oslo_config import cfg from oslo_config import cfg

View File

@ -11,12 +11,13 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# 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 oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import vitrage_tempest_tests.tests.utils as utils # noinspection PyPackageRequirements
import testtools import testtools
import vitrage_tempest_tests.tests.utils as utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
CONF = cfg.CONF CONF = cfg.CONF

View File

@ -11,12 +11,13 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# 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 oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import vitrage_tempest_tests.tests.utils as utils # noinspection PyPackageRequirements
import testtools import testtools
import vitrage_tempest_tests.tests.utils as utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
CONF = cfg.CONF CONF = cfg.CONF