'Construct direct url for nfs backend.
It creates direct url from image_location
which is a tuple with direct_url and locations.
Returns array of urls with nfs scheme if nfs store
else returns url. It needs to be verified
by backend before use.'

def _construct_image_nfs_url(self, image_location):

    (direct_url, locations) = image_location
    if ((not direct_url) and (not locations)):
        raise exception.NotFound(_('Image    location    not    present.'))
    urls = []
    if (not locations):
        urls.append(direct_url)
    else:
        for location in locations:
            if (not location['metadata']):
                continue
            location_type = location['metadata'].get('type')
            if ((not location_type) or (location_type.lower() != 'nfs')):
                continue
            share_location = location['metadata'].get('share_location')
            mountpoint = location['metadata'].get('mountpoint')
            if ((not share_location) or (not mountpoint)):
                continue
            url = location['url']
            url_parse = urllib.parse.urlparse(url)
            abs_path = os.path.join(url_parse.netloc, url_parse.path)
            rel_path = os.path.relpath(abs_path, mountpoint)
            direct_url = ('%s/%s' % (share_location, rel_path))
            urls.append(direct_url)
    return urls
