use hostname without domain name & fix the `find` command in tox
[doctor.git] / doctor_tests / scenario / fault_management.py
index ee3bf5f..0271dff 100644 (file)
@@ -40,7 +40,7 @@ sleep 1
 
 class FaultManagement(object):
 
-    def __init__(self, conf, installer, user, log):
+    def __init__(self, conf, installer, user, log, transport_url):
         self.conf = conf
         self.log = log
         self.user = user
@@ -55,7 +55,7 @@ class FaultManagement(object):
         self.network = Network(self.conf, log)
         self.instance = Instance(self.conf, log)
         self.alarm = Alarm(self.conf, log)
-        self.inspector = get_inspector(self.conf, log)
+        self.inspector = get_inspector(self.conf, log, transport_url)
         self.monitor = get_monitor(self.conf,
                                    self.inspector.get_inspector_url(),
                                    log)
@@ -111,7 +111,10 @@ class FaultManagement(object):
         server = servers.get(vm_name)
         if not server:
             raise Exception('Can not find instance: vm_name(%s)' % vm_name)
-        host_name = server.__dict__.get('OS-EXT-SRV-ATTR:hypervisor_hostname')
+        # use hostname without domain name which is mapped to the cell
+        hostname = \
+            server.__dict__.get('OS-EXT-SRV-ATTR:hypervisor_hostname')
+        host_name = hostname.split('.')[0]
         host_ip = self.installer.get_host_ip_from_hostname(host_name)
 
         self.log.info('Get host info(name:%s, ip:%s) which vm(%s) launched at'
@@ -180,9 +183,12 @@ class FaultManagement(object):
         notification_time = \
             self.consumer.notified_time - \
             self.monitor.detected_time
+
+        self.log.info('doctor fault management notification_time=%s'
+                      % notification_time)
+
         if notification_time < 1 and notification_time > 0:
-            self.log.info('doctor fault management test successfully,'
-                          'notification_time=%s' % notification_time)
+            self.log.info('doctor fault management test successfully')
         else:
             if self.conf.profiler_type:
                 self.log.info('run doctor fault management profile.......')
@@ -206,6 +212,10 @@ class FaultManagement(object):
         detected = self.monitor.detected_time
         notified = self.consumer.notified_time
 
+        if None in [vmdown, hostdown, detected, notified]:
+            self.log.info('one of the time for profiler is None, return')
+            return
+
         # TODO(yujunz) check the actual delay to verify time sync status
         # expected ~1s delay from $trigger to $linkdown
         relative_start = linkdown