'Wait for a drive to transition to the provided state.
Note: This function blocks and periodically calls "GET drive" endpoint
to check if the drive has already transitioned to the desired state.
:param drive: Drive to wait for.
:type drive: :class:`.CloudSigmaDrive`
:param state: Desired drive state.
:type state: ``str``
:param timeout: How long to wait for the transition (in seconds) before
timing out.
:type timeout: ``int``
:return: Drive object.
:rtype: :class:`.CloudSigmaDrive`'

def _wait_for_drive_state_transition(self, drive, state, timeout=DRIVE_TRANSITION_TIMEOUT):

    start_time = time.time()
    while (drive.status != state):
        drive = self.ex_get_drive(drive_id=drive.id)
        if (drive.status == state):
            break
        current_time = time.time()
        delta = (current_time - start_time)
        if (delta >= timeout):
            msg = ('Timed    out    while    waiting    for    drive    transition    (timeout=%s    seconds)' % timeout)
            raise Exception(msg)
        time.sleep(self.DRIVE_TRANSITION_SLEEP_INTERVAL)
    return drive
