def update_leases(transform, persistence_service):
    config = persistence_service.get()
    # XXX This is an optimization to avoid calling ``set`` unless the
    # value has changed. ``set`` is slow.
    new_leases = transform(config.leases)
    if new_leases != config.leases:
        # The leases in the configuration are out of date.
        new_config = config.set("leases", new_leases)
        d = persistence_service.save(new_config)
        d.addCallback(lambda _: new_config.leases)
        return d
    return succeed(new_leases)
Update the leases configuration in the persistence service.
dataset/ETHPy150Open ClusterHQ/flocker/flocker/control/_persistence.py/update_leases