Show 'project' info if heat server returns
Show 'project'/'Project' info in heatclient if heat server returns 'project' info of stacks. Change-Id: I7d95ae96a678ef41bcd3d5379f204db83e4b585c Closes-Bug: #1652412
This commit is contained in:
parent
17dd3068e4
commit
3ee70cf4e8
@ -623,8 +623,6 @@ def _list(client, args=None):
|
|||||||
columns.pop()
|
columns.pop()
|
||||||
if args.long:
|
if args.long:
|
||||||
columns.insert(2, 'Stack Owner')
|
columns.insert(2, 'Stack Owner')
|
||||||
if args.long or args.all_projects:
|
|
||||||
columns.insert(2, 'Project')
|
|
||||||
|
|
||||||
if args.nested:
|
if args.nested:
|
||||||
columns.append('Parent')
|
columns.append('Parent')
|
||||||
@ -634,6 +632,11 @@ def _list(client, args=None):
|
|||||||
columns.append('Deletion Time')
|
columns.append('Deletion Time')
|
||||||
|
|
||||||
data = client.stacks.list(**kwargs)
|
data = client.stacks.list(**kwargs)
|
||||||
|
data = list(data)
|
||||||
|
for stk in data:
|
||||||
|
if hasattr(stk, 'project'):
|
||||||
|
columns.insert(2, 'Project')
|
||||||
|
break
|
||||||
data = utils.sort_items(data, args.sort if args else None)
|
data = utils.sort_items(data, args.sort if args else None)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -453,6 +453,9 @@ class TestStackList(TestStack):
|
|||||||
'deletion_time': '2015-10-21T07:50:00Z',
|
'deletion_time': '2015-10-21T07:50:00Z',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data_with_project = copy.deepcopy(data)
|
||||||
|
data_with_project['project'] = 'test_project'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestStackList, self).setUp()
|
super(TestStackList, self).setUp()
|
||||||
self.cmd = stack.ListStack(self.app, None)
|
self.cmd = stack.ListStack(self.app, None)
|
||||||
@ -495,6 +498,8 @@ class TestStackList(TestStack):
|
|||||||
self.assertEqual(cols, columns)
|
self.assertEqual(cols, columns)
|
||||||
|
|
||||||
def test_stack_list_all_projects(self):
|
def test_stack_list_all_projects(self):
|
||||||
|
self.stack_client.list.return_value = [
|
||||||
|
stacks.Stack(None, self.data_with_project)]
|
||||||
kwargs = copy.deepcopy(self.defaults)
|
kwargs = copy.deepcopy(self.defaults)
|
||||||
kwargs['global_tenant'] = True
|
kwargs['global_tenant'] = True
|
||||||
cols = copy.deepcopy(self.columns)
|
cols = copy.deepcopy(self.columns)
|
||||||
@ -507,7 +512,23 @@ class TestStackList(TestStack):
|
|||||||
self.stack_client.list.assert_called_with(**kwargs)
|
self.stack_client.list.assert_called_with(**kwargs)
|
||||||
self.assertEqual(cols, columns)
|
self.assertEqual(cols, columns)
|
||||||
|
|
||||||
|
def test_stack_list_with_project(self):
|
||||||
|
self.stack_client.list.return_value = [
|
||||||
|
stacks.Stack(None, self.data_with_project)]
|
||||||
|
kwargs = copy.deepcopy(self.defaults)
|
||||||
|
cols = copy.deepcopy(self.columns)
|
||||||
|
cols.insert(2, 'Project')
|
||||||
|
arglist = []
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, [])
|
||||||
|
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.stack_client.list.assert_called_with(**kwargs)
|
||||||
|
self.assertEqual(cols, columns)
|
||||||
|
|
||||||
def test_stack_list_long(self):
|
def test_stack_list_long(self):
|
||||||
|
self.stack_client.list.return_value = [
|
||||||
|
stacks.Stack(None, self.data_with_project)]
|
||||||
kwargs = copy.deepcopy(self.defaults)
|
kwargs = copy.deepcopy(self.defaults)
|
||||||
kwargs['global_tenant'] = True
|
kwargs['global_tenant'] = True
|
||||||
cols = copy.deepcopy(self.columns)
|
cols = copy.deepcopy(self.columns)
|
||||||
|
@ -126,25 +126,25 @@ class TestCase(testtools.TestCase):
|
|||||||
mockfixture = self.useFixture(mockpatch.Patch(target, **kwargs))
|
mockfixture = self.useFixture(mockpatch.Patch(target, **kwargs))
|
||||||
return mockfixture.mock
|
return mockfixture.mock
|
||||||
|
|
||||||
def stack_list_resp_dict(self, show_nested=False):
|
def stack_list_resp_dict(self, show_nested=False, include_project=False):
|
||||||
resp_dict = {"stacks": [
|
stack1 = {
|
||||||
{
|
"id": "1",
|
||||||
"id": "1",
|
"stack_name": "teststack",
|
||||||
"stack_name": "teststack",
|
"stack_owner": "testowner",
|
||||||
"stack_owner": "testowner",
|
"stack_status": 'CREATE_COMPLETE',
|
||||||
"project": "testproject",
|
"creation_time": "2012-10-25T01:58:47Z"}
|
||||||
"stack_status": 'CREATE_COMPLETE',
|
stack2 = {
|
||||||
"creation_time": "2012-10-25T01:58:47Z"
|
"id": "2",
|
||||||
},
|
"stack_name": "teststack2",
|
||||||
{
|
"stack_owner": "testowner",
|
||||||
"id": "2",
|
"stack_status": 'IN_PROGRESS',
|
||||||
"stack_name": "teststack2",
|
"creation_time": "2012-10-25T01:58:47Z"
|
||||||
"stack_owner": "testowner",
|
}
|
||||||
"project": "testproject",
|
if include_project:
|
||||||
"stack_status": 'IN_PROGRESS',
|
stack1['project'] = 'testproject'
|
||||||
"creation_time": "2012-10-25T01:58:47Z"
|
stack1['project'] = 'testproject'
|
||||||
}]
|
|
||||||
}
|
resp_dict = {"stacks": [stack1, stack2]}
|
||||||
if show_nested:
|
if show_nested:
|
||||||
nested = {
|
nested = {
|
||||||
"id": "3",
|
"id": "3",
|
||||||
@ -153,6 +153,8 @@ class TestCase(testtools.TestCase):
|
|||||||
"creation_time": "2012-10-25T01:58:47Z",
|
"creation_time": "2012-10-25T01:58:47Z",
|
||||||
"parent": "theparentof3"
|
"parent": "theparentof3"
|
||||||
}
|
}
|
||||||
|
if include_project:
|
||||||
|
nested['project'] = 'testproject'
|
||||||
resp_dict["stacks"].append(nested)
|
resp_dict["stacks"].append(nested)
|
||||||
|
|
||||||
return resp_dict
|
return resp_dict
|
||||||
@ -4209,7 +4211,7 @@ class MockShellTestUserPass(MockShellBase):
|
|||||||
|
|
||||||
def test_stack_list_with_args(self):
|
def test_stack_list_with_args(self):
|
||||||
self.register_keystone_auth_fixture()
|
self.register_keystone_auth_fixture()
|
||||||
resp_dict = self.stack_list_resp_dict()
|
resp_dict = self.stack_list_resp_dict(include_project=True)
|
||||||
resp = fakes.FakeHTTPResponse(
|
resp = fakes.FakeHTTPResponse(
|
||||||
200,
|
200,
|
||||||
'success, you',
|
'success, you',
|
||||||
|
@ -689,13 +689,16 @@ def do_stack_list(hc, args=None):
|
|||||||
|
|
||||||
if args.global_tenant or args.show_owner:
|
if args.global_tenant or args.show_owner:
|
||||||
fields.append('stack_owner')
|
fields.append('stack_owner')
|
||||||
if args.global_tenant:
|
|
||||||
fields.append('project')
|
|
||||||
|
|
||||||
if args.show_deleted:
|
if args.show_deleted:
|
||||||
fields.append('deletion_time')
|
fields.append('deletion_time')
|
||||||
|
|
||||||
stacks = hc.stacks.list(**kwargs)
|
stacks = hc.stacks.list(**kwargs)
|
||||||
|
stacks = list(stacks)
|
||||||
|
for stk in stacks:
|
||||||
|
if hasattr(stk, 'project'):
|
||||||
|
fields.append('project')
|
||||||
|
break
|
||||||
utils.print_list(stacks, fields, sortby_index=sortby_index)
|
utils.print_list(stacks, fields, sortby_index=sortby_index)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user