Browse Source

Add server-side filtering Floating IPs

References for field selection:
https://developer.openstack.org/api-ref/networking/v2/index.html?expanded=list-floating-ips-detail
https://github.com/openstack/python-neutronclient/blob/master/neutronclient/neutron/v2_0/floatingip.py

Co-authored-by: Eddie Ramirez <eddie.ramirez@intel.com>
Co-authored-by: David Lyle <dklyle0@gmail.com>

Implements blueprint: server-side-filtering

Change-Id: I614f0b1d9cf685aed3e3663d512a4ccd92455093
tags/13.0.0.0b1
Eddie Ramirez 2 years ago
parent
commit
d6f1d117b4

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

@@ -32,15 +32,6 @@ from openstack_dashboard.utils import filters
32 32
 LOG = logging.getLogger(__name__)
33 33
 
34 34
 
35
-class FloatingIPFilterAction(tables.FilterAction):
36
-
37
-    def filter(self, table, fips, filter_string):
38
-        """Naive case-insensitive search."""
39
-        q = filter_string.lower()
40
-        return [ip for ip in fips
41
-                if q in ip.ip.lower()]
42
-
43
-
44 35
 class AdminAllocateFloatingIP(project_tables.AllocateIP):
45 36
     url = "horizon:admin:floating_ips:allocate"
46 37
 
@@ -72,6 +63,13 @@ class AdminSimpleDisassociateIP(project_tables.DisassociateIP):
72 63
         return shortcuts.redirect('horizon:admin:floating_ips:index')
73 64
 
74 65
 
66
+class AdminFloatingIPsFilterAction(tables.FilterAction):
67
+    filter_type = "server"
68
+    filter_choices = (
69
+        ('project_id', _('Project ID'), True), ) + \
70
+        project_tables.FLOATING_IPS_FILTER_CHOICES
71
+
72
+
75 73
 class FloatingIPsTable(project_tables.FloatingIPsTable):
76 74
     tenant = tables.Column("tenant_name", verbose_name=_("Project"))
77 75
     ip = tables.Column("ip",
@@ -83,9 +81,9 @@ class FloatingIPsTable(project_tables.FloatingIPsTable):
83 81
         name = "floating_ips"
84 82
         verbose_name = _("Floating IPs")
85 83
         status_columns = ["status"]
86
-        table_actions = (FloatingIPFilterAction,
87
-                         AdminAllocateFloatingIP,
88
-                         AdminReleaseFloatingIP)
84
+        table_actions = (AdminAllocateFloatingIP,
85
+                         AdminReleaseFloatingIP,
86
+                         AdminFloatingIPsFilterAction)
89 87
         row_actions = (AdminSimpleDisassociateIP,
90 88
                        AdminReleaseFloatingIP)
91 89
         columns = ('tenant', 'ip', 'fixed_ip', 'pool', 'status')

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

@@ -164,6 +164,20 @@ STATUS_DISPLAY_CHOICES = (
164 164
 )
165 165
 
166 166
 
167
+FLOATING_IPS_FILTER_CHOICES = (
168
+    ('floating_ip_address', _('Floating IP Address ='), True),
169
+    ('network_id', _('Network ID ='), True),
170
+    ('router_id', _('Router ID ='), True),
171
+    ('port_id', _('Port ID ='), True),
172
+    ('status', _('Status ='), True, _("e.g. ACTIVE / DOWN / ERROR")),
173
+)
174
+
175
+
176
+class FloatingIPsFilterAction(tables.FilterAction):
177
+    filter_type = "server"
178
+    filter_choices = FLOATING_IPS_FILTER_CHOICES
179
+
180
+
167 181
 class FloatingIPsTable(tables.DataTable):
168 182
     STATUS_CHOICES = (
169 183
         ("active", True),
@@ -198,5 +212,5 @@ class FloatingIPsTable(tables.DataTable):
198 212
     class Meta(object):
199 213
         name = "floating_ips"
200 214
         verbose_name = _("Floating IPs")
201
-        table_actions = (AllocateIP, ReleaseIPs)
215
+        table_actions = (AllocateIP, ReleaseIPs, FloatingIPsFilterAction)
202 216
         row_actions = (AssociateIP, DisassociateIP, ReleaseIPs)

Loading…
Cancel
Save