summaryrefslogtreecommitdiffstats
path: root/doctor_tests/inspector
diff options
context:
space:
mode:
Diffstat (limited to 'doctor_tests/inspector')
-rw-r--r--doctor_tests/inspector/base.py2
-rw-r--r--doctor_tests/inspector/congress.py20
-rw-r--r--doctor_tests/inspector/sample.py24
3 files changed, 29 insertions, 17 deletions
diff --git a/doctor_tests/inspector/base.py b/doctor_tests/inspector/base.py
index 854f0695..a6eae451 100644
--- a/doctor_tests/inspector/base.py
+++ b/doctor_tests/inspector/base.py
@@ -27,4 +27,4 @@ class BaseInspector(object):
@abc.abstractmethod
def stop(self):
- pass \ No newline at end of file
+ pass
diff --git a/doctor_tests/inspector/congress.py b/doctor_tests/inspector/congress.py
index c89a41bd..fb747ec5 100644
--- a/doctor_tests/inspector/congress.py
+++ b/doctor_tests/inspector/congress.py
@@ -20,13 +20,13 @@ class CongressInspector(BaseInspector):
policy = 'classification'
rules = {
'host_down':
- 'host_down(host) :- doctor:events(hostname=host, type="compute.host.down", status="down")',
+ 'host_down(host) :- doctor:events(hostname=host, type="compute.host.down", status="down")', # noqa
'active_instance_in_host':
- 'active_instance_in_host(vmid, host) :- nova:servers(id=vmid, host_name=host, status="ACTIVE")',
+ 'active_instance_in_host(vmid, host) :- nova:servers(id=vmid, host_name=host, status="ACTIVE")', # noqa
'host_force_down':
- 'execute[nova:services.force_down(host, "nova-compute", "True")] :- host_down(host)',
+ 'execute[nova:services.force_down(host, "nova-compute", "True")] :- host_down(host)', # noqa
'error_vm_states':
- 'execute[nova:servers.reset_state(vmid, "error")] :- host_down(host), active_instance_in_host(vmid, host)'
+ 'execute[nova:servers.reset_state(vmid, "error")] :- host_down(host), active_instance_in_host(vmid, host)' # noqa
}
def __init__(self, conf, log):
@@ -38,12 +38,14 @@ class CongressInspector(BaseInspector):
def _init_driver_and_ds(self):
datasources = \
- {ds['name']: ds for ds in self.congress.list_datasources()['results']}
+ {ds['name']: ds for ds in
+ self.congress.list_datasources()['results']}
# check nova_api version
nova_api_version = datasources['nova']['config'].get('api_version')
if nova_api_version and nova_api_version < self.nova_api_min_version:
- raise Exception('Congress Nova datasource API version < nova_api_min_version(%s)'
+ raise Exception('Congress Nova datasource API '
+ 'version < nova_api_min_version(%s)'
% self.nova_api_min_version)
# create doctor datasource if it's not exist
@@ -54,7 +56,8 @@ class CongressInspector(BaseInspector):
# check whether doctor driver exist
drivers = \
- {driver['id']: driver for driver in self.congress.list_drivers()['results']}
+ {driver['id']: driver for driver in
+ self.congress.list_drivers()['results']}
if self.doctor_driver not in drivers:
raise Exception('Do not support doctor driver in congress')
@@ -66,7 +69,8 @@ class CongressInspector(BaseInspector):
ds = self.congress.list_datasources()['results']
doctor_ds = next((item for item in ds if item['driver'] == 'doctor'),
None)
- congress_endpoint = self.congress.httpclient.get_endpoint(auth=self.auth)
+ congress_endpoint = \
+ self.congress.httpclient.get_endpoint(auth=self.auth)
return ('%s/v1/data-sources/%s/tables/events/rows' %
(congress_endpoint, doctor_ds['id']))
diff --git a/doctor_tests/inspector/sample.py b/doctor_tests/inspector/sample.py
index fe67a903..fadfd3d4 100644
--- a/doctor_tests/inspector/sample.py
+++ b/doctor_tests/inspector/sample.py
@@ -58,12 +58,15 @@ class SampleInspector(BaseInspector):
try:
host = server.__dict__.get('OS-EXT-SRV-ATTR:host')
self.servers[host].append(server)
- self.log.debug('get hostname=%s from server=%s' % (host, server))
+ self.log.debug('get hostname=%s from server=%s'
+ % (host, server))
except Exception as e:
- self.log.info('can not get hostname from server=%s' % server)
+ self.log.info('can not get hostname from server=%s, error=%s'
+ % (server, e))
def get_inspector_url(self):
- return 'http://%s:%s/events' % (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......')
@@ -105,7 +108,8 @@ class SampleInspector(BaseInspector):
@utils.run_async
def _disable_compute_host(self, hostname):
self.nova.services.force_down(hostname, 'nova-compute', True)
- self.log.info('doctor mark host(%s) down at %s' % (hostname, time.time()))
+ self.log.info('doctor mark host(%s) down at %s'
+ % (hostname, time.time()))
@utils.run_async
def _vms_reset_state(self, state, hostname):
@@ -113,7 +117,8 @@ class SampleInspector(BaseInspector):
@utils.run_async
def _vm_reset_state(nova, server, state):
nova.servers.reset_state(server, state)
- self.log.info('doctor mark vm(%s) error at %s' % (server, time.time()))
+ self.log.info('doctor mark vm(%s) error at %s'
+ % (server, time.time()))
thrs = []
for nova, server in zip(self.novaclients, self.servers[hostname]):
@@ -129,7 +134,8 @@ class SampleInspector(BaseInspector):
@utils.run_async
def _set_port_data_plane_status(port_id):
self.neutron.update_port(port_id, body)
- self.log.info('doctor set data plane status %s on port %s' % (status, port_id))
+ self.log.info('doctor set data plane status %s on port %s'
+ % (status, port_id))
thrs = []
params = {'binding:host_id': hostname}
@@ -153,9 +159,11 @@ class InspectorApp(Thread):
@app.route('/events', methods=['PUT'])
def event_posted():
- self.log.info('event posted in sample inspector at %s' % time.time())
+ self.log.info('event posted in sample inspector at %s'
+ % time.time())
self.log.info('sample inspector = %s' % self.inspector)
- self.log.info('sample inspector received data = %s' % request.data)
+ self.log.info('sample inspector received data = %s'
+ % request.data)
events = json.loads(request.data.decode('utf8'))
self.inspector.handle_events(events)
return "OK"