diff --git a/doc/source/command-objects/ip-availability.rst b/doc/source/command-objects/ip-availability.rst index 55b7842775..f200ab13a6 100644 --- a/doc/source/command-objects/ip-availability.rst +++ b/doc/source/command-objects/ip-availability.rst @@ -25,7 +25,7 @@ number of allocated IP addresses from that pool. .. option:: --ip-version {4,6} List IP availability of given IP version networks - (Default is 4) + (default is 4) .. option:: --project diff --git a/openstackclient/network/v2/ip_availability.py b/openstackclient/network/v2/ip_availability.py index d429e86c8b..1d7b2aed87 100644 --- a/openstackclient/network/v2/ip_availability.py +++ b/openstackclient/network/v2/ip_availability.py @@ -41,15 +41,17 @@ class ListIPAvailability(command.Lister): parser.add_argument( '--ip-version', type=int, + default=4, choices=[4, 6], metavar='', dest='ip_version', - help=_("List IP availability of given IP version networks"), + help=_("List IP availability of given IP version " + "networks (default is 4)"), ) parser.add_argument( '--project', metavar='', - help=_("List IP availability of given project"), + help=_("List IP availability of given project (name or ID)"), ) identity_common.add_project_domain_option_to_parser(parser) return parser diff --git a/openstackclient/tests/network/v2/test_ip_availability.py b/openstackclient/tests/network/v2/test_ip_availability.py index 39e11cd5db..c6ec2b0b06 100644 --- a/openstackclient/tests/network/v2/test_ip_availability.py +++ b/openstackclient/tests/network/v2/test_ip_availability.py @@ -82,8 +82,10 @@ class TestListIPAvailability(TestIPAvailability): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) + filters = {'ip_version': 4} - self.network.network_ip_availabilities.assert_called_once_with() + self.network.network_ip_availabilities.assert_called_once_with( + **filters) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) @@ -116,7 +118,8 @@ class TestListIPAvailability(TestIPAvailability): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) - filters = {'tenant_id': identity_fakes.project_id} + filters = {'tenant_id': identity_fakes.project_id, + 'ip_version': 4} self.network.network_ip_availabilities.assert_called_once_with( **filters) diff --git a/releasenotes/notes/bug-1592761-f45998453d6801f7.yaml b/releasenotes/notes/bug-1592761-f45998453d6801f7.yaml new file mode 100644 index 0000000000..78f5801acc --- /dev/null +++ b/releasenotes/notes/bug-1592761-f45998453d6801f7.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - Add default IP version in ``ip availability list`` command and make + this command work properly without ``--ip-version`` option. + [Bug `1592761 `_]