diff options
author | dongwenjuan <dong.wenjuan@zte.com.cn> | 2017-08-14 16:58:13 +0800 |
---|---|---|
committer | dongwenjuan <dong.wenjuan@zte.com.cn> | 2017-09-04 22:30:39 +0800 |
commit | 19f7ba75850c52e1ae163766b64b6d153e8d7e1b (patch) | |
tree | f76b13d9d9092209788624609f65872ca8d0dea5 /tests/monitor/sample.py | |
parent | 836a8932d6c6a502980009b9578f0c6ecf64cb47 (diff) |
refactor failure inject
JIRA: DOCTOR-116
Change-Id: I14deda4ccb47414cff139a522a9196b68e92500e
Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
Diffstat (limited to 'tests/monitor/sample.py')
-rw-r--r-- | tests/monitor/sample.py | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/tests/monitor/sample.py b/tests/monitor/sample.py index 1333a2ec..9ac1bccf 100644 --- a/tests/monitor/sample.py +++ b/tests/monitor/sample.py @@ -14,7 +14,6 @@ from threading import Thread import time from identity_auth import get_session -from os_clients import nova_client from monitor.base import BaseMonitor @@ -24,26 +23,18 @@ class SampleMonitor(BaseMonitor): def __init__(self, conf, inspector_url, log): super(SampleMonitor, self).__init__(conf, inspector_url, log) self.session = get_session() - self.nova = nova_client(conf.nova_version, self.session) - self.hosts = self.nova.hypervisors.list(detailed=True) - self.pingers = [] + self.pinger = None - def start(self): + def start(self, host): self.log.info('sample monitor start......') - for host in self.hosts: - host_dict = host.__dict__ - host_name = host_dict['hypervisor_hostname'] - host_ip = host_dict['host_ip'] - pinger = Pinger(host_name, host_ip, self, self.log) - pinger.start() - self.pingers.append(pinger) + self.pinger = Pinger(host.name, host.ip, self, self.log) + self.pinger.start() def stop(self): self.log.info('sample monitor stop......') - for pinger in self.pingers: - pinger.stop() - pinger.join() - del self.pingers + if self.pinger is not None: + self.pinger.stop() + self.pinger.join() def report_error(self, hostname): self.log.info('sample monitor report error......') |