def change_to_pre_migration_state(compute_api, instance_id):
    """
    Try to change instance status to one that is supported by nova migrate.
    :param compute_api: NovaClient instance
    :param instance_id: VM instance identifier
    :return:
    """
    state_change_timeout = cfglib.CONF.evacuation.state_change_timeout
    for _ in range(2):
        instance = compute_api.servers.get(instance_id)
        state = instance.status.lower()
        if state not in SUPPORTED_FINAL_STATES:
            try:
                LOG.debug('Waiting for VM %s to transit to one of folliwing '
                          'states: %s',
                          instance_id, ', '.join(SUPPORTED_FINAL_STATES))
                wait_for_condition(is_vm_status_in, compute_api, instance_id,
                                   SUPPORTED_FINAL_STATES,
                                   timeout=state_change_timeout)
            except exception.TimeoutException:
                return False
        if (ACTIVE, SHUTOFF) in state:
            return True
        if state == ERROR:
            return False
        if state == VERIFY_RESIZE:
            compute_api.servers.confirm_resize(instance_id)
        if state == SUSPENDED:
            compute_api.servers.resume(instance_id)
        if state == PAUSED:
            compute_api.servers.unpause(instance_id)
    return False
dataset/ETHPy150Open MirantisWorkloadMobility/CloudFerry/cloudferry/lib/os/compute/cold_evacuate.py/change_to_pre_migration_state/swapped operands of `in`