def resolve_parent(self, disk_path, template_store, template_repo):
qemu_info = utils.get_qemu_info(disk_path)<EOL>parent = qemu_info.get('<STR_LIT>')<EOL>if not parent:<EOL><INDENT>return<EOL><DEDENT>if os.path.isfile(parent):<EOL><INDENT>if os.path.samefile(<EOL>os.path.realpath(parent),<EOL>os.path.realpath(os.path.expandvars(disk_path))<EOL>):<EOL><INDENT>raise LagoInitException(<EOL>dedent(<EOL>"""<STR_LIT>""".format(disk_path)<EOL>)<EOL>)<EOL><DEDENT>return<EOL><DEDENT>LOGGER.info('<STR_LIT>')<EOL>try:<EOL><INDENT>name, version = os.path.basename(parent).split('<STR_LIT::>', <NUM_LIT:1>)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise LagoInitException(<EOL>dedent(<EOL>"""<STR_LIT>""".format(disk_path, parent)<EOL>)<EOL>)<EOL><DEDENT>_, _, base = self._handle_lago_template(<EOL>'<STR_LIT>', {'<STR_LIT>': name,<EOL>'<STR_LIT>': version}, template_store, template_repo<EOL>)<EOL>base = os.path.expandvars(base)<EOL>if base == parent:<EOL><INDENT>return<EOL><DEDENT>link_name = os.path.join(<EOL>os.path.dirname(disk_path), '<STR_LIT>'.format(name, version)<EOL>)<EOL>link_name = os.path.expandvars(link_name)<EOL>self._create_link_to_parent(base, link_name)<EOL>
Given a virtual disk, checks if it has a backing file, if so check
if the backing file is in the store, if not download it
from the provided template_repo.

After verifying that the backing-file is in the store,
create a symlink to that file and locate it near the layered image.

Args:
    disk_path (str): path to the layered disk
    template_repo (TemplateRepository or None): template repo instance
        to use
    template_store (TemplateStore or None): template store instance to
        use