Example #1
0
def _runtime_url(url, cluster):
    if url.startswith(m.MANILA_PREFIX) and cluster:
        path = shares_service.get_share_path(url, cluster.shares or [])
        if path is None:
            path = mount_share_at_default_path(url, cluster)
        # This gets us the mount point, but we need a file:// scheme to
        # indicate a local filesystem path
        return "file://{path}".format(path=path)
    return url
Example #2
0
def _runtime_url(url, cluster):
    if url.startswith(m.MANILA_PREFIX) and cluster:
        path = shares_service.get_share_path(url, cluster.shares or [])
        if path is None:
            path = mount_share_at_default_path(url, cluster)
        # This gets us the mount point, but we need a file:// scheme to
        # indicate a local filesystem path
        return "file://{path}".format(path=path)
    return url
Example #3
0
    def test_get_share_path_default(self, f_manilaclient):
        share_list = [{"id": "i_have_no_mnt"}]

        share = _FakeShare(share_list[0]["id"])
        f_manilaclient.return_value = mock.Mock(shares=mock.Mock(get=mock.Mock(return_value=share)))

        url = "manila://i_have_no_mnt/the_path"
        path = shares.get_share_path(url, share_list)
        self.assertEqual("/mnt/i_have_no_mnt/the_path", path)
Example #4
0
    def test_get_share_path(self):
        share_list = [
            {"id": "the_share_id", "path": "/mnt/mymountpoint"},
            {"id": "the_share_id", "path": "/mnt/othermountpoint"},
            {"id": "123456", "path": "/mnt/themountpoint"},
        ]
        url = "manila://the_share_id/the_path"

        path = shares.get_share_path(url, share_list)
        self.assertEqual("/mnt/mymountpoint/the_path", path)

        share_list.pop(0)
        path = shares.get_share_path(url, share_list)
        self.assertEqual("/mnt/othermountpoint/the_path", path)

        share_list.pop(0)
        path = shares.get_share_path(url, share_list)
        self.assertIsNone(path)
Example #5
0
    def test_get_share_path_default(self, f_manilaclient):
        share_list = [{'id': 'i_have_no_mnt'}]

        share = _FakeShare(share_list[0]['id'])
        f_manilaclient.return_value = mock.Mock(shares=mock.Mock(get=mock.Mock(
            return_value=share)))

        url = 'manila://i_have_no_mnt/the_path'
        path = shares.get_share_path(url, share_list)
        self.assertEqual("/mnt/i_have_no_mnt/the_path", path)
Example #6
0
def get_file_info(job_binary, remote):
    shares = []
    if remote.instance.node_group.cluster.shares:
        shares.extend(remote.instance.node_group.cluster.shares)
    if remote.instance.node_group.shares:
        shares.extend(remote.instance.node_group.shares)
    path = shares_service.get_share_path(job_binary.url, shares)
    if path is None:
        path = job_utils.mount_share_at_default_path(
            job_binary.url, remote.instance.node_group.cluster)
    return {'type': 'path', 'path': path}
Example #7
0
    def test_get_share_path(self):
        share_list = [
            {'id': 'the_share_id',
             'path': '/mnt/mymountpoint'},
            {'id': 'the_share_id',
             'path': '/mnt/othermountpoint'},
            {'id': '123456',
             'path': '/mnt/themountpoint'}
        ]
        url = 'manila://the_share_id/the_path'

        path = shares.get_share_path(url, share_list)
        self.assertEqual("/mnt/mymountpoint/the_path", path)

        share_list.pop(0)
        path = shares.get_share_path(url, share_list)
        self.assertEqual("/mnt/othermountpoint/the_path", path)

        share_list.pop(0)
        path = shares.get_share_path(url, share_list)
        self.assertIsNone(path)
Example #8
0
def get_file_info(job_binary, remote):
    shares = []
    if remote.instance.node_group.cluster.shares:
        shares.extend(remote.instance.node_group.cluster.shares)
    if remote.instance.node_group.shares:
        shares.extend(remote.instance.node_group.shares)
    path = shares_service.get_share_path(job_binary.url, shares)
    if path is None:
        path = job_utils.mount_share_at_default_path(
            job_binary.url,
            remote.instance.node_group.cluster)
    return {'type': 'path',
            'path': path}
Example #9
0
def mount_share_at_default_path(url, cluster):
    # Automount this share to the cluster with default path
    # url example: 'manila://ManilaShare-uuid/path_to_file'
    share_id = six.moves.urllib.parse.urlparse(url).netloc
    if cluster.shares:
        cluster_shares = [dict(s) for s in cluster.shares]
    else:
        cluster_shares = []

    needed_share = {
        'id': share_id,
        'path': shares_service.default_mount(share_id),
        'access_level': 'rw'
    }

    cluster_shares.append(needed_share)
    cluster = conductor.cluster_update(context.ctx(), cluster,
                                       {'shares': cluster_shares})
    shares_service.mount_shares(cluster)

    return shares_service.get_share_path(url, cluster.shares)
Example #10
0
def mount_share_at_default_path(url, cluster):
    # Automount this share to the cluster with default path
    # url example: 'manila://ManilaShare-uuid/path_to_file'
    share_id = six.moves.urllib.parse.urlparse(url).netloc
    if cluster.shares:
        cluster_shares = [dict(s) for s in cluster.shares]
    else:
        cluster_shares = []

    needed_share = {
        'id': share_id,
        'path': shares_service.default_mount(share_id),
        'access_level': 'rw'
    }

    cluster_shares.append(needed_share)
    cluster = conductor.cluster_update(
        context.ctx(), cluster, {'shares': cluster_shares})
    shares_service.mount_shares(cluster)

    return shares_service.get_share_path(url, cluster.shares)