Skip to content

Commit 34435d9

Browse files
committed
Exchange the check order for the dhcp and no-dhcp
The dhcp is setting with True by default and progress always jump into the first if check. So the no-dhcp option always ignored there. Check the no-dhcp option first and then the dhcp option value to avoid this. Change-Id: Ide640e2cab3936d419ca62105304ff5d4a8a2074 Closes-Bug: #1602588
1 parent 60639d7 commit 34435d9

2 files changed

Lines changed: 1 addition & 4 deletions

File tree

openstackclient/network/v2/subnet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def _get_attrs(client_manager, parsed_args, is_create=True):
168168
attrs['allocation_pools'] = parsed_args.allocation_pools
169169
if parsed_args.dhcp:
170170
attrs['enable_dhcp'] = True
171-
elif parsed_args.no_dhcp:
171+
if parsed_args.no_dhcp:
172172
attrs['enable_dhcp'] = False
173173
if ('dns_nameservers' in parsed_args and
174174
parsed_args.dns_nameservers is not None):
@@ -223,7 +223,6 @@ def get_parser(self, prog_name):
223223
dhcp_enable_group.add_argument(
224224
'--dhcp',
225225
action='store_true',
226-
default=True,
227226
help=_("Enable DHCP (default)")
228227
)
229228
dhcp_enable_group.add_argument(

openstackclient/tests/network/v2/test_subnet.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ def test_create_default_options(self):
236236

237237
self.network.create_subnet.assert_called_once_with(**{
238238
'cidr': self._subnet.cidr,
239-
'enable_dhcp': self._subnet.enable_dhcp,
240239
'ip_version': self._subnet.ip_version,
241240
'name': self._subnet.name,
242241
'network_id': self._subnet.network_id,
@@ -410,7 +409,6 @@ def test_create_with_network_segment(self):
410409

411410
self.network.create_subnet.assert_called_once_with(**{
412411
'cidr': self._subnet.cidr,
413-
'enable_dhcp': self._subnet.enable_dhcp,
414412
'ip_version': self._subnet.ip_version,
415413
'name': self._subnet.name,
416414
'network_id': self._subnet.network_id,

0 commit comments

Comments
 (0)