summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Vea <trygve.vea@gmail.com>2017-12-17 11:49:35 +0000
committerTrygve Vea <trygve.vea@gmail.com>2017-12-17 12:58:50 +0000
commitd1225c606ea60b521057be5a7409b140c62cbd28 (patch)
tree772c5a4ffc606f3ed2dd0e5d5954d50821fe951e
parentf929d39ab471e2462a2bfcd35d880e2aafb724bb (diff)
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
Notes
Notes (review): Code-Review+2: Akihiro Motoki <amotoki@gmail.com> Workflow+1: Akihiro Motoki <amotoki@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 18 Dec 2017 06:14:18 +0000 Reviewed-on: https://review.openstack.org/528541 Project: openstack/horizon Branch: refs/heads/master
-rw-r--r--openstack_dashboard/api/neutron.py2
-rw-r--r--openstack_dashboard/dashboards/admin/floating_ips/forms.py5
-rw-r--r--openstack_dashboard/dashboards/admin/floating_ips/tables.py2
-rw-r--r--openstack_dashboard/dashboards/project/floating_ips/forms.py12
-rw-r--r--openstack_dashboard/dashboards/project/floating_ips/tables.py2
-rw-r--r--releasenotes/notes/floating_ip_description-f4d2df7949b9fde9.yaml6
6 files changed, 26 insertions, 3 deletions
diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py
index 15f5481..8962179 100644
--- a/openstack_dashboard/api/neutron.py
+++ b/openstack_dashboard/api/neutron.py
@@ -591,6 +591,8 @@ class FloatingIpManager(object):
591 create_dict['subnet_id'] = params['subnet_id'] 591 create_dict['subnet_id'] = params['subnet_id']
592 if 'floating_ip_address' in params: 592 if 'floating_ip_address' in params:
593 create_dict['floating_ip_address'] = params['floating_ip_address'] 593 create_dict['floating_ip_address'] = params['floating_ip_address']
594 if 'description' in params:
595 create_dict['description'] = params['description']
594 fip = self.client.create_floatingip( 596 fip = self.client.create_floatingip(
595 {'floatingip': create_dict}).get('floatingip') 597 {'floatingip': create_dict}).get('floatingip')
596 self._set_instance_info(fip) 598 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 6dd7db2..182f720 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):
34 "You need to specify an explicit address which is under " 34 "You need to specify an explicit address which is under "
35 "the public network CIDR (e.g. 202.2.3.0/24)."), 35 "the public network CIDR (e.g. 202.2.3.0/24)."),
36 mask=False) 36 mask=False)
37 description = forms.CharField(max_length=255,
38 label=_("Description"),
39 required=False)
37 40
38 def __init__(self, *args, **kwargs): 41 def __init__(self, *args, **kwargs):
39 super(AdminFloatingIpAllocate, self).__init__(*args, **kwargs) 42 super(AdminFloatingIpAllocate, self).__init__(*args, **kwargs)
@@ -48,6 +51,8 @@ class AdminFloatingIpAllocate(forms.SelfHandlingForm):
48 param = {} 51 param = {}
49 if data['floating_ip_address']: 52 if data['floating_ip_address']:
50 param['floating_ip_address'] = data['floating_ip_address'] 53 param['floating_ip_address'] = data['floating_ip_address']
54 if data['description']:
55 param['description'] = data['description']
51 subnet = api.neutron.subnet_get(request, data['pool']) 56 subnet = api.neutron.subnet_get(request, data['pool'])
52 param['subnet_id'] = subnet.id 57 param['subnet_id'] = subnet.id
53 fip = api.neutron.tenant_floating_ip_allocate( 58 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 7fff760..ae8eaf9 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):
86 AdminFloatingIPsFilterAction) 86 AdminFloatingIPsFilterAction)
87 row_actions = (AdminSimpleDisassociateIP, 87 row_actions = (AdminSimpleDisassociateIP,
88 AdminReleaseFloatingIP) 88 AdminReleaseFloatingIP)
89 columns = ('tenant', 'ip', 'fixed_ip', 'pool', 'status') 89 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 d14de09..bab95fd 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
29 29
30class FloatingIpAllocate(forms.SelfHandlingForm): 30class FloatingIpAllocate(forms.SelfHandlingForm):
31 pool = forms.ThemableChoiceField(label=_("Pool")) 31 pool = forms.ThemableChoiceField(label=_("Pool"))
32 description = forms.CharField(max_length=255,
33 label=_("Description"),
34 required=False)
32 35
33 def __init__(self, *args, **kwargs): 36 def __init__(self, *args, **kwargs):
34 super(FloatingIpAllocate, self).__init__(*args, **kwargs) 37 super(FloatingIpAllocate, self).__init__(*args, **kwargs)
@@ -46,8 +49,13 @@ class FloatingIpAllocate(forms.SelfHandlingForm):
46 self.api_error(error_message) 49 self.api_error(error_message)
47 return False 50 return False
48 51
49 fip = api.neutron.tenant_floating_ip_allocate(request, 52 param = {}
50 pool=data['pool']) 53 if data['description']:
54 param['description'] = data['description']
55 fip = api.neutron.tenant_floating_ip_allocate(
56 request,
57 pool=data['pool'],
58 **param)
51 messages.success(request, 59 messages.success(request,
52 _('Allocated Floating IP %(ip)s.') 60 _('Allocated Floating IP %(ip)s.')
53 % {"ip": fip.ip}) 61 % {"ip": fip.ip})
diff --git a/openstack_dashboard/dashboards/project/floating_ips/tables.py b/openstack_dashboard/dashboards/project/floating_ips/tables.py
index 3c5d9f3..426a9da0 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):
187 ip = tables.Column("ip", 187 ip = tables.Column("ip",
188 verbose_name=_("IP Address"), 188 verbose_name=_("IP Address"),
189 attrs={'data-type': "ip"}) 189 attrs={'data-type': "ip"})
190 description = tables.Column("description",
191 verbose_name=_("Description"))
190 fixed_ip = tables.Column(get_instance_info, 192 fixed_ip = tables.Column(get_instance_info,
191 link=get_instance_link, 193 link=get_instance_link,
192 verbose_name=_("Mapped Fixed IP Address")) 194 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 0000000..6f57c69
--- /dev/null
+++ b/releasenotes/notes/floating_ip_description-f4d2df7949b9fde9.yaml
@@ -0,0 +1,6 @@
1---
2features:
3 - |
4 Floating IP addresses have a description field that is now exposed in the
5 dashboard. It is also possible to set the description when allocating a
6 floating IP.