From 9e36d918fef054b8d23692c0ec8c25d7b0640c07 Mon Sep 17 00:00:00 2001 From: dongwenjuan Date: Mon, 27 Nov 2017 17:42:17 +0800 Subject: support vitrage inspector for local installer JIRA: DOCTOR-122 Change-Id: I771f778767a204e809d892c70603e479c1ed2f5c Signed-off-by: dongwenjuan --- doctor_tests/inspector/__init__.py | 9 ++++++--- doctor_tests/inspector/sample.py | 2 +- doctor_tests/inspector/vitrage.py | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 doctor_tests/inspector/vitrage.py (limited to 'doctor_tests/inspector') diff --git a/doctor_tests/inspector/__init__.py b/doctor_tests/inspector/__init__.py index a9a86ece..31291baf 100644 --- a/doctor_tests/inspector/__init__.py +++ b/doctor_tests/inspector/__init__.py @@ -11,10 +11,12 @@ import os from oslo_config import cfg from oslo_utils import importutils +from doctor_tests.common.constants import Inspector + OPTS = [ cfg.StrOpt('type', - default=os.environ.get('INSPECTOR_TYPE', 'sample'), + default=os.environ.get('INSPECTOR_TYPE', Inspector.SAMPLE), choices=['sample', 'congress', 'vitrage'], help='the component of doctor inspector', required=True), @@ -34,8 +36,9 @@ OPTS = [ _inspector_name_class_mapping = { - 'sample': 'doctor_tests.inspector.sample.SampleInspector', - 'congress': 'doctor_tests.inspector.congress.CongressInspector', + Inspector.SAMPLE: 'doctor_tests.inspector.sample.SampleInspector', + Inspector.CONGRESS: 'doctor_tests.inspector.congress.CongressInspector', + Inspector.VITRAGE: 'doctor_tests.inspector.vitrage.VitrageInspector', } diff --git a/doctor_tests/inspector/sample.py b/doctor_tests/inspector/sample.py index 54328727..fe67a903 100644 --- a/doctor_tests/inspector/sample.py +++ b/doctor_tests/inspector/sample.py @@ -63,7 +63,7 @@ class SampleInspector(BaseInspector): self.log.info('can not get hostname from server=%s' % server) def get_inspector_url(self): - return 'http://%s:%s' % (self.conf.inspector.ip, self.conf.inspector.port) + return 'http://%s:%s/events' % (self.conf.inspector.ip, self.conf.inspector.port) def start(self): self.log.info('sample inspector start......') diff --git a/doctor_tests/inspector/vitrage.py b/doctor_tests/inspector/vitrage.py new file mode 100644 index 00000000..7d1dbc1c --- /dev/null +++ b/doctor_tests/inspector/vitrage.py @@ -0,0 +1,38 @@ +############################################################################## +# Copyright (c) 2017 ZTE Corporation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +from doctor_tests.identity_auth import get_identity_auth +from doctor_tests.identity_auth import get_session +from doctor_tests.os_clients import keystone_client +from doctor_tests.os_clients import vitrage_client + +from doctor_tests.inspector.base import BaseInspector + + +class VitrageInspector(BaseInspector): + + def __init__(self, conf, log): + super(VitrageInspector, self).__init__(conf, log) + self.auth = get_identity_auth() + self.keystone = keystone_client(get_session(auth=self.auth)) + self.vitrage = vitrage_client(self.conf.vitrage_version, + get_session(auth=self.auth)) + self.inspector_url = self.get_inspector_url() + + def get_inspector_url(self): + vitrage_endpoint = \ + self.keystone.session.get_endpoint( + service_type='rca', + interface='publicURL') + return '%s/v1/event' % vitrage_endpoint + + def start(self): + self.log.info('vitrage inspector start......') + + def stop(self): + self.log.info('vitrage inspector stop......') -- cgit 1.2.3-korg