From a9741971172b6be692dde67afe8f0d71bcd3d912 Mon Sep 17 00:00:00 2001 From: Bartosz Zurkowski Date: Sat, 28 Mar 2020 11:06:12 +0100 Subject: [PATCH] Minor refactorings Signed-off-by: Bartosz Zurkowski --- orca/api/resources/v1/ingestor.py | 3 --- orca/common/clients/kiali/client.py | 3 ++- orca/common/config.py | 1 - orca/topology/infra/istio/matcher.py | 2 +- orca/topology/probe.py | 6 +++--- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/orca/api/resources/v1/ingestor.py b/orca/api/resources/v1/ingestor.py index a625ab7..1302e95 100644 --- a/orca/api/resources/v1/ingestor.py +++ b/orca/api/resources/v1/ingestor.py @@ -12,12 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import json - from flask import request from flask_restplus import Namespace, Resource -from orca import exceptions from orca.common import logger from orca.topology import linker from orca.topology.alerts import elastalert diff --git a/orca/common/clients/kiali/client.py b/orca/common/clients/kiali/client.py index 8049d09..17fa8cf 100644 --- a/orca/common/clients/kiali/client.py +++ b/orca/common/clients/kiali/client.py @@ -30,7 +30,8 @@ def graph_namespaces(self, namespaces, graph_type='service'): "/namespaces/graph", namespaces=namespace_list, graphType=graph_type) @classmethod - def get(cls, url="http://localhost:20001", api_prefix="/kiali/api", username=None, password=None): + def get(cls, url="http://localhost:20001", api_prefix="/kiali/api", username=None, + password=None): basic_auth = None if username and password: basic_auth = auth.HTTPBasicAuth(username, password) diff --git a/orca/common/config.py b/orca/common/config.py index 11d3671..58af3e6 100644 --- a/orca/common/config.py +++ b/orca/common/config.py @@ -60,7 +60,6 @@ def parse(self, config_path): config_dict = file_utils.load_yaml(config_path) validator = cerberus.Validator(self._schema) is_valid = validator.validate(config_dict) - if not is_valid: raise exceptions.ConfigParseError(errors=validator.errors) return dict_lib.Dict(validator.document) diff --git a/orca/topology/infra/istio/matcher.py b/orca/topology/infra/istio/matcher.py index 03576cd..484b58d 100644 --- a/orca/topology/infra/istio/matcher.py +++ b/orca/topology/infra/istio/matcher.py @@ -70,6 +70,6 @@ def match_host_to_service(namespace, host, service): host_parts = host.split('.') service_name = host_parts[0] service_namespace = host_parts[1] if len(host_parts) > 1 else namespace - matched_name = service_name == service.properties.name + matched_name = service_name == service.properties.name matched_namespace = service_namespace == service.properties.namespace return matched_name and matched_namespace diff --git a/orca/topology/probe.py b/orca/topology/probe.py index 02f1081..bb3c338 100644 --- a/orca/topology/probe.py +++ b/orca/topology/probe.py @@ -61,10 +61,10 @@ def _initialize_linkers(self): return linkers def _setup_event_dispatcher(self, linkers): - dispatcher = linker.EventDispatcher() + event_dispatcher = linker.EventDispatcher() for linker_instance in linkers: - dispatcher.add_linker(linker_instance) - self._graph.add_listener(dispatcher) + event_dispatcher.add_linker(linker_instance) + self._graph.add_listener(event_dispatcher) class Probe(abc.ABC):