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
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)
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}
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)
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)
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)
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)
def _get_share_path(self, url, shares): return shares_service.get_share_path(url, shares)