Skip to content

Commit 50a5c36

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Remove the --dhcp option to network list"
2 parents 79c69e1 + 2d4a737 commit 50a5c36

3 files changed

Lines changed: 41 additions & 85 deletions

File tree

doc/source/backwards-incompatible.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ List of Backwards Incompatible Changes
6161
* Bug: https://bugs.launchpad.net/python-openstackclient/+bug/1461817
6262
* Commit: https://review.openstack.org/#/c/194654/
6363

64+
5. Command `openstack network list --dhcp` has been removed
65+
66+
The --dhcp option to network list is not a logical use case of listing
67+
networks, it lists agents. Another command should be added in the future
68+
to provide this functionality. It is highly unlikely anyone uses this
69+
feature as we don't support any other agent commands. Use neutron
70+
dhcp-agent-list-hosting-net command instead.
71+
72+
* In favor of: Create network agent list command in the future
73+
* As of: 1.6.0
74+
* Removed in: NA
75+
* Bug: https://bugs.launchpad.net/python-openstackclient/+bug/472613
76+
* Commit: https://review.openstack.org/#/c/194654/
77+
6478
For Developers
6579
==============
6680

openstackclient/network/v2/network.py

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ def get_parser(self, prog_name):
156156
default=False,
157157
help='List external networks',
158158
)
159-
parser.add_argument(
160-
'--dhcp',
161-
metavar='<dhcp-id>',
162-
help='DHCP agent ID')
163159
parser.add_argument(
164160
'--long',
165161
action='store_true',
@@ -172,40 +168,34 @@ def take_action(self, parsed_args):
172168
self.log.debug('take_action(%s)' % parsed_args)
173169
client = self.app.client_manager.network
174170

175-
if parsed_args.dhcp:
176-
data = client.api.dhcp_agent_list(dhcp_id=parsed_args.dhcp)
177-
178-
columns = ('ID',)
179-
column_headers = columns
171+
data = client.api.network_list(external=parsed_args.external)
172+
173+
if parsed_args.long:
174+
columns = (
175+
'ID',
176+
'Name',
177+
'Status',
178+
'project_id',
179+
'state',
180+
'Shared',
181+
'Subnets',
182+
'provider:network_type',
183+
'router_type',
184+
)
185+
column_headers = (
186+
'ID',
187+
'Name',
188+
'Status',
189+
'Project',
190+
'State',
191+
'Shared',
192+
'Subnets',
193+
'Network Type',
194+
'Router Type',
195+
)
180196
else:
181-
data = client.api.network_list(external=parsed_args.external)
182-
183-
if parsed_args.long:
184-
columns = (
185-
'ID',
186-
'Name',
187-
'Status',
188-
'project_id',
189-
'state',
190-
'Shared',
191-
'Subnets',
192-
'provider:network_type',
193-
'router_type',
194-
)
195-
column_headers = (
196-
'ID',
197-
'Name',
198-
'Status',
199-
'Project',
200-
'State',
201-
'Shared',
202-
'Subnets',
203-
'Network Type',
204-
'Router Type',
205-
)
206-
else:
207-
columns = ('ID', 'Name', 'Subnets')
208-
column_headers = columns
197+
columns = ('ID', 'Name', 'Subnets')
198+
column_headers = columns
209199

210200
for d in data:
211201
d = _prep_network_detail(d)

openstackclient/tests/network/v2/test_network.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ def test_network_list_no_options(self, n_mock):
278278
arglist = []
279279
verifylist = [
280280
('external', False),
281-
('dhcp', None),
282281
('long', False),
283282
]
284283
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -306,7 +305,6 @@ def test_list_external(self, n_mock):
306305
]
307306
verifylist = [
308307
('external', True),
309-
('dhcp', None),
310308
('long', False),
311309
]
312310
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -334,7 +332,6 @@ def test_network_list_long(self, n_mock):
334332
]
335333
verifylist = [
336334
('long', True),
337-
('dhcp', None),
338335
('external', False),
339336
]
340337
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -377,51 +374,6 @@ def test_network_list_long(self, n_mock):
377374
self.assertEqual(list(data), datalist)
378375

379376

380-
@mock.patch(
381-
'openstackclient.api.network_v2.APIv2.dhcp_agent_list'
382-
)
383-
class TestListDhcpAgent(common.TestNetworkBase):
384-
385-
def setUp(self):
386-
super(TestListDhcpAgent, self).setUp()
387-
388-
# Get the command object to test
389-
self.cmd = network.ListNetwork(self.app, self.namespace)
390-
391-
self.DHCP_LIST = [
392-
{'id': '1'},
393-
{'id': '2'},
394-
]
395-
396-
def test_list_dhcp(self, n_mock):
397-
n_mock.return_value = self.DHCP_LIST
398-
399-
arglist = [
400-
'--dhcp', 'dhcpid',
401-
]
402-
verifylist = [
403-
('external', False),
404-
('dhcp', 'dhcpid'),
405-
('long', False),
406-
]
407-
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
408-
409-
# DisplayCommandBase.take_action() returns two tuples
410-
columns, data = self.cmd.take_action(parsed_args)
411-
412-
# Set expected values
413-
n_mock.assert_called_with(
414-
dhcp_id='dhcpid',
415-
)
416-
417-
self.assertEqual(('ID',), columns)
418-
datalist = [
419-
('1',),
420-
('2',),
421-
]
422-
self.assertEqual(datalist, list(data))
423-
424-
425377
class TestSetNetwork(common.TestNetworkBase):
426378
def test_set_this(self):
427379
arglist = [

0 commit comments

Comments
 (0)