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
This commit is contained in:
parent
60639d76a7
commit
34435d9ca2
@ -168,7 +168,7 @@ def _get_attrs(client_manager, parsed_args, is_create=True):
|
|||||||
attrs['allocation_pools'] = parsed_args.allocation_pools
|
attrs['allocation_pools'] = parsed_args.allocation_pools
|
||||||
if parsed_args.dhcp:
|
if parsed_args.dhcp:
|
||||||
attrs['enable_dhcp'] = True
|
attrs['enable_dhcp'] = True
|
||||||
elif parsed_args.no_dhcp:
|
if parsed_args.no_dhcp:
|
||||||
attrs['enable_dhcp'] = False
|
attrs['enable_dhcp'] = False
|
||||||
if ('dns_nameservers' in parsed_args and
|
if ('dns_nameservers' in parsed_args and
|
||||||
parsed_args.dns_nameservers is not None):
|
parsed_args.dns_nameservers is not None):
|
||||||
@ -223,7 +223,6 @@ class CreateSubnet(command.ShowOne):
|
|||||||
dhcp_enable_group.add_argument(
|
dhcp_enable_group.add_argument(
|
||||||
'--dhcp',
|
'--dhcp',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
default=True,
|
|
||||||
help=_("Enable DHCP (default)")
|
help=_("Enable DHCP (default)")
|
||||||
)
|
)
|
||||||
dhcp_enable_group.add_argument(
|
dhcp_enable_group.add_argument(
|
||||||
|
@ -236,7 +236,6 @@ class TestCreateSubnet(TestSubnet):
|
|||||||
|
|
||||||
self.network.create_subnet.assert_called_once_with(**{
|
self.network.create_subnet.assert_called_once_with(**{
|
||||||
'cidr': self._subnet.cidr,
|
'cidr': self._subnet.cidr,
|
||||||
'enable_dhcp': self._subnet.enable_dhcp,
|
|
||||||
'ip_version': self._subnet.ip_version,
|
'ip_version': self._subnet.ip_version,
|
||||||
'name': self._subnet.name,
|
'name': self._subnet.name,
|
||||||
'network_id': self._subnet.network_id,
|
'network_id': self._subnet.network_id,
|
||||||
@ -410,7 +409,6 @@ class TestCreateSubnet(TestSubnet):
|
|||||||
|
|
||||||
self.network.create_subnet.assert_called_once_with(**{
|
self.network.create_subnet.assert_called_once_with(**{
|
||||||
'cidr': self._subnet.cidr,
|
'cidr': self._subnet.cidr,
|
||||||
'enable_dhcp': self._subnet.enable_dhcp,
|
|
||||||
'ip_version': self._subnet.ip_version,
|
'ip_version': self._subnet.ip_version,
|
||||||
'name': self._subnet.name,
|
'name': self._subnet.name,
|
||||||
'network_id': self._subnet.network_id,
|
'network_id': self._subnet.network_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user