code: def _wait_for_completion(conn, wait_timeout, server_id):
      '''
      Poll request status until resource is provisioned.
      '''
      wait_timeout = time.time() + wait_timeout
      while wait_timeout > time.time():
          time.sleep(5)
  
          server = conn.get_server(server_id)
          server_state = server['status']['state'].lower()
  
          if server_state == "powered_on":
              return
          elif server_state == 'failed':
              raise Exception('Server creation failed for {0}'.format(server_id))
          elif server_state in ('active',
                                'enabled',
                                'deploying',
                                'configuring'):
              continue
          else:
              raise Exception(
                  'Unknown server state {0}'.format(server_state))
      raise Exception(
          'Timed out waiting for server create completion for {0}'.format(server_id)
      f _wait_for_completion(conn, wait_timeout, server_id):
      '''
      Poll request status until resource is provisioned.
      '''
      wait_timeout = time.time() + wait_timeout
      while wait_timeout > time.time():
          time.sleep(5)
  
          server = conn.get_server(server_id)
          server_state = server['status']['state'].lower()
  
          if server_state == "powered_on":
              return
          elif server_state == 'failed':
              raise Exception('Server creation failed for {0}'.format(server_id))
          elif server_state in ('active',
                                'enabled',
                                'deploying',
                                'configuring'):
              continue
          else:
              raise Exception(
                  'Unknown server state {0}'.format(server_state))
      raise Exception(
          'Timed out waiting for server create completion for {0}'.format(server_id)
      )
docs: Poll request status until resource is provisioned.