diff --git a/openstackclient/network/v2/floating_ip.py b/openstackclient/network/v2/floating_ip.py index 488950485b..23b83201f6 100644 --- a/openstackclient/network/v2/floating_ip.py +++ b/openstackclient/network/v2/floating_ip.py @@ -43,24 +43,49 @@ class DeleteFloatingIP(common.NetworkAndComputeCommand): class ListFloatingIP(common.NetworkAndComputeLister): """List floating IP(s)""" - columns = ('ID', 'IP', 'Fixed IP', 'Instance ID', 'Pool') - column_headers = ('ID', 'Floating IP', 'Fixed IP', 'Server ID', 'Pool') - def take_action_network(self, client, parsed_args): + columns = ( + 'id', + 'floating_ip_address', + 'fixed_ip_address', + 'port_id', + ) + headers = ( + 'ID', + 'Floating IP Address', + 'Fixed IP Address', + 'Port', + ) + query = {} data = client.ips(**query) - return (self.column_headers, + return (headers, (utils.get_item_properties( - s, self.columns, + s, columns, formatters={}, ) for s in data)) def take_action_compute(self, client, parsed_args): + columns = ( + 'ID', + 'IP', + 'Fixed IP', + 'Instance ID', + 'Pool', + ) + headers = ( + 'ID', + 'Floating IP Address', + 'Fixed IP Address', + 'Server', + 'Pool', + ) + data = client.floating_ips.list() - return (self.column_headers, + return (headers, (utils.get_item_properties( - s, self.columns, + s, columns, formatters={}, ) for s in data)) diff --git a/openstackclient/tests/network/v2/fakes.py b/openstackclient/tests/network/v2/fakes.py index b48cde3ebb..ae205a2d51 100644 --- a/openstackclient/tests/network/v2/fakes.py +++ b/openstackclient/tests/network/v2/fakes.py @@ -619,10 +619,9 @@ class FakeFloatingIP(object): # Set default attributes. floating_ip_attrs = { 'id': 'floating-ip-id-' + uuid.uuid4().hex, - 'ip': '1.0.9.0', - 'fixed_ip': '2.0.9.0', - 'instance_id': 'server-id-' + uuid.uuid4().hex, - 'pool': 'public', + 'floating_ip_address': '1.0.9.0', + 'fixed_ip_address': '2.0.9.0', + 'port_id': 'port-id-' + uuid.uuid4().hex, } # Overwrite default attributes. diff --git a/openstackclient/tests/network/v2/test_floating_ip.py b/openstackclient/tests/network/v2/test_floating_ip.py index 031dcdac37..a29d691338 100644 --- a/openstackclient/tests/network/v2/test_floating_ip.py +++ b/openstackclient/tests/network/v2/test_floating_ip.py @@ -64,16 +64,20 @@ class TestListFloatingIPNetwork(TestFloatingIPNetwork): # The floating ips to list up floating_ips = network_fakes.FakeFloatingIP.create_floating_ips(count=3) - columns = ('ID', 'Floating IP', 'Fixed IP', 'Server ID', 'Pool') + columns = ( + 'ID', + 'Floating IP Address', + 'Fixed IP Address', + 'Port', + ) data = [] for ip in floating_ips: data.append(( ip.id, - ip.ip, - ip.fixed_ip, - ip.instance_id, - ip.pool, + ip.floating_ip_address, + ip.fixed_ip_address, + ip.port_id, )) def setUp(self): @@ -147,7 +151,13 @@ class TestListFloatingIPCompute(TestFloatingIPCompute): # The floating ips to be list up floating_ips = compute_fakes.FakeFloatingIP.create_floating_ips(count=3) - columns = ('ID', 'Floating IP', 'Fixed IP', 'Server ID', 'Pool') + columns = ( + 'ID', + 'Floating IP Address', + 'Fixed IP Address', + 'Server', + 'Pool', + ) data = [] for ip in floating_ips: