Fix share can not be found by name in admin context
Currently, when using admin context to execute 'manila show <share-name>' to show a share detail which is not owned by admin, it always fails with 'No share with a name or ID of <share-name> exists'. This patch will fix it. Change-Id: I96339778fa69c379863078250d5dfa7172f2c1b2 Closes-Bug: #1721787
This commit is contained in:
parent
3b5e6bc24f
commit
b9ebff14ca
@ -208,7 +208,8 @@ class ManagerWithFind(Manager):
|
|||||||
found = []
|
found = []
|
||||||
searches = list(kwargs.items())
|
searches = list(kwargs.items())
|
||||||
|
|
||||||
for obj in self.list():
|
search_opts = {'all_tenants': 1}
|
||||||
|
for obj in self.list(search_opts=search_opts):
|
||||||
try:
|
try:
|
||||||
if all(getattr(obj, attr) == value
|
if all(getattr(obj, attr) == value
|
||||||
for (attr, value) in searches):
|
for (attr, value) in searches):
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
from mock import mock
|
||||||
|
|
||||||
from manilaclient.common.apiclient import base as common_base
|
from manilaclient.common.apiclient import base as common_base
|
||||||
from manilaclient import exceptions
|
from manilaclient import exceptions
|
||||||
@ -60,3 +61,8 @@ class BaseTest(utils.TestCase):
|
|||||||
self.assertRaises(exceptions.NotFound,
|
self.assertRaises(exceptions.NotFound,
|
||||||
cs.shares.find,
|
cs.shares.find,
|
||||||
vegetable='carrot')
|
vegetable='carrot')
|
||||||
|
|
||||||
|
def test_findall_with_all_tenants(self):
|
||||||
|
cs.shares.list = mock.Mock(return_value=[])
|
||||||
|
cs.shares.findall()
|
||||||
|
cs.shares.list.assert_called_once_with(search_opts={'all_tenants': 1})
|
||||||
|
@ -349,7 +349,7 @@ class ShellTest(test_utils.TestCase):
|
|||||||
self.run_command,
|
self.run_command,
|
||||||
'list --snapshot not_found_expected',
|
'list --snapshot not_found_expected',
|
||||||
)
|
)
|
||||||
self.assert_called('GET', '/snapshots/detail')
|
self.assert_called('GET', '/snapshots/detail?all_tenants=1')
|
||||||
|
|
||||||
def test_list_filter_by_host(self):
|
def test_list_filter_by_host(self):
|
||||||
for separator in self.separators:
|
for separator in self.separators:
|
||||||
@ -395,7 +395,7 @@ class ShellTest(test_utils.TestCase):
|
|||||||
self.run_command,
|
self.run_command,
|
||||||
'list --share-network not_found_expected',
|
'list --share-network not_found_expected',
|
||||||
)
|
)
|
||||||
self.assert_called('GET', '/share-networks/detail')
|
self.assert_called('GET', '/share-networks/detail?all_tenants=1')
|
||||||
|
|
||||||
@mock.patch.object(cliutils, 'print_list', mock.Mock())
|
@mock.patch.object(cliutils, 'print_list', mock.Mock())
|
||||||
def test_share_instance_list(self):
|
def test_share_instance_list(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user