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 3 years ago
parent
commit
d6f1d117b4
2 changed files with 25 additions and 13 deletions
  1. +10
    -12
      openstack_dashboard/dashboards/admin/floating_ips/tables.py
  2. +15
    -1
      openstack_dashboard/dashboards/project/floating_ips/tables.py

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

@@ -32,15 +32,6 @@ from openstack_dashboard.utils import filters
LOG = logging.getLogger(__name__)


class FloatingIPFilterAction(tables.FilterAction):

def filter(self, table, fips, filter_string):
"""Naive case-insensitive search."""
q = filter_string.lower()
return [ip for ip in fips
if q in ip.ip.lower()]


class AdminAllocateFloatingIP(project_tables.AllocateIP):
url = "horizon:admin:floating_ips:allocate"

@@ -72,6 +63,13 @@ class AdminSimpleDisassociateIP(project_tables.DisassociateIP):
return shortcuts.redirect('horizon:admin:floating_ips:index')


class AdminFloatingIPsFilterAction(tables.FilterAction):
filter_type = "server"
filter_choices = (
('project_id', _('Project ID'), True), ) + \
project_tables.FLOATING_IPS_FILTER_CHOICES


class FloatingIPsTable(project_tables.FloatingIPsTable):
tenant = tables.Column("tenant_name", verbose_name=_("Project"))
ip = tables.Column("ip",
@@ -83,9 +81,9 @@ class FloatingIPsTable(project_tables.FloatingIPsTable):
name = "floating_ips"
verbose_name = _("Floating IPs")
status_columns = ["status"]
table_actions = (FloatingIPFilterAction,
AdminAllocateFloatingIP,
AdminReleaseFloatingIP)
table_actions = (AdminAllocateFloatingIP,
AdminReleaseFloatingIP,
AdminFloatingIPsFilterAction)
row_actions = (AdminSimpleDisassociateIP,
AdminReleaseFloatingIP)
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 = (
)


FLOATING_IPS_FILTER_CHOICES = (
('floating_ip_address', _('Floating IP Address ='), True),
('network_id', _('Network ID ='), True),
('router_id', _('Router ID ='), True),
('port_id', _('Port ID ='), True),
('status', _('Status ='), True, _("e.g. ACTIVE / DOWN / ERROR")),
)


class FloatingIPsFilterAction(tables.FilterAction):
filter_type = "server"
filter_choices = FLOATING_IPS_FILTER_CHOICES


class FloatingIPsTable(tables.DataTable):
STATUS_CHOICES = (
("active", True),
@@ -198,5 +212,5 @@ class FloatingIPsTable(tables.DataTable):
class Meta(object):
name = "floating_ips"
verbose_name = _("Floating IPs")
table_actions = (AllocateIP, ReleaseIPs)
table_actions = (AllocateIP, ReleaseIPs, FloatingIPsFilterAction)
row_actions = (AssociateIP, DisassociateIP, ReleaseIPs)

Loading…
Cancel
Save