code: def gce_wait_until_done(operation):
      
      operation_name = operation['name']
      if 'zone' in operation:
          zone_url_parts = operation['zone'].split('/')
          project = zone_url_parts[-3]
          zone = zone_url_parts[-1]
  
          def get_zone_operation():
              return _get_gce_compute().zoneOperations().get(
                  project=project,
                  zone=zone,
                  operation=operation_name
              )
          update = get_zone_operation
      else:
          project = operation['selfLink'].split('/')[-4]
  
          def get_global_operation():
              return _get_gce_compute().globalOperations().get(
                  project=project,
                  operation=operation_name
              )
          update = get_global_operation
      done = False
      latest_operation = None
      start = time()
      timeout = 5*60  # seconds
      while not done:
          latest_operation = update().execute()
          log_yellow("waiting for operation")
          if (latest_operation['status'] == 'DONE' or
                  time() - start > timeout):
              done = True
          else:
              sleep(10)
              print "waiting for operation"
      return latest_operation
docs: Perform a GCE operation, blocking until the operation completes.
  
      This function will then poll the operation until it reaches state
      'DONE' or times out, and then returns the final operation resource
      dict.
  
      :param operation: A dict representing a pending GCE operation resource.
  
      :returns dict: A dict representing the concluded GCE operation
          resource.