import json


def getConfigNames(xen, session, logger, ref):
    """
    Return all config names associated with the given disk by reading the disk's other config in Xen.

    :param logger: A logger used for logging possible errors.
    :type logger: seealso:: :class:`logging:Logger`

    :param ref: Xen reference of the disk.
    :type ref: str

    :returns: An array with config names that reference this disk
    :rtype: [str]
    """

    result = xen.VDI.get_other_config(session, ref)
    if result['Status'] == "Failure":
        logger.warning("Error while getting other config of VDI. Error: {1}.".format(str(result['ErrorDescription'])))
        return
    otherConfig = result['Value']

    if "configs" in otherConfig:
        return json.loads(otherConfig['configs'])
    else:
        return []