From d1225c606ea60b521057be5a7409b140c62cbd28 Mon Sep 17 00:00:00 2001 From: Trygve Vea Date: Sun, 17 Dec 2017 11:49:35 +0000 Subject: [PATCH] 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 --- openstack_dashboard/api/neutron.py | 2 ++ .../dashboards/admin/floating_ips/forms.py | 5 +++++ .../dashboards/admin/floating_ips/tables.py | 2 +- .../dashboards/project/floating_ips/forms.py | 12 ++++++++++-- .../dashboards/project/floating_ips/tables.py | 2 ++ .../floating_ip_description-f4d2df7949b9fde9.yaml | 6 ++++++ 6 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/floating_ip_description-f4d2df7949b9fde9.yaml diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py index 15f548108c..8962179936 100644 --- a/openstack_dashboard/api/neutron.py +++ b/openstack_dashboard/api/neutron.py @@ -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) diff --git a/openstack_dashboard/dashboards/admin/floating_ips/forms.py b/openstack_dashboard/dashboards/admin/floating_ips/forms.py index 6dd7db25f3..182f720ccb 100644 --- a/openstack_dashboard/dashboards/admin/floating_ips/forms.py +++ b/openstack_dashboard/dashboards/admin/floating_ips/forms.py @@ -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( diff --git a/openstack_dashboard/dashboards/admin/floating_ips/tables.py b/openstack_dashboard/dashboards/admin/floating_ips/tables.py index 7fff760a36..ae8eaf9803 100644 --- a/openstack_dashboard/dashboards/admin/floating_ips/tables.py +++ b/openstack_dashboard/dashboards/admin/floating_ips/tables.py @@ -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') diff --git a/openstack_dashboard/dashboards/project/floating_ips/forms.py b/openstack_dashboard/dashboards/project/floating_ips/forms.py index d14de094cb..bab95fd618 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/forms.py +++ b/openstack_dashboard/dashboards/project/floating_ips/forms.py @@ -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}) diff --git a/openstack_dashboard/dashboards/project/floating_ips/tables.py b/openstack_dashboard/dashboards/project/floating_ips/tables.py index 3c5d9f33da..426a9da0f1 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/tables.py +++ b/openstack_dashboard/dashboards/project/floating_ips/tables.py @@ -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")) diff --git a/releasenotes/notes/floating_ip_description-f4d2df7949b9fde9.yaml b/releasenotes/notes/floating_ip_description-f4d2df7949b9fde9.yaml new file mode 100644 index 0000000000..6f57c69c48 --- /dev/null +++ b/releasenotes/notes/floating_ip_description-f4d2df7949b9fde9.yaml @@ -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.