Skip to content

Commit ca34aa1

Browse files
author
Tang Chen
committed
Floating IP: Fix "ip floating list" in neutron network
The implementation of "ip floating list" in the commit below is incorrect: Change-Id: I253f66f6bc64470e1a18ffea506048eb53f67d5c This is because the FloatingIP objects returned from Nova and Neutron network are different. They need different handling. This patch fixes this problem. The output for Neutron network would be: +--------------------------------------+---------------------+------------------+------+ | ID | Floating IP Address | Fixed IP Address | Port | +--------------------------------------+---------------------+------------------+------+ | 1976df86-e66a-4f96-81bd-c6ffee6407f1 | 172.24.4.3 | None | None | +--------------------------------------+---------------------+------------------+------+ The output for Neutron network would be: +----+---------------------+------------------+-----------+--------+ | ID | Floating IP Address | Fixed IP Address | Server ID | Pool | +----+---------------------+------------------+-----------+--------+ | 1 | 172.24.4.1 | None | None | public | +----+---------------------+------------------+-----------+--------+ Change-Id: I1295e922df695414511d9a07ca4a8e2428040064 Partial-Bug: 1519502 Related-to: blueprint neutron-client
1 parent 444fc61 commit ca34aa1

3 files changed

Lines changed: 51 additions & 17 deletions

File tree

openstackclient/network/v2/floating_ip.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,49 @@ def take_action_compute(self, client, parsed_args):
4343
class ListFloatingIP(common.NetworkAndComputeLister):
4444
"""List floating IP(s)"""
4545

46-
columns = ('ID', 'IP', 'Fixed IP', 'Instance ID', 'Pool')
47-
column_headers = ('ID', 'Floating IP', 'Fixed IP', 'Server ID', 'Pool')
48-
4946
def take_action_network(self, client, parsed_args):
47+
columns = (
48+
'id',
49+
'floating_ip_address',
50+
'fixed_ip_address',
51+
'port_id',
52+
)
53+
headers = (
54+
'ID',
55+
'Floating IP Address',
56+
'Fixed IP Address',
57+
'Port',
58+
)
59+
5060
query = {}
5161
data = client.ips(**query)
5262

53-
return (self.column_headers,
63+
return (headers,
5464
(utils.get_item_properties(
55-
s, self.columns,
65+
s, columns,
5666
formatters={},
5767
) for s in data))
5868

5969
def take_action_compute(self, client, parsed_args):
70+
columns = (
71+
'ID',
72+
'IP',
73+
'Fixed IP',
74+
'Instance ID',
75+
'Pool',
76+
)
77+
headers = (
78+
'ID',
79+
'Floating IP Address',
80+
'Fixed IP Address',
81+
'Server',
82+
'Pool',
83+
)
84+
6085
data = client.floating_ips.list()
6186

62-
return (self.column_headers,
87+
return (headers,
6388
(utils.get_item_properties(
64-
s, self.columns,
89+
s, columns,
6590
formatters={},
6691
) for s in data))

openstackclient/tests/network/v2/fakes.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,10 +619,9 @@ def create_one_floating_ip(attrs={}, methods={}):
619619
# Set default attributes.
620620
floating_ip_attrs = {
621621
'id': 'floating-ip-id-' + uuid.uuid4().hex,
622-
'ip': '1.0.9.0',
623-
'fixed_ip': '2.0.9.0',
624-
'instance_id': 'server-id-' + uuid.uuid4().hex,
625-
'pool': 'public',
622+
'floating_ip_address': '1.0.9.0',
623+
'fixed_ip_address': '2.0.9.0',
624+
'port_id': 'port-id-' + uuid.uuid4().hex,
626625
}
627626

628627
# Overwrite default attributes.

openstackclient/tests/network/v2/test_floating_ip.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,20 @@ class TestListFloatingIPNetwork(TestFloatingIPNetwork):
6464
# The floating ips to list up
6565
floating_ips = network_fakes.FakeFloatingIP.create_floating_ips(count=3)
6666

67-
columns = ('ID', 'Floating IP', 'Fixed IP', 'Server ID', 'Pool')
67+
columns = (
68+
'ID',
69+
'Floating IP Address',
70+
'Fixed IP Address',
71+
'Port',
72+
)
6873

6974
data = []
7075
for ip in floating_ips:
7176
data.append((
7277
ip.id,
73-
ip.ip,
74-
ip.fixed_ip,
75-
ip.instance_id,
76-
ip.pool,
78+
ip.floating_ip_address,
79+
ip.fixed_ip_address,
80+
ip.port_id,
7781
))
7882

7983
def setUp(self):
@@ -147,7 +151,13 @@ class TestListFloatingIPCompute(TestFloatingIPCompute):
147151
# The floating ips to be list up
148152
floating_ips = compute_fakes.FakeFloatingIP.create_floating_ips(count=3)
149153

150-
columns = ('ID', 'Floating IP', 'Fixed IP', 'Server ID', 'Pool')
154+
columns = (
155+
'ID',
156+
'Floating IP Address',
157+
'Fixed IP Address',
158+
'Server',
159+
'Pool',
160+
)
151161

152162
data = []
153163
for ip in floating_ips:

0 commit comments

Comments
 (0)