code: def modulo_distribution(modulo=3, wait=30, non_zero_wait=False):
      
      unit_number = int(local_unit().split('/')[1])
      calculated_wait_time = (unit_number % modulo) * wait
      if non_zero_wait and calculated_wait_time == 0:
          return modulo * wait
      else:
          return calculated_wait_time
docs: Modulo distribution
  
      This helper uses the unit number, a modulo value and a constant wait time
      to produce a calculated wait time distribution. This is useful in large
      scale deployments to distribute load during an expensive operation such as
      service restarts.
  
      If you have 1000 nodes that need to restart 100 at a time 1 minute at a
      time:
  
        time.wait(modulo_distribution(modulo=100, wait=60))
        restart()
  
      If you need restarts to happen serially set modulo to the exact number of
      nodes and set a high constant wait time:
  
        time.wait(modulo_distribution(modulo=10, wait=120))
        restart()
  
      @param modulo: int The modulo number creates the group distribution
      @param wait: int The constant time wait value
      @param non_zero_wait: boolean Override unit % modulo == 0,
                            return modulo * wait. Used to avoid collisions with
                            leader nodes which are often given priority.
      @return: int Calculated time to wait for unit operation