weizhouapache commented on code in PR #8383:
URL: https://github.com/apache/cloudstack/pull/8383#discussion_r1432713732


##########
test/integration/smoke/test_vm_life_cycle.py:
##########
@@ -1011,8 +1011,36 @@ def setUpClass(cls):
 
     @classmethod
     def tearDownClass(cls):
+        cls.ensure_all_hosts_are_up()
         super(TestSecuredVmMigration, cls).tearDownClass()
 
+    @classmethod
+    def ensure_all_hosts_are_up(cls):
+        hosts = Host.list(
+            cls.apiclient,
+            zoneid=cls.zone.id,
+            type='Routing',
+            hypervisor='KVM'
+        )
+        for host in hosts:
+            if host.state != "Up":
+                SshClient(host.ipaddress, port=22, 
user=cls.hostConfig["username"], passwd=cls.hostConfig["password"]) \
+                    .execute("service cloudstack-agent stop ; \
+                              sleep 10 ; \
+                              service cloudstack-agent start")
+                interval = 5
+                retries = 10
+                while retries > -1:
+                    time.sleep(interval)
+                    restarted_host = Host.list(
+                        cls.apiclient,
+                        hostid=host.id,
+                        type='Routing'
+                    )[0]
+                    if restarted_host.state == state:

Review Comment:
   should `== state` be `== "Up"` ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to