Adding while loop to wait for cluster container creation (#4039)

* Adding while loop to wait

* Adding changelog fragment

* Adding parameter and more docs

* Adjusting docs

Co-authored-by: Travis Scotto <tscotto@webstaurantstore.com>
This commit is contained in:
tman5 2022-01-28 01:08:52 -05:00 committed by GitHub
commit 7aab4497ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View file

@ -75,11 +75,14 @@ class LXDClient(object):
else:
raise LXDClientException('URL scheme must be unix: or https:')
def do(self, method, url, body_json=None, ok_error_codes=None, timeout=None):
def do(self, method, url, body_json=None, ok_error_codes=None, timeout=None, wait_for_container=None):
resp_json = self._send_request(method, url, body_json=body_json, ok_error_codes=ok_error_codes, timeout=timeout)
if resp_json['type'] == 'async':
url = '{0}/wait'.format(resp_json['operation'])
resp_json = self._send_request('GET', url)
if wait_for_container:
while resp_json['metadata']['status'] == 'Running':
resp_json = self._send_request('GET', url)
if resp_json['metadata']['status'] != 'Success':
self._raise_err_from_json(resp_json)
return resp_json