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 1 year ago
parent
commit
d1225c606e

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

@@ -591,6 +591,8 @@ class FloatingIpManager(object):
591 591
             create_dict['subnet_id'] = params['subnet_id']
592 592
         if 'floating_ip_address' in params:
593 593
             create_dict['floating_ip_address'] = params['floating_ip_address']
594
+        if 'description' in params:
595
+            create_dict['description'] = params['description']
594 596
         fip = self.client.create_floatingip(
595 597
             {'floatingip': create_dict}).get('floatingip')
596 598
         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):
34 34
                     "You need to specify an explicit address which is under "
35 35
                     "the public network CIDR (e.g. 202.2.3.0/24)."),
36 36
         mask=False)
37
+    description = forms.CharField(max_length=255,
38
+                                  label=_("Description"),
39
+                                  required=False)
37 40
 
38 41
     def __init__(self, *args, **kwargs):
39 42
         super(AdminFloatingIpAllocate, self).__init__(*args, **kwargs)
@@ -48,6 +51,8 @@ class AdminFloatingIpAllocate(forms.SelfHandlingForm):
48 51
             param = {}
49 52
             if data['floating_ip_address']:
50 53
                 param['floating_ip_address'] = data['floating_ip_address']
54
+            if data['description']:
55
+                param['description'] = data['description']
51 56
             subnet = api.neutron.subnet_get(request, data['pool'])
52 57
             param['subnet_id'] = subnet.id
53 58
             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):
86 86
                          AdminFloatingIPsFilterAction)
87 87
         row_actions = (AdminSimpleDisassociateIP,
88 88
                        AdminReleaseFloatingIP)
89
-        columns = ('tenant', 'ip', 'fixed_ip', 'pool', 'status')
89
+        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
29 29
 
30 30
 class FloatingIpAllocate(forms.SelfHandlingForm):
31 31
     pool = forms.ThemableChoiceField(label=_("Pool"))
32
+    description = forms.CharField(max_length=255,
33
+                                  label=_("Description"),
34
+                                  required=False)
32 35
 
33 36
     def __init__(self, *args, **kwargs):
34 37
         super(FloatingIpAllocate, self).__init__(*args, **kwargs)
@@ -46,8 +49,13 @@ class FloatingIpAllocate(forms.SelfHandlingForm):
46 49
                 self.api_error(error_message)
47 50
                 return False
48 51
 
49
-            fip = api.neutron.tenant_floating_ip_allocate(request,
50
-                                                          pool=data['pool'])
52
+            param = {}
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 59
             messages.success(request,
52 60
                              _('Allocated Floating IP %(ip)s.')
53 61
                              % {"ip": fip.ip})

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

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

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

@@ -0,0 +1,6 @@
1
+---
2
+features:
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.

Loading…
Cancel
Save