Skip to content

Commit d91e104

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Make SetAggregate inherit from cliff.Command"
2 parents 5381217 + ba826fa commit d91e104

4 files changed

Lines changed: 84 additions & 14 deletions

File tree

doc/source/backwards-incompatible.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ List of Backwards Incompatible Changes
150150
* Bug: https://bugs.launchpad.net/python-openstackclient/+bug/1546065
151151
* Commit: https://review.openstack.org/#/c/281088/
152152

153+
13. `aggregate set` commands will no longer return the modified resource
154+
155+
Previously, modifying an aggregate would result in the new aggregate being
156+
displayed to the user. To keep things consistent with other `set` commands,
157+
we will no longer be showing the modified resource.
158+
159+
* In favor of: Use `set` then `show`
160+
* As of: NA
161+
* Removed in: NA
162+
* Bug: https://bugs.launchpad.net/python-openstackclient/+bug/1546065
163+
* Commit: https://review.openstack.org/#/c/281089/
164+
153165
For Developers
154166
==============
155167

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import uuid
14+
15+
from functional.common import test
16+
17+
18+
class AggregateTests(test.TestCase):
19+
"""Functional tests for aggregate. """
20+
21+
NAME = uuid.uuid4().hex
22+
HEADERS = ['Name']
23+
FIELDS = ['name']
24+
25+
@classmethod
26+
def setUpClass(cls):
27+
opts = cls.get_show_opts(cls.FIELDS)
28+
raw_output = cls.openstack('aggregate create ' + cls.NAME + opts)
29+
expected = cls.NAME + '\n'
30+
cls.assertOutput(expected, raw_output)
31+
32+
@classmethod
33+
def tearDownClass(cls):
34+
raw_output = cls.openstack('aggregate delete ' + cls.NAME)
35+
cls.assertOutput('', raw_output)
36+
37+
def test_aggregate_list(self):
38+
opts = self.get_list_opts(self.HEADERS)
39+
raw_output = self.openstack('aggregate list' + opts)
40+
self.assertIn(self.NAME, raw_output)
41+
42+
def test_aggregate_show(self):
43+
opts = self.get_show_opts(self.FIELDS)
44+
raw_output = self.openstack('aggregate show ' + self.NAME + opts)
45+
self.assertEqual(self.NAME + "\n", raw_output)
46+
47+
def test_aggregate_properties(self):
48+
opts = self.get_show_opts(['properties'])
49+
50+
raw_output = self.openstack(
51+
'aggregate set --property a=b --property c=d ' + self.NAME
52+
)
53+
self.assertEqual('', raw_output)
54+
55+
raw_output = self.openstack('aggregate show ' + self.NAME + opts)
56+
self.assertIn("a='b', c='d'\n", raw_output)

openstackclient/compute/v2/aggregate.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def take_action(self, parsed_args):
201201
return zip(*sorted(six.iteritems(info)))
202202

203203

204-
class SetAggregate(command.ShowOne):
204+
class SetAggregate(command.Command):
205205
"""Set aggregate properties"""
206206

207207
def get_parser(self, prog_name):
@@ -238,28 +238,22 @@ def take_action(self, parsed_args):
238238
parsed_args.aggregate,
239239
)
240240

241-
info = {}
242241
kwargs = {}
243242
if parsed_args.name:
244243
kwargs['name'] = parsed_args.name
245244
if parsed_args.zone:
246245
kwargs['availability_zone'] = parsed_args.zone
247246
if kwargs:
248-
info.update(compute_client.aggregates.update(
247+
compute_client.aggregates.update(
249248
aggregate,
250249
kwargs
251-
)._info)
250+
)
252251

253252
if parsed_args.property:
254-
info.update(compute_client.aggregates.set_metadata(
253+
compute_client.aggregates.set_metadata(
255254
aggregate,
256-
parsed_args.property,
257-
)._info)
258-
259-
if info:
260-
return zip(*sorted(six.iteritems(info)))
261-
else:
262-
return ({}, {})
255+
parsed_args.property
256+
)
263257

264258

265259
class ShowAggregate(command.ShowOne):
@@ -284,8 +278,14 @@ def take_action(self, parsed_args):
284278
# Remove availability_zone from metadata because Nova doesn't
285279
if 'availability_zone' in data.metadata:
286280
data.metadata.pop('availability_zone')
287-
# Map 'metadata' column to 'properties'
288-
data._info.update({'properties': data._info.pop('metadata')})
281+
282+
# Special mapping for columns to make the output easier to read:
283+
# 'metadata' --> 'properties'
284+
data._info.update(
285+
{
286+
'properties': utils.format_dict(data._info.pop('metadata')),
287+
},
288+
)
289289

290290
info = {}
291291
info.update(data._info)

releasenotes/notes/bug-1546065-41d09ffbd8606513.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ fixes:
66
[Bug `1546065 <https://bugs.launchpad.net/python-openstackclient/+bug/1546065>`_]
77
- Command ``compute agent set`` now outputs nothing.
88
[Bug `1546065 <https://bugs.launchpad.net/python-openstackclient/+bug/1546065>`_]
9+
- Command ``aggregate set`` now outputs nothing.
10+
[Bug `1546065 <https://bugs.launchpad.net/python-openstackclient/+bug/1546065>`_]

0 commit comments

Comments
 (0)