code: def _handle_units_placement(changeset, units, records):
      
      for service_name, service in sorted(changeset.bundle['services'].items()):
          num_units = service.get('num_units')
          if num_units is None:
              # This is a subordinate service.
              continue
          placement_directives = service.get('to', [])
          if not isinstance(placement_directives, (list, tuple)):
              placement_directives = [placement_directives]
          if placement_directives and not changeset.is_legacy_bundle():
              placement_directives += (
                  placement_directives[-1:] *
                  (num_units - len(placement_directives)))
          placed_in_services = {}
          for i in range(num_units):
              unit = units['{}/{}'.format(service_name, i)]
              record = records[unit['record']]
              if i < len(placement_directives):
                  record = _handle_unit_placement(
                      changeset, units, unit, record, placement_directives[i],
                      placed_in_services)
              changeset.send(record)
docs: Ensure that requires and placement directives are taken into account.