'Returns a list of hosts, subdivided into batches based on
the serial size specified in the play.'

def _get_serialized_batches(self, play):

    all_hosts = self._inventory.get_hosts(play.hosts)
    all_hosts_len = len(all_hosts)
    serial_batch_list = play.serial
    if (len(serial_batch_list) == 0):
        serial_batch_list = [(-1)]
    cur_item = 0
    serialized_batches = []
    while (len(all_hosts) > 0):
        serial = pct_to_int(serial_batch_list[cur_item], all_hosts_len)
        if (serial <= 0):
            serialized_batches.append(all_hosts)
            break
        else:
            play_hosts = []
            for x in range(serial):
                if (len(all_hosts) > 0):
                    play_hosts.append(all_hosts.pop(0))
            serialized_batches.append(play_hosts)
        cur_item += 1
        if (cur_item > (len(serial_batch_list) - 1)):
            cur_item = (len(serial_batch_list) - 1)
    return serialized_batches
