Exemplo n.º 1
0
def _wait_for_completion(azure, promise, wait_timeout, msg):
    if not promise: return
    wait_timeout = time.time() + wait_timeout
    while wait_timeout > time.time():
        operation_result = azure.get_operation_status(promise.request_id)
        time.sleep(5)
        if operation_result.status == "Succeeded":
            return

    raise AzureException('Timed out waiting for async operation ' + msg + ' "' + str(promise.request_id) + '" to complete.')
Exemplo n.º 2
0
def _delete_disks_when_detached(azure, wait_timeout, disk_names):
    def _handle_timeout(signum, frame):
        raise TimeoutError("Timeout reached while waiting for disks to become detached.")

    signal.signal(signal.SIGALRM, _handle_timeout)
    signal.alarm(wait_timeout)
    try:
        while len(disk_names) > 0:
            for disk_name in disk_names:
                disk = azure.get_disk(disk_name)
                if disk.attached_to is None:
                    azure.delete_disk(disk.name, True)
                    disk_names.remove(disk_name)
    except AzureException as e:
        raise AzureException("failed to get or delete disk %s, error was: %s" % (disk_name, str(e)))
    finally:
        signal.alarm(0)