Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1529#discussion_r61967545 --- Diff: tools/marvin/marvin/lib/base.py --- @@ -2459,13 +2460,31 @@ def create(cls, apiclient, cluster, services, zoneid=None, podid=None, hyperviso GetDetailExceptionInfo(e) return FAILED + @staticmethod + def _check_resource_state(apiclient, hostid, resourcestate): + hosts = Host.list(apiclient, id=hostid, listall=True) + + validationresult = validateList(hosts) + + if validationresult[0] == FAIL: + raise Exception("Host list validation failed: %s" % validationresult[2]) + + if str(hosts[0].resourcestate).lower().decode("string_escape") == str(resourcestate).lower(): + return True, None + + return False, "Host is not in the following state: " + str(resourcestate) + def delete(self, apiclient): """Delete Host""" # Host must be in maintenance mode before deletion cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd() cmd.id = self.id apiclient.prepareHostForMaintenance(cmd) - time.sleep(30) + + wait_result, return_val = wait_until(10, 10, Host._check_resource_state, apiclient, self.id, HOST_RS_MAINTENANCE) --- End diff -- Consider extracting the interval and timeout to constants to make the code more readable.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---