Skip to content

Commit ca5e8e6

Browse files
author
Huanxuan Ao
committed
Add default IP version and fix help messages for "ip availability list"
There was not a default IP version in "ip availability list" command, if we used this command without "--ip-version" option, the output was different from the outputs with the option "--ip-version 4" and "--ip-version 6" and it is not right. This patch add default IP version (default is 4) in ``ip availability list`` command and make this command work properly without ``--ip-version`` option. And also fix the help message. Change-Id: Idc08ab6eaf05946eb2ab59bfb3d4497a383d987d Closes-Bug: #1592761
1 parent 0ec711c commit ca5e8e6

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

doc/source/command-objects/ip-availability.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ number of allocated IP addresses from that pool.
2525
.. option:: --ip-version {4,6}
2626

2727
List IP availability of given IP version networks
28-
(Default is 4)
28+
(default is 4)
2929

3030
.. option:: --project <project>
3131

openstackclient/network/v2/ip_availability.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,17 @@ def get_parser(self, prog_name):
4141
parser.add_argument(
4242
'--ip-version',
4343
type=int,
44+
default=4,
4445
choices=[4, 6],
4546
metavar='<ip-version>',
4647
dest='ip_version',
47-
help=_("List IP availability of given IP version networks"),
48+
help=_("List IP availability of given IP version "
49+
"networks (default is 4)"),
4850
)
4951
parser.add_argument(
5052
'--project',
5153
metavar='<project>',
52-
help=_("List IP availability of given project"),
54+
help=_("List IP availability of given project (name or ID)"),
5355
)
5456
identity_common.add_project_domain_option_to_parser(parser)
5557
return parser

openstackclient/tests/network/v2/test_ip_availability.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ def test_list_no_options(self):
8282
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
8383

8484
columns, data = self.cmd.take_action(parsed_args)
85+
filters = {'ip_version': 4}
8586

86-
self.network.network_ip_availabilities.assert_called_once_with()
87+
self.network.network_ip_availabilities.assert_called_once_with(
88+
**filters)
8789
self.assertEqual(self.columns, columns)
8890
self.assertEqual(self.data, list(data))
8991

@@ -116,7 +118,8 @@ def test_list_project(self):
116118
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
117119

118120
columns, data = self.cmd.take_action(parsed_args)
119-
filters = {'tenant_id': identity_fakes.project_id}
121+
filters = {'tenant_id': identity_fakes.project_id,
122+
'ip_version': 4}
120123

121124
self.network.network_ip_availabilities.assert_called_once_with(
122125
**filters)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- Add default IP version in ``ip availability list`` command and make
4+
this command work properly without ``--ip-version`` option.
5+
[Bug `1592761 <https://bugs.launchpad.net/bugs/1592761>`_]

0 commit comments

Comments
 (0)