def add_storage_mappings_arguments_to_parser(parser):
    """ Given an `argparse.ArgumentParser` instance, add the arguments required
    for the 'storage_mappings' field for both Migrations and Replicas:
        * '--default-storage-backend' will be under 'default_storage_backend'
        * '--disk-storage-mapping's will be under 'disk_storage_mappings'
        * '--storage-backend-mapping's will be under 'storage_backend_mappings'
    """
    parser.add_argument(
        "--default-storage-backend",
        dest='default_storage_backend',
        help="Name of a storage backend on the destination platform to "
             "default to using.")

    # NOTE: arparse will just call whatever 'type=' was supplied on a value
    # so we can pass in a single-arg function to have it modify the value:
    def _split_disk_arg(arg):
        disk_id, dest = arg.split('=')
        return {
            "disk_id": disk_id.strip('\'"'),
            "destination": dest.strip('\'"')}
    parser.add_argument(
        "--disk-storage-mapping", action='append', type=_split_disk_arg,
        dest='disk_storage_mappings',
        help="Mappings between IDs of the source VM's disks and the names of "
             "storage backends on the destination platform as seen by running "
             "`coriolis endpoint storage list $DEST_ENDPOINT_ID`. "
             "Values should be fomatted with '=' (ex: \"id#1=lvm)\"."
             "Can be specified multiple times for multiple disks.")

    def _split_backend_arg(arg):
        src, dest = arg.split('=')
        return {
            "source": src.strip('\'"'),
            "destination": dest.strip('\'"')}
    parser.add_argument(
        "--storage-backend-mapping", action='append', type=_split_backend_arg,
        dest='storage_backend_mappings',
        help="Mappings between names of source and destination storage "
        "backends  as seen by running `coriolis endpoint storage "
        "list $DEST_ENDPOINT_ID`. Values should be fomatted with '=' "
        "(ex: \"id#1=lvm)\". Can be specified multiple times for "
        "multiple backends.")