Fix LP show command bug
Closes-bug: 1422494 Change-Id: I978b11faf4d144e37150fd1196f08b0af0ed95a8
This commit is contained in:
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
from solumclient.common import base as solum_base
|
from solumclient.common import base as solum_base
|
||||||
from solumclient.openstack.common.apiclient import base as apiclient_base
|
from solumclient.openstack.common.apiclient import base as apiclient_base
|
||||||
from solumclient.openstack.common import uuidutils
|
|
||||||
|
|
||||||
|
|
||||||
class Image(apiclient_base.Resource):
|
class Image(apiclient_base.Resource):
|
||||||
@@ -37,13 +36,6 @@ class ImageManager(solum_base.CrudManager, solum_base.FindMixin):
|
|||||||
return super(ImageManager, self).list(base_url="/v1", **kwargs)
|
return super(ImageManager, self).list(base_url="/v1", **kwargs)
|
||||||
|
|
||||||
def find(self, **kwargs):
|
def find(self, **kwargs):
|
||||||
if 'lp_uuid' in kwargs:
|
name_or_uuid = kwargs['name_or_id']
|
||||||
return super(ImageManager, self).get(base_url="/v1", **kwargs)
|
return super(ImageManager, self).get(base_url="/v1",
|
||||||
elif 'name_or_id' in kwargs:
|
image_id=name_or_uuid)
|
||||||
name_or_uuid = kwargs['name_or_id']
|
|
||||||
if uuidutils.is_uuid_like(name_or_uuid):
|
|
||||||
return super(ImageManager, self).get(
|
|
||||||
base_url="/v1",
|
|
||||||
lp_uuid=name_or_uuid)
|
|
||||||
else:
|
|
||||||
return super(ImageManager, self).findone(name=name_or_uuid)
|
|
||||||
|
@@ -450,11 +450,11 @@ Available commands:
|
|||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
"""Get a language pack."""
|
"""Get a language pack."""
|
||||||
self.parser.add_argument('lp_uuid',
|
self.parser.add_argument('lp_id',
|
||||||
help="Language pack id")
|
help="Language pack id")
|
||||||
self.parser._names['lp_uuid'] = 'languagepack'
|
self.parser._names['lp_id'] = 'languagepack'
|
||||||
args, _ = self.parser.parse_known_args()
|
args, _ = self.parser.parse_known_args()
|
||||||
response = self.bldclient.images.find(lp_uuid=args.lp_uuid)
|
response = self.bldclient.images.find(name_or_id=args.lp_id)
|
||||||
fields = ['uuid', 'name', 'description', 'state', 'source_uri']
|
fields = ['uuid', 'name', 'description', 'state', 'source_uri']
|
||||||
data = dict([(f, getattr(response, f, ''))
|
data = dict([(f, getattr(response, f, ''))
|
||||||
for f in fields])
|
for f in fields])
|
||||||
|
@@ -391,7 +391,7 @@ class TestSolum(base.TestCase):
|
|||||||
def test_languagepack_get(self, mock_lp_get):
|
def test_languagepack_get(self, mock_lp_get):
|
||||||
self.make_env()
|
self.make_env()
|
||||||
self.shell("languagepack show fake-lp-id1")
|
self.shell("languagepack show fake-lp-id1")
|
||||||
mock_lp_get.assert_called_once_with(lp_uuid='fake-lp-id1')
|
mock_lp_get.assert_called_once_with(name_or_id='fake-lp-id1')
|
||||||
|
|
||||||
# Component Tests #
|
# Component Tests #
|
||||||
@mock.patch.object(component.ComponentManager, "list")
|
@mock.patch.object(component.ComponentManager, "list")
|
||||||
|
Reference in New Issue
Block a user