def verifyStatus(self, url, timeout=120): counter = 0 while True: response = self.get(url) #print('\n\tverifyStatus:', response.json()) if 'status' in response.json(): currentStatus = response.json()['status'] elif 'state' in response.json(): currentStatus = response.json()['state'] if currentStatus == 'Error': errorMessage = 'Operation failed' if 'message' in response.json(): errorMessage = response.json()['message'] raise IxLoadRestApiException('verifyStatus failed: {}'.format(errorMessage)) else: raise IxLoadRestApiException('verifyStatus failed: No status and no state in json response') if currentStatus == 'Error' and 'error' in response.json(): errorMessage = response.json()['error'] raise IxLoadRestApiException('Operation failed: {0}'.format(errorMessage)) if counter <= timeout and currentStatus not in ['Successful']: self.logInfo('\tCurrent status: {0}. Wait {1}/{2} seconds...'.format(currentStatus, counter, timeout), timestamp=False) time.sleep(self.pollStatusInterval) counter += self.pollStatusInterval continue if counter <= timeout and currentStatus in ['Successful']: return if counter >= timeout and currentStatus not in ['Successful']: raise IxLoadRestApiException('Operation failed: {0}'.format(url))