'Return the driver format for self.path.
First checks self.disk_info_path for an entry.
If it\'s not there, calls self._get_driver_format(), and then
stores the result in self.disk_info_path
See https://bugs.launchpad.net/nova/+bug/1221190'

def resolve_driver_format(self):

    def _dict_from_line(line):
        if (not line):
            return {}
        try:
            return jsonutils.loads(line)
        except (TypeError, ValueError) as e:
            msg = (_('Could    not    load    line    %(line)s,    got    error    %(error)s') % {'line': line, 'error': e})
            raise exception.InvalidDiskInfo(reason=msg)
    @utils.synchronized(self.disk_info_path, external=False, lock_path=self.lock_path)
    def write_to_disk_info_file():
        fd = os.open(self.disk_info_path, (os.O_RDONLY | os.O_CREAT), 420)
        with os.fdopen(fd, 'r') as disk_info_file:
            line = disk_info_file.read().rstrip()
            dct = _dict_from_line(line)
        if (self.path in dct):
            msg = _('Attempted    overwrite    of    an    existing    value.')
            raise exception.InvalidDiskInfo(reason=msg)
        dct.update({self.path: driver_format})
        tmp_path = (self.disk_info_path + '.tmp')
        fd = os.open(tmp_path, (os.O_WRONLY | os.O_CREAT), 420)
        with os.fdopen(fd, 'w') as tmp_file:
            tmp_file.write(('%s\n' % jsonutils.dumps(dct)))
        os.rename(tmp_path, self.disk_info_path)
    try:
        if ((self.disk_info_path is not None) and os.path.exists(self.disk_info_path)):
            with open(self.disk_info_path) as disk_info_file:
                line = disk_info_file.read().rstrip()
                dct = _dict_from_line(line)
                for (path, driver_format) in dct.items():
                    if (path == self.path):
                        return driver_format
        driver_format = self._get_driver_format()
        if (self.disk_info_path is not None):
            fileutils.ensure_tree(os.path.dirname(self.disk_info_path))
            write_to_disk_info_file()
    except OSError as e:
        raise exception.DiskInfoReadWriteFail(reason=six.text_type(e))
    return driver_format
