Replaces disks on an instance.

    @type instance: str
    @param instance: instance whose disks to replace
    @type disks: list of ints
    @param disks: Indexes of disks to replace
    @type mode: str
    @param mode: replacement mode to use (defaults to replace_auto)
    @type remote_node: str or None
    @param remote_node: new secondary node to use (for use with
            replace_new_secondary mode)
    @type iallocator: str or None
    @param iallocator: instance allocator plugin to use (for use with
                                         replace_auto mode)
    @type dry_run: bool
    @param dry_run: whether to perform a dry run

    @rtype: int
    @return: job id

def ReplaceInstanceDisks(r, instance, disks=None, mode=REPLACE_DISK_AUTO,
                         remote_node=None, iallocator=None, dry_run=False):
    """
    Replaces disks on an instance.

    @type instance: str
    @param instance: instance whose disks to replace
    @type disks: list of ints
    @param disks: Indexes of disks to replace
    @type mode: str
    @param mode: replacement mode to use (defaults to replace_auto)
    @type remote_node: str or None
    @param remote_node: new secondary node to use (for use with
            replace_new_secondary mode)
    @type iallocator: str or None
    @param iallocator: instance allocator plugin to use (for use with
                                         replace_auto mode)
    @type dry_run: bool
    @param dry_run: whether to perform a dry run

    @rtype: int
    @return: job id
    """

    if mode not in REPLACE_DISK:
        raise GanetiApiError("Invalid mode %r not one of %r" % (mode,
                                                                REPLACE_DISK))

    query = {
        "mode": mode,
        "dry-run": dry_run,
    }

    if disks:
        query["disks"] = ",".join(str(idx) for idx in disks)

    if remote_node:
        query["remote_node"] = remote_node

    if iallocator:
        query["iallocator"] = iallocator

    return r.request("post", "/2/instances/%s/replace-disks" % instance,
                     query=query)