Exemplo n.º 1
0
    def _get_share_path(self, 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)
        return path
Exemplo n.º 2
0
    def _get_share_path(self, 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)
        return path
Exemplo n.º 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)
Exemplo n.º 4
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}
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 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}
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 11
0
 def _get_share_path(self, url, shares):
     return shares_service.get_share_path(url, shares)