summaryrefslogtreecommitdiffstats
path: root/tests/monitor
diff options
context:
space:
mode:
Diffstat (limited to 'tests/monitor')
-rw-r--r--tests/monitor/base.py2
-rw-r--r--tests/monitor/collectd.py13
-rw-r--r--tests/monitor/sample.py23
3 files changed, 11 insertions, 27 deletions
diff --git a/tests/monitor/base.py b/tests/monitor/base.py
index ccb647cf..119c8a1c 100644
--- a/tests/monitor/base.py
+++ b/tests/monitor/base.py
@@ -19,7 +19,7 @@ class BaseMonitor(object):
self.inspector_url = inspector_url
@abc.abstractmethod
- def start(self):
+ def start(self, host):
pass
@abc.abstractmethod
diff --git a/tests/monitor/collectd.py b/tests/monitor/collectd.py
index f7a4f442..e2a800ea 100644
--- a/tests/monitor/collectd.py
+++ b/tests/monitor/collectd.py
@@ -12,8 +12,6 @@ import socket
import getpass
import sys
-from identity_auth import get_session
-from os_clients import nova_client
from monitor.base import BaseMonitor
@@ -21,13 +19,6 @@ class CollectdMonitor(BaseMonitor):
def __init__(self, conf, inspector_url, log):
super(CollectdMonitor, self).__init__(conf, inspector_url, log)
self.top_dir = os.path.dirname(sys.path[0])
- self.session = get_session()
- self.nova = nova_client(conf.nova_version, self.session)
- self.compute_hosts = self.nova.hypervisors.list(detailed=True)
- for host in self.compute_hosts:
- host_dict = host.__dict__
- self.compute_host = host_dict['hypervisor_hostname']
- self.compute_ip = host_dict['host_ip']
tmp_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
tmp_sock.connect(("8.8.8.8", 80))
@@ -50,8 +41,10 @@ class CollectdMonitor(BaseMonitor):
self.project_domain_id = os.environ.get('OS_PROJECT_DOMAIN_ID')
self.ssh_opts_cpu = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
- def start(self):
+ def start(self, host):
self.log.info("Collectd monitor start.........")
+ self.compute_host = host.name
+ self.compute_ip = host.ip
f = open("%s/tests/collectd.conf" % self.top_dir, 'w')
collectd_conf_file = """
Hostname %s
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......')