Add floating IP filter to floating IP list command
Add a parameter ``--floating-ip-address`` to ``floating ip list`` because it's supported by the API and also more efficient than the current ``floating ip show``. This also works as a work-around for pagination issues ``floating ip show`` might run into with an IP parameter. Change-Id: I113e3fa2495e1e86bb553c55c44f71a3f9f49d23
This commit is contained in:
parent
2ab3396f19
commit
b8438adbbf
@ -144,6 +144,12 @@ List floating IP(s)
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --floating-ip-address <ip-address>
|
||||
|
||||
List floating IP(s) according to given floating IP address
|
||||
|
||||
*Network version 2 only*
|
||||
|
||||
.. option:: --long
|
||||
|
||||
List additional fields in output
|
||||
|
@ -236,6 +236,12 @@ class ListFloatingIP(common.NetworkAndComputeLister):
|
||||
help=_("List floating IP(s) according to "
|
||||
"given fixed IP address")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--floating-ip-address',
|
||||
metavar='<ip-address>',
|
||||
help=_("List floating IP(s) according to "
|
||||
"given floating IP address")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--long',
|
||||
action='store_true',
|
||||
@ -316,6 +322,8 @@ class ListFloatingIP(common.NetworkAndComputeLister):
|
||||
query['port_id'] = port.id
|
||||
if parsed_args.fixed_ip_address is not None:
|
||||
query['fixed_ip_address'] = parsed_args.fixed_ip_address
|
||||
if parsed_args.floating_ip_address is not None:
|
||||
query['floating_ip_address'] = parsed_args.floating_ip_address
|
||||
if parsed_args.status:
|
||||
query['status'] = parsed_args.status
|
||||
if parsed_args.project is not None:
|
||||
|
@ -504,6 +504,23 @@ class TestListFloatingIPNetwork(TestFloatingIPNetwork):
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
||||
|
||||
def test_floating_ip_list_floating_ip_address(self):
|
||||
arglist = [
|
||||
'--floating-ip-address', self.floating_ips[0].floating_ip_address,
|
||||
]
|
||||
verifylist = [
|
||||
('floating_ip_address', self.floating_ips[0].floating_ip_address),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network.ips.assert_called_once_with(**{
|
||||
'floating_ip_address': self.floating_ips[0].floating_ip_address,
|
||||
})
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
||||
|
||||
def test_floating_ip_list_long(self):
|
||||
arglist = ['--long', ]
|
||||
verifylist = [('long', True), ]
|
||||
|
Loading…
Reference in New Issue
Block a user