Browse Source

Floating IP: Expose description field in form and tables

The networking API supports setting a description on floating IP addresses.
This patch adds a form input field to the allocation form, and a column to the
table that displays floating IP list.

Closes-Bug: #1738625
Change-Id: I3cec286d01f319402dd652f2f0fe7a59e7d1cfbb
tags/13.0.0.0b3
Trygve Vea 2 years ago
parent
commit
d1225c606e
6 changed files with 26 additions and 3 deletions
  1. +2
    -0
      openstack_dashboard/api/neutron.py
  2. +5
    -0
      openstack_dashboard/dashboards/admin/floating_ips/forms.py
  3. +1
    -1
      openstack_dashboard/dashboards/admin/floating_ips/tables.py
  4. +10
    -2
      openstack_dashboard/dashboards/project/floating_ips/forms.py
  5. +2
    -0
      openstack_dashboard/dashboards/project/floating_ips/tables.py
  6. +6
    -0
      releasenotes/notes/floating_ip_description-f4d2df7949b9fde9.yaml

+ 2
- 0
openstack_dashboard/api/neutron.py View File

@@ -591,6 +591,8 @@ class FloatingIpManager(object):
create_dict['subnet_id'] = params['subnet_id']
if 'floating_ip_address' in params:
create_dict['floating_ip_address'] = params['floating_ip_address']
if 'description' in params:
create_dict['description'] = params['description']
fip = self.client.create_floatingip(
{'floatingip': create_dict}).get('floatingip')
self._set_instance_info(fip)

+ 5
- 0
openstack_dashboard/dashboards/admin/floating_ips/forms.py View File

@@ -34,6 +34,9 @@ class AdminFloatingIpAllocate(forms.SelfHandlingForm):
"You need to specify an explicit address which is under "
"the public network CIDR (e.g. 202.2.3.0/24)."),
mask=False)
description = forms.CharField(max_length=255,
label=_("Description"),
required=False)

def __init__(self, *args, **kwargs):
super(AdminFloatingIpAllocate, self).__init__(*args, **kwargs)
@@ -48,6 +51,8 @@ class AdminFloatingIpAllocate(forms.SelfHandlingForm):
param = {}
if data['floating_ip_address']:
param['floating_ip_address'] = data['floating_ip_address']
if data['description']:
param['description'] = data['description']
subnet = api.neutron.subnet_get(request, data['pool'])
param['subnet_id'] = subnet.id
fip = api.neutron.tenant_floating_ip_allocate(

+ 1
- 1
openstack_dashboard/dashboards/admin/floating_ips/tables.py View File

@@ -86,4 +86,4 @@ class FloatingIPsTable(project_tables.FloatingIPsTable):
AdminFloatingIPsFilterAction)
row_actions = (AdminSimpleDisassociateIP,
AdminReleaseFloatingIP)
columns = ('tenant', 'ip', 'fixed_ip', 'pool', 'status')
columns = ('tenant', 'ip', 'description', 'fixed_ip', 'pool', 'status')

+ 10
- 2
openstack_dashboard/dashboards/project/floating_ips/forms.py View File

@@ -29,6 +29,9 @@ from openstack_dashboard.usage import quotas

class FloatingIpAllocate(forms.SelfHandlingForm):
pool = forms.ThemableChoiceField(label=_("Pool"))
description = forms.CharField(max_length=255,
label=_("Description"),
required=False)

def __init__(self, *args, **kwargs):
super(FloatingIpAllocate, self).__init__(*args, **kwargs)
@@ -46,8 +49,13 @@ class FloatingIpAllocate(forms.SelfHandlingForm):
self.api_error(error_message)
return False

fip = api.neutron.tenant_floating_ip_allocate(request,
pool=data['pool'])
param = {}
if data['description']:
param['description'] = data['description']
fip = api.neutron.tenant_floating_ip_allocate(
request,
pool=data['pool'],
**param)
messages.success(request,
_('Allocated Floating IP %(ip)s.')
% {"ip": fip.ip})

+ 2
- 0
openstack_dashboard/dashboards/project/floating_ips/tables.py View File

@@ -187,6 +187,8 @@ class FloatingIPsTable(tables.DataTable):
ip = tables.Column("ip",
verbose_name=_("IP Address"),
attrs={'data-type': "ip"})
description = tables.Column("description",
verbose_name=_("Description"))
fixed_ip = tables.Column(get_instance_info,
link=get_instance_link,
verbose_name=_("Mapped Fixed IP Address"))

+ 6
- 0
releasenotes/notes/floating_ip_description-f4d2df7949b9fde9.yaml View File

@@ -0,0 +1,6 @@
---
features:
- |
Floating IP addresses have a description field that is now exposed in the
dashboard. It is also possible to set the description when allocating a
floating IP.

Loading…
Cancel
Save