diff --git a/openstack_dashboard/dashboards/admin/floating_ips/tables.py b/openstack_dashboard/dashboards/admin/floating_ips/tables.py index 5216a611d1..7fff760a36 100644 --- a/openstack_dashboard/dashboards/admin/floating_ips/tables.py +++ b/openstack_dashboard/dashboards/admin/floating_ips/tables.py @@ -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') diff --git a/openstack_dashboard/dashboards/project/floating_ips/tables.py b/openstack_dashboard/dashboards/project/floating_ips/tables.py index 2c774dae82..3c5d9f33da 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/tables.py +++ b/openstack_dashboard/dashboards/project/floating_ips/tables.py @@ -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)