@contextlib.contextmanager
def enable_nova_compute_services(compute_api, *hosts):
    """
    Disable nova-compute services on hosts listed in *hosts before decorated
    function will execute and disable previously enabled services after.
    :param compute_api:
    :param hosts:
    :return:
    """
    LOG.debug("Enabling %s nova-compute services.", ', '.join(hosts))
    services = compute_api.services.list(binary=NOVA_SERVICE)
    temporary_enabled_services = []
    for service in services:
        if hosts not in service.host:
            continue
        if service.status == SERVICE_ENABLED:
            continue
        temporary_enabled_services.append(service.host)
        compute_api.services.enable(service.host, NOVA_SERVICE)

    try:
        yield
    finally:
        LOG.debug("Disabling %s nova-compute services.",
                  ', '.join(temporary_enabled_services))
        for service_host in temporary_enabled_services:
            compute_api.services.disable(service_host, NOVA_SERVICE)
dataset/ETHPy150Open MirantisWorkloadMobility/CloudFerry/cloudferry/lib/os/compute/cold_evacuate.py/enable_nova_compute_services/swapped operands of `not in`